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 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #include "lint.h"
28 #include "thr_uberdata.h"
29 #include <sys/types.h>
30 #include <sys/time.h>
31 #include <errno.h>
32 #include <synch.h>
33 #include <sys/synch32.h>
34 #include <sys/lwp.h>
35
36 int
_lwp_mutex_lock(mutex_t * mp)37 _lwp_mutex_lock(mutex_t *mp)
38 {
39 if (set_lock_byte(&mp->mutex_lockw) == 0)
40 return (0);
41 return (___lwp_mutex_timedlock(mp, NULL, NULL));
42 }
43
44 int
_lwp_mutex_trylock(mutex_t * mp)45 _lwp_mutex_trylock(mutex_t *mp)
46 {
47 if (set_lock_byte(&mp->mutex_lockw) == 0)
48 return (0);
49 return (EBUSY);
50 }
51
52 int
_lwp_sema_init(lwp_sema_t * sp,int count)53 _lwp_sema_init(lwp_sema_t *sp, int count)
54 {
55 sp->sema_count = count;
56 sp->sema_waiters = 0;
57 sp->type = USYNC_PROCESS;
58 return (0);
59 }
60
61 int
_lwp_sema_wait(lwp_sema_t * sp)62 _lwp_sema_wait(lwp_sema_t *sp)
63 {
64 return (___lwp_sema_timedwait(sp, NULL, 0));
65 }
66
67 int
_lwp_suspend(lwpid_t lwpid)68 _lwp_suspend(lwpid_t lwpid)
69 {
70 extern int ___lwp_suspend(lwpid_t);
71 return (___lwp_suspend(lwpid));
72 }
73