lwp.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
3184N/A/*
3184N/A * CDDL HEADER START
3184N/A *
3184N/A * The contents of this file are subject to the terms of the
3184N/A * Common Development and Distribution License, Version 1.0 only
3184N/A * (the "License"). You may not use this file except in compliance
3184N/A * with the License.
3184N/A *
3184N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3184N/A * or http://www.opensolaris.org/os/licensing.
3184N/A * See the License for the specific language governing permissions
3184N/A * and limitations under the License.
3184N/A *
3184N/A * When distributing Covered Code, include this CDDL HEADER in each
3184N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3184N/A * If applicable, add the following below this CDDL HEADER, with the
3184N/A * fields enclosed by brackets "[]" replaced with your own identifying
3184N/A * information: Portions Copyright [yyyy] [name of copyright owner]
3184N/A *
3184N/A * CDDL HEADER END
3184N/A */
3184N/A/*
3184N/A * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3184N/A * Use is subject to license terms.
5150N/A */
6208N/A
3184N/A#pragma ident "%Z%%M% %I% %E% SMI"
3184N/A
3184N/A#pragma weak _private_lwp_mutex_lock = __lwp_mutex_lock
3184N/A#pragma weak _lwp_mutex_lock = __lwp_mutex_lock
6639N/A#pragma weak _lwp_mutex_trylock = __lwp_mutex_trylock
3184N/A#pragma weak _lwp_sema_init = __lwp_sema_init
6573N/A#pragma weak _lwp_sema_wait = __lwp_sema_wait
3184N/A#pragma weak _lwp_suspend = __lwp_suspend
3184N/A#if defined(__i386) || defined(__amd64)
3184N/A#pragma weak _lwp_private = __lwp_private
3184N/A#endif /* __i386 || __amd64 */
3184N/A
3184N/A#include "synonyms.h"
6621N/A#include "mtlib.h"
6621N/A#include <sys/types.h>
3184N/A#include <sys/time.h>
6639N/A#include <errno.h>
6639N/A#include <synch.h>
3184N/A#include <sys/synch32.h>
6639N/A#include <sys/lwp.h>
3184N/A
3184N/Aextern int ___lwp_mutex_timedlock(mutex_t *, timespec_t *);
3184N/Aextern int ___lwp_sema_timedwait(lwp_sema_t *, timespec_t *, int);
3184N/Aextern int set_lock_byte(volatile uint8_t *);
3184N/A
3184N/Aint
3184N/A_lwp_mutex_lock(mutex_t *mp)
3184N/A{
3184N/A if (set_lock_byte(&mp->mutex_lockw) == 0)
3184N/A return (0);
3184N/A return (___lwp_mutex_timedlock(mp, NULL));
3184N/A}
3184N/A
3184N/Aint
3184N/A_lwp_mutex_trylock(mutex_t *mp)
3184N/A{
3184N/A if (set_lock_byte(&mp->mutex_lockw) == 0)
3184N/A return (0);
3184N/A return (EBUSY);
3184N/A}
3184N/A
6573N/Aint
6639N/A_lwp_sema_init(lwp_sema_t *sp, int count)
4802N/A{
3184N/A sp->sema_count = count;
6573N/A sp->sema_waiters = 0;
6639N/A sp->type = USYNC_PROCESS;
4802N/A return (0);
3988N/A}
6573N/A
6573N/Aint
4802N/A_lwp_sema_wait(lwp_sema_t *sp)
3184N/A{
6573N/A return (___lwp_sema_timedwait(sp, NULL, 0));
6573N/A}
6573N/A
6573N/A#if defined(__i386) || defined(__amd64)
6639N/Aint
4802N/A_lwp_private(int cmd, int which, void *sbase)
3184N/A{
6573N/A extern int ___lwp_private(int, int, void *);
4802N/A return (___lwp_private(cmd, which, sbase));
3184N/A}
6573N/A#endif /* __i386 || __amd64 */
4802N/A
3988N/Aint
3184N/A_lwp_suspend(lwpid_t lwpid)
3184N/A{
3184N/A extern int ___lwp_suspend(lwpid_t);
3184N/A return (___lwp_suspend(lwpid));
3184N/A}
3184N/A
4802N/Avoid
3184N/A_halt(void)
6639N/A{
6573N/A /*LINTED*/
6573N/A while (1)
6573N/A continue;
3184N/A}
3184N/A