1700 Add SCSI UNMAP support
[unleashed.git] / usr / src / uts / common / sys / rwlock.h
blobdc2eb93ae33c5da87c0f627ad3a21b4a1842f48d
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
30 #ifndef _SYS_RWLOCK_H
31 #define _SYS_RWLOCK_H
34 * Public interface to readers/writer locks. See rwlock(9F) for details.
37 #include <sys/types.h>
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
43 #ifndef _ASM
45 typedef enum {
46 RW_DRIVER = 2, /* driver (DDI) rwlock */
47 RW_DEFAULT = 4 /* kernel default rwlock */
48 } krw_type_t;
50 typedef enum {
51 RW_WRITER,
52 RW_READER,
53 RW_READER_STARVEWRITER
54 } krw_t;
56 typedef struct _krwlock {
57 void *_opaque[1];
58 } krwlock_t;
60 #if defined(_KERNEL)
62 #define RW_READ_HELD(x) (rw_read_held((x)))
63 #define RW_WRITE_HELD(x) (rw_write_held((x)))
64 #define RW_LOCK_HELD(x) (rw_lock_held((x)))
65 #define RW_ISWRITER(x) (rw_iswriter(x))
67 extern void rw_init(krwlock_t *, char *, krw_type_t, void *);
68 extern void rw_destroy(krwlock_t *);
69 extern void rw_enter(krwlock_t *, krw_t);
70 extern int rw_tryenter(krwlock_t *, krw_t);
71 extern void rw_exit(krwlock_t *);
72 extern void rw_downgrade(krwlock_t *);
73 extern int rw_tryupgrade(krwlock_t *);
74 extern int rw_read_held(krwlock_t *);
75 extern int rw_write_held(krwlock_t *);
76 extern int rw_lock_held(krwlock_t *);
77 extern int rw_read_locked(krwlock_t *);
78 extern int rw_iswriter(krwlock_t *);
79 extern struct _kthread *rw_owner(krwlock_t *);
80 extern uint_t (*rw_lock_backoff)(uint_t);
81 extern void (*rw_lock_delay)(uint_t);
83 #endif /* defined(_KERNEL) */
85 #endif /* _ASM */
87 #ifdef __cplusplus
89 #endif
91 #endif /* _SYS_RWLOCK_H */