Skip to content
  • Sebastian Dröge's avatar
    glib/gthread-posix: Conditionally use `futex` and/or `futex_time64` syscalls... · a79c6af2
    Sebastian Dröge authored
    glib/gthread-posix: Conditionally use `futex` and/or `futex_time64` syscalls as necessary and use the correct `struct timespec` definition
    
    On some systems only `futex_time64` exists (e.g. riscv32) while on
    others only `futex` exists (old Linux, 64 bit platforms), so it is
    necessary to check for both and try calling both at runtime.
    
    Additionally use the correct `struct timespec` definition. There is not
    necessarily any relation between the libc's definition and the kernel's.
    
    Specifically, the libc headers might use 64-bit `time_t` while the kernel
    headers use 32-bit `__kernel_old_time_t` on certain systems.
    
    To get around this problem we
      a) check if `futex_time64` is available, which only exists on 32-bit
         platforms and always uses 64-bit `time_t`.
      b) otherwise (or if that returns `ENOSYS`), we call the normal `futex`
         syscall with the `struct timespec` used by the kernel, which uses
         `__kernel_long_t` for both its fields. We use that instead of
         `__kernel_old_time_t` because it is eq...
    a79c6af2