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