1*b819cea2SGordon Ross /*
2*b819cea2SGordon Ross  * CDDL HEADER START
3*b819cea2SGordon Ross  *
4*b819cea2SGordon Ross  * The contents of this file are subject to the terms of the
5*b819cea2SGordon Ross  * Common Development and Distribution License, Version 1.0 only
6*b819cea2SGordon Ross  * (the "License").  You may not use this file except in compliance
7*b819cea2SGordon Ross  * with the License.
8*b819cea2SGordon Ross  *
9*b819cea2SGordon Ross  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*b819cea2SGordon Ross  * or http://www.opensolaris.org/os/licensing.
11*b819cea2SGordon Ross  * See the License for the specific language governing permissions
12*b819cea2SGordon Ross  * and limitations under the License.
13*b819cea2SGordon Ross  *
14*b819cea2SGordon Ross  * When distributing Covered Code, include this CDDL HEADER in each
15*b819cea2SGordon Ross  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*b819cea2SGordon Ross  * If applicable, add the following below this CDDL HEADER, with the
17*b819cea2SGordon Ross  * fields enclosed by brackets "[]" replaced with your own identifying
18*b819cea2SGordon Ross  * information: Portions Copyright [yyyy] [name of copyright owner]
19*b819cea2SGordon Ross  *
20*b819cea2SGordon Ross  * CDDL HEADER END
21*b819cea2SGordon Ross  */
22*b819cea2SGordon Ross /*
23*b819cea2SGordon Ross  * Copyright (c) 1993-1998 by Sun Microsystems, Inc.
24*b819cea2SGordon Ross  * All rights reserved.
25*b819cea2SGordon Ross  *
26*b819cea2SGordon Ross  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
27*b819cea2SGordon Ross  */
28*b819cea2SGordon Ross 
29*b819cea2SGordon Ross #ifndef _SYS_SEMAPHORE_H
30*b819cea2SGordon Ross #define	_SYS_SEMAPHORE_H
31*b819cea2SGordon Ross 
32*b819cea2SGordon Ross /*
33*b819cea2SGordon Ross  * Public interface to semaphores.  See semaphore(9F) for details.
34*b819cea2SGordon Ross  */
35*b819cea2SGordon Ross 
36*b819cea2SGordon Ross #include <sys/synch.h>	/* lwp_sema_t */
37*b819cea2SGordon Ross 
38*b819cea2SGordon Ross #ifdef	__cplusplus
39*b819cea2SGordon Ross extern "C" {
40*b819cea2SGordon Ross #endif
41*b819cea2SGordon Ross 
42*b819cea2SGordon Ross typedef enum {
43*b819cea2SGordon Ross 	SEMA_DEFAULT,
44*b819cea2SGordon Ross 	SEMA_DRIVER
45*b819cea2SGordon Ross } ksema_type_t;
46*b819cea2SGordon Ross 
47*b819cea2SGordon Ross typedef lwp_sema_t ksema_t;
48*b819cea2SGordon Ross 
49*b819cea2SGordon Ross #define	SEMA_HELD(x)		(sema_held((x)))
50*b819cea2SGordon Ross 
51*b819cea2SGordon Ross /*
52*b819cea2SGordon Ross  * We're simulating the kernel mutex API here, and the
53*b819cea2SGordon Ross  * user-level has a different signature, so rename.
54*b819cea2SGordon Ross  */
55*b819cea2SGordon Ross 
56*b819cea2SGordon Ross #define	sema_init	ksema_init
57*b819cea2SGordon Ross #define	sema_destroy	ksema_destroy
58*b819cea2SGordon Ross 
59*b819cea2SGordon Ross extern	void	ksema_init(ksema_t *, uint32_t, char *, ksema_type_t, void *);
60*b819cea2SGordon Ross extern	void	ksema_destroy(ksema_t *);
61*b819cea2SGordon Ross 
62*b819cea2SGordon Ross extern	void	sema_p(ksema_t *);
63*b819cea2SGordon Ross extern	int	sema_p_sig(ksema_t *);
64*b819cea2SGordon Ross extern	void	sema_v(ksema_t *);
65*b819cea2SGordon Ross extern	int	sema_tryp(ksema_t *);
66*b819cea2SGordon Ross extern	int	sema_held(ksema_t *);
67*b819cea2SGordon Ross 
68*b819cea2SGordon Ross #ifdef	__cplusplus
69*b819cea2SGordon Ross }
70*b819cea2SGordon Ross #endif
71*b819cea2SGordon Ross 
72*b819cea2SGordon Ross #endif	/* _SYS_SEMAPHORE_H */
73