/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "lint.h"
#include "thr_uberdata.h"
/*
* Check to see if anyone is waiting for this semaphore.
*/
int
{
}
/* ARGSUSED3 */
int
{
if (_semvaluemax == 0)
(count > _semvaluemax))
return (EINVAL);
/*
* This should be at the beginning of the function,
* but for the sake of old broken applications that
* do not have proper alignment for their semaphores
* (and don't check the return code from sema_init),
* we put it here, after initializing the semaphore regardless.
*/
curthread->ul_misaligned == 0)
return (EINVAL);
return (0);
}
int
{
return (0);
}
static int
{
int error = 0;
/*
* All variations of sema_wait() are cancellation points.
*/
_cancelon();
if (ssp)
}
/* just a guess, but it looks like we will sleep */
begin_sleep = gethrtime();
else /* we changed our mind */
begin_sleep = 0;
}
set_parking_flag(self, 0);
/* the kernel always does FIFO queueing */
set_parking_flag(self, 0);
/*
* Since we are single-threaded, we don't need the
* protection of queue_lock(). However, we do need
* to block signals while modifying the count.
*/
} else { /* multithreaded or blocking */
/*
* SUSV3 requires FIFO queueing for semaphores,
* at least for SCHED_FIFO and SCHED_RR scheduling.
*/
/*
* We may have received SIGCANCEL before we
* called queue_lock(). If so and we are
* cancelable we should return EINTR.
*/
set_parking_flag(self, 0);
set_parking_flag(self, 0);
}
if (error == 0)
int more;
}
}
if (lwpid) {
(void) __lwp_unpark(lwpid);
}
}
if (ssp) {
if (error == 0) {
/* we just decremented the count */
}
if (begin_sleep)
}
_canceloff();
else
return (error);
}
int
{
}
int
{
}
int
{
}
int
{
int error = 0;
if (ssp)
else
} else { /* multithreaded */
int more;
}
}
if (lwpid) {
(void) __lwp_unpark(lwpid);
}
}
if (error == 0) {
if (ssp) {
/* we just decremented the count */
}
} else {
if (ssp)
}
}
return (error);
}
int
{
int error = 0;
if (ssp)
if (_semvaluemax == 0)
else
} else { /* multithreaded */
int more;
}
}
if (lwpid) {
(void) __lwp_unpark(lwpid);
}
}
if (error == 0) {
if (ssp) {
/* we just incremented the count */
}
}
return (error);
}