DEADSOFTWARE

add libffi bindingss for ARM
[cpc.git] / src / cpfront / 486 / Lib / Mod / FFI.cp
1 MODULE LibFFI ["ffi.h"];
3 IMPORT SYSTEM, types := PosixCtypes, sys_types := PosixCsys_types;
5 CONST
6 SIZEOF_ARG* = 4;
8 CONST (* abi *)
9 FIRST_ABI* = 0;
10 SYSV* = 1;
11 STDCALL_WIN32* = 2; (* FFI_STDCALL for win32 *)
12 THISCALL* = 3;
13 FASTCALL* = 4;
14 MS_CDECL_WIN32* = 5; (* FFI_MS_CDECL for win32 *)
15 STDCALL_GENERIC* = 5; (* FFI_STDCALL for ~win32 *)
16 PASCAL* = 6;
17 REGISTER* = 7;
18 LAST_ABI* = 7;
19 DEFAULT_ABI* = SYSV;
21 (* stub *)
22 VFP* = -1;
24 CONST (* status *)
25 OK* = 0; BAD_TYPEDEF* = 1; BAD_ABI* = 2;
27 CONST
28 TYPE_VOID* = 0;
29 TYPE_INT* = 1;
30 TYPE_FLOAT* = 2;
31 TYPE_DOUBLE* = 3;
32 TYPE_LONGDOUBLE* = 4;
33 TYPE_UINT8* = 5;
34 TYPE_SINT8* = 6;
35 TYPE_UINT16* = 7;
36 TYPE_SINT16* = 8;
37 TYPE_UINT32* = 9;
38 TYPE_SINT32* = 10;
39 TYPE_UINT64* = 11;
40 TYPE_SINT64* = 12;
41 TYPE_STRUCT* = 13;
42 TYPE_POINTER* = 14;
43 TYPE_COMPLEX* = 15;
44 TYPE_LAST* = TYPE_COMPLEX;
46 TYPE
47 abi* ["ffi_abi"] = types.int; (* !!! enum *)
48 status* ["ffi_status"] = types.int; (* !!! enum *)
50 (* Ptype* = POINTER [untagged] TO type;
51 PPtype* = POINTER [untagged] TO ARRAY [untagged] OF Ptype; *)
52 type* ["ffi_type"] = RECORD [untagged]
53 size*: sys_types.size_t;
54 alignment*: types.unsigned_short;
55 type*: types.unsigned_short;
56 elements*: POINTER [untagged] TO ARRAY [untagged] OF POINTER TO type;
57 END;
59 (* Pcif* = POINTER TO cif; *)
60 cif* ["ffi_cif"] = RECORD [untagged]
61 abi*: abi;
62 nargs*: types.unsigned;
63 arg_type*: POINTER [untagged] TO ARRAY [untagged] OF POINTER TO type;
64 rtype*: POINTER TO type;
65 bytes*: types.unsigned;
66 flags*: types.unsigned;
67 END;
69 VAR
70 type_void- ["ffi_type_void"]: type;
71 type_uint8- ["ffi_type_uint8"]: type;
72 type_sint8- ["ffi_type_sint8"]: type;
73 type_uint16- ["ffi_type_uint16"]: type;
74 type_sint16- ["ffi_type_sint16"]: type;
75 type_uint32- ["ffi_type_uint32"]: type;
76 type_sint32- ["ffi_type_sint32"]: type;
77 type_uint64- ["ffi_type_uint64"]: type;
78 type_sint64- ["ffi_type_sint64"]: type;
79 type_float- ["ffi_type_float"]: type;
80 type_double- ["ffi_type_double"]: type;
81 type_pointer- ["ffi_type_pointer"]: type;
82 type_longdouble- ["ffi_type_longdouble"]: type;
84 type_complex_single- ["ffi_type_complex_single"]: type;
85 type_complex_double- ["ffi_type_complex_double"]: type;
86 type_complex_longdouble- ["ffi_type_complex_longdouble"]: type;
88 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;
89 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;
90 PROCEDURE [ccall] call* ["ffi_call"] (VAR c: cif; fn, rvalue, avalue: SYSTEM.ADDRESS);
92 END LibFFI.