docs/how-to-build.md: use proper markup for directory names
[unleashed/tickless.git] / include / sys / sem_impl.h
blobecc220713d840a7535a9b18098a043fb289e27dd
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
30 #ifndef _SYS_SEM_IMPL_H
31 #define _SYS_SEM_IMPL_H
33 #pragma ident "%Z%%M% %I% %E% SMI"
35 #include <sys/ipc_impl.h>
36 #if defined(_KERNEL) || defined(_KMEMUSER)
37 #include <sys/sem.h>
38 #include <sys/t_lock.h>
39 #include <sys/avl.h>
40 #include <sys/list.h>
41 #endif
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
48 * Argument vectors for the various flavors of semsys().
51 #define SEMCTL 0
52 #define SEMGET 1
53 #define SEMOP 2
54 #define SEMIDS 3
55 #define SEMTIMEDOP 4
57 #if defined(_KERNEL) || defined(_KMEMUSER)
60 * There is one semaphore id data structure (semid_ds) for each set of
61 * semaphores in the system.
63 typedef struct ksemid {
64 kipc_perm_t sem_perm; /* operation permission struct */
65 struct sem *sem_base; /* ptr to first semaphore in set */
66 ushort_t sem_nsems; /* # of semaphores in set */
67 time_t sem_otime; /* last semop time */
68 time_t sem_ctime; /* last change time */
69 int sem_binary; /* flag indicating semaphore type */
70 int sem_maxops; /* maximum number of operations */
71 list_t sem_undos; /* list of undo structures */
72 } ksemid_t;
75 * There is one semaphore structure (sem) for each semaphore in the system.
77 struct sem {
78 ushort_t semval; /* semaphore value */
79 pid_t sempid; /* pid of last operation */
80 ushort_t semncnt; /* # awaiting semval > cval */
81 ushort_t semzcnt; /* # awaiting semval = 0 */
82 kcondvar_t semncnt_cv;
83 kcondvar_t semzcnt_cv;
87 * There is one undo structure per process in the system.
89 struct sem_undo {
90 avl_node_t un_avl; /* node in per-process avl tree */
91 list_node_t un_list; /* ptr to next active undo structure */
92 proc_t *un_proc; /* back-pointer to process */
93 ksemid_t *un_sp; /* back-pointer to semaphore */
94 int un_aoe[1]; /* adjust on exit values */
96 #endif /* _KERNEL */
98 #if defined(_SYSCALL32)
100 * LP64 view of the ILP32 semid_ds structure
102 struct semid_ds32 {
103 struct ipc_perm32 sem_perm; /* operation permission struct */
104 caddr32_t sem_base; /* ptr to first semaphore in set */
105 uint16_t sem_nsems; /* # of semaphores in set */
106 time32_t sem_otime; /* last semop time */
107 int32_t sem_pad1; /* reserved for time_t expansion */
108 time32_t sem_ctime; /* last semop time */
109 int32_t sem_pad2; /* reserved for time_t expansion */
110 int32_t sem_binary; /* flag indicating semaphore type */
111 int32_t sem_pad3[3]; /* reserve area */
113 #endif
115 #ifdef _KERNEL
116 extern void semexit(proc_t *);
117 #endif
119 #ifdef __cplusplus
121 #endif
123 #endif /* _SYS_SEM_IMPL_H */