annotate Include/pyport.h @ 54294:dba767bc3155 legacy-trunk

remove mention of old ctypes version
author Benjamin Peterson <benjamin@python.org>
date Sat, 23 May 2009 20:59:09 +0000
parents 6c0c15a2ed2d
children c065f33d9c9c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
1 #ifndef Py_PYPORT_H
13489
f50bdcb0dd0e Remove the "1" that Tim sticked to the preprocessor symbol for unknown reasons
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13423
diff changeset
2 #define Py_PYPORT_H
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
3
18835
2dea40e40d9d Patch #411138: Rename config.h to pyconfig.h. Closes bug #231774.
Martin v. Löwis <martin@v.loewis.de>
parents: 17831
diff changeset
4 #include "pyconfig.h" /* include for defines */
13776
33df3b516711 patch from Vladimir (move Py_Mem* interface to Include/pymem.h)
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13761
diff changeset
5
39950
1697d0d4ef33 Guard uintptr_t test with HAVE_STDINT_H, test for
Martin v. Löwis <martin@v.loewis.de>
parents: 39873
diff changeset
6 #ifdef HAVE_STDINT_H
1697d0d4ef33 Guard uintptr_t test with HAVE_STDINT_H, test for
Martin v. Löwis <martin@v.loewis.de>
parents: 39873
diff changeset
7 #include <stdint.h>
1697d0d4ef33 Guard uintptr_t test with HAVE_STDINT_H, test for
Martin v. Löwis <martin@v.loewis.de>
parents: 39873
diff changeset
8 #endif
1697d0d4ef33 Guard uintptr_t test with HAVE_STDINT_H, test for
Martin v. Löwis <martin@v.loewis.de>
parents: 39873
diff changeset
9
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
10 /**************************************************************************
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
11 Symbols and macros to supply platform-independent interfaces to basic
13671
26685bd2c09e Recent ANSIfication introduced a couple instances of
Tim Peters <tim.peters@gmail.com>
parents: 13489
diff changeset
12 C language & library operations whose spellings vary across platforms.
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
13
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
14 Please try to make documentation here as clear as possible: by definition,
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
15 the stuff here is trying to illuminate C's darkest corners.
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
16
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
17 Config #defines referenced here:
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
18
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
19 SIGNED_RIGHT_SHIFT_ZERO_FILLS
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
20 Meaning: To be defined iff i>>j does not extend the sign bit when i is a
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
21 signed integral type and i < 0.
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
22 Used in: Py_ARITHMETIC_RIGHT_SHIFT
13671
26685bd2c09e Recent ANSIfication introduced a couple instances of
Tim Peters <tim.peters@gmail.com>
parents: 13489
diff changeset
23
13674
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
24 Py_DEBUG
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
25 Meaning: Extra checks compiled in for debug mode.
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
26 Used in: Py_SAFE_DOWNCAST
14045
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
27
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
28 HAVE_UINTPTR_T
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
29 Meaning: The C9X type uintptr_t is supported by the compiler
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
30 Used in: Py_uintptr_t
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
31
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
32 HAVE_LONG_LONG
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
33 Meaning: The compiler supports the C type "long long"
28437
871da703e4c0 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.
Martin v. Löwis <martin@v.loewis.de>
parents: 27802
diff changeset
34 Used in: PY_LONG_LONG
14045
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
35
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
36 **************************************************************************/
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
37
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
38
14468
0ef6ea58590b Add missing Py_PROTO macro for backward compatibility with old extensions
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 14375
diff changeset
39 /* For backward compatibility only. Obsolete, do not use. */
0ef6ea58590b Add missing Py_PROTO macro for backward compatibility with old extensions
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 14375
diff changeset
40 #ifdef HAVE_PROTOTYPES
0ef6ea58590b Add missing Py_PROTO macro for backward compatibility with old extensions
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 14375
diff changeset
41 #define Py_PROTO(x) x
0ef6ea58590b Add missing Py_PROTO macro for backward compatibility with old extensions
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 14375
diff changeset
42 #else
0ef6ea58590b Add missing Py_PROTO macro for backward compatibility with old extensions
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 14375
diff changeset
43 #define Py_PROTO(x) ()
0ef6ea58590b Add missing Py_PROTO macro for backward compatibility with old extensions
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 14375
diff changeset
44 #endif
15032
ce5dff30a935 Added Py_FPROTO macro which was available in Python 1.5.x and below.
Marc-André Lemburg <mal@egenix.com>
parents: 15016
diff changeset
45 #ifndef Py_FPROTO
ce5dff30a935 Added Py_FPROTO macro which was available in Python 1.5.x and below.
Marc-André Lemburg <mal@egenix.com>
parents: 15016
diff changeset
46 #define Py_FPROTO(x) Py_PROTO(x)
ce5dff30a935 Added Py_FPROTO macro which was available in Python 1.5.x and below.
Marc-André Lemburg <mal@egenix.com>
parents: 15016
diff changeset
47 #endif
13761
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
48
14045
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
49 /* typedefs for some C9X-defined synonyms for integral types.
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
50 *
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
51 * The names in Python are exactly the same as the C9X names, except with a
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
52 * Py_ prefix. Until C9X is universally implemented, this is the only way
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
53 * to ensure that Python gets reliable names that don't conflict with names
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
54 * in non-Python code that are playing their own tricks to define the C9X
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
55 * names.
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
56 *
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
57 * NOTE: don't go nuts here! Python has no use for *most* of the C9X
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
58 * integral synonyms. Only define the ones we actually need.
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
59 */
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
60
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
61 #ifdef HAVE_LONG_LONG
28437
871da703e4c0 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.
Martin v. Löwis <martin@v.loewis.de>
parents: 27802
diff changeset
62 #ifndef PY_LONG_LONG
871da703e4c0 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.
Martin v. Löwis <martin@v.loewis.de>
parents: 27802
diff changeset
63 #define PY_LONG_LONG long long
42010
e2c39a30e08d Provide LLONG_MAX for S390.
Martin v. Löwis <martin@v.loewis.de>
parents: 42007
diff changeset
64 #if defined(LLONG_MAX)
42076
de880381654a Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents: 42010
diff changeset
65 /* If LLONG_MAX is defined in limits.h, use that. */
42007
e8413971212d Patch #1733960: Allow T_LONGLONG to accept ints.
Martin v. Löwis <martin@v.loewis.de>
parents: 40151
diff changeset
66 #define PY_LLONG_MIN LLONG_MIN
e8413971212d Patch #1733960: Allow T_LONGLONG to accept ints.
Martin v. Löwis <martin@v.loewis.de>
parents: 40151
diff changeset
67 #define PY_LLONG_MAX LLONG_MAX
e8413971212d Patch #1733960: Allow T_LONGLONG to accept ints.
Martin v. Löwis <martin@v.loewis.de>
parents: 40151
diff changeset
68 #define PY_ULLONG_MAX ULLONG_MAX
42076
de880381654a Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents: 42010
diff changeset
69 #elif defined(__LONG_LONG_MAX__)
de880381654a Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents: 42010
diff changeset
70 /* Otherwise, if GCC has a builtin define, use that. */
de880381654a Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents: 42010
diff changeset
71 #define PY_LLONG_MAX __LONG_LONG_MAX__
42010
e2c39a30e08d Provide LLONG_MAX for S390.
Martin v. Löwis <martin@v.loewis.de>
parents: 42007
diff changeset
72 #define PY_LLONG_MIN (-PY_LLONG_MAX-1)
42076
de880381654a Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents: 42010
diff changeset
73 #define PY_ULLONG_MAX (__LONG_LONG_MAX__*2ULL + 1ULL)
de880381654a Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents: 42010
diff changeset
74 #else
de880381654a Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents: 42010
diff changeset
75 /* Otherwise, rely on two's complement. */
de880381654a Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents: 42010
diff changeset
76 #define PY_ULLONG_MAX (~0ULL)
de880381654a Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents: 42010
diff changeset
77 #define PY_LLONG_MAX ((long long)(PY_ULLONG_MAX>>1))
de880381654a Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents: 42010
diff changeset
78 #define PY_LLONG_MIN (-PY_LLONG_MAX-1)
42010
e2c39a30e08d Provide LLONG_MAX for S390.
Martin v. Löwis <martin@v.loewis.de>
parents: 42007
diff changeset
79 #endif /* LLONG_MAX */
14045
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
80 #endif
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
81 #endif /* HAVE_LONG_LONG */
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
82
52233
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
83 /* a build with 30-bit digits for Python long integers needs an exact-width
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
84 * 32-bit unsigned integer type to store those digits. (We could just use
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
85 * type 'unsigned long', but that would be wasteful on a system where longs
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
86 * are 64-bits.) On Unix systems, the autoconf macro AC_TYPE_UINT32_T defines
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
87 * uint32_t to be such a type unless stdint.h or inttypes.h defines uint32_t.
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
88 * However, it doesn't set HAVE_UINT32_T, so we do that here.
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
89 */
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
90 #if (defined UINT32_MAX || defined uint32_t)
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
91 #ifndef PY_UINT32_T
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
92 #define HAVE_UINT32_T 1
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
93 #define PY_UINT32_T uint32_t
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
94 #endif
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
95 #endif
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
96
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
97 /* Macros for a 64-bit unsigned integer type; used for type 'twodigits' in the
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
98 * long integer implementation, when 30-bit digits are enabled.
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
99 */
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
100 #if (defined UINT64_MAX || defined uint64_t)
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
101 #ifndef PY_UINT64_T
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
102 #define HAVE_UINT64_T 1
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
103 #define PY_UINT64_T uint64_t
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
104 #endif
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
105 #endif
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
106
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
107 /* Signed variants of the above */
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
108 #if (defined INT32_MAX || defined int32_t)
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
109 #ifndef PY_INT32_T
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
110 #define HAVE_INT32_T 1
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
111 #define PY_INT32_T int32_t
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
112 #endif
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
113 #endif
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
114 #if (defined INT64_MAX || defined int64_t)
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
115 #ifndef PY_INT64_T
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
116 #define HAVE_INT64_T 1
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
117 #define PY_INT64_T int64_t
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
118 #endif
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
119 #endif
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
120
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
121 /* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
122 the necessary integer types are available, and we're on a 64-bit platform
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
123 (as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits. */
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
124
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
125 #ifndef PYLONG_BITS_IN_DIGIT
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
126 #if (defined HAVE_UINT64_T && defined HAVE_INT64_T && \
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
127 defined HAVE_UINT32_T && defined HAVE_INT32_T && SIZEOF_VOID_P >= 8)
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
128 #define PYLONG_BITS_IN_DIGIT 30
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
129 #else
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
130 #define PYLONG_BITS_IN_DIGIT 15
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
131 #endif
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
132 #endif
9b358eae532a Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents: 50786
diff changeset
133
14045
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
134 /* uintptr_t is the C9X name for an unsigned integral type such that a
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
135 * legitimate void* can be cast to uintptr_t and then back to void* again
19568
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
136 * without loss of information. Similarly for intptr_t, wrt a signed
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
137 * integral type.
14045
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
138 */
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
139 #ifdef HAVE_UINTPTR_T
19568
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
140 typedef uintptr_t Py_uintptr_t;
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
141 typedef intptr_t Py_intptr_t;
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
142
14045
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
143 #elif SIZEOF_VOID_P <= SIZEOF_INT
19568
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
144 typedef unsigned int Py_uintptr_t;
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
145 typedef int Py_intptr_t;
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
146
14045
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
147 #elif SIZEOF_VOID_P <= SIZEOF_LONG
19568
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
148 typedef unsigned long Py_uintptr_t;
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
149 typedef long Py_intptr_t;
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
150
14045
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
151 #elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG)
28437
871da703e4c0 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.
Martin v. Löwis <martin@v.loewis.de>
parents: 27802
diff changeset
152 typedef unsigned PY_LONG_LONG Py_uintptr_t;
871da703e4c0 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.
Martin v. Löwis <martin@v.loewis.de>
parents: 27802
diff changeset
153 typedef PY_LONG_LONG Py_intptr_t;
19568
b0f5278a2ab4 SF bug [#456252] Python should never stomp on [u]intptr_t.
Tim Peters <tim.peters@gmail.com>
parents: 19073
diff changeset
154
14045
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
155 #else
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
156 # error "Python needs a typedef for Py_uintptr_t in pyport.h."
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
157 #endif /* HAVE_UINTPTR_T */
c4444f68ebf9 Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents: 13976
diff changeset
158
37037
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
159 /* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) ==
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
160 * sizeof(size_t). C99 doesn't define such a thing directly (size_t is an
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
161 * unsigned integral type). See PEP 353 for details.
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
162 */
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35746
diff changeset
163 #ifdef HAVE_SSIZE_T
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35746
diff changeset
164 typedef ssize_t Py_ssize_t;
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35746
diff changeset
165 #elif SIZEOF_VOID_P == SIZEOF_SIZE_T
36566
0ef7cf5222b0 Fix intptr_t fallback for Py_ssize_t.
Martin v. Löwis <martin@v.loewis.de>
parents: 36501
diff changeset
166 typedef Py_intptr_t Py_ssize_t;
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35746
diff changeset
167 #else
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35746
diff changeset
168 # error "Python needs a typedef for Py_ssize_t in pyport.h."
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35746
diff changeset
169 #endif
37037
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
170
47587
1c964ed35ef9 Merge in release25-maint r60793:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
171 /* Largest possible value of size_t.
1c964ed35ef9 Merge in release25-maint r60793:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
172 SIZE_MAX is part of C99, so it might be defined on some
1c964ed35ef9 Merge in release25-maint r60793:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
173 platforms. If it is not defined, (size_t)-1 is a portable
1c964ed35ef9 Merge in release25-maint r60793:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
174 definition for C89, due to the way signed->unsigned
1c964ed35ef9 Merge in release25-maint r60793:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
175 conversion is defined. */
1c964ed35ef9 Merge in release25-maint r60793:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
176 #ifdef SIZE_MAX
1c964ed35ef9 Merge in release25-maint r60793:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
177 #define PY_SIZE_MAX SIZE_MAX
1c964ed35ef9 Merge in release25-maint r60793:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
178 #else
1c964ed35ef9 Merge in release25-maint r60793:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
179 #define PY_SIZE_MAX ((size_t)-1)
1c964ed35ef9 Merge in release25-maint r60793:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
180 #endif
1c964ed35ef9 Merge in release25-maint r60793:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47527
diff changeset
181
37037
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
182 /* Largest positive value of type Py_ssize_t. */
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35746
diff changeset
183 #define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
37496
4898f196a24d Fixed error in comment for new PY_SSIZE_T_MIN.
Tim Peters <tim.peters@gmail.com>
parents: 37494
diff changeset
184 /* Smallest negative value of type Py_ssize_t. */
37494
976c01091b38 Add PY_SSIZE_T_MIN, as suggested by Ralf W. Grosse-Kunstleve.
Martin v. Löwis <martin@v.loewis.de>
parents: 37363
diff changeset
185 #define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35746
diff changeset
186
45077
f0e6bb9b24f6 Fixed bug #1983: Return from fork() is pid_t, not int
Christian Heimes <christian@cheimes.de>
parents: 44874
diff changeset
187 #if SIZEOF_PID_T > SIZEOF_LONG
f0e6bb9b24f6 Fixed bug #1983: Return from fork() is pid_t, not int
Christian Heimes <christian@cheimes.de>
parents: 44874
diff changeset
188 # error "Python doesn't support sizeof(pid_t) > sizeof(long)"
f0e6bb9b24f6 Fixed bug #1983: Return from fork() is pid_t, not int
Christian Heimes <christian@cheimes.de>
parents: 44874
diff changeset
189 #endif
f0e6bb9b24f6 Fixed bug #1983: Return from fork() is pid_t, not int
Christian Heimes <christian@cheimes.de>
parents: 44874
diff changeset
190
37037
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
191 /* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
192 * format to convert an argument with the width of a size_t or Py_ssize_t.
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
193 * C99 introduced "z" for this purpose, but not all platforms support that;
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
194 * e.g., MS compilers use "I" instead.
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
195 *
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
196 * These "high level" Python format functions interpret "z" correctly on
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
197 * all platforms (Python interprets the format string itself, and does whatever
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
198 * the platform C requires to convert a size_t/Py_ssize_t argument):
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
199 *
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
200 * PyString_FromFormat
37037
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
201 * PyErr_Format
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
202 * PyString_FromFormatV
37037
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
203 *
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
204 * Lower-level uses require that you interpolate the correct format modifier
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
205 * yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
206 * example,
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
207 *
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
208 * Py_ssize_t index;
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
209 * fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index);
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
210 *
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
211 * That will expand to %ld, or %Id, or to something else correct for a
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
212 * Py_ssize_t on the platform.
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
213 */
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
214 #ifndef PY_FORMAT_SIZE_T
39873
94a8cd5888e7 Mostly revert this file to the same version as before. Only force setting
Neal Norwitz <nnorwitz@gmail.com>
parents: 39871
diff changeset
215 # if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__)
94a8cd5888e7 Mostly revert this file to the same version as before. Only force setting
Neal Norwitz <nnorwitz@gmail.com>
parents: 39871
diff changeset
216 # define PY_FORMAT_SIZE_T ""
94a8cd5888e7 Mostly revert this file to the same version as before. Only force setting
Neal Norwitz <nnorwitz@gmail.com>
parents: 39871
diff changeset
217 # elif SIZEOF_SIZE_T == SIZEOF_LONG
39871
24f9a13084b0 Fix %zd string formatting on Mac OS X so it prints negative numbers.
Neal Norwitz <nnorwitz@gmail.com>
parents: 38716
diff changeset
218 # define PY_FORMAT_SIZE_T "l"
37037
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
219 # elif defined(MS_WINDOWS)
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
220 # define PY_FORMAT_SIZE_T "I"
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
221 # else
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
222 # error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T"
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
223 # endif
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
224 #endif
bfb74a420ac8 Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents: 36566
diff changeset
225
38425
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
226 /* Py_LOCAL can be used instead of static to get the fastest possible calling
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
227 * convention for functions that are local to a given module.
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
228 *
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
229 * Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining,
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
230 * for platforms that support that.
38347
6d8615f9f1cc use Py_LOCAL also for string and unicode objects
Fredrik Lundh <fredrik@pythonware.com>
parents: 38345
diff changeset
231 *
38425
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
232 * If PY_LOCAL_AGGRESSIVE is defined before python.h is included, more
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
233 * "aggressive" inlining/optimizaion is enabled for the entire module. This
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
234 * may lead to code bloat, and may slow things down for those reasons. It may
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
235 * also lead to errors, if the code relies on pointer aliasing. Use with
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
236 * care.
38350
3bef24086ace needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
Fredrik Lundh <fredrik@pythonware.com>
parents: 38347
diff changeset
237 *
38347
6d8615f9f1cc use Py_LOCAL also for string and unicode objects
Fredrik Lundh <fredrik@pythonware.com>
parents: 38345
diff changeset
238 * NOTE: You can only use this for functions that are entirely local to a
6d8615f9f1cc use Py_LOCAL also for string and unicode objects
Fredrik Lundh <fredrik@pythonware.com>
parents: 38345
diff changeset
239 * module; functions that are exported via method tables, callbacks, etc,
6d8615f9f1cc use Py_LOCAL also for string and unicode objects
Fredrik Lundh <fredrik@pythonware.com>
parents: 38345
diff changeset
240 * should keep using static.
6d8615f9f1cc use Py_LOCAL also for string and unicode objects
Fredrik Lundh <fredrik@pythonware.com>
parents: 38345
diff changeset
241 */
38345
fe653e22488c needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents: 38298
diff changeset
242
fe653e22488c needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents: 38298
diff changeset
243 #undef USE_INLINE /* XXX - set via configure? */
fe653e22488c needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents: 38298
diff changeset
244
fe653e22488c needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents: 38298
diff changeset
245 #if defined(_MSC_VER)
38350
3bef24086ace needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
Fredrik Lundh <fredrik@pythonware.com>
parents: 38347
diff changeset
246 #if defined(PY_LOCAL_AGGRESSIVE)
3bef24086ace needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
Fredrik Lundh <fredrik@pythonware.com>
parents: 38347
diff changeset
247 /* enable more aggressive optimization for visual studio */
3bef24086ace needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
Fredrik Lundh <fredrik@pythonware.com>
parents: 38347
diff changeset
248 #pragma optimize("agtw", on)
3bef24086ace needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
Fredrik Lundh <fredrik@pythonware.com>
parents: 38347
diff changeset
249 #endif
38347
6d8615f9f1cc use Py_LOCAL also for string and unicode objects
Fredrik Lundh <fredrik@pythonware.com>
parents: 38345
diff changeset
250 /* ignore warnings if the compiler decides not to inline a function */
38345
fe653e22488c needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents: 38298
diff changeset
251 #pragma warning(disable: 4710)
fe653e22488c needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents: 38298
diff changeset
252 /* fastest possible local call under MSVC */
38425
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
253 #define Py_LOCAL(type) static type __fastcall
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
254 #define Py_LOCAL_INLINE(type) static __inline type __fastcall
38345
fe653e22488c needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents: 38298
diff changeset
255 #elif defined(USE_INLINE)
38425
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
256 #define Py_LOCAL(type) static type
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
257 #define Py_LOCAL_INLINE(type) static inline type
38345
fe653e22488c needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents: 38298
diff changeset
258 #else
fe653e22488c needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents: 38298
diff changeset
259 #define Py_LOCAL(type) static type
38425
ca657e0bd09c needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents: 38350
diff changeset
260 #define Py_LOCAL_INLINE(type) static type
38345
fe653e22488c needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents: 38298
diff changeset
261 #endif
fe653e22488c needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents: 38298
diff changeset
262
38457
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
263 /* Py_MEMCPY can be used instead of memcpy in cases where the copied blocks
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
264 * are often very short. While most platforms have highly optimized code for
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
265 * large transfers, the setup costs for memcpy are often quite high. MEMCPY
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
266 * solves this by doing short copies "in line".
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
267 */
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
268
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
269 #if defined(_MSC_VER)
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
270 #define Py_MEMCPY(target, source, length) do { \
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
271 size_t i_, n_ = (length); \
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
272 char *t_ = (void*) (target); \
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
273 const char *s_ = (void*) (source); \
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
274 if (n_ >= 16) \
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
275 memcpy(t_, s_, n_); \
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
276 else \
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
277 for (i_ = 0; i_ < n_; i_++) \
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
278 t_[i_] = s_[i_]; \
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
279 } while (0)
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
280 #else
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
281 #define Py_MEMCPY memcpy
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
282 #endif
551814e4b471 needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents: 38425
diff changeset
283
13761
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
284 #include <stdlib.h>
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
285
13918
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
286 #include <math.h> /* Moved here from the math section, before extern "C" */
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
287
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
288 /********************************************
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
289 * WRAPPER FOR <time.h> and/or <sys/time.h> *
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
290 ********************************************/
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
291
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
292 #ifdef TIME_WITH_SYS_TIME
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
293 #include <sys/time.h>
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
294 #include <time.h>
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
295 #else /* !TIME_WITH_SYS_TIME */
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
296 #ifdef HAVE_SYS_TIME_H
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
297 #include <sys/time.h>
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
298 #else /* !HAVE_SYS_TIME_H */
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
299 #include <time.h>
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
300 #endif /* !HAVE_SYS_TIME_H */
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
301 #endif /* !TIME_WITH_SYS_TIME */
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
302
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
303
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
304 /******************************
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
305 * WRAPPER FOR <sys/select.h> *
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
306 ******************************/
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
307
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
308 /* NB caller must include <sys/types.h> */
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
309
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
310 #ifdef HAVE_SYS_SELECT_H
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
311
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
312 #include <sys/select.h>
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
313
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
314 #endif /* !HAVE_SYS_SELECT_H */
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
315
15978
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
316 /*******************************
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
317 * stat() and fstat() fiddling *
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
318 *******************************/
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
319
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
320 /* We expect that stat and fstat exist on most systems.
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
321 * It's confirmed on Unix, Mac and Windows.
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
322 * If you don't have them, add
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
323 * #define DONT_HAVE_STAT
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
324 * and/or
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
325 * #define DONT_HAVE_FSTAT
18845
876aecef6483 Repair more now-obsolete references to config.h.
Tim Peters <tim.peters@gmail.com>
parents: 18835
diff changeset
326 * to your pyconfig.h. Python code beyond this should check HAVE_STAT and
15978
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
327 * HAVE_FSTAT instead.
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
328 * Also
38716
42808526511c Patch #1495999: Part two of Windows CE changes.
Martin v. Löwis <martin@v.loewis.de>
parents: 38457
diff changeset
329 * #define HAVE_SYS_STAT_H
42808526511c Patch #1495999: Part two of Windows CE changes.
Martin v. Löwis <martin@v.loewis.de>
parents: 38457
diff changeset
330 * if <sys/stat.h> exists on your platform, and
15978
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
331 * #define HAVE_STAT_H
38716
42808526511c Patch #1495999: Part two of Windows CE changes.
Martin v. Löwis <martin@v.loewis.de>
parents: 38457
diff changeset
332 * if <stat.h> does.
15978
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
333 */
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
334 #ifndef DONT_HAVE_STAT
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
335 #define HAVE_STAT
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
336 #endif
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
337
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
338 #ifndef DONT_HAVE_FSTAT
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
339 #define HAVE_FSTAT
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
340 #endif
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
341
20654
edd9d0b3c47e SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20625
diff changeset
342 #ifdef RISCOS
edd9d0b3c47e SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20625
diff changeset
343 #include <sys/types.h>
29066
90342f395721 Patch #734231: Update RiscOS support. In particular, correct
Martin v. Löwis <martin@v.loewis.de>
parents: 28437
diff changeset
344 #include "unixstuff.h"
20654
edd9d0b3c47e SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20625
diff changeset
345 #endif
edd9d0b3c47e SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents: 20625
diff changeset
346
38716
42808526511c Patch #1495999: Part two of Windows CE changes.
Martin v. Löwis <martin@v.loewis.de>
parents: 38457
diff changeset
347 #ifdef HAVE_SYS_STAT_H
22052
08d5cf596b01 OS/2 EMX port changes (Include part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21859
diff changeset
348 #if defined(PYOS_OS2) && defined(PYCC_GCC)
08d5cf596b01 OS/2 EMX port changes (Include part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21859
diff changeset
349 #include <sys/types.h>
08d5cf596b01 OS/2 EMX port changes (Include part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents: 21859
diff changeset
350 #endif
15978
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
351 #include <sys/stat.h>
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
352 #elif defined(HAVE_STAT_H)
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
353 #include <stat.h>
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
354 #endif
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
355
19061
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
356 #if defined(PYCC_VACPP)
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
357 /* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
358 #define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG)
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
359 #endif
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
360
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
361 #ifndef S_ISREG
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
362 #define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
363 #endif
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
364
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
365 #ifndef S_ISDIR
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
366 #define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
367 #endif
f51b13bf5d54 Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents: 19033
diff changeset
368
13918
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
369
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
370 #ifdef __cplusplus
13761
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
371 /* Move this down here since some C++ #include's don't like to be included
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
372 inside an extern "C" */
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
373 extern "C" {
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
374 #endif
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
375
13918
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
376
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
377 /* Py_ARITHMETIC_RIGHT_SHIFT
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
378 * C doesn't define whether a right-shift of a signed integer sign-extends
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
379 * or zero-fills. Here a macro to force sign extension:
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
380 * Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J)
52242
6c0c15a2ed2d Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
Mark Dickinson <dickinsm@gmail.com>
parents: 52233
diff changeset
381 * Return I >> J, forcing sign extension. Arithmetically, return the
6c0c15a2ed2d Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
Mark Dickinson <dickinsm@gmail.com>
parents: 52233
diff changeset
382 * floor of I/2**J.
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
383 * Requirements:
52242
6c0c15a2ed2d Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
Mark Dickinson <dickinsm@gmail.com>
parents: 52233
diff changeset
384 * I should have signed integer type. In the terminology of C99, this can
6c0c15a2ed2d Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
Mark Dickinson <dickinsm@gmail.com>
parents: 52233
diff changeset
385 * be either one of the five standard signed integer types (signed char,
6c0c15a2ed2d Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
Mark Dickinson <dickinsm@gmail.com>
parents: 52233
diff changeset
386 * short, int, long, long long) or an extended signed integer type.
6c0c15a2ed2d Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
Mark Dickinson <dickinsm@gmail.com>
parents: 52233
diff changeset
387 * J is an integer >= 0 and strictly less than the number of bits in the
6c0c15a2ed2d Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
Mark Dickinson <dickinsm@gmail.com>
parents: 52233
diff changeset
388 * type of I (because C doesn't define what happens for J outside that
6c0c15a2ed2d Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
Mark Dickinson <dickinsm@gmail.com>
parents: 52233
diff changeset
389 * range either).
6c0c15a2ed2d Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
Mark Dickinson <dickinsm@gmail.com>
parents: 52233
diff changeset
390 * TYPE used to specify the type of I, but is now ignored. It's been left
6c0c15a2ed2d Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
Mark Dickinson <dickinsm@gmail.com>
parents: 52233
diff changeset
391 * in for backwards compatibility with versions <= 2.6 or 3.0.
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
392 * Caution:
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
393 * I may be evaluated more than once.
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
394 */
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
395 #ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
396 #define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \
52242
6c0c15a2ed2d Rewrite Py_ARITHMETIC_RIGHT_SHIFT so that it's valid for all signed
Mark Dickinson <dickinsm@gmail.com>
parents: 52233
diff changeset
397 ((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J))
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
398 #else
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
399 #define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J))
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
400 #endif
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
401
13976
5ada9fa54801 Fix for http://sourceforge.net/bugs/?func=detailbug&bug_id=111866&group_id=5470.
Tim Peters <tim.peters@gmail.com>
parents: 13918
diff changeset
402 /* Py_FORCE_EXPANSION(X)
13671
26685bd2c09e Recent ANSIfication introduced a couple instances of
Tim Peters <tim.peters@gmail.com>
parents: 13489
diff changeset
403 * "Simply" returns its argument. However, macro expansions within the
26685bd2c09e Recent ANSIfication introduced a couple instances of
Tim Peters <tim.peters@gmail.com>
parents: 13489
diff changeset
404 * argument are evaluated. This unfortunate trickery is needed to get
26685bd2c09e Recent ANSIfication introduced a couple instances of
Tim Peters <tim.peters@gmail.com>
parents: 13489
diff changeset
405 * token-pasting to work as desired in some cases.
26685bd2c09e Recent ANSIfication introduced a couple instances of
Tim Peters <tim.peters@gmail.com>
parents: 13489
diff changeset
406 */
26685bd2c09e Recent ANSIfication introduced a couple instances of
Tim Peters <tim.peters@gmail.com>
parents: 13489
diff changeset
407 #define Py_FORCE_EXPANSION(X) X
26685bd2c09e Recent ANSIfication introduced a couple instances of
Tim Peters <tim.peters@gmail.com>
parents: 13489
diff changeset
408
13674
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
409 /* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW)
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
410 * Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
411 * assert-fails if any information is lost.
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
412 * Caution:
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
413 * VALUE may be evaluated more than once.
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
414 */
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
415 #ifdef Py_DEBUG
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
416 #define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
417 (assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE))
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
418 #else
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
419 #define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE)
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
420 #endif
c90d94d287d7 Included assert.h in Python.h -- it's absurd that this basic tool of
Tim Peters <tim.peters@gmail.com>
parents: 13671
diff changeset
421
31763
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
422 /* Py_SET_ERRNO_ON_MATH_ERROR(x)
19750
35b6a1d0b1e0 Rework the way we try to check for libm overflow, given that C99 no longer
Tim Peters <tim.peters@gmail.com>
parents: 19718
diff changeset
423 * If a libm function did not set errno, but it looks like the result
31763
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
424 * overflowed or not-a-number, set errno to ERANGE or EDOM. Set errno
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
425 * to 0 before calling a libm function, and invoke this macro after,
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
426 * passing the function result.
19750
35b6a1d0b1e0 Rework the way we try to check for libm overflow, given that C99 no longer
Tim Peters <tim.peters@gmail.com>
parents: 19718
diff changeset
427 * Caution:
35b6a1d0b1e0 Rework the way we try to check for libm overflow, given that C99 no longer
Tim Peters <tim.peters@gmail.com>
parents: 19718
diff changeset
428 * This isn't reliable. See Py_OVERFLOWED comments.
35b6a1d0b1e0 Rework the way we try to check for libm overflow, given that C99 no longer
Tim Peters <tim.peters@gmail.com>
parents: 19718
diff changeset
429 * X is evaluated more than once.
35b6a1d0b1e0 Rework the way we try to check for libm overflow, given that C99 no longer
Tim Peters <tim.peters@gmail.com>
parents: 19718
diff changeset
430 */
35549
b19cf73c54a7 (backport from HEAD)
Guido van Rossum <guido@python.org>
parents: 33548
diff changeset
431 #if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__hpux) && defined(__ia64))
31763
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
432 #define _Py_SET_EDOM_FOR_NAN(X) if (isnan(X)) errno = EDOM;
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
433 #else
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
434 #define _Py_SET_EDOM_FOR_NAN(X) ;
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
435 #endif
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
436 #define Py_SET_ERRNO_ON_MATH_ERROR(X) \
19750
35b6a1d0b1e0 Rework the way we try to check for libm overflow, given that C99 no longer
Tim Peters <tim.peters@gmail.com>
parents: 19718
diff changeset
437 do { \
31763
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
438 if (errno == 0) { \
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
439 if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
440 errno = ERANGE; \
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
441 else _Py_SET_EDOM_FOR_NAN(X) \
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
442 } \
19750
35b6a1d0b1e0 Rework the way we try to check for libm overflow, given that C99 no longer
Tim Peters <tim.peters@gmail.com>
parents: 19718
diff changeset
443 } while(0)
19717
01de0a703069 Try to recover from that glibc's ldexp apparently doesn't set errno on
Tim Peters <tim.peters@gmail.com>
parents: 19568
diff changeset
444
31763
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
445 /* Py_SET_ERANGE_ON_OVERFLOW(x)
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
446 * An alias of Py_SET_ERRNO_ON_MATH_ERROR for backward-compatibility.
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
447 */
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
448 #define Py_SET_ERANGE_IF_OVERFLOW(X) Py_SET_ERRNO_ON_MATH_ERROR(X)
3473dea3aa4c Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents: 31504
diff changeset
449
22201
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
450 /* Py_ADJUST_ERANGE1(x)
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
451 * Py_ADJUST_ERANGE2(x, y)
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
452 * Set errno to 0 before calling a libm function, and invoke one of these
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
453 * macros after, passing the function result(s) (Py_ADJUST_ERANGE2 is useful
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
454 * for functions returning complex results). This makes two kinds of
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
455 * adjustments to errno: (A) If it looks like the platform libm set
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
456 * errno=ERANGE due to underflow, clear errno. (B) If it looks like the
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
457 * platform libm overflowed but didn't set errno, force errno to ERANGE. In
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
458 * effect, we're trying to force a useful implementation of C89 errno
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
459 * behavior.
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
460 * Caution:
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
461 * This isn't reliable. See Py_OVERFLOWED comments.
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
462 * X and Y may be evaluated more than once.
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
463 */
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
464 #define Py_ADJUST_ERANGE1(X) \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
465 do { \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
466 if (errno == 0) { \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
467 if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
468 errno = ERANGE; \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
469 } \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
470 else if (errno == ERANGE && (X) == 0.0) \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
471 errno = 0; \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
472 } while(0)
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
473
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
474 #define Py_ADJUST_ERANGE2(X, Y) \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
475 do { \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
476 if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
477 (Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
478 if (errno == 0) \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
479 errno = ERANGE; \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
480 } \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
481 else if (errno == ERANGE) \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
482 errno = 0; \
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
483 } while(0)
ad81f8fb4ee4 SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents: 22112
diff changeset
484
26714
2f523ae90e06 Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents: 25276
diff changeset
485 /* Py_DEPRECATED(version)
26715
e82326996481 Update/correct comment
Neal Norwitz <nnorwitz@gmail.com>
parents: 26714
diff changeset
486 * Declare a variable, type, or function deprecated.
26714
2f523ae90e06 Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents: 25276
diff changeset
487 * Usage:
2f523ae90e06 Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents: 25276
diff changeset
488 * extern int old_var Py_DEPRECATED(2.3);
2f523ae90e06 Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents: 25276
diff changeset
489 * typedef int T1 Py_DEPRECATED(2.4);
2f523ae90e06 Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents: 25276
diff changeset
490 * extern int x() Py_DEPRECATED(2.5);
2f523ae90e06 Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents: 25276
diff changeset
491 */
37101
2dc63cdb09cf Get Py_DEPRECATED to work with gcc 4.x too
Neal Norwitz <nnorwitz@gmail.com>
parents: 37037
diff changeset
492 #if defined(__GNUC__) && ((__GNUC__ >= 4) || \
2dc63cdb09cf Get Py_DEPRECATED to work with gcc 4.x too
Neal Norwitz <nnorwitz@gmail.com>
parents: 37037
diff changeset
493 (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
26714
2f523ae90e06 Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents: 25276
diff changeset
494 #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
2f523ae90e06 Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents: 25276
diff changeset
495 #else
26815
8eccfae04bb4 Apparently FreeBSD enables some HW floating-point exceptions by default.
Tim Peters <tim.peters@gmail.com>
parents: 26715
diff changeset
496 #define Py_DEPRECATED(VERSION_UNUSED)
26714
2f523ae90e06 Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents: 25276
diff changeset
497 #endif
2f523ae90e06 Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents: 25276
diff changeset
498
13694
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
499 /**************************************************************************
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
500 Prototypes that are missing from the standard include files on some systems
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
501 (and possibly only some versions of such systems.)
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
502
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
503 Please be conservative with adding new ones, document them and enclose them
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
504 in platform-specific #ifdefs.
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
505 **************************************************************************/
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
506
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
507 #ifdef SOLARIS
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
508 /* Unchecked */
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
509 extern int gethostname(char *, int);
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
510 #endif
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
511
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
512 #ifdef __BEOS__
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
513 /* Unchecked */
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
514 /* It's in the libs, but not the headers... - [cjh] */
15978
24dafbb0db58 Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents: 15828
diff changeset
515 int shutdown( int, int );
13694
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
516 #endif
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
517
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
518 #ifdef HAVE__GETPTY
13719
767b2f7be40e Make mode_t available for the declaration of _getpty().
Sjoerd Mullender <sjoerd@acm.org>
parents: 13694
diff changeset
519 #include <sys/types.h> /* we need to import mode_t */
13694
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
520 extern char * _getpty(int *, int, mode_t, int);
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
521 #endif
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
522
47227
5ec9528c93de Patch #1722225: Support QNX 6.
Martin v. Löwis <martin@v.loewis.de>
parents: 46473
diff changeset
523 /* On QNX 6, struct termio must be declared by including sys/termio.h
5ec9528c93de Patch #1722225: Support QNX 6.
Martin v. Löwis <martin@v.loewis.de>
parents: 46473
diff changeset
524 if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must
5ec9528c93de Patch #1722225: Support QNX 6.
Martin v. Löwis <martin@v.loewis.de>
parents: 46473
diff changeset
525 be included before termios.h or it will generate an error. */
5ec9528c93de Patch #1722225: Support QNX 6.
Martin v. Löwis <martin@v.loewis.de>
parents: 46473
diff changeset
526 #ifdef HAVE_SYS_TERMIO_H
5ec9528c93de Patch #1722225: Support QNX 6.
Martin v. Löwis <martin@v.loewis.de>
parents: 46473
diff changeset
527 #include <sys/termio.h>
5ec9528c93de Patch #1722225: Support QNX 6.
Martin v. Löwis <martin@v.loewis.de>
parents: 46473
diff changeset
528 #endif
5ec9528c93de Patch #1722225: Support QNX 6.
Martin v. Löwis <martin@v.loewis.de>
parents: 46473
diff changeset
529
13694
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
530 #if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY)
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
531 #if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H)
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
532 /* BSDI does not supply a prototype for the 'openpty' and 'forkpty'
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
533 functions, even though they are included in libutil. */
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
534 #include <termios.h>
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
535 extern int openpty(int *, int *, char *, struct termios *, struct winsize *);
45077
f0e6bb9b24f6 Fixed bug #1983: Return from fork() is pid_t, not int
Christian Heimes <christian@cheimes.de>
parents: 44874
diff changeset
536 extern pid_t forkpty(int *, char *, struct termios *, struct winsize *);
13694
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
537 #endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
538 #endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
539
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
540
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
541 /* These are pulled from various places. It isn't obvious on what platforms
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
542 they are necessary, nor what the exact prototype should look like (which
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
543 is likely to vary between platforms!) If you find you need one of these
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
544 declarations, please move them to a platform-specific block and include
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
545 proper prototypes. */
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
546 #if 0
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
547
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
548 /* From Modules/resource.c */
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
549 extern int getrusage();
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
550 extern int getpagesize();
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
551
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
552 /* From Python/sysmodule.c and Modules/posixmodule.c */
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
553 extern int fclose(FILE *);
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
554
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
555 /* From Modules/posixmodule.c */
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
556 extern int fdatasync(int);
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
557 #endif /* 0 */
b54f11ada91e Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents: 13676
diff changeset
558
13761
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
559
37142
7049dc0c621a Remove false information from the comment and reformat it like other
Hye-Shik Chang <hyeshik@gmail.com>
parents: 37101
diff changeset
560 /* On 4.4BSD-descendants, ctype functions serves the whole range of
7049dc0c621a Remove false information from the comment and reformat it like other
Hye-Shik Chang <hyeshik@gmail.com>
parents: 37101
diff changeset
561 * wchar_t character set rather than single byte code points only.
7049dc0c621a Remove false information from the comment and reformat it like other
Hye-Shik Chang <hyeshik@gmail.com>
parents: 37101
diff changeset
562 * This characteristic can break some operations of string object
7049dc0c621a Remove false information from the comment and reformat it like other
Hye-Shik Chang <hyeshik@gmail.com>
parents: 37101
diff changeset
563 * including str.upper() and str.split() on UTF-8 locales. This
7049dc0c621a Remove false information from the comment and reformat it like other
Hye-Shik Chang <hyeshik@gmail.com>
parents: 37101
diff changeset
564 * workaround was provided by Tim Robbins of FreeBSD project.
7049dc0c621a Remove false information from the comment and reformat it like other
Hye-Shik Chang <hyeshik@gmail.com>
parents: 37101
diff changeset
565 */
32950
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
566
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
567 #ifdef __FreeBSD__
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
568 #include <osreldate.h>
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
569 #if __FreeBSD_version > 500039
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
570 #include <ctype.h>
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
571 #include <wctype.h>
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
572 #undef isalnum
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
573 #define isalnum(c) iswalnum(btowc(c))
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
574 #undef isalpha
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
575 #define isalpha(c) iswalpha(btowc(c))
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
576 #undef islower
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
577 #define islower(c) iswlower(btowc(c))
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
578 #undef isspace
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
579 #define isspace(c) iswspace(btowc(c))
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
580 #undef isupper
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
581 #define isupper(c) iswupper(btowc(c))
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
582 #undef tolower
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
583 #define tolower(c) towlower(btowc(c))
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
584 #undef toupper
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
585 #define toupper(c) towupper(btowc(c))
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
586 #endif
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
587 #endif
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
588
adfe7d39a049 Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents: 32695
diff changeset
589
24315
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
590 /* Declarations for symbol visibility.
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
591
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
592 PyAPI_FUNC(type): Declares a public Python API function and return type
26815
8eccfae04bb4 Apparently FreeBSD enables some HW floating-point exceptions by default.
Tim Peters <tim.peters@gmail.com>
parents: 26715
diff changeset
593 PyAPI_DATA(type): Declares public Python data and its type
24315
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
594 PyMODINIT_FUNC: A Python module init function. If these functions are
26815
8eccfae04bb4 Apparently FreeBSD enables some HW floating-point exceptions by default.
Tim Peters <tim.peters@gmail.com>
parents: 26715
diff changeset
595 inside the Python core, they are private to the core.
8eccfae04bb4 Apparently FreeBSD enables some HW floating-point exceptions by default.
Tim Peters <tim.peters@gmail.com>
parents: 26715
diff changeset
596 If in an extension module, it may be declared with
24315
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
597 external linkage depending on the platform.
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
598
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
599 As a number of platforms support/require "__declspec(dllimport/dllexport)",
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
600 we support a HAVE_DECLSPEC_DLL macro to save duplication.
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
601 */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
602
26815
8eccfae04bb4 Apparently FreeBSD enables some HW floating-point exceptions by default.
Tim Peters <tim.peters@gmail.com>
parents: 26715
diff changeset
603 /*
27802
372e3483d327 Make comments agree with code (I think).
Michael W. Hudson <mwh@python.net>
parents: 27104
diff changeset
604 All windows ports, except cygwin, are handled in PC/pyconfig.h.
372e3483d327 Make comments agree with code (I think).
Michael W. Hudson <mwh@python.net>
parents: 27104
diff changeset
605
372e3483d327 Make comments agree with code (I think).
Michael W. Hudson <mwh@python.net>
parents: 27104
diff changeset
606 BeOS and cygwin are the only other autoconf platform requiring special
372e3483d327 Make comments agree with code (I think).
Michael W. Hudson <mwh@python.net>
parents: 27104
diff changeset
607 linkage handling and both of these use __declspec().
24315
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
608 */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
609 #if defined(__CYGWIN__) || defined(__BEOS__)
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
610 # define HAVE_DECLSPEC_DLL
13761
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
611 #endif
24315
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
612
30310
74bc3493ce03 This patch enables the building of Cygwin Python with a static core
Jason Tishler <jason@tishler.net>
parents: 29066
diff changeset
613 /* only get special linkage if built as shared or platform is Cygwin */
74bc3493ce03 This patch enables the building of Cygwin Python with a static core
Jason Tishler <jason@tishler.net>
parents: 29066
diff changeset
614 #if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
24315
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
615 # if defined(HAVE_DECLSPEC_DLL)
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
616 # ifdef Py_BUILD_CORE
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
617 # define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
24420
36e2fd3f08f7 Excise DL_IMPORT/EXPORT from object.h, and related files. This patch
Mark Hammond <mhammond@skippinet.com.au>
parents: 24315
diff changeset
618 # define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE
24315
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
619 /* module init functions inside the core need no external linkage */
30311
f003e48f562d Bug #794140: cygwin builds do not embed
Jason Tishler <jason@tishler.net>
parents: 30310
diff changeset
620 /* except for Cygwin to handle embedding (FIXME: BeOS too?) */
f003e48f562d Bug #794140: cygwin builds do not embed
Jason Tishler <jason@tishler.net>
parents: 30310
diff changeset
621 # if defined(__CYGWIN__)
f003e48f562d Bug #794140: cygwin builds do not embed
Jason Tishler <jason@tishler.net>
parents: 30310
diff changeset
622 # define PyMODINIT_FUNC __declspec(dllexport) void
f003e48f562d Bug #794140: cygwin builds do not embed
Jason Tishler <jason@tishler.net>
parents: 30310
diff changeset
623 # else /* __CYGWIN__ */
f003e48f562d Bug #794140: cygwin builds do not embed
Jason Tishler <jason@tishler.net>
parents: 30310
diff changeset
624 # define PyMODINIT_FUNC void
f003e48f562d Bug #794140: cygwin builds do not embed
Jason Tishler <jason@tishler.net>
parents: 30310
diff changeset
625 # endif /* __CYGWIN__ */
24315
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
626 # else /* Py_BUILD_CORE */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
627 /* Building an extension module, or an embedded situation */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
628 /* public Python functions and data are imported */
27104
2443c557cbc3 Patch #661760: Cygwin auto-import module patch
Jason Tishler <jason@tishler.net>
parents: 26815
diff changeset
629 /* Under Cygwin, auto-import functions to prevent compilation */
2443c557cbc3 Patch #661760: Cygwin auto-import module patch
Jason Tishler <jason@tishler.net>
parents: 26815
diff changeset
630 /* failures similar to http://python.org/doc/FAQ.html#3.24 */
2443c557cbc3 Patch #661760: Cygwin auto-import module patch
Jason Tishler <jason@tishler.net>
parents: 26815
diff changeset
631 # if !defined(__CYGWIN__)
2443c557cbc3 Patch #661760: Cygwin auto-import module patch
Jason Tishler <jason@tishler.net>
parents: 26815
diff changeset
632 # define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
2443c557cbc3 Patch #661760: Cygwin auto-import module patch
Jason Tishler <jason@tishler.net>
parents: 26815
diff changeset
633 # endif /* !__CYGWIN__ */
24420
36e2fd3f08f7 Excise DL_IMPORT/EXPORT from object.h, and related files. This patch
Mark Hammond <mhammond@skippinet.com.au>
parents: 24315
diff changeset
634 # define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
24315
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
635 /* module init functions outside the core must be exported */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
636 # if defined(__cplusplus)
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
637 # define PyMODINIT_FUNC extern "C" __declspec(dllexport) void
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
638 # else /* __cplusplus */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
639 # define PyMODINIT_FUNC __declspec(dllexport) void
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
640 # endif /* __cplusplus */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
641 # endif /* Py_BUILD_CORE */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
642 # endif /* HAVE_DECLSPEC */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
643 #endif /* Py_ENABLE_SHARED */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
644
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
645 /* If no external linkage macros defined by now, create defaults */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
646 #ifndef PyAPI_FUNC
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
647 # define PyAPI_FUNC(RTYPE) RTYPE
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
648 #endif
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
649 #ifndef PyAPI_DATA
24420
36e2fd3f08f7 Excise DL_IMPORT/EXPORT from object.h, and related files. This patch
Mark Hammond <mhammond@skippinet.com.au>
parents: 24315
diff changeset
650 # define PyAPI_DATA(RTYPE) extern RTYPE
24315
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
651 #endif
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
652 #ifndef PyMODINIT_FUNC
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
653 # if defined(__cplusplus)
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
654 # define PyMODINIT_FUNC extern "C" void
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
655 # else /* __cplusplus */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
656 # define PyMODINIT_FUNC void
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
657 # endif /* __cplusplus */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
658 #endif
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
659
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
660 /* Deprecated DL_IMPORT and DL_EXPORT macros */
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
661 #if defined(Py_ENABLE_SHARED) && defined (HAVE_DECLSPEC_DLL)
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
662 # if defined(Py_BUILD_CORE)
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
663 # define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
664 # define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
665 # else
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
666 # define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
667 # define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
668 # endif
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
669 #endif
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
670 #ifndef DL_EXPORT
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
671 # define DL_EXPORT(RTYPE) RTYPE
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
672 #endif
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
673 #ifndef DL_IMPORT
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
674 # define DL_IMPORT(RTYPE) RTYPE
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
675 #endif
a8df0c0be242 Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24104
diff changeset
676 /* End of deprecated DL_* macros */
13761
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
677
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
678 /* If the fd manipulation macros aren't defined,
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
679 here is a set that should do the job */
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
680
13790
c66e991b5f21 Of course, you meant "#if 0" and not "#ifdef 0". :)
Guido van Rossum <guido@python.org>
parents: 13786
diff changeset
681 #if 0 /* disabled and probably obsolete */
13786
f1290aba29da Guido said this is food for the beta-testers<wink>
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13776
diff changeset
682
13761
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
683 #ifndef FD_SETSIZE
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
684 #define FD_SETSIZE 256
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
685 #endif
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
686
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
687 #ifndef FD_SET
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
688
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
689 typedef long fd_mask;
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
690
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
691 #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
692 #ifndef howmany
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
693 #define howmany(x, y) (((x)+((y)-1))/(y))
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
694 #endif /* howmany */
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
695
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
696 typedef struct fd_set {
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
697 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
698 } fd_set;
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
699
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
700 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
701 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
702 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
703 #define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p)))
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
704
59f8cedcf049 merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13719
diff changeset
705 #endif /* FD_SET */
13786
f1290aba29da Guido said this is food for the beta-testers<wink>
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13776
diff changeset
706
f1290aba29da Guido said this is food for the beta-testers<wink>
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13776
diff changeset
707 #endif /* fd manipulation macros */
f1290aba29da Guido said this is food for the beta-testers<wink>
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13776
diff changeset
708
13918
08092d1eb26a #include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents: 13912
diff changeset
709
14869
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
710 /* limits.h constants that may be missing */
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
711
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
712 #ifndef INT_MAX
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
713 #define INT_MAX 2147483647
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
714 #endif
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
715
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
716 #ifndef LONG_MAX
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
717 #if SIZEOF_LONG == 4
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
718 #define LONG_MAX 0X7FFFFFFFL
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
719 #elif SIZEOF_LONG == 8
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
720 #define LONG_MAX 0X7FFFFFFFFFFFFFFFL
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
721 #else
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
722 #error "could not set LONG_MAX in pyport.h"
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
723 #endif
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
724 #endif
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
725
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
726 #ifndef LONG_MIN
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
727 #define LONG_MIN (-LONG_MAX-1)
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
728 #endif
25ddd3dc7a7a Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents: 14497
diff changeset
729
15016
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
730 #ifndef LONG_BIT
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
731 #define LONG_BIT (8 * SIZEOF_LONG)
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
732 #endif
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
733
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
734 #if LONG_BIT != 8 * SIZEOF_LONG
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
735 /* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
736 * 32-bit platforms using gcc. We try to catch that here at compile-time
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
737 * rather than waiting for integer multiplication to trigger bogus
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
738 * overflows.
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
739 */
15828
05ad297e144f Change LONG_BIT error warning to mention glibc, too, since this is really
Andrew M. Kuchling <amk@amk.ca>
parents: 15032
diff changeset
740 #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
15016
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
741 #endif
fb7ac8a40a97 Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
742
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
743 #ifdef __cplusplus
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
744 }
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
745 #endif
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
746
20625
2c1a4584a704 Hide GCC attributes fom compilers that don't support them.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 20209
diff changeset
747 /*
2c1a4584a704 Hide GCC attributes fom compilers that don't support them.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 20209
diff changeset
748 * Hide GCC attributes from compilers that don't support them.
2c1a4584a704 Hide GCC attributes fom compilers that don't support them.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 20209
diff changeset
749 */
20726
587b74854f8c SF patch #475657 (Dietmar Schwertberger)
Guido van Rossum <guido@python.org>
parents: 20654
diff changeset
750 #if (!defined(__GNUC__) || __GNUC__ < 2 || \
21859
76607a0c6956 Got rid of a few more NeXT ifdefs. The last, I think.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21538
diff changeset
751 (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) && \
20726
587b74854f8c SF patch #475657 (Dietmar Schwertberger)
Guido van Rossum <guido@python.org>
parents: 20654
diff changeset
752 !defined(RISCOS)
25276
6c21e95a4881 Use Py_GCC_ATTRIBUTE instead of __attribute__. Compilers other than GCC
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 24420
diff changeset
753 #define Py_GCC_ATTRIBUTE(x)
6c21e95a4881 Use Py_GCC_ATTRIBUTE instead of __attribute__. Compilers other than GCC
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 24420
diff changeset
754 #else
6c21e95a4881 Use Py_GCC_ATTRIBUTE instead of __attribute__. Compilers other than GCC
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 24420
diff changeset
755 #define Py_GCC_ATTRIBUTE(x) __attribute__(x)
20625
2c1a4584a704 Hide GCC attributes fom compilers that don't support them.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 20209
diff changeset
756 #endif
2c1a4584a704 Hide GCC attributes fom compilers that don't support them.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 20209
diff changeset
757
40151
410c1c78ed51 Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents: 39950
diff changeset
758 /*
410c1c78ed51 Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents: 39950
diff changeset
759 * Add PyArg_ParseTuple format where available.
410c1c78ed51 Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents: 39950
diff changeset
760 */
410c1c78ed51 Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents: 39950
diff changeset
761 #ifdef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE
410c1c78ed51 Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents: 39950
diff changeset
762 #define Py_FORMAT_PARSETUPLE(func,p1,p2) __attribute__((format(func,p1,p2)))
410c1c78ed51 Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents: 39950
diff changeset
763 #else
410c1c78ed51 Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents: 39950
diff changeset
764 #define Py_FORMAT_PARSETUPLE(func,p1,p2)
410c1c78ed51 Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents: 39950
diff changeset
765 #endif
410c1c78ed51 Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents: 39950
diff changeset
766
50786
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47587
diff changeset
767 /*
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47587
diff changeset
768 * Specify alignment on compilers that support it.
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47587
diff changeset
769 */
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47587
diff changeset
770 #if defined(__GNUC__) && __GNUC__ >= 3
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47587
diff changeset
771 #define Py_ALIGNED(x) __attribute__((aligned(x)))
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47587
diff changeset
772 #else
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47587
diff changeset
773 #define Py_ALIGNED(x)
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47587
diff changeset
774 #endif
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47587
diff changeset
775
32695
ff26714bf86d Moved SunPro warning suppression into pyport.h and out of individual
Nicholas Bastin <nick.bastin@gmail.com>
parents: 31763
diff changeset
776 /* Eliminate end-of-loop code not reached warnings from SunPro C
ff26714bf86d Moved SunPro warning suppression into pyport.h and out of individual
Nicholas Bastin <nick.bastin@gmail.com>
parents: 31763
diff changeset
777 * when using do{...}while(0) macros
ff26714bf86d Moved SunPro warning suppression into pyport.h and out of individual
Nicholas Bastin <nick.bastin@gmail.com>
parents: 31763
diff changeset
778 */
ff26714bf86d Moved SunPro warning suppression into pyport.h and out of individual
Nicholas Bastin <nick.bastin@gmail.com>
parents: 31763
diff changeset
779 #ifdef __SUNPRO_C
ff26714bf86d Moved SunPro warning suppression into pyport.h and out of individual
Nicholas Bastin <nick.bastin@gmail.com>
parents: 31763
diff changeset
780 #pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED)
ff26714bf86d Moved SunPro warning suppression into pyport.h and out of individual
Nicholas Bastin <nick.bastin@gmail.com>
parents: 31763
diff changeset
781 #endif
ff26714bf86d Moved SunPro warning suppression into pyport.h and out of individual
Nicholas Bastin <nick.bastin@gmail.com>
parents: 31763
diff changeset
782
38232
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
783 /*
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
784 * Older Microsoft compilers don't support the C99 long long literal suffixes,
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
785 * so these will be defined in PC/pyconfig.h for those compilers.
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
786 */
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
787 #ifndef Py_LL
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
788 #define Py_LL(x) x##LL
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
789 #endif
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
790
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
791 #ifndef Py_ULL
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
792 #define Py_ULL(x) Py_LL(x##U)
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
793 #endif
aa620856e8a3 Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents: 37496
diff changeset
794
13423
a87803eb9dfb Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
795 #endif /* Py_PYPORT_H */