April 2024 | ||||||
Mo | Tu | We | Th | Fr | Sa | Su |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
01: /* Copyright (C) 2002, 2003, 2011 Free Software Foundation, Inc. 02: This file is part of the GNU C Library. 03: 04: The GNU C Library is free software; you can redistribute it and/or 05: modify it under the terms of the GNU Lesser General Public 06: License as published by the Free Software Foundation; either 07: version 2.1 of the License, or (at your option) any later version. 08: 09: The GNU C Library is distributed in the hope that it will be useful, 10: but WITHOUT ANY WARRANTY; without even the implied warranty of 11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12: Lesser General Public License for more details. 13: 14: You should have received a copy of the GNU Lesser General Public 15: License along with the GNU C Library; if not, write to the Free 16: Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17: 02111-1307 USA. */ 18: 19: #ifndef _SEMAPHORE_H 20: #define _SEMAPHORE_H 1 21: 22: #include <features.h> 23: #include <sys/types.h> 24: #ifdef __USE_XOPEN2K 25: # define __need_timespec 26: # include <time.h> 27: #endif 28: 29: /* Get the definition for sem_t. */ 30: #include <bits/semaphore.h> 31: 32: 33: __BEGIN_DECLS 34: 35: /* Initialize semaphore object SEM to VALUE. If PSHARED then share it 36: with other processes. */ 37: extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value) 38: __THROW; 39: /* Free resources associated with semaphore object SEM. */ 40: extern int sem_destroy (sem_t *__sem) __THROW; 41: 42: /* Open a named semaphore NAME with open flags OFLAG. */ 43: extern sem_t *sem_open (__const char *__name, int __oflag, ...) __THROW; 44: 45: /* Close descriptor for named semaphore SEM. */ 46: extern int sem_close (sem_t *__sem) __THROW; 47: 48: /* Remove named semaphore NAME. */ 49: extern int sem_unlink (__const char *__name) __THROW; 50: 51: /* Wait for SEM being posted. 52: 53: This function is a cancellation point and therefore not marked with 54: __THROW. */ 55: extern int sem_wait (sem_t *__sem); 56: 57: #ifdef __USE_XOPEN2K 58: /* Similar to `sem_wait' but wait only until ABSTIME. 59: 60: This function is a cancellation point and therefore not marked with 61: __THROW. */ 62: extern int sem_timedwait (sem_t *__restrict __sem, 63: __const struct timespec *__restrict __abstime); 64: #endif 65: 66: /* Test whether SEM is posted. */ 67: extern int sem_trywait (sem_t *__sem) __THROWNL; 68: 69: /* Post SEM. */ 70: extern int sem_post (sem_t *__sem) __THROWNL; 71: 72: /* Get current value of SEM and store it in *SVAL. */ 73: extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval) 74: __THROW; 75: 76: 77: __END_DECLS 78: 79: #endif /* semaphore.h */ 80: