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