Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/python3....
File: pyport.h
#ifndef Py_PYPORT_H
[0] Fix | Delete
#define Py_PYPORT_H
[1] Fix | Delete
[2] Fix | Delete
#include "pyconfig.h" /* include for defines */
[3] Fix | Delete
[4] Fix | Delete
#include <inttypes.h>
[5] Fix | Delete
[6] Fix | Delete
/**************************************************************************
[7] Fix | Delete
Symbols and macros to supply platform-independent interfaces to basic
[8] Fix | Delete
C language & library operations whose spellings vary across platforms.
[9] Fix | Delete
[10] Fix | Delete
Please try to make documentation here as clear as possible: by definition,
[11] Fix | Delete
the stuff here is trying to illuminate C's darkest corners.
[12] Fix | Delete
[13] Fix | Delete
Config #defines referenced here:
[14] Fix | Delete
[15] Fix | Delete
SIGNED_RIGHT_SHIFT_ZERO_FILLS
[16] Fix | Delete
Meaning: To be defined iff i>>j does not extend the sign bit when i is a
[17] Fix | Delete
signed integral type and i < 0.
[18] Fix | Delete
Used in: Py_ARITHMETIC_RIGHT_SHIFT
[19] Fix | Delete
[20] Fix | Delete
Py_DEBUG
[21] Fix | Delete
Meaning: Extra checks compiled in for debug mode.
[22] Fix | Delete
Used in: Py_SAFE_DOWNCAST
[23] Fix | Delete
[24] Fix | Delete
**************************************************************************/
[25] Fix | Delete
[26] Fix | Delete
/* typedefs for some C9X-defined synonyms for integral types.
[27] Fix | Delete
*
[28] Fix | Delete
* The names in Python are exactly the same as the C9X names, except with a
[29] Fix | Delete
* Py_ prefix. Until C9X is universally implemented, this is the only way
[30] Fix | Delete
* to ensure that Python gets reliable names that don't conflict with names
[31] Fix | Delete
* in non-Python code that are playing their own tricks to define the C9X
[32] Fix | Delete
* names.
[33] Fix | Delete
*
[34] Fix | Delete
* NOTE: don't go nuts here! Python has no use for *most* of the C9X
[35] Fix | Delete
* integral synonyms. Only define the ones we actually need.
[36] Fix | Delete
*/
[37] Fix | Delete
[38] Fix | Delete
/* long long is required. Ensure HAVE_LONG_LONG is defined for compatibility. */
[39] Fix | Delete
#ifndef HAVE_LONG_LONG
[40] Fix | Delete
#define HAVE_LONG_LONG 1
[41] Fix | Delete
#endif
[42] Fix | Delete
#ifndef PY_LONG_LONG
[43] Fix | Delete
#define PY_LONG_LONG long long
[44] Fix | Delete
/* If LLONG_MAX is defined in limits.h, use that. */
[45] Fix | Delete
#define PY_LLONG_MIN LLONG_MIN
[46] Fix | Delete
#define PY_LLONG_MAX LLONG_MAX
[47] Fix | Delete
#define PY_ULLONG_MAX ULLONG_MAX
[48] Fix | Delete
#endif
[49] Fix | Delete
[50] Fix | Delete
#define PY_UINT32_T uint32_t
[51] Fix | Delete
#define PY_UINT64_T uint64_t
[52] Fix | Delete
[53] Fix | Delete
/* Signed variants of the above */
[54] Fix | Delete
#define PY_INT32_T int32_t
[55] Fix | Delete
#define PY_INT64_T int64_t
[56] Fix | Delete
[57] Fix | Delete
/* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all
[58] Fix | Delete
the necessary integer types are available, and we're on a 64-bit platform
[59] Fix | Delete
(as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits. */
[60] Fix | Delete
[61] Fix | Delete
#ifndef PYLONG_BITS_IN_DIGIT
[62] Fix | Delete
#if SIZEOF_VOID_P >= 8
[63] Fix | Delete
#define PYLONG_BITS_IN_DIGIT 30
[64] Fix | Delete
#else
[65] Fix | Delete
#define PYLONG_BITS_IN_DIGIT 15
[66] Fix | Delete
#endif
[67] Fix | Delete
#endif
[68] Fix | Delete
[69] Fix | Delete
/* uintptr_t is the C9X name for an unsigned integral type such that a
[70] Fix | Delete
* legitimate void* can be cast to uintptr_t and then back to void* again
[71] Fix | Delete
* without loss of information. Similarly for intptr_t, wrt a signed
[72] Fix | Delete
* integral type.
[73] Fix | Delete
*/
[74] Fix | Delete
typedef uintptr_t Py_uintptr_t;
[75] Fix | Delete
typedef intptr_t Py_intptr_t;
[76] Fix | Delete
[77] Fix | Delete
/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) ==
[78] Fix | Delete
* sizeof(size_t). C99 doesn't define such a thing directly (size_t is an
[79] Fix | Delete
* unsigned integral type). See PEP 353 for details.
[80] Fix | Delete
*/
[81] Fix | Delete
#ifdef HAVE_SSIZE_T
[82] Fix | Delete
typedef ssize_t Py_ssize_t;
[83] Fix | Delete
#elif SIZEOF_VOID_P == SIZEOF_SIZE_T
[84] Fix | Delete
typedef Py_intptr_t Py_ssize_t;
[85] Fix | Delete
#else
[86] Fix | Delete
# error "Python needs a typedef for Py_ssize_t in pyport.h."
[87] Fix | Delete
#endif
[88] Fix | Delete
[89] Fix | Delete
/* Py_hash_t is the same size as a pointer. */
[90] Fix | Delete
#define SIZEOF_PY_HASH_T SIZEOF_SIZE_T
[91] Fix | Delete
typedef Py_ssize_t Py_hash_t;
[92] Fix | Delete
/* Py_uhash_t is the unsigned equivalent needed to calculate numeric hash. */
[93] Fix | Delete
#define SIZEOF_PY_UHASH_T SIZEOF_SIZE_T
[94] Fix | Delete
typedef size_t Py_uhash_t;
[95] Fix | Delete
[96] Fix | Delete
/* Only used for compatibility with code that may not be PY_SSIZE_T_CLEAN. */
[97] Fix | Delete
#ifdef PY_SSIZE_T_CLEAN
[98] Fix | Delete
typedef Py_ssize_t Py_ssize_clean_t;
[99] Fix | Delete
#else
[100] Fix | Delete
typedef int Py_ssize_clean_t;
[101] Fix | Delete
#endif
[102] Fix | Delete
[103] Fix | Delete
/* Largest possible value of size_t. */
[104] Fix | Delete
#define PY_SIZE_MAX SIZE_MAX
[105] Fix | Delete
[106] Fix | Delete
/* Largest positive value of type Py_ssize_t. */
[107] Fix | Delete
#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
[108] Fix | Delete
/* Smallest negative value of type Py_ssize_t. */
[109] Fix | Delete
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
[110] Fix | Delete
[111] Fix | Delete
/* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
[112] Fix | Delete
* format to convert an argument with the width of a size_t or Py_ssize_t.
[113] Fix | Delete
* C99 introduced "z" for this purpose, but not all platforms support that;
[114] Fix | Delete
* e.g., MS compilers use "I" instead.
[115] Fix | Delete
*
[116] Fix | Delete
* These "high level" Python format functions interpret "z" correctly on
[117] Fix | Delete
* all platforms (Python interprets the format string itself, and does whatever
[118] Fix | Delete
* the platform C requires to convert a size_t/Py_ssize_t argument):
[119] Fix | Delete
*
[120] Fix | Delete
* PyBytes_FromFormat
[121] Fix | Delete
* PyErr_Format
[122] Fix | Delete
* PyBytes_FromFormatV
[123] Fix | Delete
* PyUnicode_FromFormatV
[124] Fix | Delete
*
[125] Fix | Delete
* Lower-level uses require that you interpolate the correct format modifier
[126] Fix | Delete
* yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for
[127] Fix | Delete
* example,
[128] Fix | Delete
*
[129] Fix | Delete
* Py_ssize_t index;
[130] Fix | Delete
* fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index);
[131] Fix | Delete
*
[132] Fix | Delete
* That will expand to %ld, or %Id, or to something else correct for a
[133] Fix | Delete
* Py_ssize_t on the platform.
[134] Fix | Delete
*/
[135] Fix | Delete
#ifndef PY_FORMAT_SIZE_T
[136] Fix | Delete
# if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__)
[137] Fix | Delete
# define PY_FORMAT_SIZE_T ""
[138] Fix | Delete
# elif SIZEOF_SIZE_T == SIZEOF_LONG
[139] Fix | Delete
# define PY_FORMAT_SIZE_T "l"
[140] Fix | Delete
# elif defined(MS_WINDOWS)
[141] Fix | Delete
# define PY_FORMAT_SIZE_T "I"
[142] Fix | Delete
# else
[143] Fix | Delete
# error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T"
[144] Fix | Delete
# endif
[145] Fix | Delete
#endif
[146] Fix | Delete
[147] Fix | Delete
/* Py_LOCAL can be used instead of static to get the fastest possible calling
[148] Fix | Delete
* convention for functions that are local to a given module.
[149] Fix | Delete
*
[150] Fix | Delete
* Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining,
[151] Fix | Delete
* for platforms that support that.
[152] Fix | Delete
*
[153] Fix | Delete
* If PY_LOCAL_AGGRESSIVE is defined before python.h is included, more
[154] Fix | Delete
* "aggressive" inlining/optimization is enabled for the entire module. This
[155] Fix | Delete
* may lead to code bloat, and may slow things down for those reasons. It may
[156] Fix | Delete
* also lead to errors, if the code relies on pointer aliasing. Use with
[157] Fix | Delete
* care.
[158] Fix | Delete
*
[159] Fix | Delete
* NOTE: You can only use this for functions that are entirely local to a
[160] Fix | Delete
* module; functions that are exported via method tables, callbacks, etc,
[161] Fix | Delete
* should keep using static.
[162] Fix | Delete
*/
[163] Fix | Delete
[164] Fix | Delete
#if defined(_MSC_VER)
[165] Fix | Delete
#if defined(PY_LOCAL_AGGRESSIVE)
[166] Fix | Delete
/* enable more aggressive optimization for visual studio */
[167] Fix | Delete
#pragma optimize("agtw", on)
[168] Fix | Delete
#endif
[169] Fix | Delete
/* ignore warnings if the compiler decides not to inline a function */
[170] Fix | Delete
#pragma warning(disable: 4710)
[171] Fix | Delete
/* fastest possible local call under MSVC */
[172] Fix | Delete
#define Py_LOCAL(type) static type __fastcall
[173] Fix | Delete
#define Py_LOCAL_INLINE(type) static __inline type __fastcall
[174] Fix | Delete
#elif defined(USE_INLINE)
[175] Fix | Delete
#define Py_LOCAL(type) static type
[176] Fix | Delete
#define Py_LOCAL_INLINE(type) static inline type
[177] Fix | Delete
#else
[178] Fix | Delete
#define Py_LOCAL(type) static type
[179] Fix | Delete
#define Py_LOCAL_INLINE(type) static type
[180] Fix | Delete
#endif
[181] Fix | Delete
[182] Fix | Delete
/* Py_MEMCPY is kept for backwards compatibility,
[183] Fix | Delete
* see https://bugs.python.org/issue28126 */
[184] Fix | Delete
#define Py_MEMCPY memcpy
[185] Fix | Delete
[186] Fix | Delete
#include <stdlib.h>
[187] Fix | Delete
[188] Fix | Delete
#ifdef HAVE_IEEEFP_H
[189] Fix | Delete
#include <ieeefp.h> /* needed for 'finite' declaration on some platforms */
[190] Fix | Delete
#endif
[191] Fix | Delete
[192] Fix | Delete
#include <math.h> /* Moved here from the math section, before extern "C" */
[193] Fix | Delete
[194] Fix | Delete
/********************************************
[195] Fix | Delete
* WRAPPER FOR <time.h> and/or <sys/time.h> *
[196] Fix | Delete
********************************************/
[197] Fix | Delete
[198] Fix | Delete
#ifdef TIME_WITH_SYS_TIME
[199] Fix | Delete
#include <sys/time.h>
[200] Fix | Delete
#include <time.h>
[201] Fix | Delete
#else /* !TIME_WITH_SYS_TIME */
[202] Fix | Delete
#ifdef HAVE_SYS_TIME_H
[203] Fix | Delete
#include <sys/time.h>
[204] Fix | Delete
#else /* !HAVE_SYS_TIME_H */
[205] Fix | Delete
#include <time.h>
[206] Fix | Delete
#endif /* !HAVE_SYS_TIME_H */
[207] Fix | Delete
#endif /* !TIME_WITH_SYS_TIME */
[208] Fix | Delete
[209] Fix | Delete
[210] Fix | Delete
/******************************
[211] Fix | Delete
* WRAPPER FOR <sys/select.h> *
[212] Fix | Delete
******************************/
[213] Fix | Delete
[214] Fix | Delete
/* NB caller must include <sys/types.h> */
[215] Fix | Delete
[216] Fix | Delete
#ifdef HAVE_SYS_SELECT_H
[217] Fix | Delete
#include <sys/select.h>
[218] Fix | Delete
#endif /* !HAVE_SYS_SELECT_H */
[219] Fix | Delete
[220] Fix | Delete
/*******************************
[221] Fix | Delete
* stat() and fstat() fiddling *
[222] Fix | Delete
*******************************/
[223] Fix | Delete
[224] Fix | Delete
#ifdef HAVE_SYS_STAT_H
[225] Fix | Delete
#include <sys/stat.h>
[226] Fix | Delete
#elif defined(HAVE_STAT_H)
[227] Fix | Delete
#include <stat.h>
[228] Fix | Delete
#endif
[229] Fix | Delete
[230] Fix | Delete
#ifndef S_IFMT
[231] Fix | Delete
/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
[232] Fix | Delete
#define S_IFMT 0170000
[233] Fix | Delete
#endif
[234] Fix | Delete
[235] Fix | Delete
#ifndef S_IFLNK
[236] Fix | Delete
/* Windows doesn't define S_IFLNK but posixmodule.c maps
[237] Fix | Delete
* IO_REPARSE_TAG_SYMLINK to S_IFLNK */
[238] Fix | Delete
# define S_IFLNK 0120000
[239] Fix | Delete
#endif
[240] Fix | Delete
[241] Fix | Delete
#ifndef S_ISREG
[242] Fix | Delete
#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
[243] Fix | Delete
#endif
[244] Fix | Delete
[245] Fix | Delete
#ifndef S_ISDIR
[246] Fix | Delete
#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
[247] Fix | Delete
#endif
[248] Fix | Delete
[249] Fix | Delete
#ifndef S_ISCHR
[250] Fix | Delete
#define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR)
[251] Fix | Delete
#endif
[252] Fix | Delete
[253] Fix | Delete
#ifdef __cplusplus
[254] Fix | Delete
/* Move this down here since some C++ #include's don't like to be included
[255] Fix | Delete
inside an extern "C" */
[256] Fix | Delete
extern "C" {
[257] Fix | Delete
#endif
[258] Fix | Delete
[259] Fix | Delete
[260] Fix | Delete
/* Py_ARITHMETIC_RIGHT_SHIFT
[261] Fix | Delete
* C doesn't define whether a right-shift of a signed integer sign-extends
[262] Fix | Delete
* or zero-fills. Here a macro to force sign extension:
[263] Fix | Delete
* Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J)
[264] Fix | Delete
* Return I >> J, forcing sign extension. Arithmetically, return the
[265] Fix | Delete
* floor of I/2**J.
[266] Fix | Delete
* Requirements:
[267] Fix | Delete
* I should have signed integer type. In the terminology of C99, this can
[268] Fix | Delete
* be either one of the five standard signed integer types (signed char,
[269] Fix | Delete
* short, int, long, long long) or an extended signed integer type.
[270] Fix | Delete
* J is an integer >= 0 and strictly less than the number of bits in the
[271] Fix | Delete
* type of I (because C doesn't define what happens for J outside that
[272] Fix | Delete
* range either).
[273] Fix | Delete
* TYPE used to specify the type of I, but is now ignored. It's been left
[274] Fix | Delete
* in for backwards compatibility with versions <= 2.6 or 3.0.
[275] Fix | Delete
* Caution:
[276] Fix | Delete
* I may be evaluated more than once.
[277] Fix | Delete
*/
[278] Fix | Delete
#ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS
[279] Fix | Delete
#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \
[280] Fix | Delete
((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J))
[281] Fix | Delete
#else
[282] Fix | Delete
#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J))
[283] Fix | Delete
#endif
[284] Fix | Delete
[285] Fix | Delete
/* Py_FORCE_EXPANSION(X)
[286] Fix | Delete
* "Simply" returns its argument. However, macro expansions within the
[287] Fix | Delete
* argument are evaluated. This unfortunate trickery is needed to get
[288] Fix | Delete
* token-pasting to work as desired in some cases.
[289] Fix | Delete
*/
[290] Fix | Delete
#define Py_FORCE_EXPANSION(X) X
[291] Fix | Delete
[292] Fix | Delete
/* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW)
[293] Fix | Delete
* Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this
[294] Fix | Delete
* assert-fails if any information is lost.
[295] Fix | Delete
* Caution:
[296] Fix | Delete
* VALUE may be evaluated more than once.
[297] Fix | Delete
*/
[298] Fix | Delete
#ifdef Py_DEBUG
[299] Fix | Delete
#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \
[300] Fix | Delete
(assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE))
[301] Fix | Delete
#else
[302] Fix | Delete
#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE)
[303] Fix | Delete
#endif
[304] Fix | Delete
[305] Fix | Delete
/* Py_SET_ERRNO_ON_MATH_ERROR(x)
[306] Fix | Delete
* If a libm function did not set errno, but it looks like the result
[307] Fix | Delete
* overflowed or not-a-number, set errno to ERANGE or EDOM. Set errno
[308] Fix | Delete
* to 0 before calling a libm function, and invoke this macro after,
[309] Fix | Delete
* passing the function result.
[310] Fix | Delete
* Caution:
[311] Fix | Delete
* This isn't reliable. See Py_OVERFLOWED comments.
[312] Fix | Delete
* X is evaluated more than once.
[313] Fix | Delete
*/
[314] Fix | Delete
#if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__hpux) && defined(__ia64))
[315] Fix | Delete
#define _Py_SET_EDOM_FOR_NAN(X) if (isnan(X)) errno = EDOM;
[316] Fix | Delete
#else
[317] Fix | Delete
#define _Py_SET_EDOM_FOR_NAN(X) ;
[318] Fix | Delete
#endif
[319] Fix | Delete
#define Py_SET_ERRNO_ON_MATH_ERROR(X) \
[320] Fix | Delete
do { \
[321] Fix | Delete
if (errno == 0) { \
[322] Fix | Delete
if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \
[323] Fix | Delete
errno = ERANGE; \
[324] Fix | Delete
else _Py_SET_EDOM_FOR_NAN(X) \
[325] Fix | Delete
} \
[326] Fix | Delete
} while(0)
[327] Fix | Delete
[328] Fix | Delete
/* Py_SET_ERANGE_ON_OVERFLOW(x)
[329] Fix | Delete
* An alias of Py_SET_ERRNO_ON_MATH_ERROR for backward-compatibility.
[330] Fix | Delete
*/
[331] Fix | Delete
#define Py_SET_ERANGE_IF_OVERFLOW(X) Py_SET_ERRNO_ON_MATH_ERROR(X)
[332] Fix | Delete
[333] Fix | Delete
/* Py_ADJUST_ERANGE1(x)
[334] Fix | Delete
* Py_ADJUST_ERANGE2(x, y)
[335] Fix | Delete
* Set errno to 0 before calling a libm function, and invoke one of these
[336] Fix | Delete
* macros after, passing the function result(s) (Py_ADJUST_ERANGE2 is useful
[337] Fix | Delete
* for functions returning complex results). This makes two kinds of
[338] Fix | Delete
* adjustments to errno: (A) If it looks like the platform libm set
[339] Fix | Delete
* errno=ERANGE due to underflow, clear errno. (B) If it looks like the
[340] Fix | Delete
* platform libm overflowed but didn't set errno, force errno to ERANGE. In
[341] Fix | Delete
* effect, we're trying to force a useful implementation of C89 errno
[342] Fix | Delete
* behavior.
[343] Fix | Delete
* Caution:
[344] Fix | Delete
* This isn't reliable. See Py_OVERFLOWED comments.
[345] Fix | Delete
* X and Y may be evaluated more than once.
[346] Fix | Delete
*/
[347] Fix | Delete
#define Py_ADJUST_ERANGE1(X) \
[348] Fix | Delete
do { \
[349] Fix | Delete
if (errno == 0) { \
[350] Fix | Delete
if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \
[351] Fix | Delete
errno = ERANGE; \
[352] Fix | Delete
} \
[353] Fix | Delete
else if (errno == ERANGE && (X) == 0.0) \
[354] Fix | Delete
errno = 0; \
[355] Fix | Delete
} while(0)
[356] Fix | Delete
[357] Fix | Delete
#define Py_ADJUST_ERANGE2(X, Y) \
[358] Fix | Delete
do { \
[359] Fix | Delete
if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \
[360] Fix | Delete
(Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \
[361] Fix | Delete
if (errno == 0) \
[362] Fix | Delete
errno = ERANGE; \
[363] Fix | Delete
} \
[364] Fix | Delete
else if (errno == ERANGE) \
[365] Fix | Delete
errno = 0; \
[366] Fix | Delete
} while(0)
[367] Fix | Delete
[368] Fix | Delete
/* The functions _Py_dg_strtod and _Py_dg_dtoa in Python/dtoa.c (which are
[369] Fix | Delete
* required to support the short float repr introduced in Python 3.1) require
[370] Fix | Delete
* that the floating-point unit that's being used for arithmetic operations
[371] Fix | Delete
* on C doubles is set to use 53-bit precision. It also requires that the
[372] Fix | Delete
* FPU rounding mode is round-half-to-even, but that's less often an issue.
[373] Fix | Delete
*
[374] Fix | Delete
* If your FPU isn't already set to 53-bit precision/round-half-to-even, and
[375] Fix | Delete
* you want to make use of _Py_dg_strtod and _Py_dg_dtoa, then you should
[376] Fix | Delete
*
[377] Fix | Delete
* #define HAVE_PY_SET_53BIT_PRECISION 1
[378] Fix | Delete
*
[379] Fix | Delete
* and also give appropriate definitions for the following three macros:
[380] Fix | Delete
*
[381] Fix | Delete
* _PY_SET_53BIT_PRECISION_START : store original FPU settings, and
[382] Fix | Delete
* set FPU to 53-bit precision/round-half-to-even
[383] Fix | Delete
* _PY_SET_53BIT_PRECISION_END : restore original FPU settings
[384] Fix | Delete
* _PY_SET_53BIT_PRECISION_HEADER : any variable declarations needed to
[385] Fix | Delete
* use the two macros above.
[386] Fix | Delete
*
[387] Fix | Delete
* The macros are designed to be used within a single C function: see
[388] Fix | Delete
* Python/pystrtod.c for an example of their use.
[389] Fix | Delete
*/
[390] Fix | Delete
[391] Fix | Delete
/* get and set x87 control word for gcc/x86 */
[392] Fix | Delete
#ifdef HAVE_GCC_ASM_FOR_X87
[393] Fix | Delete
#define HAVE_PY_SET_53BIT_PRECISION 1
[394] Fix | Delete
/* _Py_get/set_387controlword functions are defined in Python/pymath.c */
[395] Fix | Delete
#define _Py_SET_53BIT_PRECISION_HEADER \
[396] Fix | Delete
unsigned short old_387controlword, new_387controlword
[397] Fix | Delete
#define _Py_SET_53BIT_PRECISION_START \
[398] Fix | Delete
do { \
[399] Fix | Delete
old_387controlword = _Py_get_387controlword(); \
[400] Fix | Delete
new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \
[401] Fix | Delete
if (new_387controlword != old_387controlword) \
[402] Fix | Delete
_Py_set_387controlword(new_387controlword); \
[403] Fix | Delete
} while (0)
[404] Fix | Delete
#define _Py_SET_53BIT_PRECISION_END \
[405] Fix | Delete
if (new_387controlword != old_387controlword) \
[406] Fix | Delete
_Py_set_387controlword(old_387controlword)
[407] Fix | Delete
#endif
[408] Fix | Delete
[409] Fix | Delete
/* get and set x87 control word for VisualStudio/x86 */
[410] Fix | Delete
#if defined(_MSC_VER) && !defined(_WIN64) /* x87 not supported in 64-bit */
[411] Fix | Delete
#define HAVE_PY_SET_53BIT_PRECISION 1
[412] Fix | Delete
#define _Py_SET_53BIT_PRECISION_HEADER \
[413] Fix | Delete
unsigned int old_387controlword, new_387controlword, out_387controlword
[414] Fix | Delete
/* We use the __control87_2 function to set only the x87 control word.
[415] Fix | Delete
The SSE control word is unaffected. */
[416] Fix | Delete
#define _Py_SET_53BIT_PRECISION_START \
[417] Fix | Delete
do { \
[418] Fix | Delete
__control87_2(0, 0, &old_387controlword, NULL); \
[419] Fix | Delete
new_387controlword = \
[420] Fix | Delete
(old_387controlword & ~(_MCW_PC | _MCW_RC)) | (_PC_53 | _RC_NEAR); \
[421] Fix | Delete
if (new_387controlword != old_387controlword) \
[422] Fix | Delete
__control87_2(new_387controlword, _MCW_PC | _MCW_RC, \
[423] Fix | Delete
&out_387controlword, NULL); \
[424] Fix | Delete
} while (0)
[425] Fix | Delete
#define _Py_SET_53BIT_PRECISION_END \
[426] Fix | Delete
do { \
[427] Fix | Delete
if (new_387controlword != old_387controlword) \
[428] Fix | Delete
__control87_2(old_387controlword, _MCW_PC | _MCW_RC, \
[429] Fix | Delete
&out_387controlword, NULL); \
[430] Fix | Delete
} while (0)
[431] Fix | Delete
#endif
[432] Fix | Delete
[433] Fix | Delete
#ifdef HAVE_GCC_ASM_FOR_MC68881
[434] Fix | Delete
#define HAVE_PY_SET_53BIT_PRECISION 1
[435] Fix | Delete
#define _Py_SET_53BIT_PRECISION_HEADER \
[436] Fix | Delete
unsigned int old_fpcr, new_fpcr
[437] Fix | Delete
#define _Py_SET_53BIT_PRECISION_START \
[438] Fix | Delete
do { \
[439] Fix | Delete
__asm__ ("fmove.l %%fpcr,%0" : "=g" (old_fpcr)); \
[440] Fix | Delete
/* Set double precision / round to nearest. */ \
[441] Fix | Delete
new_fpcr = (old_fpcr & ~0xf0) | 0x80; \
[442] Fix | Delete
if (new_fpcr != old_fpcr) \
[443] Fix | Delete
__asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (new_fpcr)); \
[444] Fix | Delete
} while (0)
[445] Fix | Delete
#define _Py_SET_53BIT_PRECISION_END \
[446] Fix | Delete
do { \
[447] Fix | Delete
if (new_fpcr != old_fpcr) \
[448] Fix | Delete
__asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (old_fpcr)); \
[449] Fix | Delete
} while (0)
[450] Fix | Delete
#endif
[451] Fix | Delete
[452] Fix | Delete
/* default definitions are empty */
[453] Fix | Delete
#ifndef HAVE_PY_SET_53BIT_PRECISION
[454] Fix | Delete
#define _Py_SET_53BIT_PRECISION_HEADER
[455] Fix | Delete
#define _Py_SET_53BIT_PRECISION_START
[456] Fix | Delete
#define _Py_SET_53BIT_PRECISION_END
[457] Fix | Delete
#endif
[458] Fix | Delete
[459] Fix | Delete
/* If we can't guarantee 53-bit precision, don't use the code
[460] Fix | Delete
in Python/dtoa.c, but fall back to standard code. This
[461] Fix | Delete
means that repr of a float will be long (17 sig digits).
[462] Fix | Delete
[463] Fix | Delete
Realistically, there are two things that could go wrong:
[464] Fix | Delete
[465] Fix | Delete
(1) doubles aren't IEEE 754 doubles, or
[466] Fix | Delete
(2) we're on x86 with the rounding precision set to 64-bits
[467] Fix | Delete
(extended precision), and we don't know how to change
[468] Fix | Delete
the rounding precision.
[469] Fix | Delete
*/
[470] Fix | Delete
[471] Fix | Delete
#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \
[472] Fix | Delete
!defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \
[473] Fix | Delete
!defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754)
[474] Fix | Delete
#define PY_NO_SHORT_FLOAT_REPR
[475] Fix | Delete
#endif
[476] Fix | Delete
[477] Fix | Delete
/* double rounding is symptomatic of use of extended precision on x86. If
[478] Fix | Delete
we're seeing double rounding, and we don't have any mechanism available for
[479] Fix | Delete
changing the FPU rounding precision, then don't use Python/dtoa.c. */
[480] Fix | Delete
#if defined(X87_DOUBLE_ROUNDING) && !defined(HAVE_PY_SET_53BIT_PRECISION)
[481] Fix | Delete
#define PY_NO_SHORT_FLOAT_REPR
[482] Fix | Delete
#endif
[483] Fix | Delete
[484] Fix | Delete
[485] Fix | Delete
/* Py_DEPRECATED(version)
[486] Fix | Delete
* Declare a variable, type, or function deprecated.
[487] Fix | Delete
* Usage:
[488] Fix | Delete
* extern int old_var Py_DEPRECATED(2.3);
[489] Fix | Delete
* typedef int T1 Py_DEPRECATED(2.4);
[490] Fix | Delete
* extern int x() Py_DEPRECATED(2.5);
[491] Fix | Delete
*/
[492] Fix | Delete
#if defined(__GNUC__) && ((__GNUC__ >= 4) || \
[493] Fix | Delete
(__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
[494] Fix | Delete
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
[495] Fix | Delete
#else
[496] Fix | Delete
#define Py_DEPRECATED(VERSION_UNUSED)
[497] Fix | Delete
#endif
[498] Fix | Delete
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function