1 /* -----------------------------------------------------------------------
2 ffi_common.h - Copyright (c) 1996 Red Hat, Inc.
3 Copyright (C) 2007 Free Software Foundation, Inc
5 Common internal definitions and macros. Only necessary for building
7 ----------------------------------------------------------------------- */
16 #include <fficonfig.h>
18 /* Do not move this. Some versions of AIX are very picky about where
19 this is positioned. */
21 /* mingw64 defines this already in malloc.h. */
23 # define alloca __builtin_alloca
25 # define MAYBE_UNUSED __attribute__((__unused__))
34 # ifndef alloca /* predefined by HP cc +Olibcalls */
36 # define alloca _alloca
45 /* Check for the existence of memcpy. */
50 # define memcpy(d, s, n) bcopy ((s), (d), (n))
54 #if defined(FFI_DEBUG)
59 void ffi_assert(char *expr, char *file, int line);
60 void ffi_stop_here(void);
61 void ffi_type_test(ffi_type *a, char *file, int line);
63 #define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
64 #define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
65 #define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
68 #define FFI_ASSERT_AT(x, f, l)
69 #define FFI_ASSERT_VALID_TYPE(x)
72 #define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
73 #define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)
75 /* Perform machine dependent cif processing */
76 ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
78 /* Extended cif, used in callback from assembly routine */
86 /* Terse sized type definitions. */
87 #if defined(_MSC_VER) || defined(__sgi)
88 typedef unsigned char UINT8;
89 typedef signed char SINT8;
90 typedef unsigned short UINT16;
91 typedef signed short SINT16;
92 typedef unsigned int UINT32;
93 typedef signed int SINT32;
95 typedef unsigned __int64 UINT64;
96 typedef signed __int64 SINT64;
98 # include <inttypes.h>
99 typedef uint64_t UINT64;
100 typedef int64_t SINT64;
103 typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
104 typedef signed int SINT8 __attribute__((__mode__(__QI__)));
105 typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
106 typedef signed int SINT16 __attribute__((__mode__(__HI__)));
107 typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
108 typedef signed int SINT32 __attribute__((__mode__(__SI__)));
109 typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
110 typedef signed int SINT64 __attribute__((__mode__(__DI__)));
113 typedef float FLOAT32;