diff options
Diffstat (limited to 'c')
| -rw-r--r-- | c/_cffi_backend.c | 18 | ||||
| -rw-r--r-- | c/cffi1_module.c | 5 | ||||
| -rw-r--r-- | c/parse_c_type.c | 3 | ||||
| -rw-r--r-- | c/realize_c_type.c | 6 |
4 files changed, 21 insertions, 11 deletions
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c index c7c48f8..0739927 100644 --- a/c/_cffi_backend.c +++ b/c/_cffi_backend.c @@ -60,6 +60,15 @@ # endif #endif +#ifdef __SIZEOF_INT128__ +# define HAVE_TYPE_INT128 +typedef __int128 largest_int_t; +typedef unsigned __int128 largest_uint_t; +#else +typedef long long largest_int_t; +typedef unsigned long long largest_uint_t; +#endif + /* Define the following macro ONLY if you trust libffi's version of * ffi_closure_alloc() more than the code in malloc_closure.h. @@ -254,15 +263,6 @@ static PyTypeObject CDataGCP_Type; #define CDataOwn_Check(ob) (Py_TYPE(ob) == &CDataOwning_Type || \ Py_TYPE(ob) == &CDataOwningGC_Type) -#ifdef __SIZEOF_INT128__ -# define HAVE_TYPE_INT128 -typedef __int128 largest_int_t; -typedef unsigned __int128 largest_uint_t; -#else -typedef long long largest_int_t; -typedef unsigned long long largest_uint_t; -#endif - typedef union { unsigned char m_char; unsigned short m_short; diff --git a/c/cffi1_module.c b/c/cffi1_module.c index 06a84fe..80e6988 100644 --- a/c/cffi1_module.c +++ b/c/cffi1_module.c @@ -4,7 +4,8 @@ #define CFFI_VERSION_MIN 0x2601 #define CFFI_VERSION_CHAR16CHAR32 0x2801 -#define CFFI_VERSION_MAX 0x28FF +#define CFFI_VERSION_INT128 0x2901 +#define CFFI_VERSION_MAX 0x29FF typedef struct FFIObject_s FFIObject; typedef struct LibObject_s LibObject; @@ -171,6 +172,8 @@ static PyObject *b_init_cffi_1_0_external_module(PyObject *self, PyObject *arg) num_exports = 26; if (version >= CFFI_VERSION_CHAR16CHAR32) num_exports = 28; + if (version >= CFFI_VERSION_INT128) + num_exports = 30; memcpy(exports, (char *)cffi_exports, num_exports * sizeof(void *)); /* make the module object */ diff --git a/c/parse_c_type.c b/c/parse_c_type.c index 698ef64..ffce219 100644 --- a/c/parse_c_type.c +++ b/c/parse_c_type.c @@ -43,6 +43,8 @@ enum token_e { TOK_CDECL, TOK_STDCALL, + + TOK_INT128, }; typedef struct { @@ -160,6 +162,7 @@ static void next_token(token_t *tok) if (tok->size == 7 && !memcmp(p,"__cdecl",7)) tok->kind = TOK_CDECL; if (tok->size == 9 && !memcmp(p,"__stdcall",9))tok->kind = TOK_STDCALL; if (tok->size == 8 && !memcmp(p,"_Complex",8)) tok->kind = TOK__COMPLEX; + if (tok->size == 8 && !memcmp(p,"__int128",8)) tok->kind = TOK_INT128; break; case 'c': if (tok->size == 4 && !memcmp(p, "char", 4)) tok->kind = TOK_CHAR; diff --git a/c/realize_c_type.c b/c/realize_c_type.c index 82629b7..1bb9f75 100644 --- a/c/realize_c_type.c +++ b/c/realize_c_type.c @@ -155,10 +155,14 @@ static PyObject *build_primitive_type(int num) "double _Complex", "char16_t", "char32_t", + "__int128", + "unsigned __int128", }; PyObject *x; - assert(sizeof(primitive_name) == sizeof(*primitive_name) * _CFFI__NUM_PRIM); + if (sizeof(primitive_name) != sizeof(*primitive_name) * _CFFI__NUM_PRIM) + Py_FatalError("realize_c_type.c: fix primitive_name[]"); + if (num == _CFFI_PRIM_VOID) { x = new_void_type(); } |
