1998-09-07 19:01:43 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 Alex Nash
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1999-08-28 00:22:10 +00:00
|
|
|
* $FreeBSD$
|
1998-09-07 19:01:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
1998-09-07 19:23:55 +00:00
|
|
|
#include <stdlib.h>
|
1998-09-07 19:01:43 +00:00
|
|
|
|
|
|
|
#include <pthread.h>
|
2002-09-16 08:45:36 +00:00
|
|
|
#include "thr_private.h"
|
1998-09-07 19:01:43 +00:00
|
|
|
|
2001-04-10 04:19:21 +00:00
|
|
|
__weak_reference(_pthread_rwlockattr_destroy, pthread_rwlockattr_destroy);
|
|
|
|
__weak_reference(_pthread_rwlockattr_getpshared, pthread_rwlockattr_getpshared);
|
|
|
|
__weak_reference(_pthread_rwlockattr_init, pthread_rwlockattr_init);
|
|
|
|
__weak_reference(_pthread_rwlockattr_setpshared, pthread_rwlockattr_setpshared);
|
2001-01-24 13:03:38 +00:00
|
|
|
|
1998-09-07 19:01:43 +00:00
|
|
|
int
|
2001-01-24 13:03:38 +00:00
|
|
|
_pthread_rwlockattr_destroy(pthread_rwlockattr_t *rwlockattr)
|
1998-09-07 19:01:43 +00:00
|
|
|
{
|
|
|
|
pthread_rwlockattr_t prwlockattr;
|
|
|
|
|
|
|
|
if (rwlockattr == NULL)
|
|
|
|
return(EINVAL);
|
|
|
|
|
|
|
|
prwlockattr = *rwlockattr;
|
|
|
|
|
|
|
|
if (prwlockattr == NULL)
|
|
|
|
return(EINVAL);
|
|
|
|
|
|
|
|
free(prwlockattr);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-01-24 13:03:38 +00:00
|
|
|
_pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *rwlockattr,
|
1998-09-07 19:01:43 +00:00
|
|
|
int *pshared)
|
|
|
|
{
|
|
|
|
*pshared = (*rwlockattr)->pshared;
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-01-24 13:03:38 +00:00
|
|
|
_pthread_rwlockattr_init(pthread_rwlockattr_t *rwlockattr)
|
1998-09-07 19:01:43 +00:00
|
|
|
{
|
|
|
|
pthread_rwlockattr_t prwlockattr;
|
|
|
|
|
|
|
|
if (rwlockattr == NULL)
|
|
|
|
return(EINVAL);
|
|
|
|
|
|
|
|
prwlockattr = (pthread_rwlockattr_t)
|
|
|
|
malloc(sizeof(struct pthread_rwlockattr));
|
|
|
|
|
|
|
|
if (prwlockattr == NULL)
|
|
|
|
return(ENOMEM);
|
|
|
|
|
|
|
|
prwlockattr->pshared = PTHREAD_PROCESS_PRIVATE;
|
|
|
|
*rwlockattr = prwlockattr;
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-01-24 13:03:38 +00:00
|
|
|
_pthread_rwlockattr_setpshared(pthread_rwlockattr_t *rwlockattr, int pshared)
|
1998-09-07 19:01:43 +00:00
|
|
|
{
|
1999-12-18 01:00:42 +00:00
|
|
|
/* Only PTHREAD_PROCESS_PRIVATE is supported. */
|
|
|
|
if (pshared != PTHREAD_PROCESS_PRIVATE)
|
1998-09-07 19:01:43 +00:00
|
|
|
return(EINVAL);
|
|
|
|
|
1999-12-18 01:00:42 +00:00
|
|
|
(*rwlockattr)->pshared = pshared;
|
1998-09-07 19:01:43 +00:00
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|