Back to index

plt-scheme  4.2.1
types.c
Go to the documentation of this file.
00001 /* -----------------------------------------------------------------------
00002    types.c - Copyright (c) 1996, 1998  Red Hat, Inc.
00003    
00004    Predefined ffi_types needed by libffi.
00005 
00006    Permission is hereby granted, free of charge, to any person obtaining
00007    a copy of this software and associated documentation files (the
00008    ``Software''), to deal in the Software without restriction, including
00009    without limitation the rights to use, copy, modify, merge, publish,
00010    distribute, sublicense, and/or sell copies of the Software, and to
00011    permit persons to whom the Software is furnished to do so, subject to
00012    the following conditions:
00013 
00014    The above copyright notice and this permission notice shall be included
00015    in all copies or substantial portions of the Software.
00016 
00017    THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
00018    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00019    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00020    IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00021    OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00022    ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00023    OTHER DEALINGS IN THE SOFTWARE.
00024    ----------------------------------------------------------------------- */
00025 
00026 /* Hide the basic type definitions from the header file, so that we
00027    can redefine them here as "const".  */
00028 #define LIBFFI_HIDE_BASIC_TYPES
00029 
00030 #include <ffi.h>
00031 #include <ffi_common.h>
00032 
00033 /* Type definitions */
00034 
00035 #define FFI_TYPEDEF(name, type, id)              \
00036 struct struct_align_##name {                     \
00037   char c;                                 \
00038   type x;                                 \
00039 };                                        \
00040 const ffi_type ffi_type_##name = {        \
00041   sizeof(type),                                  \
00042   offsetof(struct struct_align_##name, x),       \
00043   id, NULL                                \
00044 }
00045 
00046 /* Size and alignment are fake here. They must not be 0. */
00047 const ffi_type ffi_type_void = {
00048   1, 1, FFI_TYPE_VOID, NULL
00049 };
00050 
00051 FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8);
00052 FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8);
00053 FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16);
00054 FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16);
00055 FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32);
00056 FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32);
00057 FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64);
00058 FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64);
00059 
00060 FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER);
00061 
00062 FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT);
00063 FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE);
00064 
00065 #ifdef __alpha__
00066 /* Even if we're not configured to default to 128-bit long double, 
00067    maintain binary compatibility, as -mlong-double-128 can be used
00068    at any time.  */
00069 /* Validate the hard-coded number below.  */
00070 # if defined(__LONG_DOUBLE_128__) && FFI_TYPE_LONGDOUBLE != 4
00071 #  error FFI_TYPE_LONGDOUBLE out of date
00072 # endif
00073 const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL };
00074 #elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
00075 FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);
00076 #endif