2 /* $NetBSD: sem.h,v 1.5 1994/06/29 06:45:15 cgd Exp $ */
5 * SVID compatible sem.h file
7 * Author: Daniel Boulet
13 #ifdef _WANT_SYSVSEM_INTERNALS
14 #define _WANT_SYSVIPC_INTERNALS
18 #ifndef _PID_T_DECLARED
19 typedef __pid_t pid_t;
20 #define _PID_T_DECLARED
23 #ifndef _SIZE_T_DECLARED
24 typedef __size_t size_t;
25 #define _SIZE_T_DECLARED
28 #ifndef _TIME_T_DECLARED
29 typedef __time_t time_t;
30 #define _TIME_T_DECLARED
33 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
34 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
36 struct ipc_perm_old sem_perm; /* operation permission struct */
37 struct sem *__sem_base; /* pointer to first semaphore in set */
38 unsigned short sem_nsems; /* number of sems in set */
39 time_t sem_otime; /* last operation time */
40 long sem_pad1; /* SVABI/386 says I need this here */
41 time_t sem_ctime; /* last change time */
42 /* Times measured in secs since */
43 /* 00:00:00 UTC, Jan. 1, 1970, without leap seconds */
44 long sem_pad2; /* SVABI/386 says I need this here */
45 long sem_pad3[4]; /* SVABI/386 says I need this here */
50 struct ipc_perm sem_perm; /* operation permission struct */
51 struct sem *__sem_base; /* pointer to first semaphore in set */
52 unsigned short sem_nsems; /* number of sems in set */
53 time_t sem_otime; /* last operation time */
54 time_t sem_ctime; /* last change time */
55 /* Times measured in secs since */
56 /* 00:00:00 UTC, Jan. 1, 1970, without leap seconds */
60 * semop's sops parameter structure
63 unsigned short sem_num; /* semaphore # */
64 short sem_op; /* semaphore operation */
65 short sem_flg; /* operation flags */
67 #define SEM_UNDO 010000
69 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
70 defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) || \
71 defined(_WANT_SEMUN_OLD)
73 int val; /* value for SETVAL */
74 struct semid_ds_old *buf; /* buffer for IPC_STAT & IPC_SET */
75 unsigned short *array; /* array for GETALL & SETALL */
79 #if defined(_KERNEL) || defined(_WANT_SEMUN)
81 * semctl's arg parameter structure
84 int val; /* value for SETVAL */
85 struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
86 unsigned short *array; /* array for GETALL & SETALL */
93 #define GETNCNT 3 /* Return the value of semncnt {READ} */
94 #define GETPID 4 /* Return the value of sempid {READ} */
95 #define GETVAL 5 /* Return the value of semval {READ} */
96 #define GETALL 6 /* Return semvals into arg.array {READ} */
97 #define GETZCNT 7 /* Return the value of semzcnt {READ} */
98 #define SETVAL 8 /* Set the value of semval to arg.val {ALTER} */
99 #define SETALL 9 /* Set semvals from arg.array {ALTER} */
100 #define SEM_STAT 10 /* Like IPC_STAT but treats semid as sema-index */
101 #define SEM_INFO 11 /* Like IPC_INFO but treats semid as sema-index */
106 #define SEM_A IPC_W /* alter permission */
107 #define SEM_R IPC_R /* read permission */
109 #if defined(_KERNEL) || defined(_WANT_SYSVSEM_INTERNALS)
111 * semaphore info struct
114 int semmni; /* # of semaphore identifiers */
115 int semmns; /* # of semaphores in system */
116 int semmnu; /* # of undo structures in system */
117 int semmsl; /* max # of semaphores per id */
118 int semopm; /* max # of operations per semop call */
119 int semume; /* max # of undo entries per process */
120 int semusz; /* size in bytes of undo structure */
121 int semvmx; /* semaphore maximum value */
122 int semaem; /* adjust on exit max value */
126 * Kernel wrapper for the user-level structure
128 struct semid_kernel {
130 struct label *label; /* MAC framework label */
131 struct ucred *cred; /* creator's credentials */
134 /* internal "mode" bits */
135 #define SEM_ALLOC 01000 /* semaphore is allocated */
136 #define SEM_DEST 02000 /* semaphore will be destroyed on last detach */
140 extern struct seminfo seminfo;
142 * Process sem_undo vectors at proc exit.
144 void semexit(struct proc *p);
150 int semsys(int, ...);
152 int semctl(int, int, int, ...);
153 int semget(key_t, int, int);
154 int semop(int, struct sembuf *, size_t);
157 #endif /* !_KERNEL */
159 #endif /* !_SYS_SEM_H_ */