This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC v2 08/20] sysdeps/wait: Use waitid if avaliable
* Arnd Bergmann:
[Exposing futex as __NR_futex for 64-bit-only-time_t]
> Is there any long-term advantage for your approach that I'm
> missing?
Userspace that calls futex and does not care about timeouts would just
work on RV32 without any porting.
For example, consider this code in glib:
| static void
| g_futex_wait (const volatile gint *address,
| gint value)
| {
| syscall (__NR_futex, address, (gsize) FUTEX_WAIT_PRIVATE, (gsize) value, NULL);
| }
This will not work on RV32 for no good reason at all. You would
actually have to add an #ifdef for RV32 to fix it because you clearly
don't want to do this:
| static void
| g_futex_wait (const volatile gint *address,
| gint value)
| {
| #ifdef __NR_futex_time64
| syscall (__NR_futex_time64, address, (gsize) FUTEX_WAIT_PRIVATE, (gsize) value, NULL);
| #else
| syscall (__NR_futex, address, (gsize) FUTEX_WAIT_PRIVATE, (gsize) value, NULL);
| #endif
| }
because that would break if the library was used on an older kernel
(older than the kernel headers installed at build time).
Maybe you could use this:
| static void
| g_futex_wait (const volatile gint *address,
| gint value)
| {
| #ifdef __NR_futex
| syscall (__NR_futex_time64, address, (gsize) FUTEX_WAIT_PRIVATE, (gsize) value, NULL);
| #else
| syscall (__NR_futex_time64, address, (gsize) FUTEX_WAIT_PRIVATE, (gsize) value, NULL);
| #endif
| }
But this would still break if people actually go ahead with the removal
of the 32-bit system calls (something I think is quite impossible to do,
but some people seem to disagree).
Fallback on ENOSYS requires introducing global variable to avoid
pointless future system calls.
Thanks,
Florian