pkg: ship usr/lib/security/amd64/*.so links
[unleashed.git] / include / sys / condvar.h
blobef72c3c567faf0a0eb3610b2f0a5be0fd274f2cd
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 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * Copyright (c) 2012 by Delphix. All rights reserved.
31 * condvar.h:
33 * definitions for thread synchronization primitives: condition variables
34 * This is the public part of the interface to condition variables. The
35 * private (implementation-specific) part is in <arch>/sys/condvar_impl.h.
38 #ifndef _SYS_CONDVAR_H
39 #define _SYS_CONDVAR_H
41 #ifndef _ASM
42 #include <sys/types.h>
43 #include <sys/time.h>
44 #ifdef _KERNEL
45 #include <sys/mutex.h>
46 #endif /* _KERNEL */
47 #endif /* _ASM */
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
53 #ifndef _ASM
56 * Condtion variables.
59 typedef struct _kcondvar {
60 ushort_t _opaque;
61 } kcondvar_t;
63 typedef enum {
64 CV_DEFAULT,
65 CV_DRIVER
66 } kcv_type_t;
68 #if defined(_KERNEL)
71 * Time resolution values used in cv_reltimedwait() and cv_reltimedwait_sig()
72 * to specify how accurately a relative timeout must expire - if it can be
73 * anticipated or deferred.
75 typedef enum {
76 TR_NANOSEC,
77 TR_MICROSEC,
78 TR_MILLISEC,
79 TR_SEC,
80 TR_CLOCK_TICK,
81 TR_COUNT
82 } time_res_t;
84 extern time_res_t time_res[];
86 #define TIME_RES_VALID(tr) (tr >= TR_NANOSEC && tr < TR_COUNT)
89 * condition variable function prototypes
92 extern void cv_init(kcondvar_t *, char *, kcv_type_t, void *);
93 extern void cv_destroy(kcondvar_t *);
94 extern void cv_wait(kcondvar_t *, kmutex_t *);
95 extern void cv_wait_stop(kcondvar_t *, kmutex_t *, int);
96 extern clock_t cv_timedwait(kcondvar_t *, kmutex_t *, clock_t);
97 extern clock_t cv_timedwait_hires(kcondvar_t *, kmutex_t *, hrtime_t, hrtime_t,
98 int);
99 extern clock_t cv_reltimedwait(kcondvar_t *, kmutex_t *, clock_t, time_res_t);
100 extern int cv_wait_sig(kcondvar_t *, kmutex_t *);
101 extern clock_t cv_timedwait_sig(kcondvar_t *, kmutex_t *, clock_t);
102 extern int cv_timedwait_sig_hrtime(kcondvar_t *, kmutex_t *, hrtime_t);
103 extern clock_t cv_reltimedwait_sig(kcondvar_t *, kmutex_t *, clock_t,
104 time_res_t);
105 extern int cv_wait_sig_swap(kcondvar_t *, kmutex_t *);
106 extern int cv_wait_sig_swap_core(kcondvar_t *, kmutex_t *, int *);
107 extern void cv_signal(kcondvar_t *);
108 extern void cv_broadcast(kcondvar_t *);
109 extern int cv_waituntil_sig(kcondvar_t *, kmutex_t *, timestruc_t *, int);
111 #endif /* defined(_KERNEL) */
113 #endif /* _ASM */
115 #ifdef __cplusplus
117 #endif
119 #endif /* _SYS_CONDVAR_H */