[Python-checkins] r58427 - in python/branches/release25-maint: Misc/NEWS Modules/_ctypes/cfield.c

thomas.heller python-checkins at python.org
Fri Oct 12 08:53:33 CEST 2007


Author: thomas.heller
Date: Fri Oct 12 08:53:32 2007
New Revision: 58427

Modified:
   python/branches/release25-maint/Misc/NEWS
   python/branches/release25-maint/Modules/_ctypes/cfield.c
Log:
Fix ctypes on 32-bit systems when Python is configured --with-system-ffi.
See also https://bugs.launchpad.net/bugs/72505.

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Fri Oct 12 08:53:32 2007
@@ -32,6 +32,9 @@
 Library
 -------
 
+- ctypes will now work correctly on 32-bit systems when Python is
+  configured with --with-system-ffi.
+
 - Bug #1777530: ctypes.util.find_library uses dump(1) instead of
   objdump(1) on Solaris.
 

Modified: python/branches/release25-maint/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/release25-maint/Modules/_ctypes/cfield.c	(original)
+++ python/branches/release25-maint/Modules/_ctypes/cfield.c	Fri Oct 12 08:53:32 2007
@@ -1549,17 +1549,21 @@
 /* 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},


More information about the Python-checkins mailing list