home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / gnu / gcc-2.3.3-src.lha / src / amiga / gcc-2.3.3 / objc / mutex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-07  |  2.6 KB  |  111 lines

  1. /* Copyright (C) 1992 Free Software Foundation, Inc.
  2.  
  3. This file is part of GNU CC.
  4.  
  5. GNU CC is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. GNU CC is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with GNU CC; see the file COPYING.  If not, write to
  17. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. /* As a special exception, if you link this library with files
  20.    compiled with GCC to produce an executable, this does not cause
  21.    the resulting executable to be covered by the GNU General Public License.
  22.    This exception does not however invalidate any other reasons why
  23.    the executable file might be covered by the GNU General Public License.  */
  24.  
  25. #ifndef _MUTEX_H
  26. #define _MUTEX_H
  27.  
  28. #ifdef WANT_MUTEX
  29. #if defined (NeXT)
  30. #include  <cthreads.h>
  31. #define MUTEX               mutex_t
  32. #define MUTEX_ALLOC(mutex)  { *mutex = mutex_alloc (); }
  33. #define MUTEX_INIT(mutex)   mutex_init (mutex)
  34. #define MUTEX_FREE(mutex)   mutex_free (mutex)
  35. #define MUTEX_LOCK(mutex)   mutex_lock (mutex)
  36. #define MUTEX_UNLOCK(mutex) mutex_unlock (mutex)
  37. #define MUTEX_ISLOCK(mutex)     mutex->lock /* Gak */
  38.  
  39. #elif defined (OSF)
  40.  
  41. #elif defined (mach)
  42.  
  43. #elif defined (sun)
  44. /*
  45.  * Sun lwp uses monitors.
  46.  *
  47.  * Untested.  8-Dec-91, dennisg.
  48.  */
  49. #include  <lwp/lwp.h>
  50. #include  <assert.h>
  51.  
  52. #define MUTEX (mon_t)
  53.  
  54. inline MUTEX
  55. MUTEX_ALLOC (mutex)
  56. {
  57.   MUTEX mon;
  58.   
  59.   mon_create (&mon);
  60.   return mon;
  61. }
  62.  
  63. #define MUTEX_INIT(mutex)
  64. #define MUTEX_FREE(mutex)   mon_destroy (mutex)
  65.  
  66. inline void
  67. MUTEX_LOCK (mutex)
  68. {
  69.   int level = mon_enter (mutex);
  70.   assert (level);
  71. }
  72.  
  73. #define MUTEX_UNLOCK(mutex) mon_exit (mutex)
  74.  
  75. inline int
  76. MUTEX_ISLOCK (mutex)
  77. {
  78.   thread_t thread;
  79.  
  80.   /* Won't work? */
  81.   return mon_waiters (mutex, &thread, NULL, 0);
  82. }
  83.  
  84. #elif defined (COROUTINES)
  85. /*
  86.  * A environment where threads are implemented as a
  87.  *  set of coroutines.
  88.  */
  89.  
  90. #endif
  91. #endif
  92.  
  93. #ifndef MUTEX
  94. /*
  95.  * These are default mutex handler routines.
  96.  *  There is no mutex support.
  97.  *
  98.  * Let the optimizer get rid of mutexes.
  99.  */
  100.  
  101. #define MUTEX void *
  102. #define MUTEX_ALLOC(mutex)  (MUTEX)-1
  103. #define MUTEX_INIT(mutex)   (mutex)
  104. #define MUTEX_FREE(mutex)   (mutex)
  105. #define MUTEX_LOCK(mutex)   (mutex)
  106. #define MUTEX_UNLOCK(mutex) (mutex)
  107. #define MUTEX_ISLOCK(mutex) 1
  108. #endif
  109.  
  110. #endif /* not _MUTEX_H */
  111.