You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.7 KiB

  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. * Pthreads-win32 - POSIX Threads Library for Win32
  11. * Copyright (C) 1998
  12. *
  13. * This library is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU Library General Public
  15. * License as published by the Free Software Foundation; either
  16. * version 2 of the License, or (at your option) any later version.
  17. *
  18. * This library is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. * Library General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Library General Public
  24. * License along with this library; if not, write to the Free
  25. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  26. * MA 02111-1307, USA
  27. */
  28. /* This is hacked by Monty to be included in mysys library */
  29. #ifndef _my_semaphore_h_
  30. #define _my_semaphore_h_
  31. #ifdef THREAD
  32. C_MODE_START
  33. #ifdef HAVE_SEMAPHORE_H
  34. #include <semaphore.h>
  35. #elif !defined(__bsdi__)
  36. #ifdef __WIN__
  37. typedef HANDLE sem_t;
  38. #else
  39. typedef struct {
  40. pthread_mutex_t mutex;
  41. pthread_cond_t cond;
  42. uint count;
  43. } sem_t;
  44. #endif /* __WIN__ */
  45. int sem_init(sem_t * sem, int pshared, unsigned int value);
  46. int sem_destroy(sem_t * sem);
  47. int sem_trywait(sem_t * sem);
  48. int sem_wait(sem_t * sem);
  49. int sem_post(sem_t * sem);
  50. int sem_post_multiple(sem_t * sem, unsigned int count);
  51. int sem_getvalue(sem_t * sem, unsigned int * sval);
  52. #endif /* !__bsdi__ */
  53. C_MODE_END
  54. #endif /* THREAD */
  55. #endif /* !_my_semaphore_h_ */