This commit was manufactured by cvs2svn to create tag 'r221c2'.
[python/dscho.git] / Python / thread.c
blobf9a4de9cb26f151f4f245c7e7c6a26c99cb9aff3
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 "Python.h"
10 /* pyconfig.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 __DGUX
28 #define _USING_POSIX4A_DRAFT6
29 #endif
31 #ifdef __sgi
32 #ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.in */
33 #undef _POSIX_THREADS
34 #endif
35 #endif
37 #include "pythread.h"
39 #ifdef __ksr__
40 #define _POSIX_THREADS
41 #endif
43 #ifndef _POSIX_THREADS
45 #ifdef __sgi
46 #define SGI_THREADS
47 #endif
49 #ifdef HAVE_THREAD_H
50 #define SOLARIS_THREADS
51 #endif
53 #if defined(sun) && !defined(SOLARIS_THREADS)
54 #define SUN_LWP
55 #endif
57 #if defined(__MWERKS__) && !defined(__BEOS__)
58 #define _POSIX_THREADS
59 #endif
61 #endif /* _POSIX_THREADS */
64 #ifdef Py_DEBUG
65 static int thread_debug = 0;
66 #define dprintf(args) ((thread_debug & 1) && printf args)
67 #define d2printf(args) ((thread_debug & 8) && printf args)
68 #else
69 #define dprintf(args)
70 #define d2printf(args)
71 #endif
73 static int initialized;
75 static void PyThread__init_thread(void); /* Forward */
77 void PyThread_init_thread(void)
79 #ifdef Py_DEBUG
80 char *p = getenv("THREADDEBUG");
82 if (p) {
83 if (*p)
84 thread_debug = atoi(p);
85 else
86 thread_debug = 1;
88 #endif /* Py_DEBUG */
89 if (initialized)
90 return;
91 initialized = 1;
92 dprintf(("PyThread_init_thread called\n"));
93 PyThread__init_thread();
96 #ifdef SGI_THREADS
97 #include "thread_sgi.h"
98 #endif
100 #ifdef SOLARIS_THREADS
101 #include "thread_solaris.h"
102 #endif
104 #ifdef SUN_LWP
105 #include "thread_lwp.h"
106 #endif
108 #ifdef HAVE_PTH
109 #include "thread_pth.h"
110 #endif
112 #ifdef _POSIX_THREADS
113 #include "thread_pthread.h"
114 #endif
116 #ifdef C_THREADS
117 #include "thread_cthread.h"
118 #endif
120 #ifdef NT_THREADS
121 #include "thread_nt.h"
122 #endif
124 #ifdef OS2_THREADS
125 #include "thread_os2.h"
126 #endif
128 #ifdef BEOS_THREADS
129 #include "thread_beos.h"
130 #endif
132 #ifdef WINCE_THREADS
133 #include "thread_wince.h"
134 #endif
137 #ifdef FOOBAR_THREADS
138 #include "thread_foobar.h"
139 #endif