1 /* Copyright (C) 2002-2022 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
20 #include <pthread-offsets.h>
21 #include <shlib-compat.h>
23 static const struct pthread_rwlockattr default_rwlockattr
=
25 .lockkind
= PTHREAD_RWLOCK_DEFAULT_NP
,
26 .pshared
= PTHREAD_PROCESS_PRIVATE
30 /* See pthread_rwlock_common.c. */
32 ___pthread_rwlock_init (pthread_rwlock_t
*rwlock
,
33 const pthread_rwlockattr_t
*attr
)
35 ASSERT_TYPE_SIZE (pthread_rwlock_t
, __SIZEOF_PTHREAD_RWLOCK_T
);
37 /* The __flags is the only field where its offset should be checked to
38 avoid ABI breakage with static initializers. */
39 ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_rwlock_t
, __data
.__flags
,
40 __PTHREAD_RWLOCK_FLAGS_OFFSET
);
41 ASSERT_PTHREAD_INTERNAL_MEMBER_SIZE (pthread_rwlock_t
, __data
.__flags
,
44 const struct pthread_rwlockattr
*iattr
;
46 iattr
= ((const struct pthread_rwlockattr
*) attr
) ?: &default_rwlockattr
;
48 memset (rwlock
, '\0', sizeof (*rwlock
));
50 rwlock
->__data
.__flags
= iattr
->lockkind
;
52 /* The value of __SHARED in a private rwlock must be zero. */
53 rwlock
->__data
.__shared
= (iattr
->pshared
!= PTHREAD_PROCESS_PRIVATE
);
57 versioned_symbol (libc
, ___pthread_rwlock_init
, pthread_rwlock_init
,
59 libc_hidden_ver (___pthread_rwlock_init
, __pthread_rwlock_init
)
61 strong_alias (___pthread_rwlock_init
, __pthread_rwlock_init
)
64 #if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_1, GLIBC_2_34)
65 compat_symbol (libpthread
, ___pthread_rwlock_init
, pthread_rwlock_init
,
68 #if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_2, GLIBC_2_34)
69 compat_symbol (libpthread
, ___pthread_rwlock_init
, __pthread_rwlock_init
,