annotate libffi/src/types.c @ 111:04ced10e8804

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