Bump version to 0.9.1.
[python/dscho.git] / Python / thread.c
blob0f4c392b2de2077128d49c91b6d6dba659c786d1
1 /***********************************************************
2 Copyright (c) 2000, BeOpen.com.
3 Copyright (c) 1995-2000, Corporation for National Research Initiatives.
4 Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
5 All rights reserved.
7 See the file "Misc/COPYRIGHT" for information on usage and
8 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9 ******************************************************************/
11 /* Thread package.
12 This is intended to be usable independently from Python.
13 The implementation for system foobar is in a file thread_foobar.h
14 which is included by this file dependent on config settings.
15 Stuff shared by all thread_*.h files is collected here. */
17 #include "config.h"
19 /* config.h may or may not define DL_IMPORT */
20 #ifndef DL_IMPORT /* declarations for DLL import/export */
21 #define DL_IMPORT(RTYPE) RTYPE
22 #endif
24 #ifndef DONT_HAVE_STDIO_H
25 #include <stdio.h>
26 #endif
28 #ifdef HAVE_STDLIB_H
29 #include <stdlib.h>
30 #else
31 #ifdef Py_DEBUG
32 extern char *getenv(const char *);
33 #endif
34 #endif
36 #ifdef HAVE_UNISTD_H
37 #include <unistd.h>
38 #endif
40 #ifdef __DGUX
41 #define _USING_POSIX4A_DRAFT6
42 #endif
44 #ifdef __sgi
45 #ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.in */
46 #undef _POSIX_THREADS
47 #endif
48 #endif
50 #include "pythread.h"
52 #ifdef __ksr__
53 #define _POSIX_THREADS
54 #endif
56 #ifndef _POSIX_THREADS
58 #ifdef __sgi
59 #define SGI_THREADS
60 #endif
62 #ifdef HAVE_THREAD_H
63 #define SOLARIS_THREADS
64 #endif
66 #if defined(sun) && !defined(SOLARIS_THREADS)
67 #define SUN_LWP
68 #endif
70 #ifdef __MWERKS__
71 #define _POSIX_THREADS
72 #endif
74 #endif /* _POSIX_THREADS */
77 #ifdef Py_DEBUG
78 static int thread_debug = 0;
79 #define dprintf(args) ((thread_debug & 1) && printf args)
80 #define d2printf(args) ((thread_debug & 8) && printf args)
81 #else
82 #define dprintf(args)
83 #define d2printf(args)
84 #endif
86 static int initialized;
88 static void PyThread__init_thread(void); /* Forward */
90 void PyThread_init_thread(void)
92 #ifdef Py_DEBUG
93 char *p = getenv("THREADDEBUG");
95 if (p) {
96 if (*p)
97 thread_debug = atoi(p);
98 else
99 thread_debug = 1;
101 #endif /* Py_DEBUG */
102 if (initialized)
103 return;
104 initialized = 1;
105 dprintf(("PyThread_init_thread called\n"));
106 PyThread__init_thread();
109 #ifdef SGI_THREADS
110 #include "thread_sgi.h"
111 #endif
113 #ifdef SOLARIS_THREADS
114 #include "thread_solaris.h"
115 #endif
117 #ifdef SUN_LWP
118 #include "thread_lwp.h"
119 #endif
121 #ifdef _GNU_PTH
122 #include "thread_pth.h"
123 #else
124 #ifdef _POSIX_THREADS
125 #include "thread_pthread.h"
126 #endif
127 #endif
129 #ifdef C_THREADS
130 #include "thread_cthread.h"
131 #endif
133 #ifdef NT_THREADS
134 #include "thread_nt.h"
135 #endif
137 #ifdef OS2_THREADS
138 #include "thread_os2.h"
139 #endif
141 #ifdef BEOS_THREADS
142 #include "thread_beos.h"
143 #endif
145 #ifdef WINCE_THREADS
146 #include "thread_wince.h"
147 #endif
150 #ifdef FOOBAR_THREADS
151 #include "thread_foobar.h"
152 #endif