]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/nptl/semaphore.h
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / nptl / semaphore.h
1 /* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
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
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
17
18 #ifndef _SEMAPHORE_H
19 #define _SEMAPHORE_H    1
20
21 #include <features.h>
22 #include <sys/types.h>
23 #ifdef __USE_XOPEN2K
24 # define __need_timespec
25 # include <time.h>
26 #endif
27
28 /* Get the definition for sem_t.  */
29 #include <bits/semaphore.h>
30
31
32 __BEGIN_DECLS
33
34 /* Initialize semaphore object SEM to VALUE.  If PSHARED then share it
35    with other processes.  */
36 extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value)
37      __THROW;
38 /* Free resources associated with semaphore object SEM.  */
39 extern int sem_destroy (sem_t *__sem) __THROW;
40
41 /* Open a named semaphore NAME with open flags OFLAG.  */
42 extern sem_t *sem_open (const char *__name, int __oflag, ...) __THROW;
43
44 /* Close descriptor for named semaphore SEM.  */
45 extern int sem_close (sem_t *__sem) __THROW;
46
47 /* Remove named semaphore NAME.  */
48 extern int sem_unlink (const char *__name) __THROW;
49
50 /* Wait for SEM being posted.
51
52    This function is a cancellation point and therefore not marked with
53    __THROW.  */
54 extern int sem_wait (sem_t *__sem);
55
56 #ifdef __USE_XOPEN2K
57 /* Similar to `sem_wait' but wait only until ABSTIME.
58
59    This function is a cancellation point and therefore not marked with
60    __THROW.  */
61 extern int sem_timedwait (sem_t *__restrict __sem,
62                           const struct timespec *__restrict __abstime);
63 #endif
64
65 /* Test whether SEM is posted.  */
66 extern int sem_trywait (sem_t *__sem) __THROW;
67
68 /* Post SEM.  */
69 extern int sem_post (sem_t *__sem) __THROW;
70
71 /* Get current value of SEM and store it in *SVAL.  */
72 extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval)
73      __THROW;
74
75
76 __END_DECLS
77
78 #endif  /* semaphore.h */