ยปCore Development>Code coverage>Modules/_ctypes/libffi/src/types.c

Python code coverage for Modules/_ctypes/libffi/src/types.c

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