From: Alistair Francis <alistair.francis@wdc.com>
To: libc-alpha@sourceware.org
Cc: arnd@arndb.de, adhemerval.zanella@linaro.org, fweimer@redhat.com,
palmer@sifive.com, macro@wdc.com, zongbox@gmail.com,
alistair.francis@wdc.com, alistair23@gmail.com
Subject: [RFC v3 16/23] RISC-V: The ABI implementation for the 32-bit
Date: Tue, 16 Jul 2019 17:09:23 -0700 [thread overview]
Message-ID: <22d27f4b485ad713e982e4786859678ec7a97219.1563321716.git.alistair.francis@wdc.com> (raw)
In-Reply-To: <cover.1563321715.git.alistair.francis@wdc.com>
From: Zong Li <zongbox@gmail.com>
This patch adds the ABI implementation about 32 bit version. It contains
the Linux-specific and RISC-V architecture code, I've collected here.
2018-11-29 Zong Li <zong@andestech.com>
* sysdeps/riscv/bits/wordsize.h: Supprt rv32.
* sysdeps/riscv/nptl/bits/pthreadtypes-arch.h: Likewise.
* sysdeps/riscv/sfp-machine.h: Likewise.
* sysdeps/riscv/sys/asm.h: Likewise.
* sysdeps/unix/sysv/linux/riscv/rv32/jmp_buf-macros.h: New file.
[ Changes by AF:
- Remove lock64.c
]
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
ChangeLog | 8 +++
sysdeps/riscv/bits/wordsize.h | 4 +-
sysdeps/riscv/nptl/bits/pthreadtypes-arch.h | 25 ++++++++-
sysdeps/riscv/sfp-machine.h | 27 +++++++++-
sysdeps/riscv/sys/asm.h | 5 +-
.../sysv/linux/riscv/rv32/jmp_buf-macros.h | 53 +++++++++++++++++++
6 files changed, 118 insertions(+), 4 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/riscv/rv32/jmp_buf-macros.h
diff --git a/ChangeLog b/ChangeLog
index 4155ead682..e0446d70a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1043,6 +1043,14 @@
* sysdeps/unix/sysv/linux/riscv/ldconfig.h (LD_SO_ABI): Support rv32.
* sysdeps/unix/sysv/linux/riscv/dl-cache.h (add_system_dir): Add
libraries path for rv32.
+ * sysdeps/unix/sysv/linux/riscv/ldconfig.h (LD_SO_ABI): Support rv32.
+ * sysdeps/unix/sysv/linux/riscv/dl-cache.h (add_system_dir): Add
+ libraries path for rv32.
+ * sysdeps/riscv/bits/wordsize.h: Supprt rv32.
+ * sysdeps/riscv/nptl/bits/pthreadtypes-arch.h: Likewise.
+ * sysdeps/riscv/sfp-machine.h: Likewise.
+ * sysdeps/riscv/sys/asm.h: Likewise.
+ * sysdeps/unix/sysv/linux/riscv/rv32/jmp_buf-macros.h: New file.
2019-06-20 Dmitry V. Levin <ldv@altlinux.org>
Florian Weimer <fweimer@redhat.com>
diff --git a/sysdeps/riscv/bits/wordsize.h b/sysdeps/riscv/bits/wordsize.h
index 0b8cd8fefd..f10be0144c 100644
--- a/sysdeps/riscv/bits/wordsize.h
+++ b/sysdeps/riscv/bits/wordsize.h
@@ -25,5 +25,7 @@
#if __riscv_xlen == 64
# define __WORDSIZE_TIME64_COMPAT32 1
#else
-# error "rv32i-based targets are not supported"
+# define __WORDSIZE_TIME64_COMPAT32 0
+# define __WORDSIZE32_SIZE_ULONG 0
+# define __WORDSIZE32_PTRDIFF_LONG 0
#endif
diff --git a/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h b/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h
index e3fecc3208..4b08f7c692 100644
--- a/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h
+++ b/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h
@@ -32,7 +32,15 @@
# define __SIZEOF_PTHREAD_BARRIER_T 32
# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
#else
-# error "rv32i-based systems are not supported"
+# define __SIZEOF_PTHREAD_ATTR_T 32
+# define __SIZEOF_PTHREAD_MUTEX_T 32
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 48
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 20
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
#endif
#define __PTHREAD_COMPAT_PADDING_MID
@@ -56,11 +64,26 @@ struct __pthread_rwlock_arch_t
unsigned int __writers_futex;
unsigned int __pad3;
unsigned int __pad4;
+#if __riscv_xlen == 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_ELISION_EXTRA 0
diff --git a/sysdeps/riscv/sfp-machine.h b/sysdeps/riscv/sfp-machine.h
index fa0b8fa41a..98e1f84370 100644
--- a/sysdeps/riscv/sfp-machine.h
+++ b/sysdeps/riscv/sfp-machine.h
@@ -22,7 +22,32 @@
#if __riscv_xlen == 32
-# error "rv32i-based targets are not supported"
+# define _FP_W_TYPE_SIZE 32
+# define _FP_W_TYPE unsigned long
+# define _FP_WS_TYPE signed long
+# define _FP_I_TYPE long
+
+# define _FP_MUL_MEAT_S(R, X, Y) \
+ _FP_MUL_MEAT_1_wide (_FP_WFRACBITS_S, R, X, Y, umul_ppmm)
+# define _FP_MUL_MEAT_D(R, X, Y) \
+ _FP_MUL_MEAT_2_wide (_FP_WFRACBITS_D, R, X, Y, umul_ppmm)
+# define _FP_MUL_MEAT_Q(R, X, Y) \
+ _FP_MUL_MEAT_4_wide (_FP_WFRACBITS_Q, R, X, Y, umul_ppmm)
+
+# define _FP_MUL_MEAT_DW_S(R, X, Y) \
+ _FP_MUL_MEAT_DW_1_wide (_FP_WFRACBITS_S, R, X, Y, umul_ppmm)
+# define _FP_MUL_MEAT_DW_D(R, X, Y) \
+ _FP_MUL_MEAT_DW_2_wide (_FP_WFRACBITS_D, R, X, Y, umul_ppmm)
+# define _FP_MUL_MEAT_DW_Q(R, X, Y) \
+ _FP_MUL_MEAT_DW_4_wide (_FP_WFRACBITS_Q, R, X, Y, umul_ppmm)
+
+# define _FP_DIV_MEAT_S(R, X, Y) _FP_DIV_MEAT_1_udiv_norm (S, R, X, Y)
+# define _FP_DIV_MEAT_D(R, X, Y) _FP_DIV_MEAT_2_udiv (D, R, X, Y)
+# define _FP_DIV_MEAT_Q(R, X, Y) _FP_DIV_MEAT_4_udiv (Q, R, X, Y)
+
+# define _FP_NANFRAC_S _FP_QNANBIT_S
+# define _FP_NANFRAC_D _FP_QNANBIT_D, 0
+# define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0, 0, 0
#else
diff --git a/sysdeps/riscv/sys/asm.h b/sysdeps/riscv/sys/asm.h
index b8f90a44ce..7ea34afd6d 100644
--- a/sysdeps/riscv/sys/asm.h
+++ b/sysdeps/riscv/sys/asm.h
@@ -26,7 +26,10 @@
# define REG_S sd
# define REG_L ld
#elif __riscv_xlen == 32
-# error "rv32i-based targets are not supported"
+# define PTRLOG 2
+# define SZREG 4
+# define REG_S sw
+# define REG_L lw
#else
# error __riscv_xlen must equal 32 or 64
#endif
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/riscv/rv32/jmp_buf-macros.h
new file mode 100644
index 0000000000..e0042b9f01
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/jmp_buf-macros.h
@@ -0,0 +1,53 @@
+/* jump buffer constants for RISC-V
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ 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/>. */
+
+/* Produced by this program:
+
+ #include <stdio.h>
+ #include <unistd.h>
+ #include <setjmp.h>
+ #include <stddef.h>
+
+ int main (int argc, char **argv)
+ {
+ printf ("#define JMP_BUF_SIZE %d\n", sizeof (jmp_buf));
+ printf ("#define JMP_BUF_ALIGN %d\n", __alignof__ (jmp_buf));
+ printf ("#define SIGJMP_BUF_SIZE %d\n", sizeof (sigjmp_buf));
+ printf ("#define SIGJMP_BUF_ALIGN %d\n", __alignof__ (sigjmp_buf));
+ printf ("#define MASK_WAS_SAVED_OFFSET %d\n", offsetof (struct __jmp_buf_tag, __mask_was_saved));
+ printf ("#define SAVED_MASK_OFFSET %d\n", offsetof (struct __jmp_buf_tag, __saved_mask));
+ } */
+
+#if defined __riscv_float_abi_soft
+# define JMP_BUF_SIZE 188
+# define JMP_BUF_ALIGN 4
+# define SIGJMP_BUF_SIZE 188
+# define SIGJMP_BUF_ALIGN 4
+# define MASK_WAS_SAVED_OFFSET 56
+# define SAVED_MASK_OFFSET 60
+#elif defined __riscv_float_abi_double
+# define JMP_BUF_SIZE 288
+# define JMP_BUF_ALIGN 8
+# define SIGJMP_BUF_SIZE 288
+# define SIGJMP_BUF_ALIGN 8
+# define MASK_WAS_SAVED_OFFSET 152
+# define SAVED_MASK_OFFSET 156
+#else
+# error "Unknown RISC-V floating-point ABI"
+#endif
--
2.22.0
next prev parent reply other threads:[~2019-07-17 0:14 UTC|newest]
Thread overview: 127+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-17 0:08 [RFC v3 00/23] RISC-V glibc port for the 32-bit Alistair Francis
2019-07-17 0:08 ` [RFC v3 01/23] sysdeps/nanosleep: Use clock_nanosleep_time64 if avaliable Alistair Francis
2019-07-17 5:16 ` Florian Weimer
2019-07-19 17:25 ` Alistair Francis
2019-07-20 14:24 ` Stepan Golosunov
2019-07-22 21:14 ` Alistair Francis
2019-07-17 0:08 ` [RFC v3 02/23] sysdeps/gettimeofday: Use clock_gettime64 " Alistair Francis
2019-07-17 7:09 ` Florian Weimer
2019-07-20 3:20 ` Rich Felker
2019-07-25 20:54 ` Joseph Myers
2019-07-17 12:43 ` Lukasz Majewski
2019-07-17 12:48 ` Lukasz Majewski
2019-07-19 22:26 ` Alistair Francis
2019-07-17 0:08 ` [RFC v3 03/23] sysdeps/wait: Use waitid " Alistair Francis
2019-07-17 5:31 ` Florian Weimer
2019-07-19 17:49 ` Alistair Francis
2019-07-22 15:58 ` Florian Weimer
2019-07-22 21:02 ` Alistair Francis
2019-07-21 4:03 ` Rich Felker
2019-07-21 4:20 ` Rich Felker
2019-07-21 11:59 ` Eric W. Biederman
2019-07-21 22:59 ` Rich Felker
2019-07-21 7:57 ` Arnd Bergmann
2019-07-21 12:15 ` Eric W. Biederman
2019-07-21 12:28 ` Christian Brauner
2019-07-21 14:30 ` Arnd Bergmann
2019-07-21 15:45 ` Eric W. Biederman
2019-07-21 17:05 ` Arnd Bergmann
2019-07-21 17:16 ` Linus Torvalds
2019-07-21 21:40 ` Eric W. Biederman
2019-07-21 23:23 ` Rich Felker
2019-07-23 0:00 ` Eric W. Biederman
2019-07-23 8:12 ` Arnd Bergmann
2019-07-23 8:28 ` Christian Brauner
2019-07-23 8:45 ` Arnd Bergmann
2019-07-25 0:04 ` Alistair Francis
2019-07-25 4:40 ` Rich Felker
2019-07-25 13:15 ` Arnd Bergmann
2019-07-25 16:06 ` Christian Brauner
2019-07-25 17:14 ` Eric W. Biederman
2019-07-25 17:30 ` Christian Brauner
2019-08-13 22:22 ` Alistair Francis
2019-08-13 23:11 ` Rich Felker
2019-08-14 5:07 ` Christian Brauner
2019-08-14 11:38 ` [PATCH v1 0/1] waitid: process group enhancement christian.brauner
2019-08-14 11:38 ` [PATCH v1 1/1] waitid: Add support for waiting for the current process group christian.brauner
2019-08-14 12:29 ` Oleg Nesterov
2019-08-14 12:45 ` Christian Brauner
2019-08-14 12:50 ` Oleg Nesterov
2019-08-14 12:53 ` Christian Brauner
2019-08-14 13:07 ` [PATCH v2 0/1] waitid: process group enhancement Christian Brauner
2019-08-14 13:07 ` [PATCH v2 1/1] waitid: Add support for waiting for the current process group Christian Brauner
2019-08-14 14:19 ` Oleg Nesterov
2019-08-14 14:35 ` Christian Brauner
2019-08-14 15:27 ` Oleg Nesterov
2019-08-14 15:30 ` Christian Brauner
2019-08-14 15:43 ` [PATCH v3 0/1] waitid: process group enhancement Christian Brauner
2019-08-14 15:44 ` [PATCH v3 1/1] waitid: Add support for waiting for the current process group Christian Brauner
2019-08-14 16:09 ` Oleg Nesterov
2019-08-14 16:15 ` Christian Brauner
2019-08-14 16:34 ` Christian Brauner
2019-08-14 16:55 ` Rich Felker
2019-08-14 17:02 ` Christian Brauner
2019-08-14 17:06 ` Linus Torvalds
2019-08-14 18:00 ` Rich Felker
2019-08-14 20:50 ` Christian Brauner
2019-08-14 15:58 ` [PATCH v3 0/1] waitid: process group enhancement Rich Felker
2019-08-14 16:13 ` Christian Brauner
2019-07-26 23:35 ` [RFC v3 03/23] sysdeps/wait: Use waitid if avaliable Alistair Francis
2019-07-17 0:08 ` [RFC v3 04/23] sysdeps/clock_gettime: Use clock_gettime64 " Alistair Francis
2019-07-17 5:38 ` Florian Weimer
2019-07-17 8:04 ` Arnd Bergmann
2019-07-17 8:44 ` Florian Weimer
2019-07-17 9:10 ` Arnd Bergmann
2019-07-17 15:16 ` Florian Weimer
2019-07-18 7:38 ` Arnd Bergmann
2019-07-18 8:18 ` Florian Weimer
2019-07-18 9:14 ` Arnd Bergmann
2019-07-18 18:10 ` Adhemerval Zanella
2019-07-19 21:03 ` Alistair Francis
2019-07-17 7:03 ` Andreas Schwab
2019-07-17 12:37 ` Lukasz Majewski
2019-07-17 0:08 ` [RFC v3 05/23] sysdeps/timespec_get: " Alistair Francis
2019-07-17 5:08 ` Florian Weimer
2019-07-17 7:59 ` Arnd Bergmann
2019-07-17 8:11 ` Florian Weimer
2019-07-17 8:23 ` Arnd Bergmann
2019-07-17 8:41 ` Florian Weimer
2019-07-17 8:54 ` Arnd Bergmann
2019-07-25 20:14 ` Joseph Myers
2019-07-17 12:22 ` Lukasz Majewski
2019-07-17 0:08 ` [RFC v3 06/23] Documentation for the RISC-V 32-bit port Alistair Francis
2019-07-17 0:08 ` [RFC v3 07/23] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64 Alistair Francis
2019-07-17 8:27 ` Arnd Bergmann
2019-07-17 22:39 ` Alistair Francis
2019-07-18 7:41 ` Arnd Bergmann
2019-07-18 17:36 ` Alistair Francis
2019-07-19 6:44 ` Arnd Bergmann
2019-07-19 17:02 ` Alistair Francis
2019-07-17 0:09 ` [RFC v3 08/23] RISC-V: define __NR_futex as __NR_futex_time64 for 32-bit Alistair Francis
2019-07-17 0:09 ` [RFC v3 09/23] RISC-V: define __NR_* as __NR_*_time64/64 " Alistair Francis
2019-07-17 0:09 ` [RFC v3 10/23] RISC-V: define __NR_clock_getres as __NR_*_time64 " Alistair Francis
2019-07-17 0:09 ` [RFC v3 11/23] RISC-V: define __vdso_clock_getres as __vdso_clock_getres_time64 " Alistair Francis
2019-07-17 0:09 ` [RFC v3 12/23] RISC-V: define __vdso_clock_gettime as __vdso_clock_gettime64 " Alistair Francis
2019-07-17 8:16 ` Arnd Bergmann
2019-07-19 17:15 ` Alistair Francis
2019-07-17 0:09 ` [RFC v3 13/23] RISC-V: Use 64-bit timespec in clock_gettime vdso calls Alistair Francis
2019-07-17 8:13 ` Arnd Bergmann
2019-07-17 0:09 ` [RFC v3 14/23] RISC-V: Support dynamic loader for the 32-bit Alistair Francis
2019-07-17 0:09 ` [RFC v3 15/23] RISC-V: Add path of library directories " Alistair Francis
2019-07-17 12:20 ` Florian Weimer
2019-07-17 0:09 ` Alistair Francis [this message]
2019-07-17 0:09 ` [RFC v3 17/23] RISC-V: Hard float support for the 32 bit Alistair Francis
2019-07-17 0:09 ` [RFC v3 18/23] RISC-V: Regenerate ULPs of RISC-V Alistair Francis
2019-07-17 0:09 ` [RFC v3 19/23] RISC-V: Add ABI lists Alistair Francis
2019-07-17 0:09 ` [RFC v3 20/23] RISC-V: Build Infastructure for the 32-bit Alistair Francis
2019-07-17 0:09 ` [RFC v3 21/23] RISC-V: Fix llrint and llround missing exceptions on RV32 Alistair Francis
2019-07-17 12:22 ` Florian Weimer
2019-07-17 22:32 ` Alistair Francis
2019-07-17 0:09 ` [RFC v3 22/23] Add RISC-V 32-bit target to build-many-glibcs.py Alistair Francis
2019-07-17 0:09 ` [RFC v3 23/23] RISC-V: Use 64-bit vdso syscalls Alistair Francis
2019-07-17 5:33 ` Florian Weimer
2019-07-17 8:02 ` Arnd Bergmann
2019-07-17 22:23 ` Alistair Francis
2019-07-17 23:42 ` Alistair Francis
2019-07-18 0:01 ` Alistair Francis
2019-07-19 17:14 ` [RFC v3 00/23] RISC-V glibc port for the 32-bit Alistair Francis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=22d27f4b485ad713e982e4786859678ec7a97219.1563321716.git.alistair.francis@wdc.com \
--to=alistair.francis@wdc.com \
--cc=adhemerval.zanella@linaro.org \
--cc=alistair23@gmail.com \
--cc=arnd@arndb.de \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=macro@wdc.com \
--cc=palmer@sifive.com \
--cc=zongbox@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).