Patchwork [RFC,v6,08/23] RISC-V: Define __NR_* as __NR_*_time64/64 for 32-bit

login
register
mail settings
Submitter Alistair Francis
Date Jan. 12, 2020, 10:33 a.m.
Message ID <cfa2ae3aaba20454673c0bb6e77be535f41272fe.1578824547.git.alistair.francis@wdc.com>
Download mbox | patch
Permalink /patch/37316/
State New
Headers show

Comments

Alistair Francis - Jan. 12, 2020, 10:33 a.m.
---
 sysdeps/unix/sysv/linux/riscv/sysdep.h | 73 ++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)
arnd@arndb.de - Jan. 13, 2020, 1:39 p.m.
On Sun, Jan 12, 2020 at 11:40 AM Alistair Francis
<alistair.francis@wdc.com> wrote:

> +# ifndef __NR_timer_gettime
> +#  define __NR_timer_gettime __NR_timer_gettime64
> +# endif
> +
> +# ifndef __NR_timer_settime
> +#  define __NR_timer_settime __NR_timer_settime64
> +# endif
> +
> +# ifndef __NR_clock_getres
> +#  define __NR_clock_getres __NR_clock_getres_time64
> +# endif
> +
> +# ifndef __NR_clock_gettime
> +#  define __NR_clock_gettime __NR_clock_gettime64
> +# endif

What about clock_nanosleep and io_pgetevents?

       Arnd
Alistair Francis - Jan. 14, 2020, 7:14 a.m.
On Mon, Jan 13, 2020 at 11:39 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Sun, Jan 12, 2020 at 11:40 AM Alistair Francis
> <alistair.francis@wdc.com> wrote:
>
> > +# ifndef __NR_timer_gettime
> > +#  define __NR_timer_gettime __NR_timer_gettime64
> > +# endif
> > +
> > +# ifndef __NR_timer_settime
> > +#  define __NR_timer_settime __NR_timer_settime64
> > +# endif
> > +
> > +# ifndef __NR_clock_getres
> > +#  define __NR_clock_getres __NR_clock_getres_time64
> > +# endif
> > +
> > +# ifndef __NR_clock_gettime
> > +#  define __NR_clock_gettime __NR_clock_gettime64
> > +# endif
>
> What about clock_nanosleep and io_pgetevents?

I don't think we need clock_nanosleep as it has it's own C file and as
__ASSUME_TIME64_SYSCALLS is defined we can only ever call the *_time64
version. I think this actually applies to a few of the #defines in
this patch and that they can be removed.

My thoughts (maybe wrongly) with these #defines was to use this to
allow glibc to build and eventually we could remove these. The current
ones are what is required to allow the "old" calls in glibc to
transparently call the "new" ones and as we are using a 64-bit time_t
we can happily just change the syscall to the *_time64 version.

Alistair

>
>        Arnd
arnd@arndb.de - Jan. 14, 2020, 12:47 p.m.
On Tue, Jan 14, 2020 at 8:15 AM Alistair Francis <alistair23@gmail.com> wrote:
> On Mon, Jan 13, 2020 at 11:39 PM Arnd Bergmann <arnd@arndb.de> wrote:
> > On Sun, Jan 12, 2020 at 11:40 AM Alistair Francis
> > <alistair.francis@wdc.com> wrote:
> >
> > > +# ifndef __NR_timer_gettime
> > > +#  define __NR_timer_gettime __NR_timer_gettime64
> > > +# endif
> > > +
> > > +# ifndef __NR_timer_settime
> > > +#  define __NR_timer_settime __NR_timer_settime64
> > > +# endif
> > > +
> > > +# ifndef __NR_clock_getres
> > > +#  define __NR_clock_getres __NR_clock_getres_time64
> > > +# endif
> > > +
> > > +# ifndef __NR_clock_gettime
> > > +#  define __NR_clock_gettime __NR_clock_gettime64
> > > +# endif
> >
> > What about clock_nanosleep and io_pgetevents?
>
> I don't think we need clock_nanosleep as it has it's own C file and as
> __ASSUME_TIME64_SYSCALLS is defined we can only ever call the *_time64
> version. I think this actually applies to a few of the #defines in
> this patch and that they can be removed.

Ok.

> My thoughts (maybe wrongly) with these #defines was to use this to
> allow glibc to build and eventually we could remove these. The current
> ones are what is required to allow the "old" calls in glibc to
> transparently call the "new" ones and as we are using a 64-bit time_t
> we can happily just change the syscall to the *_time64 version.

I would certainly like that better, using the same names for the
system calls as the kernel, and across all 32-bit architectures
seems less confusing for readers, so the fewer redirects are needed,
the better.

       Arnd
