DEADSOFTWARE

replace SYSTEM.ADDRESS with SYSTEM.INTADR
[cpc.git] / src / cpfront / arm / 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 VFP* = 2;
12 LAST_ABI* = 2;
13 (* DEFAULT_ABI* = SYSV; *)
14 DEFAULT_ABI* = VFP; (* armhf *)
16 (* stub *)
17 STDCALL_WIN32* = -1; THISCALL* = -1; FASTCALL* = -1; MS_CDECL_WIN32* = -1;
18 STDCALL_GENERIC* = -1; PASCAL* = -1; REGISTER* = -1;
20 CONST (* status *)
21 OK* = 0; BAD_TYPEDEF* = 1; BAD_ABI* = 2;
23 CONST
24 TYPE_VOID* = 0;
25 TYPE_INT* = 1;
26 TYPE_FLOAT* = 2;
27 TYPE_DOUBLE* = 3;
28 TYPE_LONGDOUBLE* = 4;
29 TYPE_UINT8* = 5;
30 TYPE_SINT8* = 6;
31 TYPE_UINT16* = 7;
32 TYPE_SINT16* = 8;
33 TYPE_UINT32* = 9;
34 TYPE_SINT32* = 10;
35 TYPE_UINT64* = 11;
36 TYPE_SINT64* = 12;
37 TYPE_STRUCT* = 13;
38 TYPE_POINTER* = 14;
39 TYPE_COMPLEX* = 15;
40 TYPE_LAST* = TYPE_COMPLEX;
42 TYPE
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;
53 END;
55 (* Pcif* = POINTER TO cif; *)
56 cif* ["ffi_cif"] = RECORD [untagged]
57 abi*: abi;
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 --- *)
64 vfp_used: types.int;
65 vfp_reg_free: types.unsigned_short;
66 vfp_nargs: types.unsigned_short;
67 vfp_args: ARRAY 16 OF types.char;
68 END;
70 VAR
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);
93 END LibFFI.