Index: Modules/_ctypes/cfield.c =================================================================== --- Modules/_ctypes/cfield.c (revision 74022) +++ Modules/_ctypes/cfield.c (working copy) @@ -427,11 +427,7 @@ #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) -#else -# define BIT_MASK(size) ((1LL << NUM_BITS(size))-1) -#endif +#define BIT_MASK(v, size) (sizeof(v)*8 == NUM_BITS(size) ? ~0U : ((1U << NUM_BITS(size))-1)) /* This macro CHANGES the first parameter IN PLACE. For proper sign handling, we must first shift left, then right. @@ -445,7 +441,7 @@ /* This macro RETURNS the first parameter with the bit field CHANGED. */ #define SET(x, v, size) \ (NUM_BITS(size) ? \ - ( ( x & ~(BIT_MASK(size) << LOW_BIT(size)) ) | ( (v & BIT_MASK(size)) << LOW_BIT(size) ) ) \ + ( ( x & ~(BIT_MASK(v, size) << LOW_BIT(size)) ) | ( (v & BIT_MASK(v, size)) << LOW_BIT(size) ) ) \ : v) /* byte swapping macros */