pthr_mutex.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 1999-2003 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"
#include <pthread.h>
/*
* pthread_mutexattr_init: allocates the mutex attribute object and
* initializes it with the default values.
*/
int
{
return (ENOMEM);
return (0);
}
/*
* pthread_mutexattr_destroy: frees the mutex attribute object and
* invalidates it with NULL value.
*/
int
{
return (EINVAL);
return (0);
}
/*
* pthread_mutexattr_setpshared: sets the shared attr to PRIVATE or SHARED.
* This is equivalent to setting USYNC_PROCESS/USYNC_THREAD flag in
* mutex_init().
*/
int
{
(pshared != PTHREAD_PROCESS_PRIVATE &&
return (EINVAL);
return (0);
}
/*
* pthread_mutexattr_getpshared: gets the shared attr.
*/
int
{
return (EINVAL);
return (0);
}
/*
* pthread_mutexattr_setprioceiling: sets the prioceiling attr.
*/
#pragma weak pthread_mutexattr_setprioceiling = \
int
{
return (EINVAL);
return (0);
}
/*
* pthread_mutexattr_getprioceiling: gets the prioceiling attr.
* Currently unsupported.
*/
#pragma weak pthread_mutexattr_getprioceiling = \
int
{
return (EINVAL);
return (0);
}
/*
* pthread_mutexattr_setprotocol: sets the protocol attribute.
* Currently unsupported.
*/
int
{
return (EINVAL);
if (protocol != PTHREAD_PRIO_NONE &&
protocol != PTHREAD_PRIO_INHERIT &&
return (ENOTSUP);
return (0);
}
/*
* pthread_mutexattr_getprotocol: gets the protocol attribute.
* Currently unsupported.
*/
int
{
return (EINVAL);
return (0);
}
/*
* pthread_mutexattr_setrobust_np: sets the robustness attr to ROBUST or STALL.
*/
#pragma weak pthread_mutexattr_setrobust_np = \
int
{
(robust != PTHREAD_MUTEX_ROBUST_NP &&
return (EINVAL);
return (0);
}
/*
* pthread_mutexattr_getrobust_np: gets the robustness attr.
*/
#pragma weak pthread_mutexattr_getrobust_np = \
int
{
return (EINVAL);
return (0);
}
/*
* pthread_mutex_consistent_np: make an inconsistent mutex consistent.
* The mutex must have been made inconsistent due to the last owner of it
* having died. Currently, no validation is done to check if:
* - the caller owns the mutex
* if the caller owns the mutex, one needs to call the kernel. For now,
* such extra validation does not seem necessary.
*/
int
{
/*
* Do this only for an inconsistent, initialized, PI, Robust lock.
* For all other cases, return EINVAL.
*/
return (0);
}
return (EINVAL);
}
/*
* pthread_mutex_init: Initializes the mutex object. It copies the
* pshared attr into type argument and calls mutex_init().
*/
int
{
int type;
int pshared;
int protocol;
int prioceiling = 0;
int robust;
int error;
return (EINVAL);
if (protocol == PTHREAD_PRIO_PROTECT)
/*
* Support robust mutexes only for PI locks.
*/
if (robust == PTHREAD_MUTEX_ROBUST_NP &&
return (EINVAL);
} else {
}
if (error == 0) {
/*
* Use the same routine to set the protocol, and robustness
* attributes, as that used to set the type attribute, since
* all of these attributes translate to bits in the mutex_type
* field.
*
* Note that robustness is a new bit, not the Solaris robust
* bit - the latter implies USYNC_PROCESS_ROBUST, or
* SHARED,ROBUST together. For POSIX, since robustness is an
* orthogonal attribute, both SHARED,ROBUST and PRIVATE,ROBUST
* should be valid combinations for the future. Hence,
* introduce a new bit in the mutex type field. See
* introduce a USYNC_THREAD_ROBUST, the latter could use this
* new bit...
*/
}
return (error);
}
/*
* pthread_mutex_setprioceiling: sets the prioceiling.
*/
int
{
int error;
return (EINVAL);
if (error == 0) {
if (oceil)
}
return (error);
}
/*
* pthread_mutex_getprioceiling: gets the prioceiling.
*/
int
{
return (0);
}
/*
* UNIX98
* pthread_mutexattr_settype: sets the type attribute
*/
int
{
return (EINVAL);
switch (type) {
case PTHREAD_MUTEX_NORMAL:
type = LOCK_NORMAL;
break;
case PTHREAD_MUTEX_ERRORCHECK:
break;
case PTHREAD_MUTEX_RECURSIVE:
break;
default:
return (EINVAL);
}
return (0);
}
/*
* UNIX98
* pthread_mutexattr_gettype: gets the type attr.
*/
int
{
int type;
return (EINVAL);
case LOCK_NORMAL:
break;
case LOCK_ERRORCHECK:
break;
break;
default:
return (EINVAL);
}
return (0);
}