1 #ifndef Py_PYPORT_H 2 #define Py_PYPORT_H 3 4 #ifndef UCHAR_MAX 5 # error "<limits.h> header must define UCHAR_MAX" 6 #endif 7 #if UCHAR_MAX != 255 8 # error "Python's source code assumes C's unsigned char is an 8-bit type" 9 #endif 10 11 12 // Macro to use C++ static_cast<> in the Python C API. 13 #ifdef __cplusplus 14 # define _Py_STATIC_CAST(type, expr) static_cast<type>(expr) 15 #else 16 # define _Py_STATIC_CAST(type, expr) ((type)(expr)) 17 #endif 18 // Macro to use the more powerful/dangerous C-style cast even in C++. 19 #define _Py_CAST(type, expr) ((type)(expr)) 20 21 // Static inline functions should use _Py_NULL rather than using directly NULL 22 // to prevent C++ compiler warnings. On C23 and newer and on C++11 and newer, 23 // _Py_NULL is defined as nullptr. 24 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L) \ 25 || (defined(__cplusplus) && __cplusplus >= 201103) 26 # define _Py_NULL nullptr 27 #else 28 # define _Py_NULL NULL 29 #endif 30 31 32 /* Defines to build Python and its standard library: 33 * 34 * - Py_BUILD_CORE: Build Python core. Give access to Python internals, but 35 * should not be used by third-party modules. 36 * - Py_BUILD_CORE_BUILTIN: Build a Python stdlib module as a built-in module. 37 * - Py_BUILD_CORE_MODULE: Build a Python stdlib module as a dynamic library. 38 * 39 * Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE imply Py_BUILD_CORE. 40 * 41 * On Windows, Py_BUILD_CORE_MODULE exports "PyInit_xxx" symbol, whereas 42 * Py_BUILD_CORE_BUILTIN does not. 43 */ 44 #if defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE) 45 # define Py_BUILD_CORE 46 #endif 47 #if defined(Py_BUILD_CORE_MODULE) && !defined(Py_BUILD_CORE) 48 # define Py_BUILD_CORE 49 #endif 50 51 52 /************************************************************************** 53 Symbols and macros to supply platform-independent interfaces to basic 54 C language & library operations whose spellings vary across platforms. 55 56 Please try to make documentation here as clear as possible: by definition, 57 the stuff here is trying to illuminate C's darkest corners. 58 59 Config #defines referenced here: 60 61 SIGNED_RIGHT_SHIFT_ZERO_FILLS 62 Meaning: To be defined iff i>>j does not extend the sign bit when i is a 63 signed integral type and i < 0. 64 Used in: Py_ARITHMETIC_RIGHT_SHIFT 65 66 Py_DEBUG 67 Meaning: Extra checks compiled in for debug mode. 68 Used in: Py_SAFE_DOWNCAST 69 70 **************************************************************************/ 71 72 /* typedefs for some C9X-defined synonyms for integral types. 73 * 74 * The names in Python are exactly the same as the C9X names, except with a 75 * Py_ prefix. Until C9X is universally implemented, this is the only way 76 * to ensure that Python gets reliable names that don't conflict with names 77 * in non-Python code that are playing their own tricks to define the C9X 78 * names. 79 * 80 * NOTE: don't go nuts here! Python has no use for *most* of the C9X 81 * integral synonyms. Only define the ones we actually need. 82 */ 83 84 /* long long is required. Ensure HAVE_LONG_LONG is defined for compatibility. */ 85 #ifndef HAVE_LONG_LONG 86 #define HAVE_LONG_LONG 1 87 #endif 88 #ifndef PY_LONG_LONG 89 #define PY_LONG_LONG long long 90 /* If LLONG_MAX is defined in limits.h, use that. */ 91 #define PY_LLONG_MIN LLONG_MIN 92 #define PY_LLONG_MAX LLONG_MAX 93 #define PY_ULLONG_MAX ULLONG_MAX 94 #endif 95 96 #define PY_UINT32_T uint32_t 97 #define PY_UINT64_T uint64_t 98 99 /* Signed variants of the above */ 100 #define PY_INT32_T int32_t 101 #define PY_INT64_T int64_t 102 103 /* PYLONG_BITS_IN_DIGIT describes the number of bits per "digit" (limb) in the 104 * PyLongObject implementation (longintrepr.h). It's currently either 30 or 15, 105 * defaulting to 30. The 15-bit digit option may be removed in the future. 106 */ 107 #ifndef PYLONG_BITS_IN_DIGIT 108 #define PYLONG_BITS_IN_DIGIT 30 109 #endif 110 111 /* uintptr_t is the C9X name for an unsigned integral type such that a 112 * legitimate void* can be cast to uintptr_t and then back to void* again 113 * without loss of information. Similarly for intptr_t, wrt a signed 114 * integral type. 115 */ 116 typedef uintptr_t Py_uintptr_t; 117 typedef intptr_t Py_intptr_t; 118 119 /* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) == 120 * sizeof(size_t). C99 doesn't define such a thing directly (size_t is an 121 * unsigned integral type). See PEP 353 for details. 122 * PY_SSIZE_T_MAX is the largest positive value of type Py_ssize_t. 123 */ 124 #ifdef HAVE_PY_SSIZE_T 125 126 #elif HAVE_SSIZE_T 127 typedef ssize_t Py_ssize_t; 128 # define PY_SSIZE_T_MAX SSIZE_MAX 129 #elif SIZEOF_VOID_P == SIZEOF_SIZE_T 130 typedef Py_intptr_t Py_ssize_t; 131 # define PY_SSIZE_T_MAX INTPTR_MAX 132 #else 133 # error "Python needs a typedef for Py_ssize_t in pyport.h." 134 #endif 135 136 /* Smallest negative value of type Py_ssize_t. */ 137 #define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) 138 139 /* Py_hash_t is the same size as a pointer. */ 140 #define SIZEOF_PY_HASH_T SIZEOF_SIZE_T 141 typedef Py_ssize_t Py_hash_t; 142 /* Py_uhash_t is the unsigned equivalent needed to calculate numeric hash. */ 143 #define SIZEOF_PY_UHASH_T SIZEOF_SIZE_T 144 typedef size_t Py_uhash_t; 145 146 /* Now PY_SSIZE_T_CLEAN is mandatory. This is just for backward compatibility. */ 147 typedef Py_ssize_t Py_ssize_clean_t; 148 149 /* Largest possible value of size_t. */ 150 #define PY_SIZE_MAX SIZE_MAX 151 152 /* Macro kept for backward compatibility: use directly "z" in new code. 153 * 154 * PY_FORMAT_SIZE_T is a modifier for use in a printf format to convert an 155 * argument with the width of a size_t or Py_ssize_t: "z" (C99). 156 */ 157 #ifndef PY_FORMAT_SIZE_T 158 # define PY_FORMAT_SIZE_T "z" 159 #endif 160 161 /* Py_LOCAL can be used instead of static to get the fastest possible calling 162 * convention for functions that are local to a given module. 163 * 164 * Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining, 165 * for platforms that support that. 166 * 167 * NOTE: You can only use this for functions that are entirely local to a 168 * module; functions that are exported via method tables, callbacks, etc, 169 * should keep using static. 170 */ 171 172 #if defined(_MSC_VER) 173 /* ignore warnings if the compiler decides not to inline a function */ 174 # pragma warning(disable: 4710) 175 /* fastest possible local call under MSVC */ 176 # define Py_LOCAL(type) static type __fastcall 177 # define Py_LOCAL_INLINE(type) static __inline type __fastcall 178 #else 179 # define Py_LOCAL(type) static type 180 # define Py_LOCAL_INLINE(type) static inline type 181 #endif 182 183 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 184 # define Py_MEMCPY memcpy 185 #endif 186 187 #ifdef __cplusplus 188 /* Move this down here since some C++ #include's don't like to be included 189 inside an extern "C" */ 190 extern "C" { 191 #endif 192 193 194 /* Py_ARITHMETIC_RIGHT_SHIFT 195 * C doesn't define whether a right-shift of a signed integer sign-extends 196 * or zero-fills. Here a macro to force sign extension: 197 * Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) 198 * Return I >> J, forcing sign extension. Arithmetically, return the 199 * floor of I/2**J. 200 * Requirements: 201 * I should have signed integer type. In the terminology of C99, this can 202 * be either one of the five standard signed integer types (signed char, 203 * short, int, long, long long) or an extended signed integer type. 204 * J is an integer >= 0 and strictly less than the number of bits in the 205 * type of I (because C doesn't define what happens for J outside that 206 * range either). 207 * TYPE used to specify the type of I, but is now ignored. It's been left 208 * in for backwards compatibility with versions <= 2.6 or 3.0. 209 * Caution: 210 * I may be evaluated more than once. 211 */ 212 #ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS 213 #define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \ 214 ((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J)) 215 #else 216 #define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J)) 217 #endif 218 219 /* Py_FORCE_EXPANSION(X) 220 * "Simply" returns its argument. However, macro expansions within the 221 * argument are evaluated. This unfortunate trickery is needed to get 222 * token-pasting to work as desired in some cases. 223 */ 224 #define Py_FORCE_EXPANSION(X) X 225 226 /* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) 227 * Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this 228 * assert-fails if any information is lost. 229 * Caution: 230 * VALUE may be evaluated more than once. 231 */ 232 #ifdef Py_DEBUG 233 # define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ 234 (assert(_Py_STATIC_CAST(WIDE, _Py_STATIC_CAST(NARROW, (VALUE))) == (VALUE)), \ 235 _Py_STATIC_CAST(NARROW, (VALUE))) 236 #else 237 # define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) _Py_STATIC_CAST(NARROW, (VALUE)) 238 #endif 239 240 241 /* Py_DEPRECATED(version) 242 * Declare a variable, type, or function deprecated. 243 * The macro must be placed before the declaration. 244 * Usage: 245 * Py_DEPRECATED(3.3) extern int old_var; 246 * Py_DEPRECATED(3.4) typedef int T1; 247 * Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void); 248 */ 249 #if defined(__GNUC__) \ 250 && ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) 251 #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) 252 #elif defined(_MSC_VER) 253 #define Py_DEPRECATED(VERSION) __declspec(deprecated( \ 254 "deprecated in " #VERSION)) 255 #else 256 #define Py_DEPRECATED(VERSION_UNUSED) 257 #endif 258 259 // _Py_DEPRECATED_EXTERNALLY(version) 260 // Deprecated outside CPython core. 261 #ifdef Py_BUILD_CORE 262 #define _Py_DEPRECATED_EXTERNALLY(VERSION_UNUSED) 263 #else 264 #define _Py_DEPRECATED_EXTERNALLY(version) Py_DEPRECATED(version) 265 #endif 266 267 268 #if defined(__clang__) 269 #define _Py_COMP_DIAG_PUSH _Pragma("clang diagnostic push") 270 #define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \ 271 _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") 272 #define _Py_COMP_DIAG_POP _Pragma("clang diagnostic pop") 273 #elif defined(__GNUC__) \ 274 && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) 275 #define _Py_COMP_DIAG_PUSH _Pragma("GCC diagnostic push") 276 #define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \ 277 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") 278 #define _Py_COMP_DIAG_POP _Pragma("GCC diagnostic pop") 279 #elif defined(_MSC_VER) 280 #define _Py_COMP_DIAG_PUSH __pragma(warning(push)) 281 #define _Py_COMP_DIAG_IGNORE_DEPR_DECLS __pragma(warning(disable: 4996)) 282 #define _Py_COMP_DIAG_POP __pragma(warning(pop)) 283 #else 284 #define _Py_COMP_DIAG_PUSH 285 #define _Py_COMP_DIAG_IGNORE_DEPR_DECLS 286 #define _Py_COMP_DIAG_POP 287 #endif 288 289 /* _Py_HOT_FUNCTION 290 * The hot attribute on a function is used to inform the compiler that the 291 * function is a hot spot of the compiled program. The function is optimized 292 * more aggressively and on many target it is placed into special subsection of 293 * the text section so all hot functions appears close together improving 294 * locality. 295 * 296 * Usage: 297 * int _Py_HOT_FUNCTION x(void) { return 3; } 298 * 299 * Issue #28618: This attribute must not be abused, otherwise it can have a 300 * negative effect on performance. Only the functions were Python spend most of 301 * its time must use it. Use a profiler when running performance benchmark 302 * suite to find these functions. 303 */ 304 #if defined(__GNUC__) \ 305 && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) 306 #define _Py_HOT_FUNCTION __attribute__((hot)) 307 #else 308 #define _Py_HOT_FUNCTION 309 #endif 310 311 // Ask the compiler to always inline a static inline function. The compiler can 312 // ignore it and decides to not inline the function. 313 // 314 // It can be used to inline performance critical static inline functions when 315 // building Python in debug mode with function inlining disabled. For example, 316 // MSC disables function inlining when building in debug mode. 317 // 318 // Marking blindly a static inline function with Py_ALWAYS_INLINE can result in 319 // worse performances (due to increased code size for example). The compiler is 320 // usually smarter than the developer for the cost/benefit analysis. 321 // 322 // If Python is built in debug mode (if the Py_DEBUG macro is defined), the 323 // Py_ALWAYS_INLINE macro does nothing. 324 // 325 // It must be specified before the function return type. Usage: 326 // 327 // static inline Py_ALWAYS_INLINE int random(void) { return 4; } 328 #if defined(Py_DEBUG) 329 // If Python is built in debug mode, usually compiler optimizations are 330 // disabled. In this case, Py_ALWAYS_INLINE can increase a lot the stack 331 // memory usage. For example, forcing inlining using gcc -O0 increases the 332 // stack usage from 6 KB to 15 KB per Python function call. 333 # define Py_ALWAYS_INLINE 334 #elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) 335 # define Py_ALWAYS_INLINE __attribute__((always_inline)) 336 #elif defined(_MSC_VER) 337 # define Py_ALWAYS_INLINE __forceinline 338 #else 339 # define Py_ALWAYS_INLINE 340 #endif 341 342 // Py_NO_INLINE 343 // Disable inlining on a function. For example, it reduces the C stack 344 // consumption: useful on LTO+PGO builds which heavily inline code (see 345 // bpo-33720). 346 // 347 // Usage: 348 // 349 // Py_NO_INLINE static int random(void) { return 4; } 350 #if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) 351 # define Py_NO_INLINE __attribute__ ((noinline)) 352 #elif defined(_MSC_VER) 353 # define Py_NO_INLINE __declspec(noinline) 354 #else 355 # define Py_NO_INLINE 356 #endif 357 358 #include "exports.h" 359 360 #ifdef Py_LIMITED_API 361 // The internal C API must not be used with the limited C API: make sure 362 // that Py_BUILD_CORE macro is not defined in this case. These 3 macros are 363 // used by exports.h, so only undefine them afterwards. 364 # undef Py_BUILD_CORE 365 # undef Py_BUILD_CORE_BUILTIN 366 # undef Py_BUILD_CORE_MODULE 367 #endif 368 369 /* limits.h constants that may be missing */ 370 371 #ifndef INT_MAX 372 #define INT_MAX 2147483647 373 #endif 374 375 #ifndef LONG_MAX 376 #if SIZEOF_LONG == 4 377 #define LONG_MAX 0X7FFFFFFFL 378 #elif SIZEOF_LONG == 8 379 #define LONG_MAX 0X7FFFFFFFFFFFFFFFL 380 #else 381 #error "could not set LONG_MAX in pyport.h" 382 #endif 383 #endif 384 385 #ifndef LONG_MIN 386 #define LONG_MIN (-LONG_MAX-1) 387 #endif 388 389 #ifndef LONG_BIT 390 #define LONG_BIT (8 * SIZEOF_LONG) 391 #endif 392 393 #if LONG_BIT != 8 * SIZEOF_LONG 394 /* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent 395 * 32-bit platforms using gcc. We try to catch that here at compile-time 396 * rather than waiting for integer multiplication to trigger bogus 397 * overflows. 398 */ 399 #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." 400 #endif 401 402 #ifdef __cplusplus 403 } 404 #endif 405 406 /* 407 * Hide GCC attributes from compilers that don't support them. 408 */ 409 #if (!defined(__GNUC__) || __GNUC__ < 2 || \ 410 (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) 411 #define Py_GCC_ATTRIBUTE(x) 412 #else 413 #define Py_GCC_ATTRIBUTE(x) __attribute__(x) 414 #endif 415 416 /* 417 * Specify alignment on compilers that support it. 418 */ 419 #if defined(__GNUC__) && __GNUC__ >= 3 420 #define Py_ALIGNED(x) __attribute__((aligned(x))) 421 #else 422 #define Py_ALIGNED(x) 423 #endif 424 425 /* Eliminate end-of-loop code not reached warnings from SunPro C 426 * when using do{...}while(0) macros 427 */ 428 #ifdef __SUNPRO_C 429 #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) 430 #endif 431 432 #ifndef Py_LL 433 #define Py_LL(x) x##LL 434 #endif 435 436 #ifndef Py_ULL 437 #define Py_ULL(x) Py_LL(x##U) 438 #endif 439 440 #define Py_VA_COPY va_copy 441 442 /* 443 * Convenient macros to deal with endianness of the platform. WORDS_BIGENDIAN is 444 * detected by configure and defined in pyconfig.h. The code in pyconfig.h 445 * also takes care of Apple's universal builds. 446 */ 447 448 #ifdef WORDS_BIGENDIAN 449 # define PY_BIG_ENDIAN 1 450 # define PY_LITTLE_ENDIAN 0 451 #else 452 # define PY_BIG_ENDIAN 0 453 # define PY_LITTLE_ENDIAN 1 454 #endif 455 456 #ifdef __ANDROID__ 457 /* The Android langinfo.h header is not used. */ 458 # undef HAVE_LANGINFO_H 459 # undef CODESET 460 #endif 461 462 /* Maximum value of the Windows DWORD type */ 463 #define PY_DWORD_MAX 4294967295U 464 465 /* This macro used to tell whether Python was built with multithreading 466 * enabled. Now multithreading is always enabled, but keep the macro 467 * for compatibility. 468 */ 469 #ifndef WITH_THREAD 470 # define WITH_THREAD 471 #endif 472 473 /* Some WebAssembly platforms do not provide a working pthread implementation. 474 * Thread support is stubbed and any attempt to create a new thread fails. 475 */ 476 #if (!defined(HAVE_PTHREAD_STUBS) && \ 477 (!defined(__EMSCRIPTEN__) || defined(__EMSCRIPTEN_PTHREADS__))) 478 # define Py_CAN_START_THREADS 1 479 #endif 480 481 #ifdef WITH_THREAD 482 # ifdef Py_BUILD_CORE 483 # ifdef HAVE_THREAD_LOCAL 484 # error "HAVE_THREAD_LOCAL is already defined" 485 # endif 486 # define HAVE_THREAD_LOCAL 1 487 # ifdef thread_local 488 # define _Py_thread_local thread_local 489 # elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) 490 # define _Py_thread_local _Thread_local 491 # elif defined(_MSC_VER) /* AKA NT_THREADS */ 492 # define _Py_thread_local __declspec(thread) 493 # elif defined(__GNUC__) /* includes clang */ 494 # define _Py_thread_local __thread 495 # else 496 // fall back to the PyThread_tss_*() API, or ignore. 497 # undef HAVE_THREAD_LOCAL 498 # endif 499 # endif 500 #endif 501 502 #if defined(__ANDROID__) || defined(__VXWORKS__) 503 // Use UTF-8 as the locale encoding, ignore the LC_CTYPE locale. 504 // See _Py_GetLocaleEncoding(), PyUnicode_DecodeLocale() 505 // and PyUnicode_EncodeLocale(). 506 # define _Py_FORCE_UTF8_LOCALE 507 #endif 508 509 #if defined(_Py_FORCE_UTF8_LOCALE) || defined(__APPLE__) 510 // Use UTF-8 as the filesystem encoding. 511 // See PyUnicode_DecodeFSDefaultAndSize(), PyUnicode_EncodeFSDefault(), 512 // Py_DecodeLocale() and Py_EncodeLocale(). 513 # define _Py_FORCE_UTF8_FS_ENCODING 514 #endif 515 516 /* Mark a function which cannot return. Example: 517 PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void); 518 519 XLC support is intentionally omitted due to bpo-40244 */ 520 #ifndef _Py_NO_RETURN 521 #if defined(__clang__) || \ 522 (defined(__GNUC__) && \ 523 ((__GNUC__ >= 3) || \ 524 (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5))) 525 # define _Py_NO_RETURN __attribute__((__noreturn__)) 526 #elif defined(_MSC_VER) 527 # define _Py_NO_RETURN __declspec(noreturn) 528 #else 529 # define _Py_NO_RETURN 530 #endif 531 #endif 532 533 534 // Preprocessor check for a builtin preprocessor function. Always return 0 535 // if __has_builtin() macro is not defined. 536 // 537 // __has_builtin() is available on clang and GCC 10. 538 #ifdef __has_builtin 539 # define _Py__has_builtin(x) __has_builtin(x) 540 #else 541 # define _Py__has_builtin(x) 0 542 #endif 543 544 // _Py_TYPEOF(expr) gets the type of an expression. 545 // 546 // Example: _Py_TYPEOF(x) x_copy = (x); 547 // 548 // The macro is only defined if GCC or clang compiler is used. 549 #if defined(__GNUC__) || defined(__clang__) 550 # define _Py_TYPEOF(expr) __typeof__(expr) 551 #endif 552 553 554 /* A convenient way for code to know if sanitizers are enabled. */ 555 #if defined(__has_feature) 556 # if __has_feature(memory_sanitizer) 557 # if !defined(_Py_MEMORY_SANITIZER) 558 # define _Py_MEMORY_SANITIZER 559 # endif 560 # endif 561 # if __has_feature(address_sanitizer) 562 # if !defined(_Py_ADDRESS_SANITIZER) 563 # define _Py_ADDRESS_SANITIZER 564 # endif 565 # endif 566 # if __has_feature(thread_sanitizer) 567 # if !defined(_Py_THREAD_SANITIZER) 568 # define _Py_THREAD_SANITIZER 569 # endif 570 # endif 571 #elif defined(__GNUC__) 572 # if defined(__SANITIZE_ADDRESS__) 573 # define _Py_ADDRESS_SANITIZER 574 # endif 575 # if defined(__SANITIZE_THREAD__) 576 # define _Py_THREAD_SANITIZER 577 # endif 578 #endif 579 580 581 /* AIX has __bool__ redefined in it's system header file. */ 582 #if defined(_AIX) && defined(__bool__) 583 #undef __bool__ 584 #endif 585 586 // Make sure we have maximum alignment, even if the current compiler 587 // does not support max_align_t. Note that: 588 // - Autoconf reports alignment of unknown types to 0. 589 // - 'long double' has maximum alignment on *most* platforms, 590 // looks like the best we can do for pre-C11 compilers. 591 // - The value is tested, see test_alignof_max_align_t 592 #if !defined(ALIGNOF_MAX_ALIGN_T) || ALIGNOF_MAX_ALIGN_T == 0 593 # undef ALIGNOF_MAX_ALIGN_T 594 # define ALIGNOF_MAX_ALIGN_T _Alignof(long double) 595 #endif 596 597 #ifndef PY_CXX_CONST 598 # ifdef __cplusplus 599 # define PY_CXX_CONST const 600 # else 601 # define PY_CXX_CONST 602 # endif 603 #endif 604 605 #if defined(__sgi) && !defined(_SGI_MP_SOURCE) 606 # define _SGI_MP_SOURCE 607 #endif 608 609 #endif /* Py_PYPORT_H */ 610