]> granicus.if.org Git - python/commitdiff
Fix ctypes on 32-bit systems when Python is configured --with-system-ffi.
authorThomas Heller <theller@ctypes.org>
Fri, 19 Oct 2007 18:11:41 +0000 (18:11 +0000)
committerThomas Heller <theller@ctypes.org>
Fri, 19 Oct 2007 18:11:41 +0000 (18:11 +0000)
See also https://bugs.launchpad.net/bugs/72505.

Ported from release25-maint branch.

Misc/NEWS
Modules/_ctypes/cfield.c

index dc2ba59885933bca335e0d6ccd6cc97d222f2b38..b51c7fd736aaa09ad91c858c3fa460db0b11e20a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -272,6 +272,9 @@ Core and builtins
 Library
 -------
 
+- ctypes will now work correctly on 32-bit systems when Python is
+  configured with --with-system-ffi.
+
 - Patch #1203: ctypes now does work on OS X when Python is built with
   --disable-toolbox-glue
 
index 2f2616f9f0f68f3844217f8b057f5fee3ec78806..5f5fd998af6dc81fb3d4fcce24256c5b7fcc97f3 100644 (file)
@@ -1616,17 +1616,21 @@ static struct fielddesc formattable[] = {
 /* XXX Hm, sizeof(int) == sizeof(long) doesn't hold on every platform */
 /* As soon as we can get rid of the type codes, this is no longer a problem */
 #if SIZEOF_LONG == 4
-       { 'l', l_set, l_get, &ffi_type_sint, l_set_sw, l_get_sw},
-       { 'L', L_set, L_get, &ffi_type_uint, L_set_sw, L_get_sw},
+       { 'l', l_set, l_get, &ffi_type_sint32, l_set_sw, l_get_sw},
+       { 'L', L_set, L_get, &ffi_type_uint32, L_set_sw, L_get_sw},
 #elif SIZEOF_LONG == 8
-       { 'l', l_set, l_get, &ffi_type_slong, l_set_sw, l_get_sw},
-       { 'L', L_set, L_get, &ffi_type_ulong, L_set_sw, L_get_sw},
+       { 'l', l_set, l_get, &ffi_type_sint64, l_set_sw, l_get_sw},
+       { 'L', L_set, L_get, &ffi_type_uint64, L_set_sw, L_get_sw},
 #else
 # error
 #endif
 #ifdef HAVE_LONG_LONG
-       { 'q', q_set, q_get, &ffi_type_slong, q_set_sw, q_get_sw},
-       { 'Q', Q_set, Q_get, &ffi_type_ulong, Q_set_sw, Q_get_sw},
+#if SIZEOF_LONG_LONG == 8
+       { 'q', q_set, q_get, &ffi_type_sint64, q_set_sw, q_get_sw},
+       { 'Q', Q_set, Q_get, &ffi_type_uint64, Q_set_sw, Q_get_sw},
+#else
+# error
+#endif
 #endif
        { 'P', P_set, P_get, &ffi_type_pointer},
        { 'z', z_set, z_get, &ffi_type_pointer},