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, EXPRESS |
---|
18 | n/a | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
---|
19 | n/a | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
---|
20 | n/a | IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
---|
21 | n/a | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
---|
22 | n/a | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
---|
23 | n/a | OTHER DEALINGS IN THE SOFTWARE. |
---|
24 | n/a | ----------------------------------------------------------------------- */ |
---|
25 | n/a | |
---|
26 | n/a | #include <ffi.h> |
---|
27 | n/a | #include <ffi_common.h> |
---|
28 | n/a | |
---|
29 | n/a | /* Type definitions */ |
---|
30 | n/a | #define FFI_INTEGRAL_TYPEDEF(n, s, a, t) \ |
---|
31 | n/a | ffi_type ffi_type_##n = { s, a, t, NULL } |
---|
32 | n/a | #define FFI_AGGREGATE_TYPEDEF(n, e) \ |
---|
33 | n/a | ffi_type ffi_type_##n = { 0, 0, FFI_TYPE_STRUCT, e } |
---|
34 | n/a | |
---|
35 | n/a | FFI_INTEGRAL_TYPEDEF(uint8, 1, 1, FFI_TYPE_UINT8); |
---|
36 | n/a | FFI_INTEGRAL_TYPEDEF(sint8, 1, 1, FFI_TYPE_SINT8); |
---|
37 | n/a | FFI_INTEGRAL_TYPEDEF(uint16, 2, 2, FFI_TYPE_UINT16); |
---|
38 | n/a | FFI_INTEGRAL_TYPEDEF(sint16, 2, 2, FFI_TYPE_SINT16); |
---|
39 | n/a | FFI_INTEGRAL_TYPEDEF(uint32, 4, 4, FFI_TYPE_UINT32); |
---|
40 | n/a | FFI_INTEGRAL_TYPEDEF(sint32, 4, 4, FFI_TYPE_SINT32); |
---|
41 | n/a | FFI_INTEGRAL_TYPEDEF(float, 4, 4, FFI_TYPE_FLOAT); |
---|
42 | n/a | |
---|
43 | n/a | /* Size and alignment are fake here. They must not be 0. */ |
---|
44 | n/a | FFI_INTEGRAL_TYPEDEF(void, 1, 1, FFI_TYPE_VOID); |
---|
45 | n/a | |
---|
46 | n/a | #if defined ALPHA || defined SPARC64 || defined X86_64 || \ |
---|
47 | n/a | defined S390X || defined IA64 || defined POWERPC64 |
---|
48 | n/a | FFI_INTEGRAL_TYPEDEF(pointer, 8, 8, FFI_TYPE_POINTER); |
---|
49 | n/a | #else |
---|
50 | n/a | FFI_INTEGRAL_TYPEDEF(pointer, 4, 4, FFI_TYPE_POINTER); |
---|
51 | n/a | #endif |
---|
52 | n/a | |
---|
53 | n/a | #if defined X86 || defined ARM || defined M68K || defined(X86_DARWIN) |
---|
54 | n/a | |
---|
55 | n/a | # ifdef X86_64 |
---|
56 | n/a | FFI_INTEGRAL_TYPEDEF(uint64, 8, 8, FFI_TYPE_UINT64); |
---|
57 | n/a | FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64); |
---|
58 | n/a | # else |
---|
59 | n/a | FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64); |
---|
60 | n/a | FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64); |
---|
61 | n/a | # endif |
---|
62 | n/a | |
---|
63 | n/a | #elif defined(POWERPC_DARWIN) |
---|
64 | n/a | FFI_INTEGRAL_TYPEDEF(uint64, 8, 8, FFI_TYPE_UINT64); |
---|
65 | n/a | FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64); |
---|
66 | n/a | #elif defined SH |
---|
67 | n/a | FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64); |
---|
68 | n/a | FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64); |
---|
69 | n/a | #else |
---|
70 | n/a | FFI_INTEGRAL_TYPEDEF(uint64, 8, 8, FFI_TYPE_UINT64); |
---|
71 | n/a | FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64); |
---|
72 | n/a | #endif |
---|
73 | n/a | |
---|
74 | n/a | #if defined X86 || defined X86_WIN32 || defined M68K || defined(X86_DARWIN) |
---|
75 | n/a | |
---|
76 | n/a | # if defined X86_WIN32 || defined X86_64 |
---|
77 | n/a | FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE); |
---|
78 | n/a | # else |
---|
79 | n/a | FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE); |
---|
80 | n/a | # endif |
---|
81 | n/a | |
---|
82 | n/a | # ifdef X86_DARWIN |
---|
83 | n/a | FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE); |
---|
84 | n/a | # else |
---|
85 | n/a | FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE); |
---|
86 | n/a | # endif |
---|
87 | n/a | |
---|
88 | n/a | #elif defined ARM || defined SH || defined POWERPC_AIX |
---|
89 | n/a | FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE); |
---|
90 | n/a | FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE); |
---|
91 | n/a | #elif defined POWERPC_DARWIN |
---|
92 | n/a | FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE); |
---|
93 | n/a | |
---|
94 | n/a | # if __GNUC__ >= 4 |
---|
95 | n/a | FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE); |
---|
96 | n/a | # else |
---|
97 | n/a | FFI_INTEGRAL_TYPEDEF(longdouble, 8, 8, FFI_TYPE_LONGDOUBLE); |
---|
98 | n/a | # endif |
---|
99 | n/a | |
---|
100 | n/a | #elif defined SPARC |
---|
101 | n/a | FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE); |
---|
102 | n/a | |
---|
103 | n/a | # ifdef SPARC64 |
---|
104 | n/a | FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE); |
---|
105 | n/a | # else |
---|
106 | n/a | FFI_INTEGRAL_TYPEDEF(longdouble, 16, 8, FFI_TYPE_LONGDOUBLE); |
---|
107 | n/a | # endif |
---|
108 | n/a | |
---|
109 | n/a | #elif defined X86_64 || defined POWERPC64 |
---|
110 | n/a | FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE); |
---|
111 | n/a | FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE); |
---|
112 | n/a | #else |
---|
113 | n/a | FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE); |
---|
114 | n/a | FFI_INTEGRAL_TYPEDEF(longdouble, 8, 8, FFI_TYPE_LONGDOUBLE); |
---|
115 | n/a | #endif |
---|