xref: /titanic_44/usr/src/uts/common/sys/sem.h (revision 4496171313bed39e96f21bc2f9faf2868e267ae3)
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 1997-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 
31 #ifndef _SYS_SEM_H
32 #define	_SYS_SEM_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #include <sys/ipc.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * IPC Semaphore Facility.
44  */
45 
46 /*
47  * Implementation Constants.
48  */
49 
50 /*
51  * Permission Definitions.
52  */
53 
54 #define	SEM_A	0200	/* alter permission */
55 #define	SEM_R	0400	/* read permission */
56 
57 /*
58  * Semaphore Operation Flags.
59  */
60 
61 #define	SEM_UNDO	010000	/* set up adjust on exit entry */
62 
63 /*
64  * Semctl Command Definitions.
65  */
66 
67 #define	GETNCNT	3	/* get semncnt */
68 #define	GETPID	4	/* get sempid */
69 #define	GETVAL	5	/* get semval */
70 #define	GETALL	6	/* get all semval's */
71 #define	GETZCNT	7	/* get semzcnt */
72 #define	SETVAL	8	/* set semval */
73 #define	SETALL	9	/* set all semval's */
74 
75 /*
76  * Structure Definitions.
77  */
78 
79 struct semid_ds {
80 	struct ipc_perm sem_perm;	/* operation permission struct */
81 	struct sem	*sem_base;	/* ptr to first semaphore in set */
82 	ushort_t	sem_nsems;	/* # of semaphores in set */
83 #if defined(_LP64)
84 	time_t		sem_otime;	/* last semop time */
85 	time_t		sem_ctime;	/* last change time */
86 #else	/* _LP64 */
87 	time_t		sem_otime;	/* last semop time */
88 	int32_t		sem_pad1;	/* reserved for time_t expansion */
89 	time_t		sem_ctime;	/* last change time */
90 	int32_t		sem_pad2;	/* time_t expansion */
91 #endif	/* _LP64 */
92 	int		sem_binary;	/* flag indicating semaphore type */
93 	long		sem_pad3[3];	/* reserve area */
94 };
95 
96 /*
97  * User semaphore template for semop system calls.
98  */
99 struct sembuf {
100 	ushort_t	sem_num;	/* semaphore # */
101 	short		sem_op;		/* semaphore operation */
102 	short		sem_flg;	/* operation flags */
103 };
104 
105 #if !defined(_KERNEL)
106 #if defined(__STDC__)
107 int semctl(int, int, int, ...);
108 int semget(key_t, int, int);
109 int semids(int *, uint_t, uint_t *);
110 int semop(int, struct sembuf *, size_t);
111 #if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE)
112 int semtimedop(int, struct sembuf *, size_t, const struct timespec *);
113 #endif
114 #else /* __STDC__ */
115 int semctl();
116 int semget();
117 int semids();
118 int semop();
119 int semtimedop();
120 #endif /* __STDC__ */
121 #endif /* ! _KERNEL */
122 
123 #ifdef	__cplusplus
124 }
125 #endif
126 
127 #endif	/* _SYS_SEM_H */
128