CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
semaphore.c
Go to the documentation of this file.
1/* FUNCTION: sem_init */
2
3#include <semaphore.h>
4
5int sem_init(sem_t *sem, int pshared, unsigned int value)
6{
9 (void)value;
10 (void)sem;
11
12 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
13 __CPROVER_set_must(sem, "sem-init");
14 __CPROVER_clear_may(sem, "sem-destroyed");
15 #endif
16
17 return 0;
18}
19
20/* FUNCTION: sem_wait */
21
22#include <semaphore.h>
23
25{
27 (void)sem;
28
29 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
31 "semaphore must be initialized");
32 __CPROVER_assert(!__CPROVER_get_may(sem, "sem-destroyed"),
33 "semaphore must not be destroyed");
34 #endif
35
36 return 0;
37}
38
39/* FUNCTION: sem_timedwait */
40
41#include <semaphore.h>
42
44{
46 (void)sem;
48
49 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
51 "semaphore must be initialized");
52 __CPROVER_assert(!__CPROVER_get_may(sem, "sem-destroyed"),
53 "semaphore must not be destroyed");
54 #endif
55
56 return 0;
57}
58
59/* FUNCTION: sem_trywait */
60
61#include <semaphore.h>
62
64{
66 (void)sem;
67
68 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
70 "semaphore must be initialized");
71 __CPROVER_assert(!__CPROVER_get_may(sem, "sem-destroyed"),
72 "semaphore must not be destroyed");
73 #endif
74
75 return 0;
76}
77
78/* FUNCTION: sem_post */
79
80#include <semaphore.h>
81
83{
85 (void)sem;
86
87 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
89 "semaphore must be initialized");
90 __CPROVER_assert(!__CPROVER_get_may(sem, "sem-destroyed"),
91 "semaphore must not be destroyed");
92 #endif
93
94 return 0;
95}
96
97/* FUNCTION: sem_post_multiple */
98
99#include <semaphore.h>
100
101int sem_post_multiple(sem_t *sem, int number)
102{
104 (void)sem;
105 (void)number;
106
107 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
109 "semaphore must be initialized");
110 __CPROVER_assert(!__CPROVER_get_may(sem, "sem-destroyed"),
111 "semaphore must not be destroyed");
112 #endif
113
114 return 0;
115}
116
117/* FUNCTION: sem_getvalue */
118
119#include <semaphore.h>
120
122{
124 (void)sem;
125 (void)sval;
126
127 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
129 "semaphore must be initialized");
130 __CPROVER_assert(!__CPROVER_get_may(sem, "sem-destroyed"),
131 "semaphore must not be destroyed");
132 #endif
133
134 return 0;
135}
136
137/* FUNCTION: sem_destroy */
138
139#include <semaphore.h>
140
142{
144 (void)sem;
145
146 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
148 "semaphore must be initialized");
149 __CPROVER_assert(!__CPROVER_get_may(sem, "sem-destroyed"),
150 "semaphore must not be destroyed");
151 __CPROVER_set_may(sem, "sem-destroyed");
152 #endif
153
154 return 0;
155}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
void __CPROVER_assert(__CPROVER_bool assertion, const char *description)
__CPROVER_bool __CPROVER_get_must(const void *, const char *)
void __CPROVER_set_may(const void *, const char *)
void __CPROVER_clear_may(const void *, const char *)
__CPROVER_bool __CPROVER_get_may(const void *, const char *)
void __CPROVER_set_must(const void *, const char *)
int sem_post(sem_t *sem)
Definition semaphore.c:82
int sem_trywait(sem_t *sem)
Definition semaphore.c:63
int sem_init(sem_t *sem, int pshared, unsigned int value)
Definition semaphore.c:5
int sem_destroy(sem_t *sem)
Definition semaphore.c:141
int sem_post_multiple(sem_t *sem, int number)
Definition semaphore.c:101
int sem_getvalue(sem_t *sem, int *sval)
Definition semaphore.c:121
int sem_timedwait(sem_t *sem, const struct timespec *abstime)
Definition semaphore.c:43
int sem_wait(sem_t *sem)
Definition semaphore.c:24