Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:54

0001 #ifndef Py_PYPORT_H
0002 #define Py_PYPORT_H
0003 
0004 #ifndef UCHAR_MAX
0005 #  error "<limits.h> header must define UCHAR_MAX"
0006 #endif
0007 #if UCHAR_MAX != 255
0008 #  error "Python's source code assumes C's unsigned char is an 8-bit type"
0009 #endif
0010 
0011 
0012 // Macro to use C++ static_cast<> in the Python C API.
0013 #ifdef __cplusplus
0014 #  define _Py_STATIC_CAST(type, expr) static_cast<type>(expr)
0015 #else
0016 #  define _Py_STATIC_CAST(type, expr) ((type)(expr))
0017 #endif
0018 // Macro to use the more powerful/dangerous C-style cast even in C++.
0019 #define _Py_CAST(type, expr) ((type)(expr))
0020 
0021 // Static inline functions should use _Py_NULL rather than using directly NULL
0022 // to prevent C++ compiler warnings. On C23 and newer and on C++11 and newer,
0023 // _Py_NULL is defined as nullptr.
0024 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L) \
0025         || (defined(__cplusplus) && __cplusplus >= 201103)
0026 #  define _Py_NULL nullptr
0027 #else
0028 #  define _Py_NULL NULL
0029 #endif
0030 
0031 
0032 /* Defines to build Python and its standard library:
0033  *
0034  * - Py_BUILD_CORE: Build Python core. Give access to Python internals, but
0035  *   should not be used by third-party modules.
0036  * - Py_BUILD_CORE_BUILTIN: Build a Python stdlib module as a built-in module.
0037  * - Py_BUILD_CORE_MODULE: Build a Python stdlib module as a dynamic library.
0038  *
0039  * Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE imply Py_BUILD_CORE.
0040  *
0041  * On Windows, Py_BUILD_CORE_MODULE exports "PyInit_xxx" symbol, whereas
0042  * Py_BUILD_CORE_BUILTIN does not.
0043  */
0044 #if defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE)
0045 #  define Py_BUILD_CORE
0046 #endif
0047 #if defined(Py_BUILD_CORE_MODULE) && !defined(Py_BUILD_CORE)
0048 #  define Py_BUILD_CORE
0049 #endif
0050 
0051 
0052 /**************************************************************************
0053 Symbols and macros to supply platform-independent interfaces to basic
0054 C language & library operations whose spellings vary across platforms.
0055 
0056 Please try to make documentation here as clear as possible:  by definition,
0057 the stuff here is trying to illuminate C's darkest corners.
0058 
0059 Config #defines referenced here:
0060 
0061 SIGNED_RIGHT_SHIFT_ZERO_FILLS
0062 Meaning:  To be defined iff i>>j does not extend the sign bit when i is a
0063           signed integral type and i < 0.
0064 Used in:  Py_ARITHMETIC_RIGHT_SHIFT
0065 
0066 Py_DEBUG
0067 Meaning:  Extra checks compiled in for debug mode.
0068 Used in:  Py_SAFE_DOWNCAST
0069 
0070 **************************************************************************/
0071 
0072 /* typedefs for some C9X-defined synonyms for integral types.
0073  *
0074  * The names in Python are exactly the same as the C9X names, except with a
0075  * Py_ prefix.  Until C9X is universally implemented, this is the only way
0076  * to ensure that Python gets reliable names that don't conflict with names
0077  * in non-Python code that are playing their own tricks to define the C9X
0078  * names.
0079  *
0080  * NOTE: don't go nuts here!  Python has no use for *most* of the C9X
0081  * integral synonyms.  Only define the ones we actually need.
0082  */
0083 
0084 /* long long is required. Ensure HAVE_LONG_LONG is defined for compatibility. */
0085 #ifndef HAVE_LONG_LONG
0086 #define HAVE_LONG_LONG 1
0087 #endif
0088 #ifndef PY_LONG_LONG
0089 #define PY_LONG_LONG long long
0090 /* If LLONG_MAX is defined in limits.h, use that. */
0091 #define PY_LLONG_MIN LLONG_MIN
0092 #define PY_LLONG_MAX LLONG_MAX
0093 #define PY_ULLONG_MAX ULLONG_MAX
0094 #endif
0095 
0096 #define PY_UINT32_T uint32_t
0097 #define PY_UINT64_T uint64_t
0098 
0099 /* Signed variants of the above */
0100 #define PY_INT32_T int32_t
0101 #define PY_INT64_T int64_t
0102 
0103 /* PYLONG_BITS_IN_DIGIT describes the number of bits per "digit" (limb) in the
0104  * PyLongObject implementation (longintrepr.h). It's currently either 30 or 15,
0105  * defaulting to 30. The 15-bit digit option may be removed in the future.
0106  */
0107 #ifndef PYLONG_BITS_IN_DIGIT
0108 #define PYLONG_BITS_IN_DIGIT 30
0109 #endif
0110 
0111 /* uintptr_t is the C9X name for an unsigned integral type such that a
0112  * legitimate void* can be cast to uintptr_t and then back to void* again
0113  * without loss of information.  Similarly for intptr_t, wrt a signed
0114  * integral type.
0115  */
0116 typedef uintptr_t       Py_uintptr_t;
0117 typedef intptr_t        Py_intptr_t;
0118 
0119 /* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) ==
0120  * sizeof(size_t).  C99 doesn't define such a thing directly (size_t is an
0121  * unsigned integral type).  See PEP 353 for details.
0122  * PY_SSIZE_T_MAX is the largest positive value of type Py_ssize_t.
0123  */
0124 #ifdef HAVE_PY_SSIZE_T
0125 
0126 #elif HAVE_SSIZE_T
0127 typedef ssize_t         Py_ssize_t;
0128 #   define PY_SSIZE_T_MAX SSIZE_MAX
0129 #elif SIZEOF_VOID_P == SIZEOF_SIZE_T
0130 typedef Py_intptr_t     Py_ssize_t;
0131 #   define PY_SSIZE_T_MAX INTPTR_MAX
0132 #else
0133 #   error "Python needs a typedef for Py_ssize_t in pyport.h."
0134 #endif
0135 
0136 /* Smallest negative value of type Py_ssize_t. */
0137 #define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
0138 
0139 /* Py_hash_t is the same size as a pointer. */
0140 #define SIZEOF_PY_HASH_T SIZEOF_SIZE_T
0141 typedef Py_ssize_t Py_hash_t;
0142 /* Py_uhash_t is the unsigned equivalent needed to calculate numeric hash. */
0143 #define SIZEOF_PY_UHASH_T SIZEOF_SIZE_T
0144 typedef size_t Py_uhash_t;
0145 
0146 /* Now PY_SSIZE_T_CLEAN is mandatory. This is just for backward compatibility. */
0147 typedef Py_ssize_t Py_ssize_clean_t;
0148 
0149 /* Largest possible value of size_t. */
0150 #define PY_SIZE_MAX SIZE_MAX
0151 
0152 /* Macro kept for backward compatibility: use directly "z" in new code.
0153  *
0154  * PY_FORMAT_SIZE_T is a modifier for use in a printf format to convert an
0155  * argument with the width of a size_t or Py_ssize_t: "z" (C99).
0156  */
0157 #ifndef PY_FORMAT_SIZE_T
0158 #   define PY_FORMAT_SIZE_T "z"
0159 #endif
0160 
0161 /* Py_LOCAL can be used instead of static to get the fastest possible calling
0162  * convention for functions that are local to a given module.
0163  *
0164  * Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining,
0165  * for platforms that support that.
0166  *
0167  * NOTE: You can only use this for functions that are entirely local to a
0168  * module; functions that are exported via method tables, callbacks, etc,
0169  * should keep using static.
0170  */
0171 
0172 #if defined(_MSC_VER)
0173    /* ignore warnings if the compiler decides not to inline a function */
0174 #  pragma warning(disable: 4710)
0175    /* fastest possible local call under MSVC */
0176 #  define Py_LOCAL(type) static type __fastcall
0177 #  define Py_LOCAL_INLINE(type) static __inline type __fastcall
0178 #else
0179 #  define Py_LOCAL(type) static type
0180 #  define Py_LOCAL_INLINE(type) static inline type
0181 #endif
0182 
0183 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
0184 #  define Py_MEMCPY memcpy
0185 #endif
0186 
0187 #ifdef __cplusplus
0188 /* Move this down here since some C++ #include's don't like to be included
0189    inside an extern "C" */
0190 extern "C" {
0191 #endif
0192 
0193 
0194 /* Py_ARITHMETIC_RIGHT_SHIFT
0195  * C doesn't define whether a right-shift of a signed integer sign-extends
0196  * or zero-fills.  Here a macro to force sign extension:
0197  * Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J)
0198  *    Return I >> J, forcing sign extension.  Arithmetically, return the
0199  *    floor of I/2**J.
0200  * Requirements:
0201  *    I should have signed integer type.  In the terminology of C99, this can
0202  *    be either one of the five standard signed integer types (signed char,
0203  *    short, int, long, long long) or an extended signed integer type.
0204  *    J is an integer >= 0 and strictly less than the number of bits in the
0205  *    type of I (because C doesn't define what happens for J outside that
0206  *    range either).
0207  *    TYPE used to specify the type of I, but is now ignored.  It's been left
0208  *    in for backwards compatibility with versions <= 2.6 or 3.0.
0209  * Caution:
0210  *    I may be evaluated more than once.
0211  */
0212 #ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS
0213 #define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \
0214     ((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J))
0215 #else
0216 #define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J))
0217 #endif
0218 
0219 /* Py_FORCE_EXPANSION(X)
0220  * "Simply" returns its argument.  However, macro expansions within the
0221  * argument are evaluated.  This unfortunate trickery is needed to get
0222  * token-pasting to work as desired in some cases.
0223  */
0224 #define Py_FORCE_EXPANSION(X) X
0225 
0226 /* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW)
0227  * Cast VALUE to type NARROW from type WIDE.  In Py_DEBUG mode, this
0228  * assert-fails if any information is lost.
0229  * Caution:
0230  *    VALUE may be evaluated more than once.
0231  */
0232 #ifdef Py_DEBUG
0233 #  define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \
0234        (assert(_Py_STATIC_CAST(WIDE, _Py_STATIC_CAST(NARROW, (VALUE))) == (VALUE)), \
0235         _Py_STATIC_CAST(NARROW, (VALUE)))
0236 #else
0237 #  define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) _Py_STATIC_CAST(NARROW, (VALUE))
0238 #endif
0239 
0240 
0241 /* Py_DEPRECATED(version)
0242  * Declare a variable, type, or function deprecated.
0243  * The macro must be placed before the declaration.
0244  * Usage:
0245  *    Py_DEPRECATED(3.3) extern int old_var;
0246  *    Py_DEPRECATED(3.4) typedef int T1;
0247  *    Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);
0248  */
0249 #if defined(__GNUC__) \
0250     && ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
0251 #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
0252 #elif defined(_MSC_VER)
0253 #define Py_DEPRECATED(VERSION) __declspec(deprecated( \
0254                                           "deprecated in " #VERSION))
0255 #else
0256 #define Py_DEPRECATED(VERSION_UNUSED)
0257 #endif
0258 
0259 // _Py_DEPRECATED_EXTERNALLY(version)
0260 // Deprecated outside CPython core.
0261 #ifdef Py_BUILD_CORE
0262 #define _Py_DEPRECATED_EXTERNALLY(VERSION_UNUSED)
0263 #else
0264 #define _Py_DEPRECATED_EXTERNALLY(version) Py_DEPRECATED(version)
0265 #endif
0266 
0267 
0268 #if defined(__clang__)
0269 #define _Py_COMP_DIAG_PUSH _Pragma("clang diagnostic push")
0270 #define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
0271     _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
0272 #define _Py_COMP_DIAG_POP _Pragma("clang diagnostic pop")
0273 #elif defined(__GNUC__) \
0274     && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
0275 #define _Py_COMP_DIAG_PUSH _Pragma("GCC diagnostic push")
0276 #define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \
0277     _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
0278 #define _Py_COMP_DIAG_POP _Pragma("GCC diagnostic pop")
0279 #elif defined(_MSC_VER)
0280 #define _Py_COMP_DIAG_PUSH __pragma(warning(push))
0281 #define _Py_COMP_DIAG_IGNORE_DEPR_DECLS __pragma(warning(disable: 4996))
0282 #define _Py_COMP_DIAG_POP __pragma(warning(pop))
0283 #else
0284 #define _Py_COMP_DIAG_PUSH
0285 #define _Py_COMP_DIAG_IGNORE_DEPR_DECLS
0286 #define _Py_COMP_DIAG_POP
0287 #endif
0288 
0289 /* _Py_HOT_FUNCTION
0290  * The hot attribute on a function is used to inform the compiler that the
0291  * function is a hot spot of the compiled program. The function is optimized
0292  * more aggressively and on many target it is placed into special subsection of
0293  * the text section so all hot functions appears close together improving
0294  * locality.
0295  *
0296  * Usage:
0297  *    int _Py_HOT_FUNCTION x(void) { return 3; }
0298  *
0299  * Issue #28618: This attribute must not be abused, otherwise it can have a
0300  * negative effect on performance. Only the functions were Python spend most of
0301  * its time must use it. Use a profiler when running performance benchmark
0302  * suite to find these functions.
0303  */
0304 #if defined(__GNUC__) \
0305     && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))
0306 #define _Py_HOT_FUNCTION __attribute__((hot))
0307 #else
0308 #define _Py_HOT_FUNCTION
0309 #endif
0310 
0311 // Ask the compiler to always inline a static inline function. The compiler can
0312 // ignore it and decides to not inline the function.
0313 //
0314 // It can be used to inline performance critical static inline functions when
0315 // building Python in debug mode with function inlining disabled. For example,
0316 // MSC disables function inlining when building in debug mode.
0317 //
0318 // Marking blindly a static inline function with Py_ALWAYS_INLINE can result in
0319 // worse performances (due to increased code size for example). The compiler is
0320 // usually smarter than the developer for the cost/benefit analysis.
0321 //
0322 // If Python is built in debug mode (if the Py_DEBUG macro is defined), the
0323 // Py_ALWAYS_INLINE macro does nothing.
0324 //
0325 // It must be specified before the function return type. Usage:
0326 //
0327 //     static inline Py_ALWAYS_INLINE int random(void) { return 4; }
0328 #if defined(Py_DEBUG)
0329    // If Python is built in debug mode, usually compiler optimizations are
0330    // disabled. In this case, Py_ALWAYS_INLINE can increase a lot the stack
0331    // memory usage. For example, forcing inlining using gcc -O0 increases the
0332    // stack usage from 6 KB to 15 KB per Python function call.
0333 #  define Py_ALWAYS_INLINE
0334 #elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)
0335 #  define Py_ALWAYS_INLINE __attribute__((always_inline))
0336 #elif defined(_MSC_VER)
0337 #  define Py_ALWAYS_INLINE __forceinline
0338 #else
0339 #  define Py_ALWAYS_INLINE
0340 #endif
0341 
0342 // Py_NO_INLINE
0343 // Disable inlining on a function. For example, it reduces the C stack
0344 // consumption: useful on LTO+PGO builds which heavily inline code (see
0345 // bpo-33720).
0346 //
0347 // Usage:
0348 //
0349 //    Py_NO_INLINE static int random(void) { return 4; }
0350 #if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)
0351 #  define Py_NO_INLINE __attribute__ ((noinline))
0352 #elif defined(_MSC_VER)
0353 #  define Py_NO_INLINE __declspec(noinline)
0354 #else
0355 #  define Py_NO_INLINE
0356 #endif
0357 
0358 #include "exports.h"
0359 
0360 #ifdef Py_LIMITED_API
0361    // The internal C API must not be used with the limited C API: make sure
0362    // that Py_BUILD_CORE macro is not defined in this case. These 3 macros are
0363    // used by exports.h, so only undefine them afterwards.
0364 #  undef Py_BUILD_CORE
0365 #  undef Py_BUILD_CORE_BUILTIN
0366 #  undef Py_BUILD_CORE_MODULE
0367 #endif
0368 
0369 /* limits.h constants that may be missing */
0370 
0371 #ifndef INT_MAX
0372 #define INT_MAX 2147483647
0373 #endif
0374 
0375 #ifndef LONG_MAX
0376 #if SIZEOF_LONG == 4
0377 #define LONG_MAX 0X7FFFFFFFL
0378 #elif SIZEOF_LONG == 8
0379 #define LONG_MAX 0X7FFFFFFFFFFFFFFFL
0380 #else
0381 #error "could not set LONG_MAX in pyport.h"
0382 #endif
0383 #endif
0384 
0385 #ifndef LONG_MIN
0386 #define LONG_MIN (-LONG_MAX-1)
0387 #endif
0388 
0389 #ifndef LONG_BIT
0390 #define LONG_BIT (8 * SIZEOF_LONG)
0391 #endif
0392 
0393 #if LONG_BIT != 8 * SIZEOF_LONG
0394 /* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent
0395  * 32-bit platforms using gcc.  We try to catch that here at compile-time
0396  * rather than waiting for integer multiplication to trigger bogus
0397  * overflows.
0398  */
0399 #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
0400 #endif
0401 
0402 #ifdef __cplusplus
0403 }
0404 #endif
0405 
0406 /*
0407  * Hide GCC attributes from compilers that don't support them.
0408  */
0409 #if (!defined(__GNUC__) || __GNUC__ < 2 || \
0410      (__GNUC__ == 2 && __GNUC_MINOR__ < 7) )
0411 #define Py_GCC_ATTRIBUTE(x)
0412 #else
0413 #define Py_GCC_ATTRIBUTE(x) __attribute__(x)
0414 #endif
0415 
0416 /*
0417  * Specify alignment on compilers that support it.
0418  */
0419 #if defined(__GNUC__) && __GNUC__ >= 3
0420 #define Py_ALIGNED(x) __attribute__((aligned(x)))
0421 #else
0422 #define Py_ALIGNED(x)
0423 #endif
0424 
0425 /* Eliminate end-of-loop code not reached warnings from SunPro C
0426  * when using do{...}while(0) macros
0427  */
0428 #ifdef __SUNPRO_C
0429 #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED)
0430 #endif
0431 
0432 #ifndef Py_LL
0433 #define Py_LL(x) x##LL
0434 #endif
0435 
0436 #ifndef Py_ULL
0437 #define Py_ULL(x) Py_LL(x##U)
0438 #endif
0439 
0440 #define Py_VA_COPY va_copy
0441 
0442 /*
0443  * Convenient macros to deal with endianness of the platform. WORDS_BIGENDIAN is
0444  * detected by configure and defined in pyconfig.h. The code in pyconfig.h
0445  * also takes care of Apple's universal builds.
0446  */
0447 
0448 #ifdef WORDS_BIGENDIAN
0449 #  define PY_BIG_ENDIAN 1
0450 #  define PY_LITTLE_ENDIAN 0
0451 #else
0452 #  define PY_BIG_ENDIAN 0
0453 #  define PY_LITTLE_ENDIAN 1
0454 #endif
0455 
0456 #ifdef __ANDROID__
0457    /* The Android langinfo.h header is not used. */
0458 #  undef HAVE_LANGINFO_H
0459 #  undef CODESET
0460 #endif
0461 
0462 /* Maximum value of the Windows DWORD type */
0463 #define PY_DWORD_MAX 4294967295U
0464 
0465 /* This macro used to tell whether Python was built with multithreading
0466  * enabled.  Now multithreading is always enabled, but keep the macro
0467  * for compatibility.
0468  */
0469 #ifndef WITH_THREAD
0470 #  define WITH_THREAD
0471 #endif
0472 
0473 /* Some WebAssembly platforms do not provide a working pthread implementation.
0474  * Thread support is stubbed and any attempt to create a new thread fails.
0475  */
0476 #if (!defined(HAVE_PTHREAD_STUBS) && \
0477       (!defined(__EMSCRIPTEN__) || defined(__EMSCRIPTEN_PTHREADS__)))
0478 #  define Py_CAN_START_THREADS 1
0479 #endif
0480 
0481 #ifdef WITH_THREAD
0482 #  ifdef Py_BUILD_CORE
0483 #    ifdef HAVE_THREAD_LOCAL
0484 #      error "HAVE_THREAD_LOCAL is already defined"
0485 #    endif
0486 #    define HAVE_THREAD_LOCAL 1
0487 #    ifdef thread_local
0488 #      define _Py_thread_local thread_local
0489 #    elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
0490 #      define _Py_thread_local _Thread_local
0491 #    elif defined(_MSC_VER)  /* AKA NT_THREADS */
0492 #      define _Py_thread_local __declspec(thread)
0493 #    elif defined(__GNUC__)  /* includes clang */
0494 #      define _Py_thread_local __thread
0495 #    else
0496        // fall back to the PyThread_tss_*() API, or ignore.
0497 #      undef HAVE_THREAD_LOCAL
0498 #    endif
0499 #  endif
0500 #endif
0501 
0502 #if defined(__ANDROID__) || defined(__VXWORKS__)
0503    // Use UTF-8 as the locale encoding, ignore the LC_CTYPE locale.
0504    // See _Py_GetLocaleEncoding(), PyUnicode_DecodeLocale()
0505    // and PyUnicode_EncodeLocale().
0506 #  define _Py_FORCE_UTF8_LOCALE
0507 #endif
0508 
0509 #if defined(_Py_FORCE_UTF8_LOCALE) || defined(__APPLE__)
0510    // Use UTF-8 as the filesystem encoding.
0511    // See PyUnicode_DecodeFSDefaultAndSize(), PyUnicode_EncodeFSDefault(),
0512    // Py_DecodeLocale() and Py_EncodeLocale().
0513 #  define _Py_FORCE_UTF8_FS_ENCODING
0514 #endif
0515 
0516 /* Mark a function which cannot return. Example:
0517    PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void);
0518 
0519    XLC support is intentionally omitted due to bpo-40244 */
0520 #ifndef _Py_NO_RETURN
0521 #if defined(__clang__) || \
0522     (defined(__GNUC__) && \
0523      ((__GNUC__ >= 3) || \
0524       (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)))
0525 #  define _Py_NO_RETURN __attribute__((__noreturn__))
0526 #elif defined(_MSC_VER)
0527 #  define _Py_NO_RETURN __declspec(noreturn)
0528 #else
0529 #  define _Py_NO_RETURN
0530 #endif
0531 #endif
0532 
0533 
0534 // Preprocessor check for a builtin preprocessor function. Always return 0
0535 // if __has_builtin() macro is not defined.
0536 //
0537 // __has_builtin() is available on clang and GCC 10.
0538 #ifdef __has_builtin
0539 #  define _Py__has_builtin(x) __has_builtin(x)
0540 #else
0541 #  define _Py__has_builtin(x) 0
0542 #endif
0543 
0544 // Preprocessor check for a compiler __attribute__. Always return 0
0545 // if __has_attribute() macro is not defined.
0546 #ifdef __has_attribute
0547 #  define _Py__has_attribute(x) __has_attribute(x)
0548 #else
0549 #  define _Py__has_attribute(x) 0
0550 #endif
0551 
0552 // _Py_TYPEOF(expr) gets the type of an expression.
0553 //
0554 // Example: _Py_TYPEOF(x) x_copy = (x);
0555 //
0556 // The macro is only defined if GCC or clang compiler is used.
0557 #if defined(__GNUC__) || defined(__clang__)
0558 #  define _Py_TYPEOF(expr) __typeof__(expr)
0559 #endif
0560 
0561 
0562 /* A convenient way for code to know if sanitizers are enabled. */
0563 #if defined(__has_feature)
0564 #  if __has_feature(memory_sanitizer)
0565 #    if !defined(_Py_MEMORY_SANITIZER)
0566 #      define _Py_MEMORY_SANITIZER
0567 #    endif
0568 #  endif
0569 #  if __has_feature(address_sanitizer)
0570 #    if !defined(_Py_ADDRESS_SANITIZER)
0571 #      define _Py_ADDRESS_SANITIZER
0572 #    endif
0573 #  endif
0574 #  if __has_feature(thread_sanitizer)
0575 #    if !defined(_Py_THREAD_SANITIZER)
0576 #      define _Py_THREAD_SANITIZER
0577 #    endif
0578 #  endif
0579 #elif defined(__GNUC__)
0580 #  if defined(__SANITIZE_ADDRESS__)
0581 #    define _Py_ADDRESS_SANITIZER
0582 #  endif
0583 #  if defined(__SANITIZE_THREAD__)
0584 #    define _Py_THREAD_SANITIZER
0585 #  endif
0586 #endif
0587 
0588 
0589 /* AIX has __bool__ redefined in it's system header file. */
0590 #if defined(_AIX) && defined(__bool__)
0591 #undef __bool__
0592 #endif
0593 
0594 // Make sure we have maximum alignment, even if the current compiler
0595 // does not support max_align_t. Note that:
0596 // - Autoconf reports alignment of unknown types to 0.
0597 // - 'long double' has maximum alignment on *most* platforms,
0598 //   looks like the best we can do for pre-C11 compilers.
0599 // - The value is tested, see test_alignof_max_align_t
0600 #if !defined(ALIGNOF_MAX_ALIGN_T) || ALIGNOF_MAX_ALIGN_T == 0
0601 #   undef ALIGNOF_MAX_ALIGN_T
0602 #   define ALIGNOF_MAX_ALIGN_T _Alignof(long double)
0603 #endif
0604 
0605 #ifndef PY_CXX_CONST
0606 #  ifdef __cplusplus
0607 #    define PY_CXX_CONST const
0608 #  else
0609 #    define PY_CXX_CONST
0610 #  endif
0611 #endif
0612 
0613 #if defined(__sgi) && !defined(_SGI_MP_SOURCE)
0614 #  define _SGI_MP_SOURCE
0615 #endif
0616 
0617 
0618 // _Py_NONSTRING: The nonstring variable attribute specifies that an object or
0619 // member declaration with type array of char, signed char, or unsigned char,
0620 // or pointer to such a type is intended to store character arrays that do not
0621 // necessarily contain a terminating NUL.
0622 //
0623 // Usage:
0624 //
0625 //   char name [8] _Py_NONSTRING;
0626 #if _Py__has_attribute(nonstring)
0627 #  define _Py_NONSTRING __attribute__((nonstring))
0628 #else
0629 #  define _Py_NONSTRING
0630 #endif
0631 
0632 
0633 #endif /* Py_PYPORT_H */