Skip to contentSkip to conversation

Define __NR_futex to be __NR_futex_time64 on riscv32

PATCH New Khem Raj 2 participants 5 messages Apr 29, 2020 – May 5, 2020

Subsystems (2)
lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 Define __NR_futex to be __NR_futex_time64 on riscv32

RISCV glibc has decided to use 64bit time_t from get go unlike other 32bit architecture therefore aliasing __NR_futex to __NR_futex_time64 helps avoid the below errors on rv32

tst_checkpoint.c:99:17: error: use of undeclared identifier 'SYS_futex'

---
 lib/tst_checkpoint.c                        | 4 ++++
 testcases/kernel/syscalls/clone/clone08.c   | 4 ++++
 testcases/kernel/syscalls/futex/futextest.h | 4 ++++
 3 files changed, 12 insertions(+)
lib/tst_checkpoint.c +4 -0
index 5e5b11496c..0388e9db2f 100644
@@ -21,6 +21,10 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#if !defined(__NR_futex) && defined(__riscv) && __riscv_xlen == 32
+# define __NR_futex __NR_futex_time64
+#endif
+
 #include <stdint.h>
 #include <limits.h>
 #include <errno.h>
testcases/kernel/syscalls/clone/clone08.c +4 -0
index aace308068..85a2bd9246 100644
@@ -5,6 +5,10 @@
  * Author: Zeng Linggang <[email protected]>
  */
 
+#if !defined(__NR_futex) && defined(__riscv) && __riscv_xlen == 32
+# define __NR_futex __NR_futex_time64
+#endif
+
 #define _GNU_SOURCE
 #include <stdlib.h>
 #include <stdio.h>
testcases/kernel/syscalls/futex/futextest.h +4 -0
index 5754d36dae..59d877e30f 100644
@@ -34,6 +34,10 @@
 #ifndef _FUTEXTEST_H
 #define _FUTEXTEST_H
 
+#if !defined(__NR_futex) && defined(__riscv) && __riscv_xlen == 32
+# define __NR_futex __NR_futex_time64
+#endif
+
 #include <unistd.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/1 Define __NR_futex to be __NR_futex_time64 on riscv32

Hi Khem,

Quoted 5 lines

RISCV glibc has decided to use 64bit time_t from get go unlike other 32bit architecture therefore aliasing __NR_futex to __NR_futex_time64 helps avoid the below errors on rv32

tst_checkpoint.c:99:17: error: use of undeclared identifier 'SYS_futex'

Thanks for your fix.

BTW, out of curiosity, is Risc-v 32 bit merged into glibc master?

I found a patch from Alistair Francis from January, which implements what you claim:
https://sourceware.org/legacy-ml/libc-alpha/2020-01/msg00205.html
...
+/* RV32 and RV64 both use 64-bit time_t */
+#define __TIMESIZE 64

sysdeps/unix/sysv/linux/riscv/bits/typesizes.h +0 -0

...

(part of https://patches-gcc.linaro.org/project/glibc/list/?series=21554
patchset) but it hasn't been merged yet to master.

+ There is older patchset from Zong Li, not yet merged.
https://patches-gcc.linaro.org/cover/12952/

Quoted 12 lines
---
 lib/tst_checkpoint.c                        | 4 ++++
 testcases/kernel/syscalls/clone/clone08.c   | 4 ++++
 testcases/kernel/syscalls/futex/futextest.h | 4 ++++
 3 files changed, 12 insertions(+)
lib/tst_checkpoint.c +0 -0
index 5e5b11496c..0388e9db2f 100644

lib/tst_checkpoint.c line 26

Quoted 6 lines
lib/tst_checkpoint.c +3 -0
@@ -21,6 +21,10 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#if !defined(__NR_futex) && defined(__riscv) && __riscv_xlen == 32
+# define __NR_futex __NR_futex_time64
+#endif

I guess this should go to include/lapi/futex.h, so we don't repeat ourselves. (and clone08.c needs to include it, others already do).

...

Kind regards,
Petr

#2 lore raw

