907635b816c832e7e2ab12e61b25faa9ee318f9b
1 MODULE LibFFI
["ffi.h"];
3 IMPORT SYSTEM
, types
:= PosixCtypes
, sys_types
:= PosixCsys_types
;
13 (* DEFAULT_ABI* = SYSV; *)
14 DEFAULT_ABI
* = VFP
; (* armhf *)
17 STDCALL_WIN32
* = -1; THISCALL
* = -1; FASTCALL
* = -1; MS_CDECL_WIN32
* = -1;
18 STDCALL_GENERIC
* = -1; PASCAL
* = -1; REGISTER
* = -1;
21 OK
* = 0; BAD_TYPEDEF
* = 1; BAD_ABI
* = 2;
40 TYPE_LAST
* = TYPE_COMPLEX
;
43 abi
* ["ffi_abi"] = types
.int
; (* !!! enum *)
44 status
* ["ffi_status"] = types
.int
; (* !!! enum *)
46 (* Ptype* = POINTER [untagged] TO type;
47 PPtype* = POINTER [untagged] TO ARRAY [untagged] OF Ptype; *)
48 type
* ["ffi_type"] = RECORD [untagged
]
49 size
*: sys_types
.size_t
;
50 alignment
*: types
.unsigned_short
;
51 type
*: types
.unsigned_short
;
52 elements
*: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
;
55 (* Pcif* = POINTER TO cif; *)
56 cif
* ["ffi_cif"] = RECORD [untagged
]
58 nargs
*: types
.unsigned
;
59 arg_type
*: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
;
60 rtype
*: POINTER TO type
;
61 bytes
*: types
.unsigned
;
62 flags
*: types
.unsigned
;
63 (* --- ARM specific --- *)
65 vfp_reg_free
: types
.unsigned_short
;
66 vfp_nargs
: types
.unsigned_short
;
67 vfp_args
: ARRAY 16 OF types
.char
;
71 type_void
- ["ffi_type_void"]: type
;
72 type_uint8
- ["ffi_type_uint8"]: type
;
73 type_sint8
- ["ffi_type_sint8"]: type
;
74 type_uint16
- ["ffi_type_uint16"]: type
;
75 type_sint16
- ["ffi_type_sint16"]: type
;
76 type_uint32
- ["ffi_type_uint32"]: type
;
77 type_sint32
- ["ffi_type_sint32"]: type
;
78 type_uint64
- ["ffi_type_uint64"]: type
;
79 type_sint64
- ["ffi_type_sint64"]: type
;
80 type_float
- ["ffi_type_float"]: type
;
81 type_double
- ["ffi_type_double"]: type
;
82 type_pointer
- ["ffi_type_pointer"]: type
;
83 type_longdouble
- ["ffi_type_longdouble"]: type
;
85 type_complex_single
- ["ffi_type_complex_single"]: type
;
86 type_complex_double
- ["ffi_type_complex_double"]: type
;
87 type_complex_longdouble
- ["ffi_type_complex_longdouble"]: type
;
89 PROCEDURE [ccall
] prep_cif
* ["ffi_prep_cif"] (VAR c
: cif
; a
: abi
; nargs
: types
.unsigned_int
; rtype
: POINTER TO type
; atypes
: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
): status
;
90 PROCEDURE [ccall
] prep_cif_var
* ["ffi_prep_cif_var"] (VAR c
: cif
; a
: abi
; nfixedargs
, ntotalargs
: types
.unsigned_int
; rtype
: POINTER TO type
; atypes
: POINTER [untagged
] TO ARRAY [untagged
] OF POINTER TO type
): status
;
91 PROCEDURE [ccall
] call
* ["ffi_call"] (VAR c
: cif
; fn
, rvalue
, avalue
: INTEGER);