home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / pytexdoc / ext / source / !Python / Monty / c / thread < prev    next >
Encoding:
Text File  |  1996-11-06  |  3.3 KB  |  143 lines

  1. /***********************************************************
  2. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
  3. The Netherlands.
  4.  
  5.                         All Rights Reserved
  6.  
  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.
  16.  
  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.
  20.  
  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.
  29.  
  30. ******************************************************************/
  31.  
  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. */
  37.  
  38. #include "config.h"
  39.  
  40. #include <stdio.h>
  41.  
  42. #ifdef HAVE_STDLIB_H
  43. #include <stdlib.h>
  44. #else
  45. extern char *getenv();
  46. #endif
  47.  
  48. #include "thread.h"
  49.  
  50. #ifdef __ksr__
  51. #define _POSIX_THREADS
  52. #endif
  53.  
  54. #ifndef _POSIX_THREADS
  55.  
  56. #ifdef __sgi
  57. #define SGI_THREADS
  58. #endif
  59.  
  60. #ifdef HAVE_THREAD_H
  61. #define SOLARIS_THREADS
  62. #endif
  63.  
  64. #if defined(sun) && !defined(SOLARIS_THREADS)
  65. #define SUN_LWP
  66. #endif
  67.  
  68. #endif /* _POSIX_THREADS */
  69.  
  70. #ifdef __STDC__
  71. #define _P(args)        args
  72. #define _P0()            (void)
  73. #define _P1(v,t)        (t)
  74. #define _P2(v1,t1,v2,t2)    (t1,t2)
  75. #else
  76. #define _P(args)        ()
  77. #define _P0()            ()
  78. #define _P1(v,t)        (v) t;
  79. #define _P2(v1,t1,v2,t2)    (v1,v2) t1; t2;
  80. #endif /* __STDC__ */
  81.  
  82. #ifdef DEBUG
  83. static int thread_debug = 0;
  84. #define dprintf(args)    ((thread_debug & 1) && printf args)
  85. #define d2printf(args)    ((thread_debug & 8) && printf args)
  86. #else
  87. #define dprintf(args)
  88. #define d2printf(args)
  89. #endif
  90.  
  91. static int initialized;
  92.  
  93. static void _init_thread(); /* Forward */
  94.  
  95. void init_thread _P0()
  96. {
  97. #ifdef DEBUG
  98.     char *p = getenv("THREADDEBUG");
  99.  
  100.     if (p) {
  101.         if (*p)
  102.             thread_debug = atoi(p);
  103.         else
  104.             thread_debug = 1;
  105.     }
  106. #endif /* DEBUG */
  107.     if (initialized)
  108.         return;
  109.     initialized = 1;
  110.     dprintf(("init_thread called\n"));
  111.     _init_thread();
  112. }
  113.  
  114. #ifdef SGI_THREADS
  115. #include "thread_sgi.h"
  116. #endif
  117.  
  118. #ifdef SOLARIS_THREADS
  119. #include "thread_solaris.h"
  120. #endif
  121.  
  122. #ifdef SUN_LWP
  123. #include "thread_lwp.h"
  124. #endif
  125.  
  126. #ifdef _POSIX_THREADS
  127. #include "thread_pthread.h"
  128. #endif
  129.  
  130. #ifdef C_THREADS
  131. #include "thread_cthread.h"
  132. #endif
  133.  
  134. #ifdef NT_THREADS
  135. #include "thread_nt.h"
  136. #endif
  137.  
  138. /*
  139. #ifdef FOOBAR_THREADS
  140. #include "thread_foobar.h"
  141. #endif
  142. */
  143.