docs/how-to-build.md: use proper markup for directory names
[unleashed/tickless.git] / include / sys / lwp_upimutex_impl.h
blobef362208999cd2ebe2bb6e4b5ebc49f4e37f0a1c
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 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_LWP_UPIMUTEX_IMPL_H
28 #define _SYS_LWP_UPIMUTEX_IMPL_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/thread.h>
33 #include <sys/lwp.h>
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 typedef struct upimutex upimutex_t;
40 typedef struct upib upib_t;
42 struct upib {
43 kmutex_t upib_lock;
44 upimutex_t *upib_first;
47 struct upimutex {
48 struct _kthread *upi_owner; /* owner */
49 int upi_waiter; /* wait bit */
50 upib_t *upi_upibp; /* point back to upib bucket in hash chain */
51 lwp_mutex_t *upi_vaddr; /* virtual address, i.e. user lock ptr */
52 lwpchan_t upi_lwpchan; /* lwpchan of virtual address */
53 upimutex_t *upi_nextchain; /* next in hash chain */
54 upimutex_t *upi_nextowned; /* list of mutexes owned by lwp */
57 #define UPILWPCHAN_BITS 9
58 #define UPILWPCHAN_TABSIZ (1 << UPILWPCHAN_BITS)
59 #define UPIMUTEX_TABSIZE UPILWPCHAN_TABSIZ
60 #define UPILWPCHAN_HASH(lwpchan) \
61 (((uintptr_t)((lwpchan).lc_wchan0)^(uintptr_t)((lwpchan).lc_wchan)) ^ \
62 (((uintptr_t)((lwpchan).lc_wchan0)^(uintptr_t)((lwpchan).lc_wchan)) >> \
63 UPILWPCHAN_BITS)) & (UPIMUTEX_TABSIZE - 1)
64 #define UPI_CHAIN(lwpchan) upimutextab[UPILWPCHAN_HASH((lwpchan))]
66 #define UPIMUTEX_TRY 1
67 #define UPIMUTEX_BLOCK 0
69 #ifdef _KERNEL
70 extern void upimutex_cleanup();
71 #endif /* _KERNEL */
73 #ifdef __cplusplus
75 #endif
77 #endif /* _SYS_LWP_UPIMUTEX_IMPL_H */