stefan at bytereef
May 13, 2012, 2:48 AM
Post #2 of 2
"Martin v. L?wis" <martin [at] v> wrote:
Re: [Python-checkins] cpython: Issue #14779: Do not use get_config_var('SIZEOF_VOID_P') on OS X 64-/32-bit
[In reply to]
>> - self.sizeof_void_p = get_config_var('SIZEOF_VOID_P')
>> + self.sizeof_void_p = get_config_var('SIZEOF_VOID_P') \
>> + if sys.platform != 'darwin' else None
>> if not self.sizeof_void_p:
>> - self.sizeof_void_p = 8 if architecture() == '64bit' else 4
>> + self.sizeof_void_p = 8 if sys.maxsize> 2**32 else 4
> Why not unconditionally use sys.maxsize?
Because the tests need sizeof(void *). In an array with suboffsets void
pointers are embedded at the start of the array.
The C standard doesn't guarantee sizeof(void *) == sizeof(size_t). In
fact, there are machines where sizeof(void *) > sizeof(size_t):
If you change pyconfig.h to 128 bit pointers while leaving sizeof(size_t)
and sizeof(ssize_t) at 8, pyport.h by itself doesn't catch the mismatch.
/* The size of `uintptr_t', as computed by sizeof. */
#define SIZEOF_UINTPTR_T 16
/* The size of `void *', as computed by sizeof. */
#define SIZEOF_VOID_P 16
However, now that I tried to compile Python with that pyconfig.h,
longobject.c *does* catch it:
Objects/longobject.c:943:5: error: #error "PyLong_FromVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)"
Objects/longobject.c:970:5: error: #error "PyLong_AsVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)"
If sizeof(void *) == sizeof(size_t) is the general assumption for compiling
Python, I think the test should happen prominently in either pyport.h or
> I'd also hard-code that sys.maxsize ought to be either 2**31-1 or 2**63-1.
I would have done exactly that, but the example in the docs that was quoted
to me in the issue uses > 2**32:
Python-Dev mailing list
Python-Dev [at] python