1 | n/a | /* ----------------------------------------------------------------------- |
---|
2 | n/a | types.c - Copyright (c) 1996, 1998 Red Hat, Inc. |
---|
3 | n/a | |
---|
4 | n/a | Predefined ffi_types needed by libffi. |
---|
5 | n/a | |
---|
6 | n/a | Permission is hereby granted, free of charge, to any person obtaining |
---|
7 | n/a | a copy of this software and associated documentation files (the |
---|
8 | n/a | ``Software''), to deal in the Software without restriction, including |
---|
9 | n/a | without limitation the rights to use, copy, modify, merge, publish, |
---|
10 | n/a | distribute, sublicense, and/or sell copies of the Software, and to |
---|
11 | n/a | permit persons to whom the Software is furnished to do so, subject to |
---|
12 | n/a | the following conditions: |
---|
13 | n/a | |
---|
14 | n/a | The above copyright notice and this permission notice shall be included |
---|
15 | n/a | in all copies or substantial portions of the Software. |
---|
16 | n/a | |
---|
17 | n/a | THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, |
---|
18 | n/a | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
---|
19 | n/a | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
---|
20 | n/a | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
---|
21 | n/a | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
---|
22 | n/a | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
23 | n/a | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
24 | n/a | DEALINGS IN THE SOFTWARE. |
---|
25 | n/a | ----------------------------------------------------------------------- */ |
---|
26 | n/a | |
---|
27 | n/a | /* Hide the basic type definitions from the header file, so that we |
---|
28 | n/a | can redefine them here as "const". */ |
---|
29 | n/a | #define LIBFFI_HIDE_BASIC_TYPES |
---|
30 | n/a | |
---|
31 | n/a | #include <ffi.h> |
---|
32 | n/a | #include <ffi_common.h> |
---|
33 | n/a | |
---|
34 | n/a | /* Type definitions */ |
---|
35 | n/a | |
---|
36 | n/a | #define FFI_TYPEDEF(name, type, id) \ |
---|
37 | n/a | struct struct_align_##name { \ |
---|
38 | n/a | char c; \ |
---|
39 | n/a | type x; \ |
---|
40 | n/a | }; \ |
---|
41 | n/a | const ffi_type ffi_type_##name = { \ |
---|
42 | n/a | sizeof(type), \ |
---|
43 | n/a | offsetof(struct struct_align_##name, x), \ |
---|
44 | n/a | id, NULL \ |
---|
45 | n/a | } |
---|
46 | n/a | |
---|
47 | n/a | #define FFI_NONCONST_TYPEDEF(name, type, id) \ |
---|
48 | n/a | struct struct_align_##name { \ |
---|
49 | n/a | char c; \ |
---|
50 | n/a | type x; \ |
---|
51 | n/a | }; \ |
---|
52 | n/a | ffi_type ffi_type_##name = { \ |
---|
53 | n/a | sizeof(type), \ |
---|
54 | n/a | offsetof(struct struct_align_##name, x), \ |
---|
55 | n/a | id, NULL \ |
---|
56 | n/a | } |
---|
57 | n/a | |
---|
58 | n/a | /* Size and alignment are fake here. They must not be 0. */ |
---|
59 | n/a | const ffi_type ffi_type_void = { |
---|
60 | n/a | 1, 1, FFI_TYPE_VOID, NULL |
---|
61 | n/a | }; |
---|
62 | n/a | |
---|
63 | n/a | FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8); |
---|
64 | n/a | FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8); |
---|
65 | n/a | FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16); |
---|
66 | n/a | FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16); |
---|
67 | n/a | FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32); |
---|
68 | n/a | FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32); |
---|
69 | n/a | FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64); |
---|
70 | n/a | FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64); |
---|
71 | n/a | |
---|
72 | n/a | FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER); |
---|
73 | n/a | |
---|
74 | n/a | FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT); |
---|
75 | n/a | FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE); |
---|
76 | n/a | |
---|
77 | n/a | #ifdef __alpha__ |
---|
78 | n/a | /* Even if we're not configured to default to 128-bit long double, |
---|
79 | n/a | maintain binary compatibility, as -mlong-double-128 can be used |
---|
80 | n/a | at any time. */ |
---|
81 | n/a | /* Validate the hard-coded number below. */ |
---|
82 | n/a | # if defined(__LONG_DOUBLE_128__) && FFI_TYPE_LONGDOUBLE != 4 |
---|
83 | n/a | # error FFI_TYPE_LONGDOUBLE out of date |
---|
84 | n/a | # endif |
---|
85 | n/a | const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL }; |
---|
86 | n/a | #elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE |
---|
87 | n/a | # if HAVE_LONG_DOUBLE_VARIANT |
---|
88 | n/a | FFI_NONCONST_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE); |
---|
89 | n/a | # else |
---|
90 | n/a | FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE); |
---|
91 | n/a | # endif |
---|
92 | n/a | #endif |
---|