4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 #include <sys/types.h>
34 #include <sys/int_types.h>
43 * Thread and LWP mutexes have the same type
48 * POSIX requires that <pthread.h> define the structures pthread_mutex_t
49 * and pthread_cond_t. Although these structures are identical to mutex_t
50 * (lwp_mutex_t) and cond_t (lwp_cond_t), defined here, a typedef of these
51 * types would require including <synch.h> in <pthread.h>, pulling in
52 * non-posix symbols/constants, violating POSIX namespace restrictions. Hence,
53 * pthread_mutex_t/pthread_cond_t have been redefined (in <sys/types.h>).
54 * Any modifications done to mutex_t/lwp_mutex_t or cond_t/lwp_cond_t must
55 * also be done to pthread_mutex_t/pthread_cond_t.
57 typedef struct _lwp_mutex
{
85 * Thread and LWP condition variables have the same
88 * The layout of the following structure should be kept in sync with the
89 * layout of pthread_cond_t in sys/types.h. See NOTE above for lwp_mutex_t.
91 typedef struct _lwp_cond
{
103 typedef struct _lwp_sema
{
104 uint32_t count
; /* semaphore count */
107 uint8_t flags
[8]; /* last byte reserved for waiters */
108 upad64_t data
; /* optional data */
112 * Thread and LWP rwlocks have the same type definition.
113 * NOTE: The layout of this structure should be kept in sync with the layout
114 * of the correponding structure of pthread_rwlock_t in sys/types.h.
115 * Also, because we have to deal with C++, there is an identical structure
116 * for rwlock_t in head/sync.h that we cannot change.
118 typedef struct _lwp_rwlock
{
119 int32_t readers
; /* rwstate word */
122 lwp_mutex_t mutex
; /* used with process-shared rwlocks */
123 lwp_cond_t readercv
; /* used only to indicate ownership */
124 lwp_cond_t writercv
; /* used only to indicate ownership */
129 * Definitions of synchronization types.
131 #define USYNC_THREAD 0x00 /* private to a process */
132 #define USYNC_PROCESS 0x01 /* shared by processes */
134 /* Keep the following values in sync with pthread.h */
135 #define LOCK_NORMAL 0x00 /* same as USYNC_THREAD */
136 #define LOCK_SHARED 0x01 /* same as USYNC_PROCESS */
137 #define LOCK_ERRORCHECK 0x02 /* error check lock */
138 #define LOCK_RECURSIVE 0x04 /* recursive lock */
139 #define LOCK_PRIO_INHERIT 0x10 /* priority inheritance lock */
140 #define LOCK_PRIO_PROTECT 0x20 /* priority ceiling lock */
141 #define LOCK_ROBUST 0x40 /* robust lock */
144 * USYNC_PROCESS_ROBUST is a deprecated historical type. It is mapped
145 * into (USYNC_PROCESS | LOCK_ROBUST) by mutex_init(). Application code
146 * should be revised to use (USYNC_PROCESS | LOCK_ROBUST) rather than this.
148 #define USYNC_PROCESS_ROBUST 0x08
153 #define LOCK_OWNERDEAD 0x1
154 #define LOCK_NOTRECOVERABLE 0x2
155 #define LOCK_INITED 0x4
156 #define LOCK_UNMAPPED 0x8
162 #endif /* _SYS_SYNCH_H */