Mercurial > cpython-lru_cache-weakref
annotate Python/thread.c @ 1848:b724599401ff legacy-trunk
Merge back to main trunk
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 30 Aug 1994 08:27:36 +0000 |
| parents | b1bb74a2b593 |
| children | d0d0a69b5ca3 |
| 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 Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum, |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
3 Amsterdam, The Netherlands. |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
4 |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
5 All Rights Reserved |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
6 |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
14 |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
22 |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
23 ******************************************************************/ |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1186
diff
changeset
|
24 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
25 /* Thread package. |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 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
|
30 |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
31 #ifdef HAVE_CONFIG_H |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
32 #include "config.h" |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
33 #endif |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
34 |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
35 #include <stdio.h> |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
36 |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
37 #ifdef HAVE_STDLIB_H |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
38 #include <stdlib.h> |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
39 #else |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
40 extern char *getenv(); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
41 #endif |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
42 |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 #include "thread.h" |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
45 #ifdef __ksr__ |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
46 #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
|
47 #endif |
|
a31e07847063
New thread.c from Sjoerd, supports _exit_prog(). Use this in goaway()
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
48 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
49 #ifndef _POSIX_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
50 |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 #ifdef __sgi |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
52 #define SGI_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
53 #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
|
54 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
55 #ifdef HAVE_THREAD_H |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
56 #define SOLARIS_THREADS |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 #endif |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
59 #if defined(sun) && !defined(SOLARIS_THREADS) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
60 #define SUN_LWP |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
61 #endif |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
62 |
| 1418 | 63 #endif /* _POSIX_THREADS */ |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 #ifdef __STDC__ |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 #define _P(args) args |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 #define _P0() (void) |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
68 #define _P1(v,t) (t) |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 #define _P2(v1,t1,v2,t2) (t1,t2) |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 #else |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 #define _P(args) () |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 #define _P0() () |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 #define _P1(v,t) (v) t; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 #define _P2(v1,t1,v2,t2) (v1,v2) t1; t2; |
| 1418 | 75 #endif /* __STDC__ */ |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
77 #ifdef DEBUG |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
78 static int thread_debug = 0; |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
79 #define dprintf(args) ((thread_debug & 1) && printf args) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
80 #define d2printf(args) ((thread_debug & 8) && printf args) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
81 #else |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
82 #define dprintf(args) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
83 #define d2printf(args) |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
84 #endif |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
85 |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 static int initialized; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
88 static void _init_thread(); /* Forward */ |
|
1004
5d7142ea01b7
adapted SV module to the new svideo library.
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
89 |
|
5d7142ea01b7
adapted SV module to the new svideo library.
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
90 void init_thread _P0() |
|
5d7142ea01b7
adapted SV module to the new svideo library.
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
91 { |
|
1047
6b5a34db21fe
Added C++ support in thread.h; don't use signals if not strictly
Sjoerd Mullender <sjoerd@acm.org>
parents:
1005
diff
changeset
|
92 #ifdef DEBUG |
| 1418 | 93 char *p = getenv("THREADDEBUG"); |
| 94 | |
| 95 if (p) { | |
| 96 if (*p) | |
| 97 thread_debug = atoi(p); | |
| 98 else | |
| 99 thread_debug = 1; | |
| 100 } | |
| 101 #endif /* DEBUG */ | |
|
1004
5d7142ea01b7
adapted SV module to the new svideo library.
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
102 if (initialized) |
|
5d7142ea01b7
adapted SV module to the new svideo library.
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
103 return; |
|
5d7142ea01b7
adapted SV module to the new svideo library.
Sjoerd Mullender <sjoerd@acm.org>
parents:
961
diff
changeset
|
104 initialized = 1; |
| 1179 | 105 dprintf(("init_thread called\n")); |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
106 _init_thread(); |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
109 #ifdef SGI_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
110 #include "thread_sgi.h" |
| 1418 | 111 #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
|
112 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
113 #ifdef SOLARIS_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
114 #include "thread_solaris.h" |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 #endif |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
116 |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
117 #ifdef SUN_LWP |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
118 #include "thread_lwp.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 _POSIX_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
122 #include "thread_pthread.h" |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
123 #endif |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
125 #ifdef C_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
126 #include "thread_cthread.h" |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
127 #endif |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 |
|
961
a31e07847063
New thread.c from Sjoerd, supports _exit_prog(). Use this in goaway()
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
129 /* |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
130 #ifdef FOOBAR_THREADS |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
131 #include "thread_foobar.h" |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
132 #endif |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1418
diff
changeset
|
133 */ |
