Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd847b2

Browse files
committed
Moved LONG_LONG #define from longobject.h to here, since it's needed
by the following. typedef in a portable way the Python name for the C9X uintptr_t type. This latter is the most portable way to spell an integral type to which a void* can be cast to and back again without losing information. Parallel checkin hacks configure to check if the platform/compiler supports the C9X name.
1 parent 512bb72 commit fd847b2

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Include/pyport.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,54 @@ Used in: Py_ARITHMETIC_RIGHT_SHIFT
2828
Py_DEBUG
2929
Meaning: Extra checks compiled in for debug mode.
3030
Used in: Py_SAFE_DOWNCAST
31+
32+
HAVE_UINTPTR_T
33+
Meaning: The C9X type uintptr_t is supported by the compiler
34+
Used in: Py_uintptr_t
35+
36+
HAVE_LONG_LONG
37+
Meaning: The compiler supports the C type "long long"
38+
Used in: LONG_LONG
39+
3140
**************************************************************************/
3241

3342

3443
#define ANY void /* For API compatibility only. Obsolete, do not use. */
3544

45+
/* typedefs for some C9X-defined synonyms for integral types.
46+
*
47+
* The names in Python are exactly the same as the C9X names, except with a
48+
* Py_ prefix. Until C9X is universally implemented, this is the only way
49+
* to ensure that Python gets reliable names that don't conflict with names
50+
* in non-Python code that are playing their own tricks to define the C9X
51+
* names.
52+
*
53+
* NOTE: don't go nuts here! Python has no use for *most* of the C9X
54+
* integral synonyms. Only define the ones we actually need.
55+
*/
56+
57+
#ifdef HAVE_LONG_LONG
58+
#ifndef LONG_LONG
59+
#define LONG_LONG long long
60+
#endif
61+
#endif /* HAVE_LONG_LONG */
62+
63+
/* uintptr_t is the C9X name for an unsigned integral type such that a
64+
* legitimate void* can be cast to uintptr_t and then back to void* again
65+
* without loss of information.
66+
*/
67+
#ifdef HAVE_UINTPTR_T
68+
typedef uintptr_t Py_uintptr_t;
69+
#elif SIZEOF_VOID_P <= SIZEOF_INT
70+
typedef unsigned int Py_uintptr_t;
71+
#elif SIZEOF_VOID_P <= SIZEOF_LONG
72+
typedef unsigned long Py_uintptr_t;
73+
#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG)
74+
typedef unsigned LONG_LONG Py_uintptr_t;
75+
#else
76+
# error "Python needs a typedef for Py_uintptr_t in pyport.h."
77+
#endif /* HAVE_UINTPTR_T */
78+
3679
#ifdef HAVE_STDLIB_H
3780
#include <stdlib.h>
3881
#endif

0 commit comments

Comments
 (0)