Fix the HTML tarball target to generate the HTML if needed instead of
[python/dscho.git] / Python / thread.c
blobc533398a3cdfd5909180de0607083e0122ff09e7
1 /***********************************************************
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3 The Netherlands.
5 All Rights Reserved
7 Permission to use, copy, modify, and distribute this software and its
8 documentation for any purpose and without fee is hereby granted,
9 provided that the above copyright notice appear in all copies and that
10 both that copyright notice and this permission notice appear in
11 supporting documentation, and that the names of Stichting Mathematisch
12 Centrum or CWI or Corporation for National Research Initiatives or
13 CNRI not be used in advertising or publicity pertaining to
14 distribution of the software without specific, written prior
15 permission.
17 While CWI is the initial source for this software, a modified version
18 is made available by the Corporation for National Research Initiatives
19 (CNRI) at the Internet address ftp://ftp.python.org.
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28 PERFORMANCE OF THIS SOFTWARE.
30 ******************************************************************/
32 /* Thread package.
33 This is intended to be usable independently from Python.
34 The implementation for system foobar is in a file thread_foobar.h
35 which is included by this file dependent on config settings.
36 Stuff shared by all thread_*.h files is collected here. */
38 #include "config.h"
40 /* config.h may or may not define DL_IMPORT */
41 #ifndef DL_IMPORT /* declarations for DLL import/export */
42 #define DL_IMPORT(RTYPE) RTYPE
43 #endif
45 #include <stdio.h>
47 #ifdef HAVE_STDLIB_H
48 #include <stdlib.h>
49 #else
50 extern char *getenv();
51 #endif
53 #ifdef HAVE_UNISTD_H
54 #include <unistd.h>
55 #endif
57 #ifdef __DGUX
58 #define _USING_POSIX4A_DRAFT6
59 #endif
61 #ifdef __sgi
62 #ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.in */
63 #undef _POSIX_THREADS
64 #endif
65 #endif
67 #include "pythread.h"
69 #ifdef __ksr__
70 #define _POSIX_THREADS
71 #endif
73 #ifndef _POSIX_THREADS
75 #ifdef __sgi
76 #define SGI_THREADS
77 #endif
79 #ifdef HAVE_THREAD_H
80 #define SOLARIS_THREADS
81 #endif
83 #if defined(sun) && !defined(SOLARIS_THREADS)
84 #define SUN_LWP
85 #endif
87 #endif /* _POSIX_THREADS */
89 #ifdef __STDC__
90 #define _P(args) args
91 #define _P0() (void)
92 #define _P1(v,t) (t)
93 #define _P2(v1,t1,v2,t2) (t1,t2)
94 #else
95 #define _P(args) ()
96 #define _P0() ()
97 #define _P1(v,t) (v) t;
98 #define _P2(v1,t1,v2,t2) (v1,v2) t1; t2;
99 #endif /* __STDC__ */
101 #ifdef Py_DEBUG
102 static int thread_debug = 0;
103 #define dprintf(args) ((thread_debug & 1) && printf args)
104 #define d2printf(args) ((thread_debug & 8) && printf args)
105 #else
106 #define dprintf(args)
107 #define d2printf(args)
108 #endif
110 static int initialized;
112 static void PyThread__init_thread(); /* Forward */
114 void PyThread_init_thread _P0()
116 #ifdef Py_DEBUG
117 char *p = getenv("THREADDEBUG");
119 if (p) {
120 if (*p)
121 thread_debug = atoi(p);
122 else
123 thread_debug = 1;
125 #endif /* Py_DEBUG */
126 if (initialized)
127 return;
128 initialized = 1;
129 dprintf(("PyThread_init_thread called\n"));
130 PyThread__init_thread();
133 #ifdef SGI_THREADS
134 #include "thread_sgi.h"
135 #endif
137 #ifdef SOLARIS_THREADS
138 #include "thread_solaris.h"
139 #endif
141 #ifdef SUN_LWP
142 #include "thread_lwp.h"
143 #endif
145 #ifdef _POSIX_THREADS
146 #include "thread_pthread.h"
147 #endif
149 #ifdef C_THREADS
150 #include "thread_cthread.h"
151 #endif
153 #ifdef NT_THREADS
154 #include "thread_nt.h"
155 #endif
157 #ifdef OS2_THREADS
158 #include "thread_os2.h"
159 #endif
161 #ifdef BEOS_THREADS
162 #include "thread_beos.h"
163 #endif
166 #ifdef FOOBAR_THREADS
167 #include "thread_foobar.h"
168 #endif