Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,324
Issues
4,324
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
360
Merge Requests
360
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
3b4572b7
Commit
3b4572b7
authored
Feb 17, 2012
by
Ian Lynagh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add another test for CAPI / CTYPE
This tests that the header given in the CTYPE pragma is handled.
parent
baf18818
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
0 deletions
+82
-0
testsuite/tests/ffi/should_run/Capi_Ctype_002.hs
testsuite/tests/ffi/should_run/Capi_Ctype_002.hs
+19
-0
testsuite/tests/ffi/should_run/Capi_Ctype_002.stdout
testsuite/tests/ffi/should_run/Capi_Ctype_002.stdout
+1
-0
testsuite/tests/ffi/should_run/Capi_Ctype_A_002.hsc
testsuite/tests/ffi/should_run/Capi_Ctype_A_002.hsc
+28
-0
testsuite/tests/ffi/should_run/Makefile
testsuite/tests/ffi/should_run/Makefile
+8
-0
testsuite/tests/ffi/should_run/all.T
testsuite/tests/ffi/should_run/all.T
+6
-0
testsuite/tests/ffi/should_run/capi_ctype_002_A.h
testsuite/tests/ffi/should_run/capi_ctype_002_A.h
+12
-0
testsuite/tests/ffi/should_run/capi_ctype_002_B.h
testsuite/tests/ffi/should_run/capi_ctype_002_B.h
+8
-0
No files found.
testsuite/tests/ffi/should_run/Capi_Ctype_002.hs
0 → 100644
View file @
3b4572b7
{-# LANGUAGE CApiFFI #-}
module
Main
(
main
)
where
import
Capi_Ctype_A_002
import
Foreign
import
Foreign.C
main
::
IO
()
main
=
alloca
$
\
p
->
do
poke
p
(
Foo
5
6
7
)
r1
<-
f
p
print
r1
foreign
import
capi
unsafe
"capi_ctype_002_B.h f"
f
::
Ptr
Foo
->
IO
CInt
testsuite/tests/ffi/should_run/Capi_Ctype_002.stdout
0 → 100644
View file @
3b4572b7
6
testsuite/tests/ffi/should_run/Capi_Ctype_A_002.hsc
0 → 100644
View file @
3b4572b7
{-# LANGUAGE CApiFFI #-}
module Capi_Ctype_A_002 (Foo(..)) where
#include "capi_ctype_002_A.h"
import Foreign
import Foreign.C
data {-# CTYPE "capi_ctype_002_A.h" "Foo" #-}
Foo = Foo {
i :: CInt,
j :: CInt,
k :: CInt
}
instance Storable Foo where
sizeOf _ = #size Foo
alignment = sizeOf
peek p = do i <- (# peek Foo, i) p
j <- (# peek Foo, j) p
k <- (# peek Foo, k) p
return $ Foo i j k
poke p foo = do (# poke Foo, i) p (i foo)
(# poke Foo, j) p (j foo)
(# poke Foo, k) p (k foo)
testsuite/tests/ffi/should_run/Makefile
View file @
3b4572b7
...
...
@@ -30,3 +30,11 @@ Capi_Ctype_001:
'
$(TEST_HC)
'
$(TEST_HC_OPTS)
capi_ctype_001.o Capi_Ctype_A_001.o Capi_Ctype_001.o
-o
Capi_Ctype_001
./Capi_Ctype_001
.PHONY
:
Capi_Ctype_002
Capi_Ctype_002
:
'
$(HSC2HS)
'
Capi_Ctype_A_002.hsc
'
$(TEST_HC)
'
$(TEST_HC_OPTS)
-c
Capi_Ctype_A_002.hs
'
$(TEST_HC)
'
$(TEST_HC_OPTS)
-c
Capi_Ctype_002.hs
'
$(TEST_HC)
'
$(TEST_HC_OPTS)
Capi_Ctype_A_002.o Capi_Ctype_002.o
-o
Capi_Ctype_002
./Capi_Ctype_002
testsuite/tests/ffi/should_run/all.T
View file @
3b4572b7
...
...
@@ -195,3 +195,9 @@ test('Capi_Ctype_001',
run_command
,
['
$MAKE -s --no-print-directory Capi_Ctype_001
'])
test
('
Capi_Ctype_002
',
extra_clean
(['
Capi_Ctype_A_002.o
',
'
Capi_Ctype_A_002.hi
',
'
Capi_Ctype_A_002.hs
']),
run_command
,
['
$MAKE -s --no-print-directory Capi_Ctype_002
'])
testsuite/tests/ffi/should_run/capi_ctype_002_A.h
0 → 100644
View file @
3b4572b7
#ifndef __capi_ctype_002_A_H__
#define __capi_ctype_002_A_H__
typedef
struct
{
int
i
;
int
j
;
int
k
;
}
Foo
;
#endif
testsuite/tests/ffi/should_run/capi_ctype_002_B.h
0 → 100644
View file @
3b4572b7
#ifndef __capi_ctype_002_B_H__
#define __capi_ctype_002_B_H__
#define f(p) p->j
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment