6069 libdisasm: instrlen arch op should have a sane default
[illumos-gate.git] / usr / src / lib / libc / port / sys / lwp.c
blob46ba41c07060945d129e422991255ffbcbe0e2c8
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
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>
36 int
37 _lwp_mutex_lock(mutex_t *mp)
39 if (set_lock_byte(&mp->mutex_lockw) == 0)
40 return (0);
41 return (___lwp_mutex_timedlock(mp, NULL, NULL));
44 int
45 _lwp_mutex_trylock(mutex_t *mp)
47 if (set_lock_byte(&mp->mutex_lockw) == 0)
48 return (0);
49 return (EBUSY);
52 int
53 _lwp_sema_init(lwp_sema_t *sp, int count)
55 sp->sema_count = count;
56 sp->sema_waiters = 0;
57 sp->type = USYNC_PROCESS;
58 return (0);
61 int
62 _lwp_sema_wait(lwp_sema_t *sp)
64 return (___lwp_sema_timedwait(sp, NULL, 0));
67 int
68 _lwp_suspend(lwpid_t lwpid)
70 extern int ___lwp_suspend(lwpid_t);
71 return (___lwp_suspend(lwpid));