ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
semaphore.h
Go to the documentation of this file.
1/* Copyright (C) 2002-2022 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 <https://www.gnu.org/licenses/>. */
17
18#ifndef _SEMAPHORE_H
19#define _SEMAPHORE_H 1
20
21#include <time.h>
22
23/* Definition for sem_t. */
24typedef struct
25{
26 int __lock;
28 int __init;
29 /* Threads currently blocked on this semaphore; see __ESBMC_sem_waiters. */
30 unsigned int __waiters;
31} sem_t;
32
33/* Initialize semaphore object SEM to VALUE. If PSHARED then share it
34 with other processes. */
35extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value);
36
37/* Free resources associated with semaphore object SEM. */
38extern int sem_destroy (sem_t *__sem);
39
40/* Open a named semaphore NAME with open flags OFLAG. */
41extern sem_t *sem_open (const char *__name, int __oflag, ...);
42
43/* Close descriptor for named semaphore SEM. */
44extern int sem_close (sem_t *__sem);
45
46/* Remove named semaphore NAME. */
47extern int sem_unlink (const char *__name);
48
49/* Wait for SEM being posted.
50
51 This function is a cancellation point and therefore not marked with
52 __THROW. */
53extern int sem_wait (sem_t *__sem);
54
55#ifdef __USE_XOPEN2K
56/* Similar to `sem_wait' but wait only until ABSTIME.
57
58 This function is a cancellation point and therefore not marked with
59 __THROW. */
60# ifndef __USE_TIME_BITS64
61extern int sem_timedwait (sem_t *__restrict __sem,
62 const struct timespec *__restrict __abstime);
63# else
64# ifdef __REDIRECT
65extern int __REDIRECT (sem_timedwait,
66 (sem_t *__restrict __sem,
67 const struct timespec *__restrict __abstime),
68 __sem_timedwait64);
69# else
70# define sem_timedwait __sem_timedwait64
71# endif
72# endif
73#endif
74
75#ifdef __USE_GNU
76# ifndef __USE_TIME_BITS64
77extern int sem_clockwait (sem_t *__restrict __sem,
79 const struct timespec *__restrict __abstime);
80# else
81# ifdef __REDIRECT
82extern int __REDIRECT (sem_clockwait,
83 (sem_t *__restrict __sem,
85 const struct timespec *__restrict __abstime),
86 __sem_clockwait64);
87# else
88# define sem_clockwait __sem_clockwait64
89# endif
90# endif
91#endif
92
93/* Test whether SEM is posted. */
94extern int sem_trywait (sem_t *__sem);
95
96/* Post SEM. */
97extern int sem_post (sem_t *__sem);
98
99/* Get current value of SEM and store it in *SVAL. */
100extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval);
101
102#endif /* semaphore.h */
int sem_init(sem_t *__sem, int __pshared, unsigned int __value)
Definition semaphore_lib.c:17
sem_t * sem_open(const char *__name, int __oflag,...)
int sem_trywait(sem_t *__sem)
int sem_wait(sem_t *__sem)
int sem_post(sem_t *__sem)
Definition semaphore_lib.c:88
int sem_close(sem_t *__sem)
int sem_unlink(const char *__name)
int sem_destroy(sem_t *__sem)
Definition semaphore_lib.c:104
int sem_getvalue(sem_t *__restrict __sem, int *__restrict __sval)
Definition semaphore.h:25
int __count
Definition semaphore.h:27
int __init
Definition semaphore.h:28
int __lock
Definition semaphore.h:26
unsigned int __waiters
Definition semaphore.h:30
Definition time.h:69
int clockid_t
Definition time.h:29
clock_t clock(void)
Definition time.c:105