Mercurial > cpython-lru_cache-weakref
annotate Include/pyport.h @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | bf3b77722c9f |
| children | 23ebb8936bf6 |
| 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 |
|
54990
c065f33d9c9c
Issue #6347: Add inttypes.h to the pyport.h #includes; fixes a build
Mark Dickinson <dickinsm@gmail.com>
parents:
52242
diff
changeset
|
6 /* Some versions of HP-UX & Solaris need inttypes.h for int32_t, |
|
c065f33d9c9c
Issue #6347: Add inttypes.h to the pyport.h #includes; fixes a build
Mark Dickinson <dickinsm@gmail.com>
parents:
52242
diff
changeset
|
7 INT32_MAX, etc. */ |
|
c065f33d9c9c
Issue #6347: Add inttypes.h to the pyport.h #includes; fixes a build
Mark Dickinson <dickinsm@gmail.com>
parents:
52242
diff
changeset
|
8 #ifdef HAVE_INTTYPES_H |
|
c065f33d9c9c
Issue #6347: Add inttypes.h to the pyport.h #includes; fixes a build
Mark Dickinson <dickinsm@gmail.com>
parents:
52242
diff
changeset
|
9 #include <inttypes.h> |
|
c065f33d9c9c
Issue #6347: Add inttypes.h to the pyport.h #includes; fixes a build
Mark Dickinson <dickinsm@gmail.com>
parents:
52242
diff
changeset
|
10 #endif |
|
c065f33d9c9c
Issue #6347: Add inttypes.h to the pyport.h #includes; fixes a build
Mark Dickinson <dickinsm@gmail.com>
parents:
52242
diff
changeset
|
11 |
|
39951
5c36ec5fd3c2
Guard uintptr_t test with HAVE_STDINT_H, test for
Martin v. Löwis <martin@v.loewis.de>
parents:
39886
diff
changeset
|
12 #ifdef HAVE_STDINT_H |
|
5c36ec5fd3c2
Guard uintptr_t test with HAVE_STDINT_H, test for
Martin v. Löwis <martin@v.loewis.de>
parents:
39886
diff
changeset
|
13 #include <stdint.h> |
|
5c36ec5fd3c2
Guard uintptr_t test with HAVE_STDINT_H, test for
Martin v. Löwis <martin@v.loewis.de>
parents:
39886
diff
changeset
|
14 #endif |
|
5c36ec5fd3c2
Guard uintptr_t test with HAVE_STDINT_H, test for
Martin v. Löwis <martin@v.loewis.de>
parents:
39886
diff
changeset
|
15 |
|
13423
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 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
|
18 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
|
19 |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
20 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
|
21 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
|
22 |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
23 Config #defines referenced here: |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
24 |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
25 SIGNED_RIGHT_SHIFT_ZERO_FILLS |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
26 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
|
27 signed integral type and i < 0. |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
28 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
|
29 |
|
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
|
30 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
|
31 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
|
32 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
|
33 |
|
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
34 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
|
35 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
|
36 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
|
37 |
|
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 |
|
13423
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
42 **************************************************************************/ |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
43 |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
44 |
|
14468
0ef6ea58590b
Add missing Py_PROTO macro for backward compatibility with old extensions
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
14375
diff
changeset
|
45 /* 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
|
46 #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
|
47 #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
|
48 #else |
|
0ef6ea58590b
Add missing Py_PROTO macro for backward compatibility with old extensions
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
14375
diff
changeset
|
49 #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
|
50 #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
|
51 #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
|
52 #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
|
53 #endif |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
54 |
|
14045
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
55 /* 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
|
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 * 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
|
58 * 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
|
59 * 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
|
60 * 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
|
61 * names. |
|
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
62 * |
|
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
63 * 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
|
64 * 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
|
65 */ |
|
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
66 |
|
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
67 #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
|
68 #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
|
69 #define PY_LONG_LONG long long |
|
42011
731b69942317
Backport r55845: Provide LLONG_MAX for S390.
Martin v. Löwis <martin@v.loewis.de>
parents:
42009
diff
changeset
|
70 #if defined(LLONG_MAX) |
|
42077
0318a0f54520
Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents:
42011
diff
changeset
|
71 /* If LLONG_MAX is defined in limits.h, use that. */ |
|
42009
7c9225da5f61
Patch #1733960: Allow T_LONGLONG to accept ints.
Martin v. Löwis <martin@v.loewis.de>
parents:
39951
diff
changeset
|
72 #define PY_LLONG_MIN LLONG_MIN |
|
7c9225da5f61
Patch #1733960: Allow T_LONGLONG to accept ints.
Martin v. Löwis <martin@v.loewis.de>
parents:
39951
diff
changeset
|
73 #define PY_LLONG_MAX LLONG_MAX |
|
7c9225da5f61
Patch #1733960: Allow T_LONGLONG to accept ints.
Martin v. Löwis <martin@v.loewis.de>
parents:
39951
diff
changeset
|
74 #define PY_ULLONG_MAX ULLONG_MAX |
|
42077
0318a0f54520
Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents:
42011
diff
changeset
|
75 #elif defined(__LONG_LONG_MAX__) |
|
0318a0f54520
Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents:
42011
diff
changeset
|
76 /* Otherwise, if GCC has a builtin define, use that. */ |
|
0318a0f54520
Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents:
42011
diff
changeset
|
77 #define PY_LLONG_MAX __LONG_LONG_MAX__ |
|
42011
731b69942317
Backport r55845: Provide LLONG_MAX for S390.
Martin v. Löwis <martin@v.loewis.de>
parents:
42009
diff
changeset
|
78 #define PY_LLONG_MIN (-PY_LLONG_MAX-1) |
|
42077
0318a0f54520
Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents:
42011
diff
changeset
|
79 #define PY_ULLONG_MAX (__LONG_LONG_MAX__*2ULL + 1ULL) |
|
0318a0f54520
Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents:
42011
diff
changeset
|
80 #else |
|
0318a0f54520
Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents:
42011
diff
changeset
|
81 /* Otherwise, rely on two's complement. */ |
|
0318a0f54520
Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents:
42011
diff
changeset
|
82 #define PY_ULLONG_MAX (~0ULL) |
|
0318a0f54520
Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents:
42011
diff
changeset
|
83 #define PY_LLONG_MAX ((long long)(PY_ULLONG_MAX>>1)) |
|
0318a0f54520
Provide PY_LLONG_MAX on all systems having long long.
Martin v. Löwis <martin@v.loewis.de>
parents:
42011
diff
changeset
|
84 #define PY_LLONG_MIN (-PY_LLONG_MAX-1) |
|
42011
731b69942317
Backport r55845: Provide LLONG_MAX for S390.
Martin v. Löwis <martin@v.loewis.de>
parents:
42009
diff
changeset
|
85 #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
|
86 #endif |
|
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
87 #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
|
88 |
|
52233
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
89 /* 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
|
90 * 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
|
91 * 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
|
92 * 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
|
93 * 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
|
94 * 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
|
95 */ |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
96 #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
|
97 #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
|
98 #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
|
99 #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
|
100 #endif |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
101 #endif |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
102 |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
103 /* 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
|
104 * 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
|
105 */ |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
106 #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
|
107 #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
|
108 #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
|
109 #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
|
110 #endif |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
111 #endif |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
112 |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
113 /* 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
|
114 #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
|
115 #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
|
116 #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
|
117 #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
|
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 #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
|
121 #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
|
122 #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
|
123 #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
|
124 #endif |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
125 #endif |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
126 |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
127 /* 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
|
128 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
|
129 (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
|
130 |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
131 #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
|
132 #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
|
133 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
|
134 #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
|
135 #else |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
136 #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
|
137 #endif |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
138 #endif |
|
9b358eae532a
Issue #4258: Use 30-bit digits for Python longs, on 64-bit platforms.
Mark Dickinson <dickinsm@gmail.com>
parents:
50786
diff
changeset
|
139 |
|
14045
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
140 /* 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
|
141 * 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
|
142 * 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
|
143 * 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
|
144 */ |
|
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
145 #ifdef HAVE_UINTPTR_T |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
146 typedef uintptr_t Py_uintptr_t; |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
147 typedef intptr_t 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
|
148 |
|
14045
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
149 #elif SIZEOF_VOID_P <= SIZEOF_INT |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
150 typedef unsigned int Py_uintptr_t; |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
151 typedef int 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
|
152 |
|
14045
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
153 #elif SIZEOF_VOID_P <= SIZEOF_LONG |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
154 typedef unsigned long Py_uintptr_t; |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
155 typedef 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
|
156 |
|
14045
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
157 #elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG) |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
158 typedef unsigned PY_LONG_LONG Py_uintptr_t; |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
159 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
|
160 |
|
14045
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
161 #else |
|
c4444f68ebf9
Moved LONG_LONG #define from longobject.h to here, since it's needed
Barry Warsaw <barry@python.org>
parents:
13976
diff
changeset
|
162 # 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
|
163 #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
|
164 |
|
37037
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
165 /* 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
|
166 * 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
|
167 * 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
|
168 */ |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35746
diff
changeset
|
169 #ifdef HAVE_SSIZE_T |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
170 typedef ssize_t Py_ssize_t; |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35746
diff
changeset
|
171 #elif SIZEOF_VOID_P == SIZEOF_SIZE_T |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
172 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
|
173 #else |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
35746
diff
changeset
|
174 # 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
|
175 #endif |
|
37037
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
176 |
|
45337
8cbe0bd93c28
Added checks for integer overflows, contributed by Google. Some are
Martin v. Löwis <martin@v.loewis.de>
parents:
42077
diff
changeset
|
177 /* Largest possible value of size_t. |
|
8cbe0bd93c28
Added checks for integer overflows, contributed by Google. Some are
Martin v. Löwis <martin@v.loewis.de>
parents:
42077
diff
changeset
|
178 SIZE_MAX is part of C99, so it might be defined on some |
|
8cbe0bd93c28
Added checks for integer overflows, contributed by Google. Some are
Martin v. Löwis <martin@v.loewis.de>
parents:
42077
diff
changeset
|
179 platforms. If it is not defined, (size_t)-1 is a portable |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
180 definition for C89, due to the way signed->unsigned |
|
45337
8cbe0bd93c28
Added checks for integer overflows, contributed by Google. Some are
Martin v. Löwis <martin@v.loewis.de>
parents:
42077
diff
changeset
|
181 conversion is defined. */ |
|
8cbe0bd93c28
Added checks for integer overflows, contributed by Google. Some are
Martin v. Löwis <martin@v.loewis.de>
parents:
42077
diff
changeset
|
182 #ifdef SIZE_MAX |
|
8cbe0bd93c28
Added checks for integer overflows, contributed by Google. Some are
Martin v. Löwis <martin@v.loewis.de>
parents:
42077
diff
changeset
|
183 #define PY_SIZE_MAX SIZE_MAX |
|
8cbe0bd93c28
Added checks for integer overflows, contributed by Google. Some are
Martin v. Löwis <martin@v.loewis.de>
parents:
42077
diff
changeset
|
184 #else |
|
8cbe0bd93c28
Added checks for integer overflows, contributed by Google. Some are
Martin v. Löwis <martin@v.loewis.de>
parents:
42077
diff
changeset
|
185 #define PY_SIZE_MAX ((size_t)-1) |
|
8cbe0bd93c28
Added checks for integer overflows, contributed by Google. Some are
Martin v. Löwis <martin@v.loewis.de>
parents:
42077
diff
changeset
|
186 #endif |
|
8cbe0bd93c28
Added checks for integer overflows, contributed by Google. Some are
Martin v. Löwis <martin@v.loewis.de>
parents:
42077
diff
changeset
|
187 |
|
37037
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
188 /* 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
|
189 #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
|
190 /* 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
|
191 #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
|
192 |
|
45077
f0e6bb9b24f6
Fixed bug #1983: Return from fork() is pid_t, not int
Christian Heimes <christian@cheimes.de>
parents:
44874
diff
changeset
|
193 #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
|
194 # 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
|
195 #endif |
|
f0e6bb9b24f6
Fixed bug #1983: Return from fork() is pid_t, not int
Christian Heimes <christian@cheimes.de>
parents:
44874
diff
changeset
|
196 |
|
37037
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
197 /* 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
|
198 * 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
|
199 * 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
|
200 * 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
|
201 * |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
202 * 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
|
203 * 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
|
204 * 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
|
205 * |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
206 * PyString_FromFormat |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
207 * PyErr_Format |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
208 * PyString_FromFormatV |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
209 * |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
210 * 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
|
211 * 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
|
212 * example, |
|
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 * 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
|
215 * 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
|
216 * |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
217 * 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
|
218 * 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
|
219 */ |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
220 #ifndef PY_FORMAT_SIZE_T |
| 39886 | 221 # if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__) |
|
37363
59185ffa861d
Add a clause to the PY_FORMAT_SIZE_T to stop warnings on 32 bit intel
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37142
diff
changeset
|
222 # define PY_FORMAT_SIZE_T "" |
|
59185ffa861d
Add a clause to the PY_FORMAT_SIZE_T to stop warnings on 32 bit intel
Anthony Baxter <anthonybaxter@gmail.com>
parents:
37142
diff
changeset
|
223 # elif SIZEOF_SIZE_T == SIZEOF_LONG |
|
37037
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
224 # define PY_FORMAT_SIZE_T "l" |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
225 # 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
|
226 # 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
|
227 # else |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
228 # 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
|
229 # endif |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
230 #endif |
|
bfb74a420ac8
Introduced symbol PY_FORMAT_SIZE_T. See the new comments
Tim Peters <tim.peters@gmail.com>
parents:
36566
diff
changeset
|
231 |
|
57277
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
232 /* PY_FORMAT_LONG_LONG is analogous to PY_FORMAT_SIZE_T above, but for |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
233 * the long long type instead of the size_t type. It's only available |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
234 * when HAVE_LONG_LONG is defined. The "high level" Python format |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
235 * functions listed above will interpret "lld" or "llu" correctly on |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
236 * all platforms. |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
237 */ |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
238 #ifdef HAVE_LONG_LONG |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
239 # ifndef PY_FORMAT_LONG_LONG |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
240 # if defined(MS_WIN64) || defined(MS_WINDOWS) |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
241 # define PY_FORMAT_LONG_LONG "I64" |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
242 # else |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
243 # error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG" |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
244 # endif |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
245 # endif |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
246 #endif |
|
51028709abc3
Issue #7228: Add '%lld' and '%llu' support to PyFormat_FromString,
Mark Dickinson <dickinsm@gmail.com>
parents:
56721
diff
changeset
|
247 |
|
38425
ca657e0bd09c
needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents:
38350
diff
changeset
|
248 /* 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
|
249 * 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
|
250 * |
|
ca657e0bd09c
needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents:
38350
diff
changeset
|
251 * 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
|
252 * 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
|
253 * |
|
38425
ca657e0bd09c
needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
Fredrik Lundh <fredrik@pythonware.com>
parents:
38350
diff
changeset
|
254 * 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
|
255 * "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
|
256 * 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
|
257 * 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
|
258 * care. |
|
38350
3bef24086ace
needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
Fredrik Lundh <fredrik@pythonware.com>
parents:
38347
diff
changeset
|
259 * |
|
38347
6d8615f9f1cc
use Py_LOCAL also for string and unicode objects
Fredrik Lundh <fredrik@pythonware.com>
parents:
38345
diff
changeset
|
260 * 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
|
261 * 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
|
262 * should keep using static. |
|
6d8615f9f1cc
use Py_LOCAL also for string and unicode objects
Fredrik Lundh <fredrik@pythonware.com>
parents:
38345
diff
changeset
|
263 */ |
|
38345
fe653e22488c
needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents:
38298
diff
changeset
|
264 |
|
fe653e22488c
needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents:
38298
diff
changeset
|
265 #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
|
266 |
|
fe653e22488c
needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents:
38298
diff
changeset
|
267 #if defined(_MSC_VER) |
|
38350
3bef24086ace
needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
Fredrik Lundh <fredrik@pythonware.com>
parents:
38347
diff
changeset
|
268 #if defined(PY_LOCAL_AGGRESSIVE) |
|
3bef24086ace
needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
Fredrik Lundh <fredrik@pythonware.com>
parents:
38347
diff
changeset
|
269 /* 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
|
270 #pragma optimize("agtw", on) |
|
3bef24086ace
needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
Fredrik Lundh <fredrik@pythonware.com>
parents:
38347
diff
changeset
|
271 #endif |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
272 /* 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
|
273 #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
|
274 /* 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
|
275 #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
|
276 #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
|
277 #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
|
278 #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
|
279 #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
|
280 #else |
|
fe653e22488c
needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents:
38298
diff
changeset
|
281 #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
|
282 #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
|
283 #endif |
|
fe653e22488c
needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
Fredrik Lundh <fredrik@pythonware.com>
parents:
38298
diff
changeset
|
284 |
|
38457
551814e4b471
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents:
38425
diff
changeset
|
285 /* 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
|
286 * 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
|
287 * 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
|
288 * 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
|
289 */ |
|
551814e4b471
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents:
38425
diff
changeset
|
290 |
|
551814e4b471
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents:
38425
diff
changeset
|
291 #if defined(_MSC_VER) |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
292 #define Py_MEMCPY(target, source, length) do { \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
293 size_t i_, n_ = (length); \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
294 char *t_ = (void*) (target); \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
295 const char *s_ = (void*) (source); \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
296 if (n_ >= 16) \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
297 memcpy(t_, s_, n_); \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
298 else \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
299 for (i_ = 0; i_ < n_; i_++) \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
300 t_[i_] = s_[i_]; \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
301 } while (0) |
|
38457
551814e4b471
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents:
38425
diff
changeset
|
302 #else |
|
551814e4b471
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents:
38425
diff
changeset
|
303 #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
|
304 #endif |
|
551814e4b471
needforspeed: added Py_MEMCPY macro (currently tuned for Visual C only),
Fredrik Lundh <fredrik@pythonware.com>
parents:
38425
diff
changeset
|
305 |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
306 #include <stdlib.h> |
|
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
307 |
|
57485
297df77ba396
Include ieeefp.h (when available) in pyport.h instead of individually in
Mark Dickinson <dickinsm@gmail.com>
parents:
57330
diff
changeset
|
308 #ifdef HAVE_IEEEFP_H |
|
297df77ba396
Include ieeefp.h (when available) in pyport.h instead of individually in
Mark Dickinson <dickinsm@gmail.com>
parents:
57330
diff
changeset
|
309 #include <ieeefp.h> /* needed for 'finite' declaration on some platforms */ |
|
297df77ba396
Include ieeefp.h (when available) in pyport.h instead of individually in
Mark Dickinson <dickinsm@gmail.com>
parents:
57330
diff
changeset
|
310 #endif |
|
297df77ba396
Include ieeefp.h (when available) in pyport.h instead of individually in
Mark Dickinson <dickinsm@gmail.com>
parents:
57330
diff
changeset
|
311 |
|
13918
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
312 #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
|
313 |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
314 /******************************************** |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
315 * 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
|
316 ********************************************/ |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
317 |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
318 #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
|
319 #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
|
320 #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
|
321 #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
|
322 #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
|
323 #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
|
324 #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
|
325 #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
|
326 #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
|
327 #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
|
328 |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
329 |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
330 /****************************** |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
331 * 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
|
332 ******************************/ |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
333 |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
334 /* 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
|
335 |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
336 #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
|
337 |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
338 #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
|
339 |
|
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
340 #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
|
341 |
|
15978
24dafbb0db58
Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents:
15828
diff
changeset
|
342 /******************************* |
|
24dafbb0db58
Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents:
15828
diff
changeset
|
343 * 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
|
344 *******************************/ |
|
24dafbb0db58
Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents:
15828
diff
changeset
|
345 |
|
24dafbb0db58
Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents:
15828
diff
changeset
|
346 /* 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
|
347 * 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
|
348 * 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
|
349 * #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
|
350 * 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
|
351 * #define DONT_HAVE_FSTAT |
|
18845
876aecef6483
Repair more now-obsolete references to config.h.
Tim Peters <tim.peters@gmail.com>
parents:
18835
diff
changeset
|
352 * 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
|
353 * 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
|
354 * Also |
|
38716
42808526511c
Patch #1495999: Part two of Windows CE changes.
Martin v. Löwis <martin@v.loewis.de>
parents:
38457
diff
changeset
|
355 * #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
|
356 * 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
|
357 * #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
|
358 * 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
|
359 */ |
|
24dafbb0db58
Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents:
15828
diff
changeset
|
360 #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
|
361 #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
|
362 #endif |
|
24dafbb0db58
Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents:
15828
diff
changeset
|
363 |
|
24dafbb0db58
Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents:
15828
diff
changeset
|
364 #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
|
365 #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
|
366 #endif |
|
24dafbb0db58
Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents:
15828
diff
changeset
|
367 |
|
20654
edd9d0b3c47e
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20625
diff
changeset
|
368 #ifdef RISCOS |
|
edd9d0b3c47e
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20625
diff
changeset
|
369 #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
|
370 #include "unixstuff.h" |
|
20654
edd9d0b3c47e
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20625
diff
changeset
|
371 #endif |
|
edd9d0b3c47e
SF patch #474590 -- RISC OS support
Guido van Rossum <guido@python.org>
parents:
20625
diff
changeset
|
372 |
|
38716
42808526511c
Patch #1495999: Part two of Windows CE changes.
Martin v. Löwis <martin@v.loewis.de>
parents:
38457
diff
changeset
|
373 #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
|
374 #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
|
375 #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
|
376 #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
|
377 #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
|
378 #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
|
379 #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
|
380 #endif |
|
24dafbb0db58
Move distributed and duplicated config for stat() and fstat() into pyport.h.
Tim Peters <tim.peters@gmail.com>
parents:
15828
diff
changeset
|
381 |
|
19061
f51b13bf5d54
Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents:
19033
diff
changeset
|
382 #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
|
383 /* 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
|
384 #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
|
385 #endif |
|
f51b13bf5d54
Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents:
19033
diff
changeset
|
386 |
|
f51b13bf5d54
Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents:
19033
diff
changeset
|
387 #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
|
388 #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
|
389 #endif |
|
f51b13bf5d54
Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents:
19033
diff
changeset
|
390 |
|
f51b13bf5d54
Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents:
19033
diff
changeset
|
391 #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
|
392 #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
|
393 #endif |
|
f51b13bf5d54
Put conditional S_ISDIR definition(s) into pyport.h.
Martin v. Löwis <martin@v.loewis.de>
parents:
19033
diff
changeset
|
394 |
|
13918
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
395 |
|
13423
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
396 #ifdef __cplusplus |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
397 /* 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
|
398 inside an extern "C" */ |
|
13423
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
399 extern "C" { |
|
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 |
|
13918
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
402 |
|
13423
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
403 /* Py_ARITHMETIC_RIGHT_SHIFT |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
404 * 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
|
405 * 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
|
406 * 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
|
407 * 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
|
408 * floor of I/2**J. |
|
13423
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
409 * 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
|
410 * 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
|
411 * 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
|
412 * 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
|
413 * 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
|
414 * 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
|
415 * 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
|
416 * 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
|
417 * 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
|
418 * Caution: |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
419 * I may be evaluated more than once. |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
420 */ |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
421 #ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
422 #define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \ |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
423 ((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
|
424 #else |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
425 #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
|
426 #endif |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
427 |
|
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
|
428 /* Py_FORCE_EXPANSION(X) |
|
13671
26685bd2c09e
Recent ANSIfication introduced a couple instances of
Tim Peters <tim.peters@gmail.com>
parents:
13489
diff
changeset
|
429 * "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
|
430 * 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
|
431 * 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
|
432 */ |
|
26685bd2c09e
Recent ANSIfication introduced a couple instances of
Tim Peters <tim.peters@gmail.com>
parents:
13489
diff
changeset
|
433 #define Py_FORCE_EXPANSION(X) X |
|
26685bd2c09e
Recent ANSIfication introduced a couple instances of
Tim Peters <tim.peters@gmail.com>
parents:
13489
diff
changeset
|
434 |
|
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
|
435 /* 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
|
436 * 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
|
437 * 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
|
438 * 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
|
439 * 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
|
440 */ |
|
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
|
441 #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
|
442 #define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
443 (assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE)) |
|
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
|
444 #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
|
445 #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
|
446 #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
|
447 |
|
31763
3473dea3aa4c
Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31504
diff
changeset
|
448 /* 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
|
449 * 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
|
450 * 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
|
451 * 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
|
452 * 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
|
453 * 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
|
454 * 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
|
455 * 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
|
456 */ |
| 35549 | 457 #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
|
458 #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
|
459 #else |
|
3473dea3aa4c
Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31504
diff
changeset
|
460 #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
|
461 #endif |
|
3473dea3aa4c
Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31504
diff
changeset
|
462 #define Py_SET_ERRNO_ON_MATH_ERROR(X) \ |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
463 do { \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
464 if (errno == 0) { \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
465 if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
466 errno = ERANGE; \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
467 else _Py_SET_EDOM_FOR_NAN(X) \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
468 } \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
469 } 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
|
470 |
|
31763
3473dea3aa4c
Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31504
diff
changeset
|
471 /* 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
|
472 * 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
|
473 */ |
|
3473dea3aa4c
Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31504
diff
changeset
|
474 #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
|
475 |
|
22201
ad81f8fb4ee4
SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents:
22112
diff
changeset
|
476 /* Py_ADJUST_ERANGE1(x) |
|
ad81f8fb4ee4
SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents:
22112
diff
changeset
|
477 * Py_ADJUST_ERANGE2(x, y) |
|
ad81f8fb4ee4
SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents:
22112
diff
changeset
|
478 * 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
|
479 * 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
|
480 * 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
|
481 * 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
|
482 * 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
|
483 * 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
|
484 * 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
|
485 * behavior. |
|
ad81f8fb4ee4
SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents:
22112
diff
changeset
|
486 * Caution: |
|
ad81f8fb4ee4
SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents:
22112
diff
changeset
|
487 * 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
|
488 * 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
|
489 */ |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
490 #define Py_ADJUST_ERANGE1(X) \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
491 do { \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
492 if (errno == 0) { \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
493 if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
494 errno = ERANGE; \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
495 } \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
496 else if (errno == ERANGE && (X) == 0.0) \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
497 errno = 0; \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
498 } while(0) |
|
22201
ad81f8fb4ee4
SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents:
22112
diff
changeset
|
499 |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
500 #define Py_ADJUST_ERANGE2(X, Y) \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
501 do { \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
502 if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
503 (Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
504 if (errno == 0) \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
505 errno = ERANGE; \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
506 } \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
507 else if (errno == ERANGE) \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
508 errno = 0; \ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
509 } while(0) |
|
22201
ad81f8fb4ee4
SF bug 525705: [2.2] underflow raise OverflowException.
Tim Peters <tim.peters@gmail.com>
parents:
22112
diff
changeset
|
510 |
|
56707
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
511 /* The functions _Py_dg_strtod and _Py_dg_dtoa in Python/dtoa.c (which are |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
512 * required to support the short float repr introduced in Python 3.1) require |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
513 * that the floating-point unit that's being used for arithmetic operations |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
514 * on C doubles is set to use 53-bit precision. It also requires that the |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
515 * FPU rounding mode is round-half-to-even, but that's less often an issue. |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
516 * |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
517 * If your FPU isn't already set to 53-bit precision/round-half-to-even, and |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
518 * you want to make use of _Py_dg_strtod and _Py_dg_dtoa, then you should |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
519 * |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
520 * #define HAVE_PY_SET_53BIT_PRECISION 1 |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
521 * |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
522 * and also give appropriate definitions for the following three macros: |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
523 * |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
524 * _PY_SET_53BIT_PRECISION_START : store original FPU settings, and |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
525 * set FPU to 53-bit precision/round-half-to-even |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
526 * _PY_SET_53BIT_PRECISION_END : restore original FPU settings |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
527 * _PY_SET_53BIT_PRECISION_HEADER : any variable declarations needed to |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
528 * use the two macros above. |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
529 * |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
530 * The macros are designed to be used within a single C function: see |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
531 * Python/pystrtod.c for an example of their use. |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
532 */ |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
533 |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
534 /* get and set x87 control word for gcc/x86 */ |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
535 #ifdef HAVE_GCC_ASM_FOR_X87 |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
536 #define HAVE_PY_SET_53BIT_PRECISION 1 |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
537 /* _Py_get/set_387controlword functions are defined in Python/pymath.c */ |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
538 #define _Py_SET_53BIT_PRECISION_HEADER \ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
539 unsigned short old_387controlword, new_387controlword |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
540 #define _Py_SET_53BIT_PRECISION_START \ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
541 do { \ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
542 old_387controlword = _Py_get_387controlword(); \ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
543 new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
544 if (new_387controlword != old_387controlword) \ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
545 _Py_set_387controlword(new_387controlword); \ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
546 } while (0) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
547 #define _Py_SET_53BIT_PRECISION_END \ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
548 if (new_387controlword != old_387controlword) \ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
60685
diff
changeset
|
549 _Py_set_387controlword(old_387controlword) |
|
56707
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
550 #endif |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
551 |
|
76322
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
552 /* get and set x87 control word for VisualStudio/x86 */ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
553 #if defined(_MSC_VER) && !defined(_WIN64) /* x87 not supported in 64-bit */ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
554 #define HAVE_PY_SET_53BIT_PRECISION 1 |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
555 #define _Py_SET_53BIT_PRECISION_HEADER \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
556 unsigned int old_387controlword, new_387controlword, out_387controlword |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
557 /* We use the __control87_2 function to set only the x87 control word. |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
558 The SSE control word is unaffected. */ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
559 #define _Py_SET_53BIT_PRECISION_START \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
560 do { \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
561 __control87_2(0, 0, &old_387controlword, NULL); \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
562 new_387controlword = \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
563 (old_387controlword & ~(_MCW_PC | _MCW_RC)) | (_PC_53 | _RC_NEAR); \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
564 if (new_387controlword != old_387controlword) \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
565 __control87_2(new_387controlword, _MCW_PC | _MCW_RC, \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
566 &out_387controlword, NULL); \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
567 } while (0) |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
568 #define _Py_SET_53BIT_PRECISION_END \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
569 do { \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
570 if (new_387controlword != old_387controlword) \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
571 __control87_2(old_387controlword, _MCW_PC | _MCW_RC, \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
572 &out_387controlword, NULL); \ |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
573 } while (0) |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
574 #endif |
|
bf3b77722c9f
Issue #13889: On MSVC builds, set FPU control word at runtime for all string <-> float conversions. Patch by Samuel Iseli and Stefan Krah.
Mark Dickinson <mdickinson@enthought.com>
parents:
68256
diff
changeset
|
575 |
|
56707
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
576 /* default definitions are empty */ |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
577 #ifndef HAVE_PY_SET_53BIT_PRECISION |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
578 #define _Py_SET_53BIT_PRECISION_HEADER |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
579 #define _Py_SET_53BIT_PRECISION_START |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
580 #define _Py_SET_53BIT_PRECISION_END |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
581 #endif |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
582 |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
583 /* If we can't guarantee 53-bit precision, don't use the code |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
584 in Python/dtoa.c, but fall back to standard code. This |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
585 means that repr of a float will be long (17 sig digits). |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
586 |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
587 Realistically, there are two things that could go wrong: |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
588 |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
589 (1) doubles aren't IEEE 754 doubles, or |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
590 (2) we're on x86 with the rounding precision set to 64-bits |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
591 (extended precision), and we don't know how to change |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
592 the rounding precision. |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
593 */ |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
594 |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
595 #if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \ |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
596 !defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \ |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
597 !defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754) |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
598 #define PY_NO_SHORT_FLOAT_REPR |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
599 #endif |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
600 |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
601 /* double rounding is symptomatic of use of extended precision on x86. If |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
602 we're seeing double rounding, and we don't have any mechanism available for |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
603 changing the FPU rounding precision, then don't use Python/dtoa.c. */ |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
604 #if defined(X87_DOUBLE_ROUNDING) && !defined(HAVE_PY_SET_53BIT_PRECISION) |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
605 #define PY_NO_SHORT_FLOAT_REPR |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
606 #endif |
|
2ab08c919648
Issue #7117 (backport py3k float repr) continued:
Mark Dickinson <dickinsm@gmail.com>
parents:
54990
diff
changeset
|
607 |
|
26714
2f523ae90e06
Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents:
25276
diff
changeset
|
608 /* Py_DEPRECATED(version) |
| 26715 | 609 * 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
|
610 * Usage: |
|
2f523ae90e06
Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents:
25276
diff
changeset
|
611 * 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
|
612 * 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
|
613 * 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
|
614 */ |
|
37101
2dc63cdb09cf
Get Py_DEPRECATED to work with gcc 4.x too
Neal Norwitz <nnorwitz@gmail.com>
parents:
37037
diff
changeset
|
615 #if defined(__GNUC__) && ((__GNUC__ >= 4) || \ |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
616 (__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
|
617 #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
|
618 #else |
|
26815
8eccfae04bb4
Apparently FreeBSD enables some HW floating-point exceptions by default.
Tim Peters <tim.peters@gmail.com>
parents:
26715
diff
changeset
|
619 #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
|
620 #endif |
|
2f523ae90e06
Provide mechanism to deprecate functions, types, and struct members.
Neal Norwitz <nnorwitz@gmail.com>
parents:
25276
diff
changeset
|
621 |
|
13694
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
622 /************************************************************************** |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
623 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
|
624 (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
|
625 |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
626 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
|
627 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
|
628 **************************************************************************/ |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
629 |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
630 #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
|
631 /* Unchecked */ |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
632 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
|
633 #endif |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
634 |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
635 #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
|
636 /* Unchecked */ |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
637 /* 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
|
638 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
|
639 #endif |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
640 |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
641 #ifdef HAVE__GETPTY |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
642 #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
|
643 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
|
644 #endif |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
645 |
|
47227
5ec9528c93de
Patch #1722225: Support QNX 6.
Martin v. Löwis <martin@v.loewis.de>
parents:
46473
diff
changeset
|
646 /* 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
|
647 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
|
648 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
|
649 #ifdef HAVE_SYS_TERMIO_H |
|
5ec9528c93de
Patch #1722225: Support QNX 6.
Martin v. Löwis <martin@v.loewis.de>
parents:
46473
diff
changeset
|
650 #include <sys/termio.h> |
|
5ec9528c93de
Patch #1722225: Support QNX 6.
Martin v. Löwis <martin@v.loewis.de>
parents:
46473
diff
changeset
|
651 #endif |
|
5ec9528c93de
Patch #1722225: Support QNX 6.
Martin v. Löwis <martin@v.loewis.de>
parents:
46473
diff
changeset
|
652 |
|
13694
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
653 #if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) |
|
58397
0c8cbdbafaad
- Issue #7658: Ensure that the new pythonw executable works on OSX 10.4
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
57485
diff
changeset
|
654 #if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) && !defined(HAVE_UTIL_H) |
|
13694
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
655 /* 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
|
656 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
|
657 #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
|
658 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
|
659 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
|
660 #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
|
661 #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
|
662 |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
663 |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
664 /* 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
|
665 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
|
666 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
|
667 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
|
668 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
|
669 #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
|
670 |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
671 /* 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
|
672 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
|
673 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
|
674 |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
675 /* 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
|
676 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
|
677 |
|
b54f11ada91e
Create a new section of pyport.h to hold all external function declarations
Thomas Wouters <thomas@python.org>
parents:
13676
diff
changeset
|
678 /* 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
|
679 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
|
680 #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
|
681 |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
682 |
|
37142
7049dc0c621a
Remove false information from the comment and reformat it like other
Hye-Shik Chang <hyeshik@gmail.com>
parents:
37101
diff
changeset
|
683 /* 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
|
684 * 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
|
685 * 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
|
686 * 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
|
687 * 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
|
688 */ |
|
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
|
689 |
|
adfe7d39a049
Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32695
diff
changeset
|
690 #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
|
691 #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
|
692 #if __FreeBSD_version > 500039 |
|
60687
6cb1c4804f9c
Merged revisions 80178 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
50786
diff
changeset
|
693 # define _PY_PORT_CTYPE_UTF8_ISSUE |
|
6cb1c4804f9c
Merged revisions 80178 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
50786
diff
changeset
|
694 #endif |
|
6cb1c4804f9c
Merged revisions 80178 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
50786
diff
changeset
|
695 #endif |
|
6cb1c4804f9c
Merged revisions 80178 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
50786
diff
changeset
|
696 |
|
6cb1c4804f9c
Merged revisions 80178 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
50786
diff
changeset
|
697 |
|
6cb1c4804f9c
Merged revisions 80178 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
50786
diff
changeset
|
698 #if defined(__APPLE__) |
|
6cb1c4804f9c
Merged revisions 80178 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
50786
diff
changeset
|
699 # define _PY_PORT_CTYPE_UTF8_ISSUE |
|
6cb1c4804f9c
Merged revisions 80178 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
50786
diff
changeset
|
700 #endif |
|
6cb1c4804f9c
Merged revisions 80178 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
50786
diff
changeset
|
701 |
|
6cb1c4804f9c
Merged revisions 80178 via svnmerge from
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
50786
diff
changeset
|
702 #ifdef _PY_PORT_CTYPE_UTF8_ISSUE |
|
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
|
703 #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
|
704 #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
|
705 #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
|
706 #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
|
707 #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
|
708 #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
|
709 #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
|
710 #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
|
711 #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
|
712 #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
|
713 #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
|
714 #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
|
715 #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
|
716 #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
|
717 #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
|
718 #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
|
719 #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
|
720 |
|
adfe7d39a049
Add a workaround for a problem that UTF-8 strings can be corrupted
Hye-Shik Chang <hyeshik@gmail.com>
parents:
32695
diff
changeset
|
721 |
|
24315
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
722 /* Declarations for symbol visibility. |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
723 |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
724 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
|
725 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
|
726 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
|
727 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
|
728 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
|
729 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
|
730 |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
731 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
|
732 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
|
733 */ |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
734 |
|
26815
8eccfae04bb4
Apparently FreeBSD enables some HW floating-point exceptions by default.
Tim Peters <tim.peters@gmail.com>
parents:
26715
diff
changeset
|
735 /* |
|
27802
372e3483d327
Make comments agree with code (I think).
Michael W. Hudson <mwh@python.net>
parents:
27104
diff
changeset
|
736 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
|
737 |
|
372e3483d327
Make comments agree with code (I think).
Michael W. Hudson <mwh@python.net>
parents:
27104
diff
changeset
|
738 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
|
739 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
|
740 */ |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
741 #if defined(__CYGWIN__) || defined(__BEOS__) |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
742 # define HAVE_DECLSPEC_DLL |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
743 #endif |
|
24315
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
744 |
|
30310
74bc3493ce03
This patch enables the building of Cygwin Python with a static core
Jason Tishler <jason@tishler.net>
parents:
29066
diff
changeset
|
745 /* 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
|
746 #if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
747 # if defined(HAVE_DECLSPEC_DLL) |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
748 # ifdef Py_BUILD_CORE |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
749 # define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
750 # define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE |
|
64746
eded0caee621
Merged revisions 84810 via svnmerge from
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
61463
diff
changeset
|
751 /* module init functions inside the core need no external linkage */ |
|
eded0caee621
Merged revisions 84810 via svnmerge from
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
61463
diff
changeset
|
752 /* except for Cygwin to handle embedding (FIXME: BeOS too?) */ |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
753 # if defined(__CYGWIN__) |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
754 # define PyMODINIT_FUNC __declspec(dllexport) void |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
755 # else /* __CYGWIN__ */ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
756 # define PyMODINIT_FUNC void |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
757 # endif /* __CYGWIN__ */ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
758 # else /* Py_BUILD_CORE */ |
|
64746
eded0caee621
Merged revisions 84810 via svnmerge from
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
61463
diff
changeset
|
759 /* Building an extension module, or an embedded situation */ |
|
eded0caee621
Merged revisions 84810 via svnmerge from
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
61463
diff
changeset
|
760 /* public Python functions and data are imported */ |
|
eded0caee621
Merged revisions 84810 via svnmerge from
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
61463
diff
changeset
|
761 /* Under Cygwin, auto-import functions to prevent compilation */ |
|
eded0caee621
Merged revisions 84810 via svnmerge from
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
61463
diff
changeset
|
762 /* failures similar to those described at the bottom of 4.1: */ |
|
eded0caee621
Merged revisions 84810 via svnmerge from
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
61463
diff
changeset
|
763 /* http://docs.python.org/extending/windows.html#a-cookbook-approach */ |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
764 # if !defined(__CYGWIN__) |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
765 # define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
766 # endif /* !__CYGWIN__ */ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
767 # define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE |
|
64746
eded0caee621
Merged revisions 84810 via svnmerge from
Daniel Stutzbach <daniel@stutzbachenterprises.com>
parents:
61463
diff
changeset
|
768 /* module init functions outside the core must be exported */ |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
769 # if defined(__cplusplus) |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
770 # define PyMODINIT_FUNC extern "C" __declspec(dllexport) void |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
771 # else /* __cplusplus */ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
772 # define PyMODINIT_FUNC __declspec(dllexport) void |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
773 # endif /* __cplusplus */ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
774 # endif /* Py_BUILD_CORE */ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
775 # endif /* HAVE_DECLSPEC */ |
|
24315
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
776 #endif /* Py_ENABLE_SHARED */ |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
777 |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
778 /* 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
|
779 #ifndef PyAPI_FUNC |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
780 # define PyAPI_FUNC(RTYPE) RTYPE |
|
24315
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
781 #endif |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
782 #ifndef PyAPI_DATA |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
783 # 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
|
784 #endif |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
785 #ifndef PyMODINIT_FUNC |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
786 # if defined(__cplusplus) |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
787 # define PyMODINIT_FUNC extern "C" void |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
788 # else /* __cplusplus */ |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
789 # define PyMODINIT_FUNC void |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
790 # endif /* __cplusplus */ |
|
24315
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
791 #endif |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
792 |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
793 /* 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
|
794 #if defined(Py_ENABLE_SHARED) && defined (HAVE_DECLSPEC_DLL) |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
795 # if defined(Py_BUILD_CORE) |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
796 # define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
797 # define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
798 # else |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
799 # define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
800 # define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
801 # endif |
|
24315
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
802 #endif |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
803 #ifndef DL_EXPORT |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
804 # define DL_EXPORT(RTYPE) RTYPE |
|
24315
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
805 #endif |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
806 #ifndef DL_IMPORT |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
807 # define DL_IMPORT(RTYPE) RTYPE |
|
24315
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
808 #endif |
|
a8df0c0be242
Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.
Mark Hammond <mhammond@skippinet.com.au>
parents:
24104
diff
changeset
|
809 /* 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
|
810 |
|
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
811 /* 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
|
812 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
|
813 |
|
13790
c66e991b5f21
Of course, you meant "#if 0" and not "#ifdef 0". :)
Guido van Rossum <guido@python.org>
parents:
13786
diff
changeset
|
814 #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
|
815 |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
816 #ifndef FD_SETSIZE |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
817 #define FD_SETSIZE 256 |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
818 #endif |
|
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
819 |
|
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
820 #ifndef FD_SET |
|
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
821 |
|
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
822 typedef long fd_mask; |
|
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
823 |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
824 #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
825 #ifndef howmany |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
826 #define howmany(x, y) (((x)+((y)-1))/(y)) |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
827 #endif /* howmany */ |
|
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
828 |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
829 typedef struct fd_set { |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
830 fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
831 } fd_set; |
|
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
832 |
|
61465
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
833 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
834 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
835 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) |
|
e38335d4df91
Recorded merge of revisions 81029 via svnmerge from
Antoine Pitrou <solipsis@pitrou.net>
parents:
60687
diff
changeset
|
836 #define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p))) |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
837 |
|
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13719
diff
changeset
|
838 #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
|
839 |
|
f1290aba29da
Guido said this is food for the beta-testers<wink>
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13776
diff
changeset
|
840 #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
|
841 |
|
13918
08092d1eb26a
#include reordering so that extern "C" does not interfere with
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
13912
diff
changeset
|
842 |
|
14869
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
843 /* 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
|
844 |
|
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
845 #ifndef INT_MAX |
|
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
846 #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
|
847 #endif |
|
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
848 |
|
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
849 #ifndef LONG_MAX |
|
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
850 #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
|
851 #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
|
852 #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
|
853 #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
|
854 #else |
|
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
855 #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
|
856 #endif |
|
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
857 #endif |
|
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
858 |
|
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
859 #ifndef LONG_MIN |
|
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
860 #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
|
861 #endif |
|
25ddd3dc7a7a
Rationalize use of limits.h, moving the inclusion to Python.h.
Fred Drake <fdrake@acm.org>
parents:
14497
diff
changeset
|
862 |
|
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
|
863 #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
|
864 #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
|
865 #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
|
866 |
|
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
|
867 #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
|
868 /* 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
|
869 * 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
|
870 * 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
|
871 * 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
|
872 */ |
|
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
|
873 #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
|
874 #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
|
875 |
|
13423
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
876 #ifdef __cplusplus |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
877 } |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
878 #endif |
|
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
879 |
|
20625
2c1a4584a704
Hide GCC attributes fom compilers that don't support them.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
20209
diff
changeset
|
880 /* |
|
2c1a4584a704
Hide GCC attributes fom compilers that don't support them.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
20209
diff
changeset
|
881 * 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
|
882 */ |
|
20726
587b74854f8c
SF patch #475657 (Dietmar Schwertberger)
Guido van Rossum <guido@python.org>
parents:
20654
diff
changeset
|
883 #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
|
884 (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) && \ |
|
20726
587b74854f8c
SF patch #475657 (Dietmar Schwertberger)
Guido van Rossum <guido@python.org>
parents:
20654
diff
changeset
|
885 !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
|
886 #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
|
887 #else |
|
6c21e95a4881
Use Py_GCC_ATTRIBUTE instead of __attribute__. Compilers other than GCC
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
24420
diff
changeset
|
888 #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
|
889 #endif |
|
2c1a4584a704
Hide GCC attributes fom compilers that don't support them.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
20209
diff
changeset
|
890 |
|
40151
410c1c78ed51
Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents:
39950
diff
changeset
|
891 /* |
|
410c1c78ed51
Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents:
39950
diff
changeset
|
892 * 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
|
893 */ |
|
410c1c78ed51
Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents:
39950
diff
changeset
|
894 #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
|
895 #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
|
896 #else |
|
410c1c78ed51
Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents:
39950
diff
changeset
|
897 #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
|
898 #endif |
|
410c1c78ed51
Add check for the PyArg_ParseTuple format, and declare
Martin v. Löwis <martin@v.loewis.de>
parents:
39950
diff
changeset
|
899 |
|
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
|
900 /* |
|
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
|
901 * 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
|
902 */ |
|
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
|
903 #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
|
904 #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
|
905 #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
|
906 #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
|
907 #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
|
908 |
|
32695
ff26714bf86d
Moved SunPro warning suppression into pyport.h and out of individual
Nicholas Bastin <nick.bastin@gmail.com>
parents:
31763
diff
changeset
|
909 /* 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
|
910 * 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
|
911 */ |
|
ff26714bf86d
Moved SunPro warning suppression into pyport.h and out of individual
Nicholas Bastin <nick.bastin@gmail.com>
parents:
31763
diff
changeset
|
912 #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
|
913 #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
|
914 #endif |
|
ff26714bf86d
Moved SunPro warning suppression into pyport.h and out of individual
Nicholas Bastin <nick.bastin@gmail.com>
parents:
31763
diff
changeset
|
915 |
|
38232
aa620856e8a3
Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents:
37496
diff
changeset
|
916 /* |
|
aa620856e8a3
Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents:
37496
diff
changeset
|
917 * 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
|
918 * 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
|
919 */ |
|
aa620856e8a3
Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents:
37496
diff
changeset
|
920 #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
|
921 #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
|
922 #endif |
|
aa620856e8a3
Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents:
37496
diff
changeset
|
923 |
|
aa620856e8a3
Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents:
37496
diff
changeset
|
924 #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
|
925 #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
|
926 #endif |
|
aa620856e8a3
Patch #1492356: Port to Windows CE (patch set 1).
Martin v. Löwis <martin@v.loewis.de>
parents:
37496
diff
changeset
|
927 |
|
13423
a87803eb9dfb
Cray J90 fixes for long ints.
Tim Peters <tim.peters@gmail.com>
parents:
diff
changeset
|
928 #endif /* Py_PYPORT_H */ |
