semaphore.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Module: semaphore.h
  3. *
  4. * Purpose:
  5. * Semaphores aren't actually part of the PThreads standard.
  6. * They are defined by the POSIX Standard:
  7. *
  8. * POSIX 1003.1b-1993 (POSIX.1b)
  9. *
  10. * --------------------------------------------------------------------------
  11. *
  12. * Pthreads-embedded (PTE) - POSIX Threads Library for embedded systems
  13. * Copyright(C) 2008 Jason Schmidlapp
  14. *
  15. * Contact Email: [email protected]
  16. *
  17. *
  18. * Pthreads-embedded (PTE) - POSIX Threads Library for embedded systems
  19. * Copyright(C) 2008 Jason Schmidlapp
  20. *
  21. * Contact Email: [email protected]
  22. *
  23. *
  24. * Based upon Pthreads-win32 - POSIX Threads Library for Win32
  25. * Copyright(C) 1998 John E. Bossom
  26. * Copyright(C) 1999,2005 Pthreads-win32 contributors
  27. *
  28. * Contact Email: [email protected]
  29. *
  30. * The original list of contributors to the Pthreads-win32 project
  31. * is contained in the file CONTRIBUTORS.ptw32 included with the
  32. * source code distribution. The list can also be seen at the
  33. * following World Wide Web location:
  34. * http://sources.redhat.com/pthreads-win32/contributors.html
  35. *
  36. * This library is free software; you can redistribute it and/or
  37. * modify it under the terms of the GNU Lesser General Public
  38. * License as published by the Free Software Foundation; either
  39. * version 2 of the License, or (at your option) any later version.
  40. *
  41. * This library is distributed in the hope that it will be useful,
  42. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  43. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  44. * Lesser General Public License for more details.
  45. *
  46. * You should have received a copy of the GNU Lesser General Public
  47. * License along with this library in the file COPYING.LIB;
  48. * if not, write to the Free Software Foundation, Inc.,
  49. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  50. */
  51. #if !defined( SEMAPHORE_H )
  52. #define SEMAPHORE_H
  53. #if defined(_POSIX_SOURCE)
  54. #define PTE_LEVEL 0
  55. /* Early POSIX */
  56. #endif
  57. #if defined(INCLUDE_NP)
  58. #undef PTE_LEVEL
  59. #define PTE_LEVEL 2
  60. /* Include Non-Portable extensions */
  61. #endif
  62. /*
  63. *
  64. */
  65. #define _POSIX_SEMAPHORES
  66. #ifdef __cplusplus
  67. extern "C"
  68. {
  69. #endif /* __cplusplus */
  70. typedef struct sem_t_ * sem_t;
  71. int sem_init (sem_t * sem,
  72. int pshared,
  73. unsigned int value);
  74. int sem_destroy (sem_t * sem);
  75. int sem_trywait (sem_t * sem);
  76. int sem_wait (sem_t * sem);
  77. int sem_timedwait (sem_t * sem,
  78. const struct timespec * abstime);
  79. int sem_post (sem_t * sem);
  80. int sem_post_multiple (sem_t * sem,
  81. int count);
  82. int sem_open (const char * name,
  83. int oflag,
  84. mode_t mode,
  85. unsigned int value);
  86. int sem_close (sem_t * sem);
  87. int sem_unlink (const char * name);
  88. int sem_getvalue (sem_t * sem,
  89. int * sval);
  90. #ifdef __cplusplus
  91. } /* End of extern "C" */
  92. #endif /* __cplusplus */
  93. #endif /* !SEMAPHORE_H */