PATCH 1/1 Define __NR_futex to be __NR_futex_time64 on riscv32

Hi Khem,

Quoted 6 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+#if !defined(__NR_futex) && defined(__riscv) && __riscv_xlen == 32
+# define __NR_futex __NR_futex_time64
+#endif

I guess this should go to include/lapi/futex.h, so we don't repeat ourselves. (and clone08.c needs to include it, others already do).

I've noticed that we still don't have risc-v support in include/lapi/syscalls/. IMHO adding it would be better, than fixing just one missing __NR numbers.

Kind regards,
Petr

author
#3 lore raw

PATCH 1/1 Define __NR_futex to be __NR_futex_time64 on riscv32

In reply to Petr Vorel
Quoted 7 lines · Petr Vorel

Hi Khem,

Quoted 3 lines

RISCV glibc has decided to use 64bit time_t from get go unlike other 32bit architecture therefore aliasing __NR_futex to __NR_futex_time64 helps avoid the below errors on rv32

Quoted 5 lines
Quoted 1 line

tst_checkpoint.c:99:17: error: use of undeclared identifier 'SYS_futex'

Thanks for your fix.

BTW, out of curiosity, is Risc-v 32 bit merged into glibc master?

Not yet but its almost finalised and should be merged before 2.32 hopefully

sysdeps/unix/sysv/linux/riscv/bits/typesizes.h

Quoted 9 lines

I found a patch from Alistair Francis from January, which implements what you claim:
https://sourceware.org/legacy-ml/libc-alpha/2020-01/msg00205.html
...

(quoted diff) +2 -0
+/* RV32 and RV64 both use 64-bit time_t */
+#define __TIMESIZE     64
sysdeps/unix/sysv/linux/riscv/bits/typesizes.h +0 -0
...

right

Quoted 2 lines

(part of https://patches-gcc.linaro.org/project/glibc/list/?series=21554
patchset) but it hasn't been merged yet to master.

Its being reviewed

Quoted 4 lines

+ There is older patchset from Zong Li, not yet merged.
https://patches-gcc.linaro.org/cover/12952/

above patches are newer versions of this one.

Quoted 15 lines
Quoted 14 lines
---
 lib/tst_checkpoint.c                        | 4 ++++
 testcases/kernel/syscalls/clone/clone08.c   | 4 ++++
 testcases/kernel/syscalls/futex/futextest.h | 4 ++++
 3 files changed, 12 insertions(+)
lib/tst_checkpoint.c +0 -0
index 5e5b11496c..0388e9db2f 100644
@@ -21,6 +21,10 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
Quoted 7 lines

lib/tst_checkpoint.c line 25

Quoted 3 lines
lib/tst_checkpoint.c +3 -0
+#if !defined(__NR_futex) && defined(__riscv) && __riscv_xlen == 32
+# define __NR_futex __NR_futex_time64
+#endif

I guess this should go to include/lapi/futex.h, so we don't repeat ourselves. (and clone08.c needs to include it, others already do).

OK makes sense, will send v2 ?

Quoted 4 lines

...

Kind regards,
Petr

#4 lore raw

PATCH 1/1 Define __NR_futex to be __NR_futex_time64 on riscv32

Hi Khem,

sorry for a delay.

Quoted 11 lines
Quoted 9 lines
Quoted 5 lines

RISCV glibc has decided to use 64bit time_t from get go unlike other 32bit architecture therefore aliasing __NR_futex to __NR_futex_time64 helps avoid the below errors on rv32

tst_checkpoint.c:99:17: error: use of undeclared identifier 'SYS_futex'

Thanks for your fix.

BTW, out of curiosity, is Risc-v 32 bit merged into glibc master?

Not yet but its almost finalised and should be merged before 2.32 hopefully

Nice!

Quoted 5 lines
Quoted 2 lines

I guess this should go to include/lapi/futex.h, so we don't repeat ourselves. (and clone08.c needs to include it, others already do).

OK makes sense, will send v2 ?

Yes please.

Kind regards,
Petr