Index: Modules/_ctypes/cfield.c =================================================================== --- Modules/_ctypes/cfield.c (revision 85158) +++ Modules/_ctypes/cfield.c (working copy) @@ -428,13 +428,15 @@ #define LOW_BIT(x) ((x) & 0xFFFF) #define NUM_BITS(x) ((x) >> 16) -/* This seems nore a compiler issue than a Windows/non-Windows one */ -#ifdef MS_WIN32 -# define BIT_MASK(size) ((1 << NUM_BITS(size))-1) +#ifdef HAVE_LONG_LONG +# define MAX_SIZE_INT(n) Py_ULL(1) #else -# define BIT_MASK(size) ((1LL << NUM_BITS(size))-1) +# define MAX_SIZE_INT(n) n##UL #endif +/* BIT_MASK(0) won't return correct result */ +#define BIT_MASK(size) ((((MAX_SIZE_INT(1) << (NUM_BITS(size) - 1)) - 1) << 1) + 1) + /* This macro CHANGES the first parameter IN PLACE. For proper sign handling, we must first shift left, then right. */