1/* Copyright (C) 1995-2020 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 _SYS_SEM_H
19# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
20#endif
21
22#include <sys/types.h>
23#include <bits/sem-pad.h>
24
25/* Flags for `semop'. */
26#define SEM_UNDO 0x1000 /* undo the operation on exit */
27
28/* Commands for `semctl'. */
29#define GETPID 11 /* get sempid */
30#define GETVAL 12 /* get semval */
31#define GETALL 13 /* get all semval's */
32#define GETNCNT 14 /* get semncnt */
33#define GETZCNT 15 /* get semzcnt */
34#define SETVAL 16 /* set semval */
35#define SETALL 17 /* set all semval's */
36
37
38#if __SEM_PAD_BEFORE_TIME
39# define __SEM_PAD_TIME(NAME, RES) \
40 __syscall_ulong_t __glibc_reserved ## RES; __time_t NAME
41#elif __SEM_PAD_AFTER_TIME
42# define __SEM_PAD_TIME(NAME, RES) \
43 __time_t NAME; __syscall_ulong_t __glibc_reserved ## RES
44#else
45# define __SEM_PAD_TIME(NAME, RES) \
46 __time_t NAME
47#endif
48
49/* Data structure describing a set of semaphores. */
50struct semid_ds
51{
52 struct ipc_perm sem_perm; /* operation permission struct */
53 __SEM_PAD_TIME (sem_otime, 1); /* last semop() time */
54 __SEM_PAD_TIME (sem_ctime, 2); /* last time changed by semctl() */
55 __syscall_ulong_t sem_nsems; /* number of semaphores in set */
56 __syscall_ulong_t __glibc_reserved3;
57 __syscall_ulong_t __glibc_reserved4;
58};
59
60/* The user should define a union like the following to use it for arguments
61 for `semctl'.
62
63 union semun
64 {
65 int val; <= value for SETVAL
66 struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
67 unsigned short int *array; <= array for GETALL & SETALL
68 struct seminfo *__buf; <= buffer for IPC_INFO
69 };
70
71 Previous versions of this file used to define this union but this is
72 incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
73 one must define the union or not. */
74#define _SEM_SEMUN_UNDEFINED 1
75
76#ifdef __USE_MISC
77
78/* ipcs ctl cmds */
79# define SEM_STAT 18
80# define SEM_INFO 19
81# define SEM_STAT_ANY 20
82
83struct seminfo
84{
85 int semmap;
86 int semmni;
87 int semmns;
88 int semmnu;
89 int semmsl;
90 int semopm;
91 int semume;
92 int semusz;
93 int semvmx;
94 int semaem;
95};
96
97#endif /* __USE_MISC */
98