Updated for 2.1b2 distribution.
[python/dscho.git] / Python / thread.c
blobb5d99ef4bd6860a926037026ac84bea3311aa52b
2 /* Thread package.
3 This is intended to be usable independently from Python.
4 The implementation for system foobar is in a file thread_foobar.h
5 which is included by this file dependent on config settings.
6 Stuff shared by all thread_*.h files is collected here. */
8 #include "config.h"
10 /* config.h may or may not define DL_IMPORT */
11 #ifndef DL_IMPORT /* declarations for DLL import/export */
12 #define DL_IMPORT(RTYPE) RTYPE
13 #endif
15 #ifndef DONT_HAVE_STDIO_H
16 #include <stdio.h>
17 #endif
19 #ifdef HAVE_STDLIB_H
20 #include <stdlib.h>
21 #else
22 #ifdef Py_DEBUG
23 extern char *getenv(const char *);
24 #endif
25 #endif
27 #ifdef HAVE_UNISTD_H
28 #include <unistd.h>
29 #endif
31 #ifdef __DGUX
32 #define _USING_POSIX4A_DRAFT6
33 #endif
35 #ifdef __sgi
36 #ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.in */
37 #undef _POSIX_THREADS
38 #endif
39 #endif
41 #include "pythread.h"
43 #ifdef __ksr__
44 #define _POSIX_THREADS
45 #endif
47 #ifndef _POSIX_THREADS
49 #ifdef __sgi
50 #define SGI_THREADS
51 #endif
53 #ifdef HAVE_THREAD_H
54 #define SOLARIS_THREADS
55 #endif
57 #if defined(sun) && !defined(SOLARIS_THREADS)
58 #define SUN_LWP
59 #endif
61 #if defined(__MWERKS__) && !defined(__BEOS__)
62 #define _POSIX_THREADS
63 #endif
65 #endif /* _POSIX_THREADS */
68 #ifdef Py_DEBUG
69 static int thread_debug = 0;
70 #define dprintf(args) ((thread_debug & 1) && printf args)
71 #define d2printf(args) ((thread_debug & 8) && printf args)
72 #else
73 #define dprintf(args)
74 #define d2printf(args)
75 #endif
77 static int initialized;
79 static void PyThread__init_thread(void); /* Forward */
81 void PyThread_init_thread(void)
83 #ifdef Py_DEBUG
84 char *p = getenv("THREADDEBUG");
86 if (p) {
87 if (*p)
88 thread_debug = atoi(p);
89 else
90 thread_debug = 1;
92 #endif /* Py_DEBUG */
93 if (initialized)
94 return;
95 initialized = 1;
96 dprintf(("PyThread_init_thread called\n"));
97 PyThread__init_thread();
100 #ifdef SGI_THREADS
101 #include "thread_sgi.h"
102 #endif
104 #ifdef SOLARIS_THREADS
105 #include "thread_solaris.h"
106 #endif
108 #ifdef SUN_LWP
109 #include "thread_lwp.h"
110 #endif
112 #ifdef HAVE_PTH
113 #include "thread_pth.h"
114 #undef _POSIX_THREADS
115 #endif
117 #ifdef _POSIX_THREADS
118 #include "thread_pthread.h"
119 #endif
121 #ifdef C_THREADS
122 #include "thread_cthread.h"
123 #endif
125 #ifdef NT_THREADS
126 #include "thread_nt.h"
127 #endif
129 #ifdef OS2_THREADS
130 #include "thread_os2.h"
131 #endif
133 #ifdef BEOS_THREADS
134 #include "thread_beos.h"
135 #endif
137 #ifdef WINCE_THREADS
138 #include "thread_wince.h"
139 #endif
142 #ifdef FOOBAR_THREADS
143 #include "thread_foobar.h"
144 #endif