Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
pyport.h711 linesDownload Raw Back to include
1#ifndef Py_PYPORT_H2#define Py_PYPORT_H3 4#ifndef UCHAR_MAX5#  error "<limits.h> header must define UCHAR_MAX"6#endif7#if UCHAR_MAX != 2558#  error "Python's source code assumes C's unsigned char is an 8-bit type"9#endif10 11 12// Preprocessor check for a builtin preprocessor function. Always return 013// if __has_builtin() macro is not defined.14//15// __has_builtin() is available on clang and GCC 10.16#ifdef __has_builtin17#  define _Py__has_builtin(x) __has_builtin(x)18#else19#  define _Py__has_builtin(x) 020#endif21 22// Preprocessor check for a compiler __attribute__. Always return 023// if __has_attribute() macro is not defined.24#ifdef __has_attribute25#  define _Py__has_attribute(x) __has_attribute(x)26#else27#  define _Py__has_attribute(x) 028#endif29 30// Macro to use C++ static_cast<> in the Python C API.31#ifdef __cplusplus32#  define _Py_STATIC_CAST(type, expr) static_cast<type>(expr)33#else34#  define _Py_STATIC_CAST(type, expr) ((type)(expr))35#endif36// Macro to use the more powerful/dangerous C-style cast even in C++.37#define _Py_CAST(type, expr) ((type)(expr))38 39// Cast a function to another function type T.40//41// The macro first casts the function to the "void func(void)" type42// to prevent compiler warnings.43//44// Note that using this cast only prevents the compiler from emitting45// warnings, but does not prevent an undefined behavior at runtime if46// the original function signature is not respected.47#define _Py_FUNC_CAST(T, func) _Py_CAST(T, _Py_CAST(void(*)(void), (func)))48 49// Static inline functions should use _Py_NULL rather than using directly NULL50// to prevent C++ compiler warnings. On C23 and newer and on C++11 and newer,51// _Py_NULL is defined as nullptr.52#if !defined(_MSC_VER) && \53    ((defined (__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) \54        || (defined(__cplusplus) && __cplusplus >= 201103))55#  define _Py_NULL nullptr56#else57#  define _Py_NULL NULL58#endif59 60 61/* Defines to build Python and its standard library:62 *63 * - Py_BUILD_CORE: Build Python core. Give access to Python internals, but64 *   should not be used by third-party modules.65 * - Py_BUILD_CORE_BUILTIN: Build a Python stdlib module as a built-in module.66 * - Py_BUILD_CORE_MODULE: Build a Python stdlib module as a dynamic library.67 *68 * Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE imply Py_BUILD_CORE.69 *70 * On Windows, Py_BUILD_CORE_MODULE exports "PyInit_xxx" symbol, whereas71 * Py_BUILD_CORE_BUILTIN does not.72 */73#if defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE)74#  define Py_BUILD_CORE75#endif76#if defined(Py_BUILD_CORE_MODULE) && !defined(Py_BUILD_CORE)77#  define Py_BUILD_CORE78#endif79 80 81/**************************************************************************82Symbols and macros to supply platform-independent interfaces to basic83C language & library operations whose spellings vary across platforms.84 85Please try to make documentation here as clear as possible:  by definition,86the stuff here is trying to illuminate C's darkest corners.87 88Config #defines referenced here:89 90SIGNED_RIGHT_SHIFT_ZERO_FILLS91Meaning:  To be defined iff i>>j does not extend the sign bit when i is a92          signed integral type and i < 0.93Used in:  Py_ARITHMETIC_RIGHT_SHIFT94 95Py_DEBUG96Meaning:  Extra checks compiled in for debug mode.97Used in:  Py_SAFE_DOWNCAST98 99**************************************************************************/100 101/* typedefs for some C9X-defined synonyms for integral types.102 *103 * The names in Python are exactly the same as the C9X names, except with a104 * Py_ prefix.  Until C9X is universally implemented, this is the only way105 * to ensure that Python gets reliable names that don't conflict with names106 * in non-Python code that are playing their own tricks to define the C9X107 * names.108 *109 * NOTE: don't go nuts here!  Python has no use for *most* of the C9X110 * integral synonyms.  Only define the ones we actually need.111 */112 113/* long long is required. Ensure HAVE_LONG_LONG is defined for compatibility. */114#ifndef HAVE_LONG_LONG115#define HAVE_LONG_LONG 1116#endif117#ifndef PY_LONG_LONG118#define PY_LONG_LONG long long119/* If LLONG_MAX is defined in limits.h, use that. */120#define PY_LLONG_MIN LLONG_MIN121#define PY_LLONG_MAX LLONG_MAX122#define PY_ULLONG_MAX ULLONG_MAX123#endif124 125#define PY_UINT32_T uint32_t126#define PY_UINT64_T uint64_t127 128/* Signed variants of the above */129#define PY_INT32_T int32_t130#define PY_INT64_T int64_t131 132/* PYLONG_BITS_IN_DIGIT describes the number of bits per "digit" (limb) in the133 * PyLongObject implementation (longintrepr.h). It's currently either 30 or 15,134 * defaulting to 30. The 15-bit digit option may be removed in the future.135 */136#ifndef PYLONG_BITS_IN_DIGIT137#define PYLONG_BITS_IN_DIGIT 30138#endif139 140/* uintptr_t is the C9X name for an unsigned integral type such that a141 * legitimate void* can be cast to uintptr_t and then back to void* again142 * without loss of information.  Similarly for intptr_t, wrt a signed143 * integral type.144 */145typedef uintptr_t       Py_uintptr_t;146typedef intptr_t        Py_intptr_t;147 148/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) ==149 * sizeof(size_t).  C99 doesn't define such a thing directly (size_t is an150 * unsigned integral type).  See PEP 353 for details.151 * PY_SSIZE_T_MAX is the largest positive value of type Py_ssize_t.152 */153#ifdef HAVE_PY_SSIZE_T154 155#elif HAVE_SSIZE_T156typedef ssize_t         Py_ssize_t;157#   define PY_SSIZE_T_MAX SSIZE_MAX158#elif SIZEOF_VOID_P == SIZEOF_SIZE_T159typedef Py_intptr_t     Py_ssize_t;160#   define PY_SSIZE_T_MAX INTPTR_MAX161#else162#   error "Python needs a typedef for Py_ssize_t in pyport.h."163#endif164 165/* Smallest negative value of type Py_ssize_t. */166#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)167 168/* Py_hash_t is the same size as a pointer. */169#define SIZEOF_PY_HASH_T SIZEOF_SIZE_T170typedef Py_ssize_t Py_hash_t;171/* Py_uhash_t is the unsigned equivalent needed to calculate numeric hash. */172#define SIZEOF_PY_UHASH_T SIZEOF_SIZE_T173typedef size_t Py_uhash_t;174 175/* Now PY_SSIZE_T_CLEAN is mandatory. This is just for backward compatibility. */176typedef Py_ssize_t Py_ssize_clean_t;177 178/* Largest possible value of size_t. */179#define PY_SIZE_MAX SIZE_MAX180 181/* Macro kept for backward compatibility: use directly "z" in new code.182 *183 * PY_FORMAT_SIZE_T is a modifier for use in a printf format to convert an184 * argument with the width of a size_t or Py_ssize_t: "z" (C99).185 */186#ifndef PY_FORMAT_SIZE_T187#   define PY_FORMAT_SIZE_T "z"188#endif189 190/* Py_LOCAL can be used instead of static to get the fastest possible calling191 * convention for functions that are local to a given module.192 *193 * Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining,194 * for platforms that support that.195 *196 * NOTE: You can only use this for functions that are entirely local to a197 * module; functions that are exported via method tables, callbacks, etc,198 * should keep using static.199 */200 201#if defined(_MSC_VER)202   /* ignore warnings if the compiler decides not to inline a function */203#  pragma warning(disable: 4710)204   /* fastest possible local call under MSVC */205#  define Py_LOCAL(type) static type __fastcall206#  define Py_LOCAL_INLINE(type) static __inline type __fastcall207#else208#  define Py_LOCAL(type) static type209#  define Py_LOCAL_INLINE(type) static inline type210#endif211 212// Soft deprecated since Python 3.14, use memcpy() instead.213#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000214#  define Py_MEMCPY memcpy215#endif216 217#ifdef __cplusplus218/* Move this down here since some C++ #include's don't like to be included219   inside an extern "C" */220extern "C" {221#endif222 223 224/* Py_ARITHMETIC_RIGHT_SHIFT225 * C doesn't define whether a right-shift of a signed integer sign-extends226 * or zero-fills.  Here a macro to force sign extension:227 * Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J)228 *    Return I >> J, forcing sign extension.  Arithmetically, return the229 *    floor of I/2**J.230 * Requirements:231 *    I should have signed integer type.  In the terminology of C99, this can232 *    be either one of the five standard signed integer types (signed char,233 *    short, int, long, long long) or an extended signed integer type.234 *    J is an integer >= 0 and strictly less than the number of bits in the235 *    type of I (because C doesn't define what happens for J outside that236 *    range either).237 *    TYPE used to specify the type of I, but is now ignored.  It's been left238 *    in for backwards compatibility with versions <= 2.6 or 3.0.239 * Caution:240 *    I may be evaluated more than once.241 */242#ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS243#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \244    ((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J))245#else246#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J))247#endif248 249/* Py_FORCE_EXPANSION(X)250 * "Simply" returns its argument.  However, macro expansions within the251 * argument are evaluated.  This unfortunate trickery is needed to get252 * token-pasting to work as desired in some cases.253 */254#define Py_FORCE_EXPANSION(X) X255 256/* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW)257 * Cast VALUE to type NARROW from type WIDE.  In Py_DEBUG mode, this258 * assert-fails if any information is lost.259 * Caution:260 *    VALUE may be evaluated more than once.261 */262#ifdef Py_DEBUG263#  define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \264       (assert(_Py_STATIC_CAST(WIDE, _Py_STATIC_CAST(NARROW, (VALUE))) == (VALUE)), \265        _Py_STATIC_CAST(NARROW, (VALUE)))266#else267#  define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) _Py_STATIC_CAST(NARROW, (VALUE))268#endif269 270 271/* Py_DEPRECATED(version)272 * Declare a variable, type, or function deprecated.273 * The macro must be placed before the declaration.274 * Usage:275 *    Py_DEPRECATED(3.3) extern int old_var;276 *    Py_DEPRECATED(3.4) typedef int T1;277 *    Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);278 */279#if defined(__GNUC__) \280    && ((__GNUC__ >= 4) || (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))281#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))282#elif defined(_MSC_VER)283#define Py_DEPRECATED(VERSION) __declspec(deprecated( \284                                          "deprecated in " #VERSION))285#else286#define Py_DEPRECATED(VERSION_UNUSED)287#endif288 289// _Py_DEPRECATED_EXTERNALLY(version)290// Deprecated outside CPython core.291#ifdef Py_BUILD_CORE292#define _Py_DEPRECATED_EXTERNALLY(VERSION_UNUSED)293#else294#define _Py_DEPRECATED_EXTERNALLY(version) Py_DEPRECATED(version)295#endif296 297 298#if defined(__clang__)299#define _Py_COMP_DIAG_PUSH _Pragma("clang diagnostic push")300#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \301    _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")302#define _Py_COMP_DIAG_POP _Pragma("clang diagnostic pop")303#elif defined(__GNUC__) \304    && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))305#define _Py_COMP_DIAG_PUSH _Pragma("GCC diagnostic push")306#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS \307    _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")308#define _Py_COMP_DIAG_POP _Pragma("GCC diagnostic pop")309#elif defined(_MSC_VER)310#define _Py_COMP_DIAG_PUSH __pragma(warning(push))311#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS __pragma(warning(disable: 4996))312#define _Py_COMP_DIAG_POP __pragma(warning(pop))313#else314#define _Py_COMP_DIAG_PUSH315#define _Py_COMP_DIAG_IGNORE_DEPR_DECLS316#define _Py_COMP_DIAG_POP317#endif318 319/* _Py_HOT_FUNCTION320 * The hot attribute on a function is used to inform the compiler that the321 * function is a hot spot of the compiled program. The function is optimized322 * more aggressively and on many target it is placed into special subsection of323 * the text section so all hot functions appears close together improving324 * locality.325 *326 * Usage:327 *    int _Py_HOT_FUNCTION x(void) { return 3; }328 *329 * Issue #28618: This attribute must not be abused, otherwise it can have a330 * negative effect on performance. Only the functions were Python spend most of331 * its time must use it. Use a profiler when running performance benchmark332 * suite to find these functions.333 */334#if defined(__GNUC__) \335    && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))336#define _Py_HOT_FUNCTION __attribute__((hot))337#else338#define _Py_HOT_FUNCTION339#endif340 341// Ask the compiler to always inline a static inline function. The compiler can342// ignore it and decides to not inline the function.343//344// It can be used to inline performance critical static inline functions when345// building Python in debug mode with function inlining disabled. For example,346// MSC disables function inlining when building in debug mode.347//348// Marking blindly a static inline function with Py_ALWAYS_INLINE can result in349// worse performances (due to increased code size for example). The compiler is350// usually smarter than the developer for the cost/benefit analysis.351//352// If Python is built in debug mode (if the Py_DEBUG macro is defined), the353// Py_ALWAYS_INLINE macro does nothing.354//355// It must be specified before the function return type. Usage:356//357//     static inline Py_ALWAYS_INLINE int random(void) { return 4; }358#if defined(Py_DEBUG)359   // If Python is built in debug mode, usually compiler optimizations are360   // disabled. In this case, Py_ALWAYS_INLINE can increase a lot the stack361   // memory usage. For example, forcing inlining using gcc -O0 increases the362   // stack usage from 6 KB to 15 KB per Python function call.363#  define Py_ALWAYS_INLINE364#elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)365#  define Py_ALWAYS_INLINE __attribute__((always_inline))366#elif defined(_MSC_VER)367#  define Py_ALWAYS_INLINE __forceinline368#else369#  define Py_ALWAYS_INLINE370#endif371 372// Py_NO_INLINE373// Disable inlining on a function. For example, it reduces the C stack374// consumption: useful on LTO+PGO builds which heavily inline code (see375// bpo-33720).376//377// Usage:378//379//    Py_NO_INLINE static int random(void) { return 4; }380#if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)381#  define Py_NO_INLINE __attribute__ ((noinline))382#elif defined(_MSC_VER)383#  define Py_NO_INLINE __declspec(noinline)384#else385#  define Py_NO_INLINE386#endif387 388#include "exports.h"389 390#ifdef Py_LIMITED_API391   // The internal C API must not be used with the limited C API: make sure392   // that Py_BUILD_CORE macro is not defined in this case. These 3 macros are393   // used by exports.h, so only undefine them afterwards.394#  undef Py_BUILD_CORE395#  undef Py_BUILD_CORE_BUILTIN396#  undef Py_BUILD_CORE_MODULE397#endif398 399/* limits.h constants that may be missing */400 401#ifndef INT_MAX402#define INT_MAX 2147483647403#endif404 405#ifndef LONG_MAX406#if SIZEOF_LONG == 4407#define LONG_MAX 0X7FFFFFFFL408#elif SIZEOF_LONG == 8409#define LONG_MAX 0X7FFFFFFFFFFFFFFFL410#else411#error "could not set LONG_MAX in pyport.h"412#endif413#endif414 415#ifndef LONG_MIN416#define LONG_MIN (-LONG_MAX-1)417#endif418 419#ifndef LONG_BIT420#define LONG_BIT (8 * SIZEOF_LONG)421#endif422 423#if LONG_BIT != 8 * SIZEOF_LONG424/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent425 * 32-bit platforms using gcc.  We try to catch that here at compile-time426 * rather than waiting for integer multiplication to trigger bogus427 * overflows.428 */429#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."430#endif431 432#ifdef __cplusplus433}434#endif435 436/*437 * Hide GCC attributes from compilers that don't support them.438 */439#if (!defined(__GNUC__) || __GNUC__ < 2 || \440     (__GNUC__ == 2 && __GNUC_MINOR__ < 7) )441#define Py_GCC_ATTRIBUTE(x)442#else443#define Py_GCC_ATTRIBUTE(x) __attribute__(x)444#endif445 446/*447 * Specify alignment on compilers that support it.448 */449#if defined(__GNUC__) && __GNUC__ >= 3450#define Py_ALIGNED(x) __attribute__((aligned(x)))451#else452#define Py_ALIGNED(x)453#endif454 455/* Eliminate end-of-loop code not reached warnings from SunPro C456 * when using do{...}while(0) macros457 */458#ifdef __SUNPRO_C459#pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED)460#endif461 462#ifndef Py_LL463#define Py_LL(x) x##LL464#endif465 466#ifndef Py_ULL467#define Py_ULL(x) Py_LL(x##U)468#endif469 470#define Py_VA_COPY va_copy471 472/*473 * Convenient macros to deal with endianness of the platform. WORDS_BIGENDIAN is474 * detected by configure and defined in pyconfig.h. The code in pyconfig.h475 * also takes care of Apple's universal builds.476 */477 478#ifdef WORDS_BIGENDIAN479#  define PY_BIG_ENDIAN 1480#  define PY_LITTLE_ENDIAN 0481#else482#  define PY_BIG_ENDIAN 0483#  define PY_LITTLE_ENDIAN 1484#endif485 486#ifdef __ANDROID__487   /* The Android langinfo.h header is not used. */488#  undef HAVE_LANGINFO_H489#  undef CODESET490#endif491 492/* Maximum value of the Windows DWORD type */493#define PY_DWORD_MAX 4294967295U494 495/* This macro used to tell whether Python was built with multithreading496 * enabled.  Now multithreading is always enabled, but keep the macro497 * for compatibility.498 */499#ifndef WITH_THREAD500#  define WITH_THREAD501#endif502 503/* Some WebAssembly platforms do not provide a working pthread implementation.504 * Thread support is stubbed and any attempt to create a new thread fails.505 */506#if (!defined(HAVE_PTHREAD_STUBS) && \507      (!defined(__EMSCRIPTEN__) || defined(__EMSCRIPTEN_PTHREADS__)))508#  define Py_CAN_START_THREADS 1509#endif510 511#ifdef WITH_THREAD512#  ifdef Py_BUILD_CORE513#    ifdef HAVE_THREAD_LOCAL514#      error "HAVE_THREAD_LOCAL is already defined"515#    endif516#    define HAVE_THREAD_LOCAL 1517#    ifdef thread_local518#      define _Py_thread_local thread_local519#    elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)520#      define _Py_thread_local _Thread_local521#    elif defined(_MSC_VER)  /* AKA NT_THREADS */522#      define _Py_thread_local __declspec(thread)523#    elif defined(__GNUC__)  /* includes clang */524#      define _Py_thread_local __thread525#    else526       // fall back to the PyThread_tss_*() API, or ignore.527#      undef HAVE_THREAD_LOCAL528#    endif529#  endif530#endif531 532#if defined(__ANDROID__) || defined(__VXWORKS__)533   // Use UTF-8 as the locale encoding, ignore the LC_CTYPE locale.534   // See _Py_GetLocaleEncoding(), PyUnicode_DecodeLocale()535   // and PyUnicode_EncodeLocale().536#  define _Py_FORCE_UTF8_LOCALE537#endif538 539#if defined(_Py_FORCE_UTF8_LOCALE) || defined(__APPLE__)540   // Use UTF-8 as the filesystem encoding.541   // See PyUnicode_DecodeFSDefaultAndSize(), PyUnicode_EncodeFSDefault(),542   // Py_DecodeLocale() and Py_EncodeLocale().543#  define _Py_FORCE_UTF8_FS_ENCODING544#endif545 546/* Mark a function which cannot return. Example:547   PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void);548 549   XLC support is intentionally omitted due to bpo-40244 */550#ifndef _Py_NO_RETURN551#if defined(__clang__) || \552    (defined(__GNUC__) && \553     ((__GNUC__ >= 3) || \554      (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)))555#  define _Py_NO_RETURN __attribute__((__noreturn__))556#elif defined(_MSC_VER)557#  define _Py_NO_RETURN __declspec(noreturn)558#else559#  define _Py_NO_RETURN560#endif561#endif562 563 564// _Py_TYPEOF(expr) gets the type of an expression.565//566// Example: _Py_TYPEOF(x) x_copy = (x);567//568// The macro is only defined if GCC or clang compiler is used.569#if defined(__GNUC__) || defined(__clang__)570#  define _Py_TYPEOF(expr) __typeof__(expr)571#endif572 573 574/* A convenient way for code to know if sanitizers are enabled. */575#if defined(__has_feature)576#  if __has_feature(memory_sanitizer)577#    if !defined(_Py_MEMORY_SANITIZER)578#      define _Py_MEMORY_SANITIZER579#      define _Py_NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))580#    endif581#  endif582#  if __has_feature(address_sanitizer)583#    if !defined(_Py_ADDRESS_SANITIZER)584#      define _Py_ADDRESS_SANITIZER585#      define _Py_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))586#    endif587#  endif588#  if __has_feature(thread_sanitizer)589#    if !defined(_Py_THREAD_SANITIZER)590#      define _Py_THREAD_SANITIZER591#      define _Py_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread))592#    endif593#  endif594#elif defined(__GNUC__)595#  if defined(__SANITIZE_ADDRESS__)596#    define _Py_ADDRESS_SANITIZER597#    define _Py_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))598#  endif599#  if defined(__SANITIZE_THREAD__)600#    define _Py_THREAD_SANITIZER601#    define _Py_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread))602#  elif  __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)603     // TSAN is supported since GCC 5.1, but __SANITIZE_THREAD__ macro604     // is provided only since GCC 7.605#    define _Py_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread))606#  endif607#endif608 609#ifndef _Py_NO_SANITIZE_ADDRESS610#  define _Py_NO_SANITIZE_ADDRESS611#endif612#ifndef _Py_NO_SANITIZE_THREAD613#  define _Py_NO_SANITIZE_THREAD614#endif615#ifndef _Py_NO_SANITIZE_MEMORY616#  define _Py_NO_SANITIZE_MEMORY617#endif618 619/* AIX has __bool__ redefined in it's system header file. */620#if defined(_AIX) && defined(__bool__)621#undef __bool__622#endif623 624// Make sure we have maximum alignment, even if the current compiler625// does not support max_align_t. Note that:626// - Autoconf reports alignment of unknown types to 0.627// - 'long double' has maximum alignment on *most* platforms,628//   looks like the best we can do for pre-C11 compilers.629// - The value is tested, see test_alignof_max_align_t630#if !defined(ALIGNOF_MAX_ALIGN_T) || ALIGNOF_MAX_ALIGN_T == 0631#   undef ALIGNOF_MAX_ALIGN_T632#   define ALIGNOF_MAX_ALIGN_T _Alignof(long double)633#endif634 635#ifndef PY_CXX_CONST636#  ifdef __cplusplus637#    define PY_CXX_CONST const638#  else639#    define PY_CXX_CONST640#  endif641#endif642 643#if defined(__sgi) && !defined(_SGI_MP_SOURCE)644#  define _SGI_MP_SOURCE645#endif646 647// Explicit fallthrough in switch case to avoid warnings648// with compiler flag -Wimplicit-fallthrough.649//650// Usage example:651//652//     switch (value) {653//     case 1: _Py_FALLTHROUGH;654//     case 2: code; break;655//     }656//657// __attribute__((fallthrough)) was introduced in GCC 7 and Clang 10 /658// Apple Clang 12.0. Earlier Clang versions support only the C++11659// style fallthrough attribute, not the GCC extension syntax used here,660// and __has_attribute(fallthrough) evaluates to 1.661#if _Py__has_attribute(fallthrough) && (!defined(__clang__) || \662    (!defined(__apple_build_version__) && __clang_major__ >= 10) || \663    (defined(__apple_build_version__) && __clang_major__ >= 12))664#  define _Py_FALLTHROUGH __attribute__((fallthrough))665#else666#  define _Py_FALLTHROUGH do { } while (0)667#endif668 669 670// _Py_NO_SANITIZE_UNDEFINED(): Disable Undefined Behavior sanitizer (UBsan)671// on a function.672//673// Clang and GCC 9.0+ use __attribute__((no_sanitize("undefined"))).674// GCC 4.9+ uses __attribute__((no_sanitize_undefined)).675#if defined(__has_feature)676#  if __has_feature(undefined_behavior_sanitizer)677#    define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))678#  endif679#endif680#if !defined(_Py_NO_SANITIZE_UNDEFINED) && defined(__GNUC__) \681    && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9))682#  define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize_undefined))683#endif684#ifndef _Py_NO_SANITIZE_UNDEFINED685#  define _Py_NO_SANITIZE_UNDEFINED686#endif687 688 689// _Py_NONSTRING: The nonstring variable attribute specifies that an object or690// member declaration with type array of char, signed char, or unsigned char,691// or pointer to such a type is intended to store character arrays that do not692// necessarily contain a terminating NUL.693//694// Usage:695//696//   char name [8] _Py_NONSTRING;697#if _Py__has_attribute(nonstring)698#  define _Py_NONSTRING __attribute__((nonstring))699#else700#  define _Py_NONSTRING701#endif702 703 704// Assume the stack grows down unless specified otherwise705#ifndef _Py_STACK_GROWS_DOWN706#  define _Py_STACK_GROWS_DOWN 1707#endif708 709 710#endif /* Py_PYPORT_H */711 
codekingpro/portable-devtools · Team Ai