Debian Codegraph @

share/libc/sys/sem.h

raw
1 /**************************************************************************/
2 /* */
3 /* This file is part of Frama-C. */
4 /* */
5 /* Copyright (C) 2007-2022 */
6 /* CEA (Commissariat à l'énergie atomique et aux énergies */
7 /* alternatives) */
8 /* */
9 /* you can redistribute it and/or modify it under the terms of the GNU */
10 /* Lesser General Public License as published by the Free Software */
11 /* Foundation, version 2.1. */
12 /* */
13 /* It is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
16 /* GNU Lesser General Public License for more details. */
17 /* */
18 /* See the GNU Lesser General Public License version 2.1 */
19 /* for more details (enclosed in the file licenses/LGPLv2.1). */
20 /* */
21 /**************************************************************************/
22
23 #ifndef __FC_SYS_SEM
24 #define __FC_SYS_SEM
25 #include "../features.h"
26 __PUSH_FC_STDLIB
27 #include "../__fc_define_pid_t.h"
28 #include "../__fc_define_size_t.h"
29 #include "../__fc_define_time_t.h"
30 #include "ipc.h"
31
32 __BEGIN_DECLS
33
34 #define SEM_UNDO 0x1000
35
36 #define GETNCNT 14
37 #define GETPID 11
38 #define GETVAL 12
39 #define GETALL 13
40 #define GETZCNT 15
41 #define SETVAL 16
42 #define SETALL 17
43
44 struct semid_ds {
45 struct ipc_perm sem_perm;
46 unsigned short sem_nsems;
47 time_t sem_otime;
48 time_t sem_ctime;
49 };
50
51 // POSIX 2018 states: "a semaphore shall be represented by an anonymous
52 // structure, which shall include the following members".
53 struct __fc_sem {
54 unsigned short semval;
55 pid_t sempid;
56 unsigned short semncnt;
57 unsigned short semzcnt;
58 };
59
60 struct sembuf {
61 unsigned short sem_num;
62 short sem_op;
63 short sem_flg;
64 };
65
66 extern int semctl(int semid, int semnum, int cmd, ...);
67
68 extern int semget(key_t key, int nsems, int semflg);
69
70 extern int semop(int semid, struct sembuf *sops, size_t nsops);
71
72 __END_DECLS
73
74 __POP_FC_STDLIB
75 #endif