Eneboo - Documentación para desarrolladores
src/pthreads/semaphore.h
Ir a la documentación de este archivo.
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,2005 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 #ifndef PTW32_STATIC_LIB
00079 #  ifdef PTW32_BUILD
00080 #    define PTW32_DLLPORT __declspec (dllexport)
00081 #  else
00082 #    define PTW32_DLLPORT __declspec (dllimport)
00083 #  endif
00084 #else
00085 #  define PTW32_DLLPORT
00086 #endif
00087 
00088 /*
00089  * This is a duplicate of what is in the autoconf config.h,
00090  * which is only used when building the pthread-win32 libraries.
00091  */
00092 
00093 #ifndef PTW32_CONFIG_H
00094 #  if defined(WINCE)
00095 #    define NEED_ERRNO
00096 #    define NEED_SEM
00097 #  endif
00098 #  if defined(_UWIN) || defined(__MINGW32__)
00099 #    define HAVE_MODE_T
00100 #  endif
00101 #endif
00102 
00103 /*
00104  *
00105  */
00106 
00107 #if PTW32_LEVEL >= PTW32_LEVEL_MAX
00108 #ifdef NEED_ERRNO
00109 #include "need_errno.h"
00110 #else
00111 #include <errno.h>
00112 #endif
00113 #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
00114 
00115 #define _POSIX_SEMAPHORES
00116 
00117 #ifdef __cplusplus
00118 extern "C"
00119 {
00120 #endif                          /* __cplusplus */
00121 
00122 #ifndef HAVE_MODE_T
00123 typedef unsigned int mode_t;
00124 #endif
00125 
00126 
00127 typedef struct sem_t_ * sem_t;
00128 
00129 PTW32_DLLPORT int __cdecl sem_init (sem_t * sem,
00130                             int pshared,
00131                             unsigned int value);
00132 
00133 PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem);
00134 
00135 PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem);
00136 
00137 PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem);
00138 
00139 PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem,
00140                                  const struct timespec * abstime);
00141 
00142 PTW32_DLLPORT int __cdecl sem_post (sem_t * sem);
00143 
00144 PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem,
00145                                      int count);
00146 
00147 PTW32_DLLPORT int __cdecl sem_open (const char * name,
00148                             int oflag,
00149                             mode_t mode,
00150                             unsigned int value);
00151 
00152 PTW32_DLLPORT int __cdecl sem_close (sem_t * sem);
00153 
00154 PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
00155 
00156 PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
00157                                 int * sval);
00158 
00159 #ifdef __cplusplus
00160 }                               /* End of extern "C" */
00161 #endif                          /* __cplusplus */
00162 
00163 #undef PTW32_LEVEL
00164 #undef PTW32_LEVEL_MAX
00165 
00166 #endif                          /* !SEMAPHORE_H */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'