]>
Commit | Line | Data |
---|---|---|
04277e02 | 1 | /* Copyright (C) 2002-2019 Free Software Foundation, Inc. |
76a50749 UD |
2 | This file is part of the GNU C Library. |
3 | ||
4 | The GNU C Library is free software; you can redistribute it and/or | |
5 | modify it under the terms of the GNU Lesser General Public | |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
8 | ||
9 | 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 | |
59ba27a6 | 15 | License along with the GNU C Library; if not, see |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
76a50749 UD |
17 | |
18 | #ifndef _SEMAPHORE_H | |
19 | #define _SEMAPHORE_H 1 | |
20 | ||
21 | #include <features.h> | |
22 | #include <sys/types.h> | |
23 | #ifdef __USE_XOPEN2K | |
05b68e14 | 24 | # include <bits/types/struct_timespec.h> |
76a50749 UD |
25 | #endif |
26 | ||
27 | /* Get the definition for sem_t. */ | |
28 | #include <bits/semaphore.h> | |
29 | ||
30 | ||
31 | __BEGIN_DECLS | |
32 | ||
33 | /* Initialize semaphore object SEM to VALUE. If PSHARED then share it | |
34 | with other processes. */ | |
35 | extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value) | |
f492fc99 YD |
36 | __THROW __nonnull ((1)); |
37 | ||
76a50749 | 38 | /* Free resources associated with semaphore object SEM. */ |
f492fc99 | 39 | extern int sem_destroy (sem_t *__sem) __THROW __nonnull ((1)); |
76a50749 | 40 | |
dc2f6455 | 41 | /* Open a named semaphore NAME with open flags OFLAG. */ |
f492fc99 YD |
42 | extern sem_t *sem_open (const char *__name, int __oflag, ...) |
43 | __THROW __nonnull ((1)); | |
76a50749 UD |
44 | |
45 | /* Close descriptor for named semaphore SEM. */ | |
f492fc99 | 46 | extern int sem_close (sem_t *__sem) __THROW __nonnull ((1)); |
76a50749 UD |
47 | |
48 | /* Remove named semaphore NAME. */ | |
f492fc99 | 49 | extern int sem_unlink (const char *__name) __THROW __nonnull ((1)); |
76a50749 | 50 | |
4e648ea3 UD |
51 | /* Wait for SEM being posted. |
52 | ||
53 | This function is a cancellation point and therefore not marked with | |
54 | __THROW. */ | |
f492fc99 | 55 | extern int sem_wait (sem_t *__sem) __nonnull ((1)); |
76a50749 UD |
56 | |
57 | #ifdef __USE_XOPEN2K | |
4e648ea3 UD |
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. */ | |
76a50749 | 62 | extern int sem_timedwait (sem_t *__restrict __sem, |
f492fc99 YD |
63 | const struct timespec *__restrict __abstime) |
64 | __nonnull ((1, 2)); | |
76a50749 UD |
65 | #endif |
66 | ||
6615f779 MC |
67 | #ifdef __USE_GNU |
68 | extern int sem_clockwait (sem_t *__restrict __sem, | |
69 | clockid_t clock, | |
70 | const struct timespec *__restrict __abstime) | |
71 | __nonnull ((1, 3)); | |
72 | #endif | |
73 | ||
76a50749 | 74 | /* Test whether SEM is posted. */ |
f492fc99 | 75 | extern int sem_trywait (sem_t *__sem) __THROWNL __nonnull ((1)); |
76a50749 UD |
76 | |
77 | /* Post SEM. */ | |
f492fc99 | 78 | extern int sem_post (sem_t *__sem) __THROWNL __nonnull ((1)); |
76a50749 UD |
79 | |
80 | /* Get current value of SEM and store it in *SVAL. */ | |
81 | extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval) | |
f492fc99 | 82 | __THROW __nonnull ((1, 2)); |
76a50749 UD |
83 | |
84 | ||
85 | __END_DECLS | |
86 | ||
87 | #endif /* semaphore.h */ |