xref: /illumos-gate/usr/src/uts/common/sys/condvar.h (revision 7c478bd9)
1 /*
2  * CDDL HEADER START
3  *
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.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * condvar.h:
29  *
30  * definitions for thread synchronization primitives: condition variables
31  * This is the public part of the interface to condition variables. The
32  * private (implementation-specific) part is in <arch>/sys/condvar_impl.h.
33  */
34 
35 #ifndef _SYS_CONDVAR_H
36 #define	_SYS_CONDVAR_H
37 
38 #pragma ident	"%Z%%M%	%I%	%E% SMI"
39 
40 #ifndef	_ASM
41 #include <sys/types.h>
42 #include <sys/time.h>
43 #ifdef _KERNEL
44 #include <sys/mutex.h>
45 #endif	/* _KERNEL */
46 #endif	/* _ASM */
47 
48 #ifdef	__cplusplus
49 extern "C" {
50 #endif
51 
52 #ifndef	_ASM
53 
54 /*
55  * Condtion variables.
56  */
57 
58 typedef struct _kcondvar {
59 	ushort_t	_opaque;
60 } kcondvar_t;
61 
62 typedef	enum {
63 	CV_DEFAULT,
64 	CV_DRIVER
65 } kcv_type_t;
66 
67 
68 #if defined(_KERNEL)
69 
70 /*
71  * condition variable function prototypes
72  */
73 
74 extern	void	cv_init(kcondvar_t *, char *, kcv_type_t, void *);
75 extern  void	cv_destroy(kcondvar_t *);
76 extern	void	cv_wait(kcondvar_t *, kmutex_t *);
77 extern	void	cv_wait_stop(kcondvar_t *, kmutex_t *, int);
78 extern	clock_t	cv_timedwait(kcondvar_t *, kmutex_t *, clock_t);
79 extern	int	cv_wait_sig(kcondvar_t *, kmutex_t *);
80 extern	clock_t	cv_timedwait_sig(kcondvar_t *, kmutex_t *, clock_t);
81 extern	int	cv_wait_sig_swap(kcondvar_t *, kmutex_t *);
82 extern	int	cv_wait_sig_swap_core(kcondvar_t *, kmutex_t *, int *);
83 extern	void	cv_signal(kcondvar_t *);
84 extern	void	cv_broadcast(kcondvar_t *);
85 extern	int	cv_waituntil_sig(kcondvar_t *, kmutex_t *, timestruc_t *, int);
86 
87 #endif	/* defined(_KERNEL) */
88 
89 #endif	/* _ASM */
90 
91 #ifdef	__cplusplus
92 }
93 #endif
94 
95 #endif	/* _SYS_CONDVAR_H */
96