aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/riscv/nptl
diff options
context:
space:
mode:
authorAlistair Francis <alistair.francis@wdc.com>2020-02-10 10:36:21 -0800
committerAlistair Francis <alistair.francis@wdc.com>2020-08-27 08:17:42 -0700
commit5b6113d62efabb123db433b14adddd4a5fb6b7ec (patch)
tree1959bde3e74c6e491bbce89f0f8e1806647c9225 /sysdeps/riscv/nptl
parent07598d76006faec6c60a9d86bda44dcb81b3a743 (diff)
downloadglibc-5b6113d62efabb123db433b14adddd4a5fb6b7ec.zip
glibc-5b6113d62efabb123db433b14adddd4a5fb6b7ec.tar.gz
glibc-5b6113d62efabb123db433b14adddd4a5fb6b7ec.tar.bz2
RISC-V: Support the 32-bit ABI implementation
This patch adds the ABI implementation for 32-bit RISC-V. It contains the Linux-specific and RISC-V architecture code. Reviewed-by: Maciej W. Rozycki <macro@wdc.com>
Diffstat (limited to 'sysdeps/riscv/nptl')
-rw-r--r--sysdeps/riscv/nptl/bits/pthreadtypes-arch.h26
-rw-r--r--sysdeps/riscv/nptl/bits/struct_rwlock.h27
-rw-r--r--sysdeps/riscv/nptl/pthread-offsets.h17
3 files changed, 55 insertions, 15 deletions
diff --git a/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h b/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h
index c3c72d6..8a602e8 100644
--- a/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h
+++ b/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h
@@ -21,18 +21,22 @@
#include <bits/endian.h>
-#if __riscv_xlen == 64
-# define __SIZEOF_PTHREAD_ATTR_T 56
-# define __SIZEOF_PTHREAD_MUTEX_T 40
-# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
-# define __SIZEOF_PTHREAD_CONDATTR_T 4
-# define __SIZEOF_PTHREAD_RWLOCK_T 56
-# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
-# define __SIZEOF_PTHREAD_BARRIER_T 32
-# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+#if __WORDSIZE == 64
+# define __SIZEOF_PTHREAD_ATTR_T 56
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+# define __SIZEOF_PTHREAD_RWLOCK_T 56
+# define __SIZEOF_PTHREAD_BARRIER_T 32
#else
-# error "rv32i-based systems are not supported"
+# define __SIZEOF_PTHREAD_ATTR_T 32
+# define __SIZEOF_PTHREAD_MUTEX_T 32
+# define __SIZEOF_PTHREAD_RWLOCK_T 48
+# define __SIZEOF_PTHREAD_BARRIER_T 20
#endif
#define __LOCK_ALIGNMENT
diff --git a/sysdeps/riscv/nptl/bits/struct_rwlock.h b/sysdeps/riscv/nptl/bits/struct_rwlock.h
index acfaa75..dc467d4 100644
--- a/sysdeps/riscv/nptl/bits/struct_rwlock.h
+++ b/sysdeps/riscv/nptl/bits/struct_rwlock.h
@@ -15,7 +15,7 @@
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#ifndef _RWLOCK_INTERNAL_H
#define _RWLOCK_INTERNAL_H
@@ -32,14 +32,37 @@ struct __pthread_rwlock_arch_t
unsigned int __writers_futex;
unsigned int __pad3;
unsigned int __pad4;
+#if __WORDSIZE == 64
int __cur_writer;
int __shared;
unsigned long int __pad1;
unsigned long int __pad2;
unsigned int __flags;
+#else
+# if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __shared;
+ unsigned char __flags;
+# else
+ unsigned char __flags;
+ unsigned char __shared;
+ unsigned char __pad1;
+ unsigned char __pad2;
+# endif
+ int __cur_writer;
+#endif
};
-#define __PTHREAD_RWLOCK_INITIALIZER(__flags) \
+#if __WORDSIZE == 64
+# define __PTHREAD_RWLOCK_INITIALIZER(__flags) \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, __flags
+#elif __BYTE_ORDER == __BIG_ENDIAN
+# define __PTHREAD_RWLOCK_INITIALIZER(__flags) \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, __flags, 0
+#else
+# define __PTHREAD_RWLOCK_INITIALIZER(__flags) \
+ 0, 0, 0, 0, 0, 0, __flags, 0, 0, 0, 0
+#endif
#endif
diff --git a/sysdeps/riscv/nptl/pthread-offsets.h b/sysdeps/riscv/nptl/pthread-offsets.h
index 31f0587..d76c6cf 100644
--- a/sysdeps/riscv/nptl/pthread-offsets.h
+++ b/sysdeps/riscv/nptl/pthread-offsets.h
@@ -1,3 +1,16 @@
-#define __PTHREAD_MUTEX_KIND_OFFSET 16
+#if __WORDSIZE == 64
+# define __PTHREAD_MUTEX_KIND_OFFSET 16
+#else
+# define __PTHREAD_MUTEX_KIND_OFFSET 12
+#endif
-#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
+
+#if __WORDSIZE == 64
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
+#else
+# if __BYTE_ORDER == __BIG_ENDIAN
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
+# else
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24
+# endif
+#endif