home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / Python2 / Python20_source / Python / thread.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-25  |  2.3 KB  |  146 lines

  1.  
  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. */
  7.  
  8. #include "config.h"
  9.  
  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
  14.  
  15. #ifndef DONT_HAVE_STDIO_H
  16. #include <stdio.h>
  17. #endif
  18.  
  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
  26.  
  27. #ifdef HAVE_UNISTD_H
  28. #include <unistd.h>
  29. #endif
  30.  
  31. #ifdef __DGUX
  32. #define _USING_POSIX4A_DRAFT6
  33. #endif
  34.  
  35. #ifdef __sgi
  36. #ifndef HAVE_PTHREAD_H /* XXX Need to check in configure.in */
  37. #undef _POSIX_THREADS
  38. #endif
  39. #endif
  40.  
  41. #include "pythread.h"
  42.  
  43. #ifdef __ksr__
  44. #define _POSIX_THREADS
  45. #endif
  46.  
  47. #ifndef _POSIX_THREADS
  48.  
  49. #ifdef __sgi
  50. #define SGI_THREADS
  51. #endif
  52.  
  53. #ifdef HAVE_THREAD_H
  54. #define SOLARIS_THREADS
  55. #endif
  56.  
  57. #if defined(sun) && !defined(SOLARIS_THREADS)
  58. #define SUN_LWP
  59. #endif
  60.  
  61. #if defined(__MWERKS__) && !defined(__BEOS__)
  62. #define _POSIX_THREADS
  63. #endif
  64.  
  65. #endif /* _POSIX_THREADS */
  66.  
  67.  
  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
  76.  
  77. static int initialized;
  78.  
  79. static void PyThread__init_thread(void); /* Forward */
  80.  
  81. void PyThread_init_thread(void)
  82. {
  83. #ifdef Py_DEBUG
  84.     char *p = getenv("THREADDEBUG");
  85.  
  86.     if (p) {
  87.         if (*p)
  88.             thread_debug = atoi(p);
  89.         else
  90.             thread_debug = 1;
  91.     }
  92. #endif /* Py_DEBUG */
  93.     if (initialized)
  94.         return;
  95.     initialized = 1;
  96.     dprintf(("PyThread_init_thread called\n"));
  97.     PyThread__init_thread();
  98. }
  99.  
  100. #ifdef SGI_THREADS
  101. #include "thread_sgi.h"
  102. #endif
  103.  
  104. #ifdef SOLARIS_THREADS
  105. #include "thread_solaris.h"
  106. #endif
  107.  
  108. #ifdef SUN_LWP
  109. #include "thread_lwp.h"
  110. #endif
  111.  
  112. #ifdef HAVE_PTH
  113. #include "thread_pth.h"
  114. #undef _POSIX_THREADS
  115. #endif
  116.  
  117. #ifdef _POSIX_THREADS
  118. #include "thread_pthread.h"
  119. #endif
  120.  
  121. #ifdef C_THREADS
  122. #include "thread_cthread.h"
  123. #endif
  124.  
  125. #ifdef NT_THREADS
  126. #include "thread_nt.h"
  127. #endif
  128.  
  129. #ifdef OS2_THREADS
  130. #include "thread_os2.h"
  131. #endif
  132.  
  133. #ifdef BEOS_THREADS
  134. #include "thread_beos.h"
  135. #endif
  136.  
  137. #ifdef WINCE_THREADS
  138. #include "thread_wince.h"
  139. #endif
  140.  
  141. /*
  142. #ifdef FOOBAR_THREADS
  143. #include "thread_foobar.h"
  144. #endif
  145. */
  146.