2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
20 /* This is the API we're emulating */
21 #include <sys/semaphore.h>
23 #include <sys/errno.h>
24 #include <sys/debug.h>
27 int _lwp_sema_init(lwp_sema_t
*, int);
28 int _lwp_sema_wait(lwp_sema_t
*);
29 int _lwp_sema_trywait(lwp_sema_t
*);
30 int _lwp_sema_post(lwp_sema_t
*);
35 ksema_init(ksema_t
*sem
, uint32_t val
,
36 char *name
, ksema_type_t st
, void *arg
)
38 (void) _lwp_sema_init(sem
, val
);
43 ksema_destroy(ksema_t
*sem
)
52 rv
= _lwp_sema_wait(sem
);
53 } while (rv
== EINTR
);
59 (void) _lwp_sema_post(sem
);
68 sema_p_sig(ksema_t
*sem
)
71 rv
= _lwp_sema_wait(sem
);
74 /* rv = 0 ; success */
78 rv
= 1; /* interrrupted */
87 * 0: could not get semaphore
88 * 1: successful (backwards from sema_p_sig!)
91 sema_tryp(ksema_t
*sem
)
94 rv
= _lwp_sema_trywait(sem
);