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]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 #include "thr_uberdata.h"
32 * pthread_rwlockattr_init: allocates the mutex attribute object and
33 * initializes it with the default values.
36 pthread_rwlockattr_init(pthread_rwlockattr_t
*attr
)
40 if ((ap
= lmalloc(sizeof (rwlattr_t
))) == NULL
)
42 ap
->pshared
= PTHREAD_PROCESS_PRIVATE
;
43 attr
->__pthread_rwlockattrp
= ap
;
49 * pthread_rwlockattr_destroy: frees the rwlock attribute object and
50 * invalidates it with NULL value.
53 pthread_rwlockattr_destroy(pthread_rwlockattr_t
*attr
)
55 if (attr
== NULL
|| attr
->__pthread_rwlockattrp
== NULL
)
57 lfree(attr
->__pthread_rwlockattrp
, sizeof (rwlattr_t
));
58 attr
->__pthread_rwlockattrp
= NULL
;
64 * pthread_rwlockattr_setpshared: sets the shared attr to PRIVATE or SHARED.
67 pthread_rwlockattr_setpshared(pthread_rwlockattr_t
*attr
, int pshared
)
71 if (attr
!= NULL
&& (ap
= attr
->__pthread_rwlockattrp
) != NULL
&&
72 (pshared
== PTHREAD_PROCESS_PRIVATE
||
73 pshared
== PTHREAD_PROCESS_SHARED
)) {
74 ap
->pshared
= pshared
;
82 * pthread_rwlockattr_getpshared: gets the shared attr.
85 pthread_rwlockattr_getpshared(const pthread_rwlockattr_t
*attr
, int *pshared
)
89 if (attr
!= NULL
&& (ap
= attr
->__pthread_rwlockattrp
) != NULL
&&
91 *pshared
= ap
->pshared
;
99 * pthread_rwlock_init: Initializes the rwlock object. It copies the
100 * pshared attr into type argument and calls rwlock_init().
103 pthread_rwlock_init(pthread_rwlock_t
*_RESTRICT_KYWD rwlock
,
104 const pthread_rwlockattr_t
*_RESTRICT_KYWD attr
)
110 type
= PTHREAD_PROCESS_PRIVATE
;
111 else if ((ap
= attr
->__pthread_rwlockattrp
) != NULL
)
116 return (rwlock_init((rwlock_t
*)rwlock
, type
, NULL
));