Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

semaphore.h

Go to the documentation of this file.
00001 /*
00002  * Module: semaphore.h
00003  *
00004  * Purpose:
00005  *      Semaphores aren't actually part of the PThreads standard.
00006  *      They are defined by the POSIX Standard:
00007  *
00008  *              POSIX 1003.1b-1993      (POSIX.1b)
00009  *
00010  * --------------------------------------------------------------------------
00011  *
00012  *      Pthreads-win32 - POSIX Threads Library for Win32
00013  *      Copyright(C) 1998 John E. Bossom
00014  *      Copyright(C) 1999,2003 Pthreads-win32 contributors
00015  * 
00016  *      Contact Email: rpj@callisto.canberra.edu.au
00017  * 
00018  *      The current list of contributors is contained
00019  *      in the file CONTRIBUTORS included with the source
00020  *      code distribution. The list can also be seen at the
00021  *      following World Wide Web location:
00022  *      http://sources.redhat.com/pthreads-win32/contributors.html
00023  * 
00024  *      This library is free software; you can redistribute it and/or
00025  *      modify it under the terms of the GNU Lesser General Public
00026  *      License as published by the Free Software Foundation; either
00027  *      version 2 of the License, or (at your option) any later version.
00028  * 
00029  *      This library is distributed in the hope that it will be useful,
00030  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00031  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00032  *      Lesser General Public License for more details.
00033  * 
00034  *      You should have received a copy of the GNU Lesser General Public
00035  *      License along with this library in the file COPYING.LIB;
00036  *      if not, write to the Free Software Foundation, Inc.,
00037  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00038  */
00039 #if !defined( SEMAPHORE_H )
00040 #define SEMAPHORE_H
00041 
00042 #undef PTW32_LEVEL
00043 
00044 #if defined(_POSIX_SOURCE)
00045 #define PTW32_LEVEL 0
00046 /* Early POSIX */
00047 #endif
00048 
00049 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
00050 #undef PTW32_LEVEL
00051 #define PTW32_LEVEL 1
00052 /* Include 1b, 1c and 1d */
00053 #endif
00054 
00055 #if defined(INCLUDE_NP)
00056 #undef PTW32_LEVEL
00057 #define PTW32_LEVEL 2
00058 /* Include Non-Portable extensions */
00059 #endif
00060 
00061 #define PTW32_LEVEL_MAX 3
00062 
00063 #if !defined(PTW32_LEVEL)
00064 #define PTW32_LEVEL PTW32_LEVEL_MAX
00065 /* Include everything */
00066 #endif
00067 
00068 #if __GNUC__ && ! defined (__declspec)
00069 # error Please upgrade your GNU compiler to one that supports __declspec.
00070 #endif
00071 
00072 /*
00073  * When building the DLL code, you should define PTW32_BUILD so that
00074  * the variables/functions are exported correctly. When using the DLL,
00075  * do NOT define PTW32_BUILD, and then the variables/functions will
00076  * be imported correctly.
00077  */
00078 #ifdef PTW32_BUILD
00079 # define PTW32_DLLPORT __declspec (dllexport)
00080 #else
00081 # define PTW32_DLLPORT __declspec (dllimport)
00082 #endif
00083 
00084 
00085 /*
00086  * This is a duplicate of what is in the autoconf config.h,
00087  * which is only used when building the pthread-win32 libraries.
00088  */
00089 
00090 #ifndef PTW32_CONFIG_H
00091 #  if defined(WINCE)
00092 #    define NEED_ERRNO
00093 #    define NEED_SEM
00094 #  endif
00095 #  if defined(_UWIN) || defined(__MINGW32__)
00096 #    define HAVE_MODE_T
00097 #  endif
00098 #endif
00099 
00100 /*
00101  *
00102  */
00103 
00104 #if PTW32_LEVEL >= PTW32_LEVEL_MAX
00105 #ifdef NEED_ERRNO
00106 #include "need_errno.h"
00107 #else
00108 #include <errno.h>
00109 #endif
00110 #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
00111 
00112 #define _POSIX_SEMAPHORES
00113 
00114 #ifdef __cplusplus
00115 extern "C"
00116 {
00117 #endif                          /* __cplusplus */
00118 
00119 #ifndef HAVE_MODE_T
00120 typedef unsigned int mode_t;
00121 #endif
00122 
00123 
00124 typedef struct sem_t_ * sem_t;
00125 
00126 PTW32_DLLPORT int sem_init (sem_t * sem,
00127                             int pshared,
00128                             unsigned int value);
00129 
00130 PTW32_DLLPORT int sem_destroy (sem_t * sem);
00131 
00132 PTW32_DLLPORT int sem_trywait (sem_t * sem);
00133 
00134 PTW32_DLLPORT int sem_wait (sem_t * sem);
00135 
00136 PTW32_DLLPORT int sem_timedwait (sem_t * sem,
00137                                  const struct timespec * abstime);
00138 
00139 PTW32_DLLPORT int sem_post (sem_t * sem);
00140 
00141 PTW32_DLLPORT int sem_post_multiple (sem_t * sem,
00142                                      int count);
00143 
00144 PTW32_DLLPORT int sem_open (const char * name,
00145                             int oflag,
00146                             mode_t mode,
00147                             unsigned int value);
00148 
00149 PTW32_DLLPORT int sem_close (sem_t * sem);
00150 
00151 PTW32_DLLPORT int sem_unlink (const char * name);
00152 
00153 PTW32_DLLPORT int sem_getvalue (sem_t * sem,
00154                                 int * sval);
00155 
00156 #ifdef __cplusplus
00157 }                               /* End of extern "C" */
00158 #endif                          /* __cplusplus */
00159 
00160 #undef PTW32_LEVEL
00161 #undef PTW32_LEVEL_MAX
00162 
00163 #endif                          /* !SEMAPHORE_H */

Generated on Sun May 14 14:51:20 2006 by  doxygen 1.4.2