0001-sysdeps-unix-sysv-linux-microblaze-pselect32.c-add-m.patch 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. From af06fe63f9babb6d0179ae5d7d9245daada6bf56 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  3. Date: Sun, 26 Dec 2021 10:30:01 +0100
  4. Subject: [PATCH] sysdeps/unix/sysv/linux/microblaze/pselect32.c: add missing
  5. implementation when !__ASSUME_TIME64_SYSCALLS
  6. In commit a92f4e6299fe0e3cb6f77e79de00817aece501ce ("linux: Add time64
  7. pselect support"), a Microblaze specific implementation of
  8. __pselect32() was added to cover the case of kernels < 3.15 which lack
  9. the pselect6 system call.
  10. This new file sysdeps/unix/sysv/linux/microblaze/pselect32.c takes
  11. precedence over the default implementation
  12. sysdeps/unix/sysv/linux/pselect32.c.
  13. However sysdeps/unix/sysv/linux/pselect32.c provides an implementation
  14. of __pselect32() which is needed when __ASSUME_TIME64_SYSCALLS is not
  15. defined. On Microblaze, which is a 32-bit architecture,
  16. __ASSUME_TIME64_SYSCALLS is only true for kernels >= 5.1.
  17. Due to sysdeps/unix/sysv/linux/microblaze/pselect32.c taking
  18. precedence over sysdeps/unix/sysv/linux/pselect32.c, it means that
  19. when we are with a kernel >= 3.15 but < 5.1, we need a __pselect32()
  20. implementation, but sysdeps/unix/sysv/linux/microblaze/pselect32.c
  21. doesn't provide it, and sysdeps/unix/sysv/linux/pselect32.c which
  22. would provide it is not compiled in.
  23. This causes the following build failure on Microblaze with for example
  24. Linux kernel headers 4.9:
  25. /home/thomas/buildroot/buildroot/output/host/lib/gcc/microblazeel-buildroot-linux-gnu/10.3.0/../../../../microblazeel-buildroot-linux-gnu/bin/ld: /home/thomas/buildroot/buildroot/output/build/glibc-2.34-9-g9acab0bba6a5a57323b1f94bf95b21618a9e5aa4/build/libc_pic.os: in function `__pselect64':
  26. (.text+0x120b44): undefined reference to `__pselect32'
  27. collect2: error: ld returned 1 exit status
  28. To fix this, we take a crude approach: replicate in
  29. sysdeps/unix/sysv/linux/microblaze/pselect32.c the
  30. !__ASSUME_TIME64_SYSCALLS implementation that is already in
  31. sysdeps/unix/sysv/linux/pselect32.c.
  32. Upstream: https://sourceware.org/pipermail/libc-alpha/2021-December/134635.html
  33. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  34. ---
  35. .../unix/sysv/linux/microblaze/pselect32.c | 22 +++++++++++++++++--
  36. 1 file changed, 20 insertions(+), 2 deletions(-)
  37. diff --git a/sysdeps/unix/sysv/linux/microblaze/pselect32.c b/sysdeps/unix/sysv/linux/microblaze/pselect32.c
  38. index 70b7b52a48..6b6b3e8a2e 100644
  39. --- a/sysdeps/unix/sysv/linux/microblaze/pselect32.c
  40. +++ b/sysdeps/unix/sysv/linux/microblaze/pselect32.c
  41. @@ -22,7 +22,25 @@
  42. #include <sys/poll.h>
  43. #include <sysdep-cancel.h>
  44. -#ifndef __ASSUME_PSELECT
  45. +#if !defined(__ASSUME_TIME64_SYSCALLS)
  46. +int
  47. +__pselect32 (int nfds, fd_set *readfds, fd_set *writefds,
  48. + fd_set *exceptfds, const struct __timespec64 *timeout,
  49. + const sigset_t *sigmask)
  50. +{
  51. + struct timespec ts32, *pts32 = NULL;
  52. + if (timeout != NULL)
  53. + {
  54. + ts32 = valid_timespec64_to_timespec (*timeout);
  55. + pts32 = &ts32;
  56. + }
  57. +
  58. + return SYSCALL_CANCEL (pselect6, nfds, readfds, writefds, exceptfds,
  59. + pts32,
  60. + ((__syscall_ulong_t[]){ (uintptr_t) sigmask,
  61. + __NSIG_BYTES }));
  62. +}
  63. +#elif !defined(__ASSUME_PSELECT)
  64. int
  65. __pselect32 (int nfds, fd_set *readfds, fd_set *writefds,
  66. fd_set *exceptfds, const struct __timespec64 *timeout,
  67. @@ -57,4 +75,4 @@ __pselect32 (int nfds, fd_set *readfds, fd_set *writefds,
  68. return ret;
  69. }
  70. -#endif /* __ASSUME_PSELECT */
  71. +#endif
  72. --
  73. 2.31.1