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