]>
Commit | Line | Data |
---|---|---|
581c785b | 1 | /* Copyright (C) 2002-2022 Free Software Foundation, Inc. |
76a50749 | 2 | This file is part of the GNU C Library. |
9459fe9d | 3 | Ulrich Drepper <drepper@redhat.com>, 2002. |
76a50749 UD |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
76a50749 | 18 | |
fddfebbd | 19 | #include <semaphore.h> |
a28296e7 | 20 | #include <futex-internal.h> |
76a50749 UD |
21 | #include "pthreadP.h" |
22 | ||
e4f639e4 | 23 | #define SEM_SHM_PREFIX "sem." |
76a50749 | 24 | |
a28296e7 ST |
25 | static inline void __new_sem_open_init (struct new_sem *sem, unsigned value) |
26 | { | |
27 | #if __HAVE_64B_ATOMICS | |
28 | sem->data = value; | |
29 | #else | |
30 | sem->value = value << SEM_VALUE_SHIFT; | |
31 | sem->nwaiters = 0; | |
32 | #endif | |
33 | /* pad is used as a mutex on pre-v9 sparc and ignored otherwise. */ | |
34 | sem->pad = 0; | |
35 | ||
36 | /* This always is a shared semaphore. */ | |
37 | sem->private = FUTEX_SHARED; | |
38 | } | |
76a50749 UD |
39 | |
40 | /* Prototypes of functions with multiple interfaces. */ | |
41 | extern int __new_sem_init (sem_t *sem, int pshared, unsigned int value); | |
3d2dd6ca | 42 | extern int __old_sem_init (sem_t *sem, int pshared, unsigned int value); |
76a50749 UD |
43 | extern int __new_sem_destroy (sem_t *sem); |
44 | extern int __new_sem_post (sem_t *sem); | |
45 | extern int __new_sem_wait (sem_t *sem); | |
3d2dd6ca | 46 | extern int __old_sem_wait (sem_t *sem); |
76a50749 UD |
47 | extern int __new_sem_trywait (sem_t *sem); |
48 | extern int __new_sem_getvalue (sem_t *sem, int *sval); | |
b8d3e8fb LM |
49 | |
50 | #if __TIMESIZE == 64 | |
51 | # define __sem_clockwait64 __sem_clockwait | |
52 | # define __sem_timedwait64 __sem_timedwait | |
53 | #else | |
54 | extern int | |
55 | __sem_clockwait64 (sem_t *sem, clockid_t clockid, | |
56 | const struct __timespec64 *abstime); | |
19cc20ef | 57 | libc_hidden_proto (__sem_clockwait64) |
b8d3e8fb LM |
58 | extern int |
59 | __sem_timedwait64 (sem_t *sem, const struct __timespec64 *abstime); | |
018c75dc | 60 | libc_hidden_proto (__sem_timedwait64) |
b8d3e8fb | 61 | #endif |