Alistair Francis - Jan. 15, 2020, 7:03 a.m.
On Tue, Jan 14, 2020 at 10:48 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Tue, Jan 14, 2020 at 8:15 AM Alistair Francis <alistair23@gmail.com> wrote:
> > On Mon, Jan 13, 2020 at 11:39 PM Arnd Bergmann <arnd@arndb.de> wrote:
> > > On Sun, Jan 12, 2020 at 11:40 AM Alistair Francis
> > > <alistair.francis@wdc.com> wrote:
> > >
> > > > +# ifndef __NR_timer_gettime
> > > > +#  define __NR_timer_gettime __NR_timer_gettime64
> > > > +# endif
> > > > +
> > > > +# ifndef __NR_timer_settime
> > > > +#  define __NR_timer_settime __NR_timer_settime64
> > > > +# endif
> > > > +
> > > > +# ifndef __NR_clock_getres
> > > > +#  define __NR_clock_getres __NR_clock_getres_time64
> > > > +# endif
> > > > +
> > > > +# ifndef __NR_clock_gettime
> > > > +#  define __NR_clock_gettime __NR_clock_gettime64
> > > > +# endif
> > >
> > > What about clock_nanosleep and io_pgetevents?
> >
> > I don't think we need clock_nanosleep as it has it's own C file and as
> > __ASSUME_TIME64_SYSCALLS is defined we can only ever call the *_time64
> > version. I think this actually applies to a few of the #defines in
> > this patch and that they can be removed.
>
> Ok.
>
> > My thoughts (maybe wrongly) with these #defines was to use this to
> > allow glibc to build and eventually we could remove these. The current
> > ones are what is required to allow the "old" calls in glibc to
> > transparently call the "new" ones and as we are using a 64-bit time_t
> > we can happily just change the syscall to the *_time64 version.
>
> I would certainly like that better, using the same names for the
> system calls as the kernel, and across all 32-bit architectures
> seems less confusing for readers, so the fewer redirects are needed,
> the better.

Great! In which case I will keep this list as short as possible.

Alistair

>
>        Arnd

Patch

diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 201bf9a91b..d030bf0db0 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -116,6 +116,79 @@ 
 
 #include <sysdeps/unix/sysdep.h>
 
+#if __riscv_xlen == 32
+/* Define the __NR_futex as __NR_futex64 as RV32 doesn't have a
+ * __NR_futex syscall.
+ */
+# ifndef __NR_futex
+#  define __NR_futex __NR_futex_time64
+# endif
+
+# ifndef __NR_rt_sigtimedwait
+#  define __NR_rt_sigtimedwait __NR_rt_sigtimedwait_time64
+# endif
+
+# ifndef __NR_ppoll
+#  define __NR_ppoll __NR_ppoll_time64
+# endif
+
+# ifndef __NR_utimensat
+#  define __NR_utimensat __NR_utimensat_time64
+# endif
+
+# ifndef __NR_pselect6
+#  define __NR_pselect6 __NR_pselect6_time64
+# endif
+
+# ifndef __NR_recvmmsg
+#  define __NR_recvmmsg __NR_recvmmsg_time64
+# endif
+
+# ifndef __NR_semtimedop
+#  define __NR_semtimedop __NR_semtimedop_time64
+# endif
+
+# ifndef __NR_mq_timedreceive
+#  define __NR_mq_timedreceive __NR_mq_timedreceive_time64
+# endif
+
+# ifndef __NR_mq_timedsend
+#  define __NR_mq_timedsend __NR_mq_timedsend_time64
+# endif
+
+# ifndef __NR_timer_gettime
+#  define __NR_timer_gettime __NR_timer_gettime64
+# endif
+
+# ifndef __NR_timer_settime
+#  define __NR_timer_settime __NR_timer_settime64
+# endif
+
+# ifndef __NR_clock_getres
+#  define __NR_clock_getres __NR_clock_getres_time64
+# endif
+
+# ifndef __NR_clock_gettime
+#  define __NR_clock_gettime __NR_clock_gettime64
+# endif
+
+# ifndef __NR_timerfd_settime
+#  define __NR_timerfd_settime __NR_timerfd_settime64
+# endif
+
+# ifndef __NR_timerfd_gettime
+#  define __NR_timerfd_gettime __NR_timerfd_gettime64
+# endif
+
+# ifndef __NR_sched_rr_get_interval
+#  define __NR_sched_rr_get_interval __NR_sched_rr_get_interval_time64
+# endif
+
+# ifndef __NR_clock_adjtime
+#  define __NR_clock_adjtime __NR_clock_adjtime64
+# endif
+#endif /* __riscv_xlen == 32 */
+
 #undef SYS_ify
 #define SYS_ify(syscall_name)	__NR_##syscall_name