xref: /titanic_52/usr/src/lib/libbc/inc/include/sys/sem.h (revision d58fda4376e4bf67072ce2e69f6f47036f9dbb68)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1986 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*      Copyright (c) 1984 AT&T */
28 /*        All Rights Reserved   */
29 
30 #ifndef _sys_sem_h
31 #define	_sys_sem_h
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 /*
36  *	IPC Semaphore Facility.
37  */
38 
39 /*
40  *	Semaphore Operation Flags.
41  */
42 #define	SEM_UNDO	010000	/* set up adjust on exit entry */
43 
44 /*
45  *	Semctl Command Definitions.
46  */
47 
48 #define	GETNCNT	3	/* get semncnt */
49 #define	GETPID	4	/* get sempid */
50 #define	GETVAL	5	/* get semval */
51 #define	GETALL	6	/* get all semval's */
52 #define	GETZCNT	7	/* get semzcnt */
53 #define	SETVAL	8	/* set semval */
54 #define	SETALL	9	/* set all semval's */
55 
56 /*
57  *	Structure Definitions.
58  */
59 
60 /*
61  *	There is one semaphore id data structure for each set of semaphores
62  *		in the system.
63  */
64 
65 struct semid_ds {
66 	struct ipc_perm	sem_perm;	/* operation permission struct */
67 	struct sem	*sem_base;	/* ptr to first semaphore in set */
68 	ushort		sem_nsems;	/* # of semaphores in set */
69 	time_t		sem_otime;	/* last semop time */
70 	time_t		sem_ctime;	/* last change time */
71 };
72 
73 /*
74  *	There is one semaphore structure for each semaphore in the system.
75  */
76 
77 struct sem {
78 	ushort	semval;		/* semaphore text map address */
79 	short	sempid;		/* pid of last operation */
80 	ushort	semncnt;	/* # awaiting semval > cval */
81 	ushort	semzcnt;	/* # awaiting semval = 0 */
82 };
83 
84 /*
85  *	User semaphore template for semop system calls.
86  */
87 
88 struct sembuf {
89 	short	sem_num;	/* semaphore # */
90 	short	sem_op;		/* semaphore operation */
91 	short	sem_flg;	/* operation flags */
92 };
93 
94 /*
95  *	'arg' argument template for semctl system calls.
96  */
97 union semun {
98 	int		val;	/* value for SETVAL */
99 	struct semid_ds	*buf;	/* buffer for IPC_STAT & IPC_SET */
100 	ushort		*array;	/* array for GETALL & SETALL */
101 };
102 
103 #endif /* !_sys_sem_h */
104