xref: /titanic_54/usr/src/uts/common/sys/condvar.h (revision 3348528f7ec68bf2f11d0cbd5c3b9932ea7f0d5c)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*3348528fSdm120769  * Common Development and Distribution License, Version 1.0 only
6*3348528fSdm120769  * (the "License").  You may not use this file except in compliance
7*3348528fSdm120769  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*3348528fSdm120769  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  * condvar.h:
297c478bd9Sstevel@tonic-gate  *
307c478bd9Sstevel@tonic-gate  * definitions for thread synchronization primitives: condition variables
317c478bd9Sstevel@tonic-gate  * This is the public part of the interface to condition variables. The
327c478bd9Sstevel@tonic-gate  * private (implementation-specific) part is in <arch>/sys/condvar_impl.h.
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifndef _SYS_CONDVAR_H
367c478bd9Sstevel@tonic-gate #define	_SYS_CONDVAR_H
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #ifndef	_ASM
417c478bd9Sstevel@tonic-gate #include <sys/types.h>
427c478bd9Sstevel@tonic-gate #include <sys/time.h>
437c478bd9Sstevel@tonic-gate #ifdef _KERNEL
447c478bd9Sstevel@tonic-gate #include <sys/mutex.h>
457c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
467c478bd9Sstevel@tonic-gate #endif	/* _ASM */
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
497c478bd9Sstevel@tonic-gate extern "C" {
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #ifndef	_ASM
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  * Condtion variables.
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate typedef struct _kcondvar {
597c478bd9Sstevel@tonic-gate 	ushort_t	_opaque;
607c478bd9Sstevel@tonic-gate } kcondvar_t;
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate typedef	enum {
637c478bd9Sstevel@tonic-gate 	CV_DEFAULT,
647c478bd9Sstevel@tonic-gate 	CV_DRIVER
657c478bd9Sstevel@tonic-gate } kcv_type_t;
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * condition variable function prototypes
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate extern	void	cv_init(kcondvar_t *, char *, kcv_type_t, void *);
757c478bd9Sstevel@tonic-gate extern  void	cv_destroy(kcondvar_t *);
767c478bd9Sstevel@tonic-gate extern	void	cv_wait(kcondvar_t *, kmutex_t *);
777c478bd9Sstevel@tonic-gate extern	void	cv_wait_stop(kcondvar_t *, kmutex_t *, int);
787c478bd9Sstevel@tonic-gate extern	clock_t	cv_timedwait(kcondvar_t *, kmutex_t *, clock_t);
797c478bd9Sstevel@tonic-gate extern	int	cv_wait_sig(kcondvar_t *, kmutex_t *);
807c478bd9Sstevel@tonic-gate extern	clock_t	cv_timedwait_sig(kcondvar_t *, kmutex_t *, clock_t);
817c478bd9Sstevel@tonic-gate extern	int	cv_wait_sig_swap(kcondvar_t *, kmutex_t *);
827c478bd9Sstevel@tonic-gate extern	int	cv_wait_sig_swap_core(kcondvar_t *, kmutex_t *, int *);
837c478bd9Sstevel@tonic-gate extern	void	cv_signal(kcondvar_t *);
847c478bd9Sstevel@tonic-gate extern	void	cv_broadcast(kcondvar_t *);
85*3348528fSdm120769 extern	int	cv_waituntil_sig(kcondvar_t *, kmutex_t *, timestruc_t *, int);
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #endif	/* defined(_KERNEL) */
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate #endif	/* _ASM */
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
927c478bd9Sstevel@tonic-gate }
937c478bd9Sstevel@tonic-gate #endif
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate #endif	/* _SYS_CONDVAR_H */
96