github.com/whamcloud/lemur@v0.0.0-20190827193804-4655df8a52af/packaging/ci/lambda/GitPullS3/cffi/_cffi_include.h (about) 1 #define _CFFI_ 2 #include <Python.h> 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 #include <stddef.h> 7 #include "parse_c_type.h" 8 9 /* this block of #ifs should be kept exactly identical between 10 c/_cffi_backend.c, cffi/vengine_cpy.py, cffi/vengine_gen.py 11 and cffi/_cffi_include.h */ 12 #if defined(_MSC_VER) 13 # include <malloc.h> /* for alloca() */ 14 # if _MSC_VER < 1600 /* MSVC < 2010 */ 15 typedef __int8 int8_t; 16 typedef __int16 int16_t; 17 typedef __int32 int32_t; 18 typedef __int64 int64_t; 19 typedef unsigned __int8 uint8_t; 20 typedef unsigned __int16 uint16_t; 21 typedef unsigned __int32 uint32_t; 22 typedef unsigned __int64 uint64_t; 23 typedef __int8 int_least8_t; 24 typedef __int16 int_least16_t; 25 typedef __int32 int_least32_t; 26 typedef __int64 int_least64_t; 27 typedef unsigned __int8 uint_least8_t; 28 typedef unsigned __int16 uint_least16_t; 29 typedef unsigned __int32 uint_least32_t; 30 typedef unsigned __int64 uint_least64_t; 31 typedef __int8 int_fast8_t; 32 typedef __int16 int_fast16_t; 33 typedef __int32 int_fast32_t; 34 typedef __int64 int_fast64_t; 35 typedef unsigned __int8 uint_fast8_t; 36 typedef unsigned __int16 uint_fast16_t; 37 typedef unsigned __int32 uint_fast32_t; 38 typedef unsigned __int64 uint_fast64_t; 39 typedef __int64 intmax_t; 40 typedef unsigned __int64 uintmax_t; 41 # else 42 # include <stdint.h> 43 # endif 44 # if _MSC_VER < 1800 /* MSVC < 2013 */ 45 typedef unsigned char _Bool; 46 # endif 47 #else 48 # include <stdint.h> 49 # if (defined (__SVR4) && defined (__sun)) || defined(_AIX) || defined(__hpux) 50 # include <alloca.h> 51 # endif 52 #endif 53 54 #ifdef __GNUC__ 55 # define _CFFI_UNUSED_FN __attribute__((unused)) 56 #else 57 # define _CFFI_UNUSED_FN /* nothing */ 58 #endif 59 60 #ifdef __cplusplus 61 # ifndef _Bool 62 # define _Bool bool /* semi-hackish: C++ has no _Bool; bool is builtin */ 63 # endif 64 #endif 65 66 /********** CPython-specific section **********/ 67 #ifndef PYPY_VERSION 68 69 70 #if PY_MAJOR_VERSION >= 3 71 # define PyInt_FromLong PyLong_FromLong 72 #endif 73 74 #define _cffi_from_c_double PyFloat_FromDouble 75 #define _cffi_from_c_float PyFloat_FromDouble 76 #define _cffi_from_c_long PyInt_FromLong 77 #define _cffi_from_c_ulong PyLong_FromUnsignedLong 78 #define _cffi_from_c_longlong PyLong_FromLongLong 79 #define _cffi_from_c_ulonglong PyLong_FromUnsignedLongLong 80 81 #define _cffi_to_c_double PyFloat_AsDouble 82 #define _cffi_to_c_float PyFloat_AsDouble 83 84 #define _cffi_from_c_int(x, type) \ 85 (((type)-1) > 0 ? /* unsigned */ \ 86 (sizeof(type) < sizeof(long) ? \ 87 PyInt_FromLong((long)x) : \ 88 sizeof(type) == sizeof(long) ? \ 89 PyLong_FromUnsignedLong((unsigned long)x) : \ 90 PyLong_FromUnsignedLongLong((unsigned long long)x)) : \ 91 (sizeof(type) <= sizeof(long) ? \ 92 PyInt_FromLong((long)x) : \ 93 PyLong_FromLongLong((long long)x))) 94 95 #define _cffi_to_c_int(o, type) \ 96 ((type)( \ 97 sizeof(type) == 1 ? (((type)-1) > 0 ? (type)_cffi_to_c_u8(o) \ 98 : (type)_cffi_to_c_i8(o)) : \ 99 sizeof(type) == 2 ? (((type)-1) > 0 ? (type)_cffi_to_c_u16(o) \ 100 : (type)_cffi_to_c_i16(o)) : \ 101 sizeof(type) == 4 ? (((type)-1) > 0 ? (type)_cffi_to_c_u32(o) \ 102 : (type)_cffi_to_c_i32(o)) : \ 103 sizeof(type) == 8 ? (((type)-1) > 0 ? (type)_cffi_to_c_u64(o) \ 104 : (type)_cffi_to_c_i64(o)) : \ 105 (Py_FatalError("unsupported size for type " #type), (type)0))) 106 107 #define _cffi_to_c_i8 \ 108 ((int(*)(PyObject *))_cffi_exports[1]) 109 #define _cffi_to_c_u8 \ 110 ((int(*)(PyObject *))_cffi_exports[2]) 111 #define _cffi_to_c_i16 \ 112 ((int(*)(PyObject *))_cffi_exports[3]) 113 #define _cffi_to_c_u16 \ 114 ((int(*)(PyObject *))_cffi_exports[4]) 115 #define _cffi_to_c_i32 \ 116 ((int(*)(PyObject *))_cffi_exports[5]) 117 #define _cffi_to_c_u32 \ 118 ((unsigned int(*)(PyObject *))_cffi_exports[6]) 119 #define _cffi_to_c_i64 \ 120 ((long long(*)(PyObject *))_cffi_exports[7]) 121 #define _cffi_to_c_u64 \ 122 ((unsigned long long(*)(PyObject *))_cffi_exports[8]) 123 #define _cffi_to_c_char \ 124 ((int(*)(PyObject *))_cffi_exports[9]) 125 #define _cffi_from_c_pointer \ 126 ((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[10]) 127 #define _cffi_to_c_pointer \ 128 ((char *(*)(PyObject *, CTypeDescrObject *))_cffi_exports[11]) 129 #define _cffi_get_struct_layout \ 130 not used any more 131 #define _cffi_restore_errno \ 132 ((void(*)(void))_cffi_exports[13]) 133 #define _cffi_save_errno \ 134 ((void(*)(void))_cffi_exports[14]) 135 #define _cffi_from_c_char \ 136 ((PyObject *(*)(char))_cffi_exports[15]) 137 #define _cffi_from_c_deref \ 138 ((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[16]) 139 #define _cffi_to_c \ 140 ((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[17]) 141 #define _cffi_from_c_struct \ 142 ((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[18]) 143 #define _cffi_to_c_wchar_t \ 144 ((wchar_t(*)(PyObject *))_cffi_exports[19]) 145 #define _cffi_from_c_wchar_t \ 146 ((PyObject *(*)(wchar_t))_cffi_exports[20]) 147 #define _cffi_to_c_long_double \ 148 ((long double(*)(PyObject *))_cffi_exports[21]) 149 #define _cffi_to_c__Bool \ 150 ((_Bool(*)(PyObject *))_cffi_exports[22]) 151 #define _cffi_prepare_pointer_call_argument \ 152 ((Py_ssize_t(*)(CTypeDescrObject *, PyObject *, char **))_cffi_exports[23]) 153 #define _cffi_convert_array_from_object \ 154 ((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[24]) 155 #define _CFFI_CPIDX 25 156 #define _cffi_call_python \ 157 ((void(*)(struct _cffi_externpy_s *, char *))_cffi_exports[_CFFI_CPIDX]) 158 #define _CFFI_NUM_EXPORTS 26 159 160 typedef struct _ctypedescr CTypeDescrObject; 161 162 static void *_cffi_exports[_CFFI_NUM_EXPORTS]; 163 164 #define _cffi_type(index) ( \ 165 assert((((uintptr_t)_cffi_types[index]) & 1) == 0), \ 166 (CTypeDescrObject *)_cffi_types[index]) 167 168 static PyObject *_cffi_init(const char *module_name, Py_ssize_t version, 169 const struct _cffi_type_context_s *ctx) 170 { 171 PyObject *module, *o_arg, *new_module; 172 void *raw[] = { 173 (void *)module_name, 174 (void *)version, 175 (void *)_cffi_exports, 176 (void *)ctx, 177 }; 178 179 module = PyImport_ImportModule("_cffi_backend"); 180 if (module == NULL) 181 goto failure; 182 183 o_arg = PyLong_FromVoidPtr((void *)raw); 184 if (o_arg == NULL) 185 goto failure; 186 187 new_module = PyObject_CallMethod( 188 module, (char *)"_init_cffi_1_0_external_module", (char *)"O", o_arg); 189 190 Py_DECREF(o_arg); 191 Py_DECREF(module); 192 return new_module; 193 194 failure: 195 Py_XDECREF(module); 196 return NULL; 197 } 198 199 _CFFI_UNUSED_FN 200 static PyObject **_cffi_unpack_args(PyObject *args_tuple, Py_ssize_t expected, 201 const char *fnname) 202 { 203 if (PyTuple_GET_SIZE(args_tuple) != expected) { 204 PyErr_Format(PyExc_TypeError, 205 "%.150s() takes exactly %zd arguments (%zd given)", 206 fnname, expected, PyTuple_GET_SIZE(args_tuple)); 207 return NULL; 208 } 209 return &PyTuple_GET_ITEM(args_tuple, 0); /* pointer to the first item, 210 the others follow */ 211 } 212 213 /********** end CPython-specific section **********/ 214 #else 215 _CFFI_UNUSED_FN 216 static void (*_cffi_call_python_org)(struct _cffi_externpy_s *, char *); 217 # define _cffi_call_python _cffi_call_python_org 218 #endif 219 220 221 #define _cffi_array_len(array) (sizeof(array) / sizeof((array)[0])) 222 223 #define _cffi_prim_int(size, sign) \ 224 ((size) == 1 ? ((sign) ? _CFFI_PRIM_INT8 : _CFFI_PRIM_UINT8) : \ 225 (size) == 2 ? ((sign) ? _CFFI_PRIM_INT16 : _CFFI_PRIM_UINT16) : \ 226 (size) == 4 ? ((sign) ? _CFFI_PRIM_INT32 : _CFFI_PRIM_UINT32) : \ 227 (size) == 8 ? ((sign) ? _CFFI_PRIM_INT64 : _CFFI_PRIM_UINT64) : \ 228 _CFFI__UNKNOWN_PRIM) 229 230 #define _cffi_prim_float(size) \ 231 ((size) == sizeof(float) ? _CFFI_PRIM_FLOAT : \ 232 (size) == sizeof(double) ? _CFFI_PRIM_DOUBLE : \ 233 (size) == sizeof(long double) ? _CFFI__UNKNOWN_LONG_DOUBLE : \ 234 _CFFI__UNKNOWN_FLOAT_PRIM) 235 236 #define _cffi_check_int(got, got_nonpos, expected) \ 237 ((got_nonpos) == (expected <= 0) && \ 238 (got) == (unsigned long long)expected) 239 240 #ifdef MS_WIN32 241 # define _cffi_stdcall __stdcall 242 #else 243 # define _cffi_stdcall /* nothing */ 244 #endif 245 246 #ifdef __cplusplus 247 } 248 #endif