57 #endif
58
59 #if defined(FFI_DEBUG)
60 #include <stdio.h>
61 #endif
62
63 #ifdef FFI_DEBUG
64 void ffi_assert(char *expr, char *file, int line);
65 void ffi_stop_here(void);
66 void ffi_type_test(ffi_type *a, char *file, int line);
67
68 #define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
69 #define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
70 #define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
71 #else
72 #define FFI_ASSERT(x)
73 #define FFI_ASSERT_AT(x, f, l)
74 #define FFI_ASSERT_VALID_TYPE(x)
75 #endif
76
77 #define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
78 #define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)
79
80 /* Perform machine dependent cif processing */
81 ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
82 ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
83 unsigned int nfixedargs, unsigned int ntotalargs);
84
85 /* Extended cif, used in callback from assembly routine */
86 typedef struct
87 {
88 ffi_cif *cif;
89 void *rvalue;
90 void **avalue;
91 } extended_cif;
92
93 /* Terse sized type definitions. */
94 #if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C)
95 typedef unsigned char UINT8;
96 typedef signed char SINT8;
97 typedef unsigned short UINT16;
98 typedef signed short SINT16;
99 typedef unsigned int UINT32;
100 typedef signed int SINT32;
101 # ifdef _MSC_VER
102 typedef unsigned __int64 UINT64;
103 typedef signed __int64 SINT64;
104 # else
|
57 #endif
58
59 #if defined(FFI_DEBUG)
60 #include <stdio.h>
61 #endif
62
63 #ifdef FFI_DEBUG
64 void ffi_assert(char *expr, char *file, int line);
65 void ffi_stop_here(void);
66 void ffi_type_test(ffi_type *a, char *file, int line);
67
68 #define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
69 #define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
70 #define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
71 #else
72 #define FFI_ASSERT(x)
73 #define FFI_ASSERT_AT(x, f, l)
74 #define FFI_ASSERT_VALID_TYPE(x)
75 #endif
76
77 /* v cast to size_t and aligned up to a multiple of a */
78 #define FFI_ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
79 /* v cast to size_t and aligned down to a multiple of a */
80 #define FFI_ALIGN_DOWN(v, a) (((size_t) (v)) & -a)
81
82 /* Perform machine dependent cif processing */
83 ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
84 ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
85 unsigned int nfixedargs, unsigned int ntotalargs);
86
87
88 #if HAVE_LONG_DOUBLE_VARIANT
89 /* Used to adjust size/alignment of ffi types. */
90 void ffi_prep_types (ffi_abi abi);
91 #endif
92
93 /* Used internally, but overridden by some architectures */
94 ffi_status ffi_prep_cif_core(ffi_cif *cif,
95 ffi_abi abi,
96 unsigned int isvariadic,
97 unsigned int nfixedargs,
98 unsigned int ntotalargs,
99 ffi_type *rtype,
100 ffi_type **atypes);
101
102 /* Translate a data pointer to a code pointer. Needed for closures on
103 some targets. */
104 void *ffi_data_to_code_pointer (void *data) FFI_HIDDEN;
105
106 /* Extended cif, used in callback from assembly routine */
107 typedef struct
108 {
109 ffi_cif *cif;
110 void *rvalue;
111 void **avalue;
112 } extended_cif;
113
114 /* Terse sized type definitions. */
115 #if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C)
116 typedef unsigned char UINT8;
117 typedef signed char SINT8;
118 typedef unsigned short UINT16;
119 typedef signed short SINT16;
120 typedef unsigned int UINT32;
121 typedef signed int SINT32;
122 # ifdef _MSC_VER
123 typedef unsigned __int64 UINT64;
124 typedef signed __int64 SINT64;
125 # else
|