Mercurial > cpython-lru_cache-weakref
annotate Python/thread.c @ 19601:04fd3869c6bb legacy-trunk
Removed unreachable goto statement to silence SGI compiler.
| author | Sjoerd Mullender <sjoerd@acm.org> |
|---|---|
| date | Thu, 30 Aug 2001 14:06:45 +0000 |
| parents | 876aecef6483 |
| children | ebfd87e87884 |
| rev | line source |
|---|---|
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
1 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
2 /* Thread package. |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
3 This is intended to be usable independently from Python. |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
4 The implementation for system foobar is in a file thread_foobar.h |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
5 which is included by this file dependent on config settings. |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
6 Stuff shared by all thread_*.h files is collected here. */ |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
7 |
|
18835
2dea40e40d9d
Patch #411138: Rename config.h to pyconfig.h. Closes bug #231774.
Martin v. Löwis <martin@v.loewis.de>
parents:
15047
diff
changeset
|
8 #include "pyconfig.h" |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
9 |
|
18845
876aecef6483
Repair more now-obsolete references to config.h.
Tim Peters <tim.peters@gmail.com>
parents:
18835
diff
changeset
|
10 /* pyconfig.h may or may not define DL_IMPORT */ |
|
9589
01c8fe44064b
Need to add default decl of DL_IMPORT, for mymalloc.h
Guido van Rossum <guido@python.org>
parents:
9203
diff
changeset
|
11 #ifndef DL_IMPORT /* declarations for DLL import/export */ |
|
01c8fe44064b
Need to add default decl of DL_IMPORT, for mymalloc.h
Guido van Rossum <guido@python.org>
parents:
9203
diff
changeset
|
12 #define DL_IMPORT(RTYPE) RTYPE |
|
01c8fe44064b
Need to add default decl of DL_IMPORT, for mymalloc.h
Guido van Rossum <guido@python.org>
parents:
9203
diff
changeset
|
13 #endif |
|
01c8fe44064b
Need to add default decl of DL_IMPORT, for mymalloc.h
Guido van Rossum <guido@python.org>
parents:
9203
diff
changeset
|
14 |
|
10530
d834ecdf8c26
Changes by Mark Hammond for Windows CE. Mostly of the form
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
15 #ifndef DONT_HAVE_STDIO_H |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
16 #include <stdio.h> |
|
10530
d834ecdf8c26
Changes by Mark Hammond for Windows CE. Mostly of the form
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
17 #endif |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
18 |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
19 #ifdef HAVE_STDLIB_H |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
20 #include <stdlib.h> |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
21 #else |
|
10530
d834ecdf8c26
Changes by Mark Hammond for Windows CE. Mostly of the form
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
22 #ifdef Py_DEBUG |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13256
diff
changeset
|
23 extern char *getenv(const char *); |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
24 #endif |
|
10530
d834ecdf8c26
Changes by Mark Hammond for Windows CE. Mostly of the form
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
25 #endif |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
26 |
| 4596 | 27 #ifdef HAVE_UNISTD_H |
| 28 #include <unistd.h> | |
| 29 #endif | |
| 30 | |
|
5599
b5e51ae9f832
DG/UX thread patches (Ross Andrus)
Guido van Rossum <guido@python.org>
parents:
5381
diff
changeset
|
31 #ifdef __DGUX |
|
b5e51ae9f832
DG/UX thread patches (Ross Andrus)
Guido van Rossum <guido@python.org>
parents:
5381
diff
changeset
|
32 #define _USING_POSIX4A_DRAFT6 |
|
b5e51ae9f832
DG/UX thread patches (Ross Andrus)
Guido van Rossum <guido@python.org>
parents:
5381
diff
changeset
|
33 #endif |
|
b5e51ae9f832
DG/UX thread patches (Ross Andrus)
Guido van Rossum <guido@python.org>
parents:
5381
diff
changeset
|
34 |
|
5381
339d4129d3f7
Ugly hack for SGI IRIX 6.2. Apparently _POSIX_THREADS is defined even
Guido van Rossum <guido@python.org>
parents:
4839
diff
changeset
|
35 #ifdef __sgi |
|
339d4129d3f7
Ugly hack for SGI IRIX 6.2. Apparently _POSIX_THREADS is defined even
Guido van Rossum <guido@python.org>
parents:
4839
diff
changeset
|
36 #ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.in */ |
|
339d4129d3f7
Ugly hack for SGI IRIX 6.2. Apparently _POSIX_THREADS is defined even
Guido van Rossum <guido@python.org>
parents:
4839
diff
changeset
|
37 #undef _POSIX_THREADS |
|
339d4129d3f7
Ugly hack for SGI IRIX 6.2. Apparently _POSIX_THREADS is defined even
Guido van Rossum <guido@python.org>
parents:
4839
diff
changeset
|
38 #endif |
|
339d4129d3f7
Ugly hack for SGI IRIX 6.2. Apparently _POSIX_THREADS is defined even
Guido van Rossum <guido@python.org>
parents:
4839
diff
changeset
|
39 #endif |
|
339d4129d3f7
Ugly hack for SGI IRIX 6.2. Apparently _POSIX_THREADS is defined even
Guido van Rossum <guido@python.org>
parents:
4839
diff
changeset
|
40 |
|
9203
07dae6fdae79
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
41 #include "pythread.h" |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
43 #ifdef __ksr__ |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
44 #define _POSIX_THREADS |
|
961
a31e07847063
New thread.c from Sjoerd, supports _exit_prog(). Use this in goaway()
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
45 #endif |
|
a31e07847063
New thread.c from Sjoerd, supports _exit_prog(). Use this in goaway()
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
46 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
47 #ifndef _POSIX_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
48 |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 #ifdef __sgi |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
50 #define SGI_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
51 #endif |
|
961
a31e07847063
New thread.c from Sjoerd, supports _exit_prog(). Use this in goaway()
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
52 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
53 #ifdef HAVE_THREAD_H |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
54 #define SOLARIS_THREADS |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 #endif |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
57 #if defined(sun) && !defined(SOLARIS_THREADS) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
58 #define SUN_LWP |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
59 #endif |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
60 |
|
15047
457f0df46dd9
Donn Cave <donn@u.washington.edu>:
Fred Drake <fdrake@acm.org>
parents:
14674
diff
changeset
|
61 #if defined(__MWERKS__) && !defined(__BEOS__) |
|
12475
c27f484aefff
Jack Jansen: Posix threads are now supported on the Macintosh too.
Guido van Rossum <guido@python.org>
parents:
10530
diff
changeset
|
62 #define _POSIX_THREADS |
|
c27f484aefff
Jack Jansen: Posix threads are now supported on the Macintosh too.
Guido van Rossum <guido@python.org>
parents:
10530
diff
changeset
|
63 #endif |
|
c27f484aefff
Jack Jansen: Posix threads are now supported on the Macintosh too.
Guido van Rossum <guido@python.org>
parents:
10530
diff
changeset
|
64 |
| 1418 | 65 #endif /* _POSIX_THREADS */ |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 |
|
4839
4567e158d20c
Rename DEBUG macro to Py_DEBUG
Guido van Rossum <guido@python.org>
parents:
4596
diff
changeset
|
68 #ifdef Py_DEBUG |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
69 static int thread_debug = 0; |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
70 #define dprintf(args) ((thread_debug & 1) && printf args) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
71 #define d2printf(args) ((thread_debug & 8) && printf args) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
72 #else |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
73 #define dprintf(args) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
74 #define d2printf(args) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
75 #endif |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
76 |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 static int initialized; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 |
|
13689
9db86b27278f
Prototype yet another forward declaration.
Thomas Wouters <thomas@python.org>
parents:
13658
diff
changeset
|
79 static void PyThread__init_thread(void); /* Forward */ |
|
1004
5d7142ea01b7
adapted SV module to the new svideo library.
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
80 |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13256
diff
changeset
|
81 void PyThread_init_thread(void) |
|
1004
5d7142ea01b7
adapted SV module to the new svideo library.
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
82 { |
|
4839
4567e158d20c
Rename DEBUG macro to Py_DEBUG
Guido van Rossum <guido@python.org>
parents:
4596
diff
changeset
|
83 #ifdef Py_DEBUG |
| 1418 | 84 char *p = getenv("THREADDEBUG"); |
| 85 | |
| 86 if (p) { | |
| 87 if (*p) | |
| 88 thread_debug = atoi(p); | |
| 89 else | |
| 90 thread_debug = 1; | |
| 91 } | |
|
4839
4567e158d20c
Rename DEBUG macro to Py_DEBUG
Guido van Rossum <guido@python.org>
parents:
4596
diff
changeset
|
92 #endif /* Py_DEBUG */ |
|
1004
5d7142ea01b7
adapted SV module to the new svideo library.
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
93 if (initialized) |
|
5d7142ea01b7
adapted SV module to the new svideo library.
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
94 return; |
|
5d7142ea01b7
adapted SV module to the new svideo library.
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
95 initialized = 1; |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
9589
diff
changeset
|
96 dprintf(("PyThread_init_thread called\n")); |
|
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
9589
diff
changeset
|
97 PyThread__init_thread(); |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
100 #ifdef SGI_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
101 #include "thread_sgi.h" |
| 1418 | 102 #endif |
|
961
a31e07847063
New thread.c from Sjoerd, supports _exit_prog(). Use this in goaway()
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
103 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
104 #ifdef SOLARIS_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
105 #include "thread_solaris.h" |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 #endif |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
107 |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
108 #ifdef SUN_LWP |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
109 #include "thread_lwp.h" |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 #endif |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 |
|
14674
756c8c6535fe
Make better use of GNU Pth -- patch by Andy Dustman.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
112 #ifdef HAVE_PTH |
|
12611
b320cf3a98b9
Andy Dustman: add GNU pth user-space thread support.
Guido van Rossum <guido@python.org>
parents:
12475
diff
changeset
|
113 #include "thread_pth.h" |
|
14674
756c8c6535fe
Make better use of GNU Pth -- patch by Andy Dustman.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
114 #undef _POSIX_THREADS |
|
756c8c6535fe
Make better use of GNU Pth -- patch by Andy Dustman.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
115 #endif |
|
756c8c6535fe
Make better use of GNU Pth -- patch by Andy Dustman.
Guido van Rossum <guido@python.org>
parents:
14375
diff
changeset
|
116 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
117 #ifdef _POSIX_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
118 #include "thread_pthread.h" |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 #endif |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
121 #ifdef C_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
122 #include "thread_cthread.h" |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
123 #endif |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 |
| 2152 | 125 #ifdef NT_THREADS |
| 126 #include "thread_nt.h" | |
| 127 #endif | |
| 128 | |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
5599
diff
changeset
|
129 #ifdef OS2_THREADS |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
5599
diff
changeset
|
130 #include "thread_os2.h" |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
5599
diff
changeset
|
131 #endif |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
5599
diff
changeset
|
132 |
|
8822
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
133 #ifdef BEOS_THREADS |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
134 #include "thread_beos.h" |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
135 #endif |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
136 |
|
10530
d834ecdf8c26
Changes by Mark Hammond for Windows CE. Mostly of the form
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
137 #ifdef WINCE_THREADS |
|
d834ecdf8c26
Changes by Mark Hammond for Windows CE. Mostly of the form
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
138 #include "thread_wince.h" |
|
d834ecdf8c26
Changes by Mark Hammond for Windows CE. Mostly of the form
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
139 #endif |
|
d834ecdf8c26
Changes by Mark Hammond for Windows CE. Mostly of the form
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
140 |
|
961
a31e07847063
New thread.c from Sjoerd, supports _exit_prog(). Use this in goaway()
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
141 /* |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
142 #ifdef FOOBAR_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
143 #include "thread_foobar.h" |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 #endif |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
145 */ |
