4 #include "pyconfig.h" /* include for defines */
6 /**************************************************************************
7 Symbols and macros to supply platform-independent interfaces to basic
8 C language & library operations whose spellings vary across platforms.
10 Please try to make documentation here as clear as possible: by definition,
11 the stuff here is trying to illuminate C's darkest corners.
13 Config #defines referenced here:
15 SIGNED_RIGHT_SHIFT_ZERO_FILLS
16 Meaning: To be defined iff i>>j does not extend the sign bit when i is a
17 signed integral type and i < 0.
18 Used in: Py_ARITHMETIC_RIGHT_SHIFT
21 Meaning: Extra checks compiled in for debug mode.
22 Used in: Py_SAFE_DOWNCAST
25 Meaning: The C9X type uintptr_t is supported by the compiler
29 Meaning: The compiler supports the C type "long long"
32 **************************************************************************/
35 /* For backward compatibility only. Obsolete, do not use. */
36 #ifdef HAVE_PROTOTYPES
39 #define Py_PROTO(x) ()
42 #define Py_FPROTO(x) Py_PROTO(x)
45 /* typedefs for some C9X-defined synonyms for integral types.
47 * The names in Python are exactly the same as the C9X names, except with a
48 * Py_ prefix. Until C9X is universally implemented, this is the only way
49 * to ensure that Python gets reliable names that don't conflict with names
50 * in non-Python code that are playing their own tricks to define the C9X
53 * NOTE: don't go nuts here! Python has no use for *most* of the C9X
54 * integral synonyms. Only define the ones we actually need.
59 #define PY_LONG_LONG long long
61 #endif /* HAVE_LONG_LONG */
63 /* uintptr_t is the C9X name for an unsigned integral type such that a
64 * legitimate void* can be cast to uintptr_t and then back to void* again
65 * without loss of information. Similarly for intptr_t, wrt a signed
69 typedef uintptr_t Py_uintptr_t
;
70 typedef intptr_t Py_intptr_t
;
72 #elif SIZEOF_VOID_P <= SIZEOF_INT
73 typedef unsigned int Py_uintptr_t
;
74 typedef int Py_intptr_t
;
76 #elif SIZEOF_VOID_P <= SIZEOF_LONG
77 typedef unsigned long Py_uintptr_t
;
78 typedef long Py_intptr_t
;
80 #elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG)
81 typedef unsigned PY_LONG_LONG Py_uintptr_t
;
82 typedef PY_LONG_LONG Py_intptr_t
;
85 # error "Python needs a typedef for Py_uintptr_t in pyport.h."
86 #endif /* HAVE_UINTPTR_T */
88 /* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) ==
89 * sizeof(size_t). C99 doesn't define such a thing directly (size_t is an
90 * unsigned integral type). See PEP 353 for details.
93 typedef ssize_t Py_ssize_t
;
94 #elif SIZEOF_VOID_P == SIZEOF_SIZE_T
95 typedef Py_intptr_t Py_ssize_t
;
97 # error "Python needs a typedef for Py_ssize_t in pyport.h."
100 /* Largest positive value of type Py_ssize_t. */
101 #define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
102 /* Smallest negative value of type Py_ssize_t. */
103 #define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
105 /* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
106 * format to convert an argument with the width of a size_t or Py_ssize_t.
107 * C99 introduced "z" for this purpose, but not all platforms support that;
108 * e.g., MS compilers use "I" instead.
110 * These "high level" Python format functions interpret "z" correctly on
111 * all platforms (Python interprets the format string itself, and does whatever
112 * the platform C requires to convert a size_t/Py_ssize_t argument):
114 * PyString_FromFormat
116 * PyString_FromFormatV
118 * Lower-level uses require that you interpolate the correct format modifier
119 * yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for
123 * fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index);
125 * That will expand to %ld, or %Id, or to something else correct for a
126 * Py_ssize_t on the platform.
128 #ifndef PY_FORMAT_SIZE_T
129 # if SIZEOF_SIZE_T == SIZEOF_INT
130 # define PY_FORMAT_SIZE_T ""
131 # elif SIZEOF_SIZE_T == SIZEOF_LONG
132 # define PY_FORMAT_SIZE_T "l"
133 # elif defined(MS_WINDOWS)
134 # define PY_FORMAT_SIZE_T "I"
136 # error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T"
140 /* Py_LOCAL can be used instead of static to get the fastest possible calling
141 * convention for functions that are local to a given module.
143 * Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining,
144 * for platforms that support that.
146 * If PY_LOCAL_AGGRESSIVE is defined before python.h is included, more
147 * "aggressive" inlining/optimizaion is enabled for the entire module. This
148 * may lead to code bloat, and may slow things down for those reasons. It may
149 * also lead to errors, if the code relies on pointer aliasing. Use with
152 * NOTE: You can only use this for functions that are entirely local to a
153 * module; functions that are exported via method tables, callbacks, etc,
154 * should keep using static.
157 #undef USE_INLINE /* XXX - set via configure? */
159 #if defined(_MSC_VER)
160 #if defined(PY_LOCAL_AGGRESSIVE)
161 /* enable more aggressive optimization for visual studio */
162 #pragma optimize("agtw", on)
164 /* ignore warnings if the compiler decides not to inline a function */
165 #pragma warning(disable: 4710)
166 /* fastest possible local call under MSVC */
167 #define Py_LOCAL(type) static type __fastcall
168 #define Py_LOCAL_INLINE(type) static __inline type __fastcall
169 #elif defined(USE_INLINE)
170 #define Py_LOCAL(type) static type
171 #define Py_LOCAL_INLINE(type) static inline type
173 #define Py_LOCAL(type) static type
174 #define Py_LOCAL_INLINE(type) static type
177 /* Py_MEMCPY can be used instead of memcpy in cases where the copied blocks
178 * are often very short. While most platforms have highly optimized code for
179 * large transfers, the setup costs for memcpy are often quite high. MEMCPY
180 * solves this by doing short copies "in line".
183 #if defined(_MSC_VER)
184 #define Py_MEMCPY(target, source, length) do { \
185 size_t i_, n_ = (length); \
186 char *t_ = (void*) (target); \
187 const char *s_ = (void*) (source); \
189 memcpy(t_, s_, n_); \
191 for (i_ = 0; i_ < n_; i_++) \
195 #define Py_MEMCPY memcpy
200 #include <math.h> /* Moved here from the math section, before extern "C" */
202 /********************************************
203 * WRAPPER FOR <time.h> and/or <sys/time.h> *
204 ********************************************/
206 #ifdef TIME_WITH_SYS_TIME
207 #include <sys/time.h>
209 #else /* !TIME_WITH_SYS_TIME */
210 #ifdef HAVE_SYS_TIME_H
211 #include <sys/time.h>
212 #else /* !HAVE_SYS_TIME_H */
214 #endif /* !HAVE_SYS_TIME_H */
215 #endif /* !TIME_WITH_SYS_TIME */
218 /******************************
219 * WRAPPER FOR <sys/select.h> *
220 ******************************/
222 /* NB caller must include <sys/types.h> */
224 #ifdef HAVE_SYS_SELECT_H
226 #include <sys/select.h>
228 #endif /* !HAVE_SYS_SELECT_H */
230 /*******************************
231 * stat() and fstat() fiddling *
232 *******************************/
234 /* We expect that stat and fstat exist on most systems.
235 * It's confirmed on Unix, Mac and Windows.
236 * If you don't have them, add
237 * #define DONT_HAVE_STAT
239 * #define DONT_HAVE_FSTAT
240 * to your pyconfig.h. Python code beyond this should check HAVE_STAT and
241 * HAVE_FSTAT instead.
243 * #define DONT_HAVE_SYS_STAT_H
244 * if <sys/stat.h> doesn't exist on your platform, and
245 * #define HAVE_STAT_H
246 * if <stat.h> does (don't look at me -- ths mess is inherited).
248 #ifndef DONT_HAVE_STAT
252 #ifndef DONT_HAVE_FSTAT
257 #include <sys/types.h>
258 #include "unixstuff.h"
261 #ifndef DONT_HAVE_SYS_STAT_H
262 #if defined(PYOS_OS2) && defined(PYCC_GCC)
263 #include <sys/types.h>
265 #include <sys/stat.h>
266 #elif defined(HAVE_STAT_H)
270 #if defined(PYCC_VACPP)
271 /* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
272 #define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG)
276 #define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
280 #define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
285 /* Move this down here since some C++ #include's don't like to be included
286 inside an extern "C" */
291 /* Py_ARITHMETIC_RIGHT_SHIFT
292 * C doesn't define whether a right-shift of a signed integer sign-extends
293 * or zero-fills. Here a macro to force sign extension:
294 * Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J)
295 * Return I >> J, forcing sign extension.
297 * I is of basic signed type TYPE (char, short, int, long, or long long).
298 * TYPE is one of char, short, int, long, or long long, although long long
299 * must not be used except on platforms that support it.
300 * J is an integer >= 0 and strictly less than the number of bits in TYPE
301 * (because C doesn't define what happens for J outside that range either).
303 * I may be evaluated more than once.
305 #ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS
306 #define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \
307 ((I) < 0 ? ~((~(unsigned TYPE)(I)) >> (J)) : (I) >> (J))
309 #define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J))
312 /* Py_FORCE_EXPANSION(X)
313 * "Simply" returns its argument. However, macro expansions within the
314 * argument are evaluated. This unfortunate trickery is needed to get
315 * token-pasting to work as desired in some cases.
317 #define Py_FORCE_EXPANSION(X) X
319 /* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW)
320 * Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this
321 * assert-fails if any information is lost.
323 * VALUE may be evaluated more than once.
326 #define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \
327 (assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE))
329 #define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE)
333 * Return 1 if float or double arg is a NaN, else 0.
335 * X is evaluated more than once.
336 * This may not work on all platforms. Each platform has *some*
337 * way to spell this, though -- override in pyconfig.h if you have
338 * a platform where it doesn't work.
341 #define Py_IS_NAN(X) ((X) != (X))
345 * Return 1 if float or double arg is an infinity, else 0.
347 * X is evaluated more than once.
348 * This implementation may set the underflow flag if |X| is very small;
349 * it really can't be implemented correctly (& easily) before C99.
350 * Override in pyconfig.h if you have a better spelling on your platform.
352 #ifndef Py_IS_INFINITY
353 #define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X))
357 * Return 1 if float or double arg is neither infinite nor NAN, else 0.
358 * Some compilers (e.g. VisualStudio) have intrisics for this, so a special
359 * macro for this particular test is useful
362 #define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X))
365 /* HUGE_VAL is supposed to expand to a positive double infinity. Python
366 * uses Py_HUGE_VAL instead because some platforms are broken in this
367 * respect. We used to embed code in pyport.h to try to worm around that,
368 * but different platforms are broken in conflicting ways. If you're on
369 * a platform where HUGE_VAL is defined incorrectly, fiddle your Python
370 * config to #define Py_HUGE_VAL to something that works on your platform.
373 #define Py_HUGE_VAL HUGE_VAL
377 * Return 1 iff a libm function overflowed. Set errno to 0 before calling
378 * a libm function, and invoke this macro after, passing the function
381 * This isn't reliable. C99 no longer requires libm to set errno under
382 * any exceptional condition, but does require +- HUGE_VAL return
383 * values on overflow. A 754 box *probably* maps HUGE_VAL to a
384 * double infinity, and we're cool if that's so, unless the input
385 * was an infinity and an infinity is the expected result. A C89
386 * system sets errno to ERANGE, so we check for that too. We're
387 * out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or
388 * if the returned result is a NaN, or if a C89 box returns HUGE_VAL
389 * in non-overflow cases.
390 * X is evaluated more than once.
391 * Some platforms have better way to spell this, so expect some #ifdef'ery.
393 * OpenBSD uses 'isinf()' because a compiler bug on that platform causes
394 * the longer macro version to be mis-compiled. This isn't optimal, and
395 * should be removed once a newer compiler is available on that platform.
396 * The system that had the failure was running OpenBSD 3.2 on Intel, with
399 * According to Tim's checkin, the FreeBSD systems use isinf() to work
400 * around a FPE bug on that platform.
402 #if defined(__FreeBSD__) || defined(__OpenBSD__)
403 #define Py_OVERFLOWED(X) isinf(X)
405 #define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE || \
406 (X) == Py_HUGE_VAL || \
407 (X) == -Py_HUGE_VAL))
410 /* Py_SET_ERRNO_ON_MATH_ERROR(x)
411 * If a libm function did not set errno, but it looks like the result
412 * overflowed or not-a-number, set errno to ERANGE or EDOM. Set errno
413 * to 0 before calling a libm function, and invoke this macro after,
414 * passing the function result.
416 * This isn't reliable. See Py_OVERFLOWED comments.
417 * X is evaluated more than once.
419 #if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__hpux) && defined(__ia64))
420 #define _Py_SET_EDOM_FOR_NAN(X) if (isnan(X)) errno = EDOM;
422 #define _Py_SET_EDOM_FOR_NAN(X) ;
424 #define Py_SET_ERRNO_ON_MATH_ERROR(X) \
427 if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \
429 else _Py_SET_EDOM_FOR_NAN(X) \
433 /* Py_SET_ERANGE_ON_OVERFLOW(x)
434 * An alias of Py_SET_ERRNO_ON_MATH_ERROR for backward-compatibility.
436 #define Py_SET_ERANGE_IF_OVERFLOW(X) Py_SET_ERRNO_ON_MATH_ERROR(X)
438 /* Py_ADJUST_ERANGE1(x)
439 * Py_ADJUST_ERANGE2(x, y)
440 * Set errno to 0 before calling a libm function, and invoke one of these
441 * macros after, passing the function result(s) (Py_ADJUST_ERANGE2 is useful
442 * for functions returning complex results). This makes two kinds of
443 * adjustments to errno: (A) If it looks like the platform libm set
444 * errno=ERANGE due to underflow, clear errno. (B) If it looks like the
445 * platform libm overflowed but didn't set errno, force errno to ERANGE. In
446 * effect, we're trying to force a useful implementation of C89 errno
449 * This isn't reliable. See Py_OVERFLOWED comments.
450 * X and Y may be evaluated more than once.
452 #define Py_ADJUST_ERANGE1(X) \
455 if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \
458 else if (errno == ERANGE && (X) == 0.0) \
462 #define Py_ADJUST_ERANGE2(X, Y) \
464 if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \
465 (Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \
469 else if (errno == ERANGE) \
473 /* Py_DEPRECATED(version)
474 * Declare a variable, type, or function deprecated.
476 * extern int old_var Py_DEPRECATED(2.3);
477 * typedef int T1 Py_DEPRECATED(2.4);
478 * extern int x() Py_DEPRECATED(2.5);
480 #if defined(__GNUC__) && ((__GNUC__ >= 4) || \
481 (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
482 #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
484 #define Py_DEPRECATED(VERSION_UNUSED)
487 /**************************************************************************
488 Prototypes that are missing from the standard include files on some systems
489 (and possibly only some versions of such systems.)
491 Please be conservative with adding new ones, document them and enclose them
492 in platform-specific #ifdefs.
493 **************************************************************************/
497 extern int gethostname(char *, int);
502 /* It's in the libs, but not the headers... - [cjh] */
503 int shutdown( int, int );
507 #include <sys/types.h> /* we need to import mode_t */
508 extern char * _getpty(int *, int, mode_t
, int);
511 #if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY)
512 #if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H)
513 /* BSDI does not supply a prototype for the 'openpty' and 'forkpty'
514 functions, even though they are included in libutil. */
516 extern int openpty(int *, int *, char *, struct termios
*, struct winsize
*);
517 extern int forkpty(int *, char *, struct termios
*, struct winsize
*);
518 #endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */
519 #endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
522 /* These are pulled from various places. It isn't obvious on what platforms
523 they are necessary, nor what the exact prototype should look like (which
524 is likely to vary between platforms!) If you find you need one of these
525 declarations, please move them to a platform-specific block and include
526 proper prototypes. */
529 /* From Modules/resource.c */
530 extern int getrusage();
531 extern int getpagesize();
533 /* From Python/sysmodule.c and Modules/posixmodule.c */
534 extern int fclose(FILE *);
536 /* From Modules/posixmodule.c */
537 extern int fdatasync(int);
541 /************************
542 * WRAPPER FOR <math.h> *
543 ************************/
546 extern double hypot(double, double);
550 /* On 4.4BSD-descendants, ctype functions serves the whole range of
551 * wchar_t character set rather than single byte code points only.
552 * This characteristic can break some operations of string object
553 * including str.upper() and str.split() on UTF-8 locales. This
554 * workaround was provided by Tim Robbins of FreeBSD project.
558 #include <osreldate.h>
559 #if __FreeBSD_version > 500039
563 #define isalnum(c) iswalnum(btowc(c))
565 #define isalpha(c) iswalpha(btowc(c))
567 #define islower(c) iswlower(btowc(c))
569 #define isspace(c) iswspace(btowc(c))
571 #define isupper(c) iswupper(btowc(c))
573 #define tolower(c) towlower(btowc(c))
575 #define toupper(c) towupper(btowc(c))
580 /* Declarations for symbol visibility.
582 PyAPI_FUNC(type): Declares a public Python API function and return type
583 PyAPI_DATA(type): Declares public Python data and its type
584 PyMODINIT_FUNC: A Python module init function. If these functions are
585 inside the Python core, they are private to the core.
586 If in an extension module, it may be declared with
587 external linkage depending on the platform.
589 As a number of platforms support/require "__declspec(dllimport/dllexport)",
590 we support a HAVE_DECLSPEC_DLL macro to save duplication.
594 All windows ports, except cygwin, are handled in PC/pyconfig.h.
596 BeOS and cygwin are the only other autoconf platform requiring special
597 linkage handling and both of these use __declspec().
599 #if defined(__CYGWIN__) || defined(__BEOS__)
600 # define HAVE_DECLSPEC_DLL
603 /* only get special linkage if built as shared or platform is Cygwin */
604 #if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
605 # if defined(HAVE_DECLSPEC_DLL)
606 # ifdef Py_BUILD_CORE
607 # define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
608 # define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE
609 /* module init functions inside the core need no external linkage */
610 /* except for Cygwin to handle embedding (FIXME: BeOS too?) */
611 # if defined(__CYGWIN__)
612 # define PyMODINIT_FUNC __declspec(dllexport) void
613 # else /* __CYGWIN__ */
614 # define PyMODINIT_FUNC void
615 # endif /* __CYGWIN__ */
616 # else /* Py_BUILD_CORE */
617 /* Building an extension module, or an embedded situation */
618 /* public Python functions and data are imported */
619 /* Under Cygwin, auto-import functions to prevent compilation */
620 /* failures similar to http://python.org/doc/FAQ.html#3.24 */
621 # if !defined(__CYGWIN__)
622 # define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
623 # endif /* !__CYGWIN__ */
624 # define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
625 /* module init functions outside the core must be exported */
626 # if defined(__cplusplus)
627 # define PyMODINIT_FUNC extern "C" __declspec(dllexport) void
628 # else /* __cplusplus */
629 # define PyMODINIT_FUNC __declspec(dllexport) void
630 # endif /* __cplusplus */
631 # endif /* Py_BUILD_CORE */
632 # endif /* HAVE_DECLSPEC */
633 #endif /* Py_ENABLE_SHARED */
635 /* If no external linkage macros defined by now, create defaults */
637 # define PyAPI_FUNC(RTYPE) RTYPE
640 # define PyAPI_DATA(RTYPE) extern RTYPE
642 #ifndef PyMODINIT_FUNC
643 # if defined(__cplusplus)
644 # define PyMODINIT_FUNC extern "C" void
645 # else /* __cplusplus */
646 # define PyMODINIT_FUNC void
647 # endif /* __cplusplus */
650 /* Deprecated DL_IMPORT and DL_EXPORT macros */
651 #if defined(Py_ENABLE_SHARED) && defined (HAVE_DECLSPEC_DLL)
652 # if defined(Py_BUILD_CORE)
653 # define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
654 # define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
656 # define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
657 # define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
661 # define DL_EXPORT(RTYPE) RTYPE
664 # define DL_IMPORT(RTYPE) RTYPE
666 /* End of deprecated DL_* macros */
668 /* If the fd manipulation macros aren't defined,
669 here is a set that should do the job */
671 #if 0 /* disabled and probably obsolete */
674 #define FD_SETSIZE 256
679 typedef long fd_mask
;
681 #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
683 #define howmany(x, y) (((x)+((y)-1))/(y))
686 typedef struct fd_set
{
687 fd_mask fds_bits
[howmany(FD_SETSIZE
, NFDBITS
)];
690 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
691 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
692 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
693 #define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p)))
697 #endif /* fd manipulation macros */
700 /* limits.h constants that may be missing */
703 #define INT_MAX 2147483647
708 #define LONG_MAX 0X7FFFFFFFL
709 #elif SIZEOF_LONG == 8
710 #define LONG_MAX 0X7FFFFFFFFFFFFFFFL
712 #error "could not set LONG_MAX in pyport.h"
717 #define LONG_MIN (-LONG_MAX-1)
721 #define LONG_BIT (8 * SIZEOF_LONG)
724 #if LONG_BIT != 8 * SIZEOF_LONG
725 /* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent
726 * 32-bit platforms using gcc. We try to catch that here at compile-time
727 * rather than waiting for integer multiplication to trigger bogus
730 #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
738 * Hide GCC attributes from compilers that don't support them.
740 #if (!defined(__GNUC__) || __GNUC__ < 2 || \
741 (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) && \
743 #define Py_GCC_ATTRIBUTE(x)
745 #define Py_GCC_ATTRIBUTE(x) __attribute__(x)
748 /* Eliminate end-of-loop code not reached warnings from SunPro C
749 * when using do{...}while(0) macros
752 #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED)
756 * Older Microsoft compilers don't support the C99 long long literal suffixes,
757 * so these will be defined in PC/pyconfig.h for those compilers.
760 #define Py_LL(x) x##LL
764 #define Py_ULL(x) Py_LL(x##U)
767 #endif /* Py_PYPORT_H */