1 /* Default read-write lock implementation struct definitions.
2    Copyright (C) 2019-2021 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4 
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18 
19 #ifndef __RWLOCK_INTERNAL_H
20 #define __RWLOCK_INTERNAL_H
21 
22 #include <bits/endian.h>
23 
24 /* Generic struct for both POSIX read-write lock.  New ports are expected
25    to use the default layout, however archictetures can redefine it to add
26    arch-specific extensions (such as lock-elision).  The struct have a size
27    of 32 bytes on both LP32 and LP64 architectures.  */
28 
29 struct __pthread_rwlock_arch_t
30 {
31   unsigned int __readers;
32   unsigned int __writers;
33   unsigned int __wrphase_futex;
34   unsigned int __writers_futex;
35   unsigned int __pad3;
36   unsigned int __pad4;
37   /* FLAGS must stay at its position in the structure to maintain
38      binary compatibility.  */
39 #if __BYTE_ORDER == __BIG_ENDIAN
40   unsigned char __pad1;
41   unsigned char __pad2;
42   unsigned char __shared;
43   unsigned char __flags;
44 #else
45   unsigned char __flags;
46   unsigned char __shared;
47   unsigned char __pad1;
48   unsigned char __pad2;
49 #endif
50   int __cur_writer;
51 };
52 
53 #if __BYTE_ORDER == __BIG_ENDIAN
54 # define __PTHREAD_RWLOCK_INITIALIZER(__flags) \
55   0, 0, 0, 0, 0, 0, 0, 0, 0, __flags, 0
56 #else
57 # define __PTHREAD_RWLOCK_INITIALIZER(__flags) \
58   0, 0, 0, 0, 0, 0, __flags, 0, 0, 0, 0
59 #endif
60 
61 #endif