public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 00/24] Add 64 bit time support on legacy ABIs
@ 2021-06-07 20:35 Adhemerval Zanella
  2021-06-07 20:35 ` [PATCH v3 01/24] linux: mips: Split librt.abilist in n32 and n64 Adhemerval Zanella
                   ` (23 more replies)
  0 siblings, 24 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:35 UTC (permalink / raw)
  To: libc-alpha

This is an updated version of my previous patchset [1].  The main
changes are the one noted by Carlos's review:

  - Drop the libpthread abi change for mips (not really anymore
    due the libpthread move to libc).
  - Handle the POSIX requirement for getsockopt fallback.
  - Add extra members to struct stat, msqid_ds, semid_ds, and
    shmid_ds.
  - Remove the extra 'shm-directoy' make rule.
  - Replace all "64 bit" with "64-bit".  The only I didn't change is
    at the manual because it mimics what _LARGEFILE64_SOURCE and
    _FILE_OFFSET_BITS already do (I think an extra patch would be
    better to fix it).

As before this patchset add support for 64 bit time on ABIs which only
support 32 bit time.  It is done through a new build flags,
_TIME_BITS=64, which is supported only when Long File Support is also
used (_FILE_OFFSET_BITS=64).  The new flag redefine the required
structures and redirected the required symbols to newer exported ones.

However, different then LFS support, the new 64 bit time_t symbols
are only exported for the ABI that require them.  ABIs that provides
64 bit time as the default ABI are unaffected.

On Linux, to fully support 64 bit time_t it requires a minimum of
kernel v5.1 due the newer syscalls.

I checked for i686-linux-gnu running on a x86_64 5.4 kernel,
powerpc-linux-gnu running on ppc64 5.10 kernel, and on
arm-linux-gnueabihf running on arm64 5.4 kernel.  The new 64 bit time_t
tests when running on older kernels shows as unsupported.

[1] https://patchwork.sourceware.org/project/glibc/list/?series=2199

Adhemerval Zanella (22):
  linux: mips: Split librt.abilist in n32 and n64
  linux: mips: Split libanl.abilist in n32 and n64
  linux: s390: Add libanl.abilist in s390 and s390x
  linux: Add fallback for 64-bit time_t SO_{RCV,SND}TIMEO
  linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS}
  linux: Add recvvmsg fallback for 64-bit time_t SO_TIMESTAMP{NS}
  y2038: Add __USE_TIME_BITS64 support for time_t
  y2038: Add __USE_TIME_BITS64 support for struct timeval
  y2038: Add __USE_TIME_BITS64 support for struct timespec
  y2038: Add __USE_TIME_BITS64 support for struct utimbuf
  y2038: linux: Add __USE_TIME_BITS64 support for struct timex
  y2038: Use a common definition for semid_ds
  y2038: Use a common definition for shmid_ds
  y2038: Add __USE_TIME_BITS64 support for socket-constants.h
  time: Add 64-bit time support for getdate
  y2038: Add support for 64-bit time on legacy ABIs
  posix: Add glob64 with 64-bit time_t support
  io: Add fts64 with 64-bit time_t support
  io: Add ftw64 with 64-bit time_t support
  libsupport: Add 64-bit time_t support for time functions
  libsupport: Add 64-bit time_t support for stat functions
  y2038: Add test coverage

Lukasz Majewski (2):
  y2038: Use a common definition for stat
  y2038: Use a common definition for msqid_ds

 Makeconfig                                    |  14 ++
 Makefile                                      |   2 +-
 Makerules                                     |  18 ++-
 NEWS                                          |   5 +
 include/features-time64.h                     |   1 +
 include/features.h                            |   2 +
 include/fts.h                                 |  51 +++++++
 include/ftw.h                                 |  18 +++
 include/glob.h                                |  28 ++++
 include/sys/socket.h                          |   5 +
 include/sys/stat.h                            |   2 +-
 include/time.h                                |  12 +-
 io/Makefile                                   |  28 +++-
 io/fts.h                                      |  43 +++++-
 io/fts64-time64.c                             |  35 +++++
 io/ftw.c                                      |   5 +-
 io/ftw.h                                      |  46 +++++-
 io/ftw64-time64.c                             |  34 +++++
 io/ftwtest-time64.c                           |   1 +
 io/sys/poll.h                                 |  11 ++
 io/sys/stat.h                                 | 113 ++++++++++++--
 io/tst-fts-time64.c                           |   1 +
 io/tst-futimens-time64.c                      |   2 +
 io/tst-futimens.c                             |   6 +-
 io/tst-futimes-time64.c                       |   2 +
 io/tst-futimes.c                              |   6 +-
 io/tst-futimesat-time64.c                     |   4 +
 io/tst-futimesat.c                            |  47 ++++--
 io/tst-lutimes-time64.c                       |   2 +
 io/tst-lutimes.c                              |  10 +-
 io/tst-stat-time64.c                          | 102 +++++++++++++
 io/tst-utime-time64.c                         |   2 +
 io/tst-utime.c                                |   6 +-
 io/tst-utimensat-time64.c                     |   2 +
 io/tst-utimensat.c                            |  12 +-
 io/tst-utimes-time64.c                        |   2 +
 io/tst-utimes.c                               |   6 +-
 io/utime.h                                    |  16 ++
 manual/creature.texi                          |  44 ++++++
 misc/Makefile                                 |   4 +
 misc/sys/select.h                             |  27 ++++
 misc/tst-pselect-time64.c                     |   1 +
 misc/tst-select-time64.c                      |   1 +
 nptl/Makefile                                 |   3 +
 nptl/pthread_clockjoin.c                      |   3 +-
 nptl/pthread_cond_wait.c                      |   9 +-
 nptl/pthread_mutex_timedlock.c                |   8 +-
 nptl/pthread_rwlock_clockrdlock.c             |   4 +-
 nptl/pthread_rwlock_clockwrlock.c             |   4 +-
 nptl/pthread_rwlock_timedrdlock.c             |   4 +-
 nptl/pthread_rwlock_timedwrlock.c             |   4 +-
 nptl/pthread_timedjoin.c                      |   3 +-
 nptl/sem_clockwait.c                          |   3 +-
 nptl/sem_timedwait.c                          |   4 +-
 nptl/tst-cancel4_2-time64.c                   |   1 +
 posix/Makefile                                |   6 +-
 posix/glob.c                                  |  46 +++---
 posix/glob.h                                  |  22 +++
 posix/glob64-lstat-compat.c                   |   3 +-
 posix/glob64-time64.c                         |  49 +++++++
 posix/globfree64-time64.c                     |  30 ++++
 posix/sched.h                                 |  11 +-
 posix/sys/wait.h                              |  20 +++
 posix/tst-gnuglob64-time64.c                  |   7 +
 posix/tst-sched_rr_get_interval-time64.c      |   1 +
 posix/tst-wait3-time64.c                      |   1 +
 posix/tst-wait4-time64.c                      |   1 +
 resolv/netdb.h                                |  11 ++
 resource/sys/resource.h                       |  10 ++
 rt/Makefile                                   |   9 ++
 rt/aio.h                                      |  15 +-
 rt/mqueue.h                                   |  22 +++
 rt/tst-aio6-time64.c                          |   1 +
 rt/tst-cpuclock2-time64.c                     |   1 +
 rt/tst-cpuclock2.c                            |   9 +-
 rt/tst-mqueue1-time64.c                       |   1 +
 rt/tst-mqueue2-time64.c                       |   1 +
 rt/tst-mqueue4-time64.c                       |   1 +
 rt/tst-mqueue8-time64.c                       |   1 +
 rt/tst-timer4-time64.c                        |   1 +
 signal/signal.h                               |  13 ++
 socket/sys/socket.h                           |  11 ++
 support/Makefile                              |   9 ++
 support/support-xfstat-time64.c               |  32 ++++
 support/support-xstat-time64.c                |  32 ++++
 support/timespec-add-time64.c                 |  27 ++++
 support/timespec-add.c                        |   2 +-
 support/timespec-sub-time64.c                 |  27 ++++
 support/timespec-sub.c                        |   2 +-
 support/timespec-time64.c                     |  40 +++++
 support/timespec.c                            |   9 +-
 support/timespec.h                            |  52 +++++--
 support/xclock_gettime_time64.c               |  26 ++++
 support/xclock_settime_time64.c               |  26 ++++
 support/xlstat-time64.c                       |  32 ++++
 support/xtime.h                               |   7 +
 support/xunistd.h                             |  13 ++
 sysdeps/generic/features-time64.h             |  19 +++
 sysdeps/generic/time64-compat.h               |   3 +
 sysdeps/gnu/glob64-lstat-compat.c             |   3 +-
 sysdeps/nptl/pthread.h                        | 119 +++++++++++++++
 sysdeps/pthread/Makefile                      |  10 ++
 sysdeps/pthread/semaphore.h                   |  25 ++++
 sysdeps/pthread/threads.h                     |  33 +++++
 sysdeps/pthread/tst-abstime-time64.c          |   1 +
 sysdeps/pthread/tst-cnd-timedwait-time64.c    |   1 +
 sysdeps/pthread/tst-cond11-time64.c           |   1 +
 sysdeps/pthread/tst-join14-time64.c           |   1 +
 sysdeps/pthread/tst-mtx-timedlock-time64.c    |   1 +
 sysdeps/pthread/tst-rwlock14-time64.c         |   1 +
 sysdeps/pthread/tst-sem5-time64.c             |   1 +
 sysdeps/pthread/tst-thrd-sleep-time64.c       |   1 +
 sysdeps/unix/sysv/linux/Makefile              |  21 ++-
 sysdeps/unix/sysv/linux/Versions              | 107 ++++++++++++++
 sysdeps/unix/sysv/linux/arm/be/libanl.abilist |   1 +
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |  76 ++++++++++
 sysdeps/unix/sysv/linux/arm/be/librt.abilist  |   5 +
 sysdeps/unix/sysv/linux/arm/le/libanl.abilist |   1 +
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  76 ++++++++++
 sysdeps/unix/sysv/linux/arm/le/librt.abilist  |   5 +
 sysdeps/unix/sysv/linux/arm/time64-compat.h   |   2 +
 sysdeps/unix/sysv/linux/bits/msq.h            |   1 +
 sysdeps/unix/sysv/linux/bits/sem.h            |   1 +
 sysdeps/unix/sysv/linux/bits/shm.h            |   1 +
 .../unix/sysv/linux/bits/socket-constants.h   |  47 +++++-
 sysdeps/unix/sysv/linux/bits/struct_stat.h    |  50 ++++---
 .../linux/bits/struct_stat_time64_helper.h    |  66 +++++++++
 sysdeps/unix/sysv/linux/bits/time.h           |  10 ++
 sysdeps/unix/sysv/linux/bits/timex.h          |  31 ++++
 .../sysv/linux/bits/types/struct_msqid64_ds.h |  10 +-
 .../bits/types/struct_msqid64_ds_helper.h     |  30 ++++
 .../sysv/linux/bits/types/struct_msqid_ds.h   |  12 +-
 .../sysv/linux/bits/types/struct_semid64_ds.h |   5 +-
 .../bits/types/struct_semid64_ds_helper.h     |  25 ++++
 .../sysv/linux/bits/types/struct_semid_ds.h   |  10 +-
 .../sysv/linux/bits/types/struct_shmid64_ds.h |   9 +-
 .../bits/types/struct_shmid64_ds_helper.h     |  28 ++++
 .../sysv/linux/bits/types/struct_shmid_ds.h   |  10 +-
 sysdeps/unix/sysv/linux/cnd_timedwait.c       |   8 +-
 .../unix/sysv/linux/convert_scm_timestamps.c  |  96 ++++++++++++
 sysdeps/unix/sysv/linux/csky/libanl.abilist   |   1 +
 sysdeps/unix/sysv/linux/csky/libc.abilist     |  76 ++++++++++
 sysdeps/unix/sysv/linux/csky/librt.abilist    |   5 +
 sysdeps/unix/sysv/linux/csky/time64-compat.h  |   2 +
 sysdeps/unix/sysv/linux/features-time64.h     |  37 +++++
 sysdeps/unix/sysv/linux/getsockopt.c          |  82 ++++++++++-
 sysdeps/unix/sysv/linux/glob-lstat-compat.c   |   6 +-
 sysdeps/unix/sysv/linux/glob.c                |   6 +
 sysdeps/unix/sysv/linux/glob64-lstat-compat.c |  12 +-
 sysdeps/unix/sysv/linux/glob64-time64.c       |  44 ++++++
 sysdeps/unix/sysv/linux/glob64.c              |   8 +-
 sysdeps/unix/sysv/linux/globfree64-time64.c   |  35 +++++
 .../sysv/linux/hppa/bits/socket-constants.h   |  36 ++++-
 .../linux/hppa/bits/types/struct_msqid_ds.h   |  12 +-
 .../linux/hppa/bits/types/struct_semid_ds.h   |   4 +
 .../linux/hppa/bits/types/struct_shmid_ds.h   |  10 +-
 sysdeps/unix/sysv/linux/hppa/libanl.abilist   |   1 +
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |  76 ++++++++++
 sysdeps/unix/sysv/linux/hppa/librt.abilist    |   5 +
 .../sysv/linux/hppa/socket-constants-time64.h |  35 +++++
 sysdeps/unix/sysv/linux/hppa/time64-compat.h  |   2 +
 sysdeps/unix/sysv/linux/i386/libanl.abilist   |   1 +
 sysdeps/unix/sysv/linux/i386/libc.abilist     |  76 ++++++++++
 sysdeps/unix/sysv/linux/i386/librt.abilist    |   5 +
 sysdeps/unix/sysv/linux/i386/time64-compat.h  |   2 +
 sysdeps/unix/sysv/linux/include/sys/msg.h     |   2 -
 sysdeps/unix/sysv/linux/include/sys/shm.h     |   2 -
 sysdeps/unix/sysv/linux/include/sys/timex.h   |   2 +
 .../unix/sysv/linux/m68k/bits/struct_stat.h   |  50 ++++---
 .../sysv/linux/m68k/coldfire/libanl.abilist   |   1 +
 .../sysv/linux/m68k/coldfire/libc.abilist     |  76 ++++++++++
 .../sysv/linux/m68k/coldfire/librt.abilist    |   5 +
 .../sysv/linux/m68k/m680x0/libanl.abilist     |   1 +
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  76 ++++++++++
 .../unix/sysv/linux/m68k/m680x0/librt.abilist |   5 +
 sysdeps/unix/sysv/linux/m68k/time64-compat.h  |   2 +
 .../sysv/linux/microblaze/be/libanl.abilist   |   1 +
 .../sysv/linux/microblaze/be/libc.abilist     |  76 ++++++++++
 .../sysv/linux/microblaze/be/librt.abilist    |   5 +
 .../sysv/linux/microblaze/bits/struct_stat.h  |  48 +++---
 .../sysv/linux/microblaze/le/libanl.abilist   |   1 +
 .../sysv/linux/microblaze/le/libc.abilist     |  76 ++++++++++
 .../sysv/linux/microblaze/le/librt.abilist    |   5 +
 .../sysv/linux/microblaze/time64-compat.h     |   2 +
 .../sysv/linux/mips/bits/socket-constants.h   |  36 ++++-
 .../unix/sysv/linux/mips/bits/struct_stat.h   |  89 ++++++-----
 .../linux/mips/bits/types/struct_msqid_ds.h   |  18 ++-
 .../linux/mips/bits/types/struct_semid_ds.h   |   4 +
 .../linux/mips/bits/types/struct_shmid_ds.h   |  14 +-
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  76 ++++++++++
 .../sysv/linux/mips/mips32/libanl.abilist     |   1 +
 .../unix/sysv/linux/mips/mips32/librt.abilist |   5 +
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |  76 ++++++++++
 .../sysv/linux/mips/mips32/time64-compat.h    |   2 +
 .../sysv/linux/mips/mips64/n32/libanl.abilist |   5 +
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  76 ++++++++++
 .../sysv/linux/mips/mips64/n32/librt.abilist  |  42 ++++++
 .../linux/mips/mips64/n32/time64-compat.h     |   2 +
 .../mips/mips64/{ => n64}/libanl.abilist      |   0
 .../linux/mips/mips64/{ => n64}/librt.abilist |   0
 .../sysv/linux/mips/socket-constants-time64.h |  35 +++++
 sysdeps/unix/sysv/linux/mtx_timedlock.c       |   8 +-
 sysdeps/unix/sysv/linux/nios2/libanl.abilist  |   1 +
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |  76 ++++++++++
 sysdeps/unix/sysv/linux/nios2/librt.abilist   |   5 +
 sysdeps/unix/sysv/linux/nios2/time64-compat.h |   2 +
 sysdeps/unix/sysv/linux/oldglob.c             |  11 +-
 .../linux/powerpc/bits/socket-constants.h     |  36 ++++-
 .../sysv/linux/powerpc/bits/struct_stat.h     |  52 ++++---
 .../powerpc/bits/types/struct_msqid_ds.h      |  12 +-
 .../powerpc/bits/types/struct_semid_ds.h      |  10 +-
 .../powerpc/bits/types/struct_shmid_ds.h      |  10 +-
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  76 ++++++++++
 .../linux/powerpc/powerpc32/libanl.abilist    |   1 +
 .../linux/powerpc/powerpc32/librt.abilist     |   5 +
 .../powerpc/powerpc32/nofpu/libc.abilist      |  76 ++++++++++
 .../linux/powerpc/powerpc32/time64-compat.h   |   2 +
 .../linux/powerpc/socket-constants-time64.h   |  35 +++++
 sysdeps/unix/sysv/linux/recvmmsg.c            |  17 ++-
 sysdeps/unix/sysv/linux/recvmsg.c             |  23 ++-
 .../unix/sysv/linux/s390/bits/struct_stat.h   |  56 ++++---
 .../sysv/linux/s390/s390-32/libanl.abilist    |   5 +
 .../unix/sysv/linux/s390/s390-32/libc.abilist |  76 ++++++++++
 .../sysv/linux/s390/s390-32/librt.abilist     |   5 +
 .../sysv/linux/s390/s390-32/time64-compat.h   |   2 +
 .../linux/s390/{ => s390-64}/libanl.abilist   |   0
 sysdeps/unix/sysv/linux/semctl.c              |   1 -
 sysdeps/unix/sysv/linux/setsockopt.c          |  83 ++++++++++-
 sysdeps/unix/sysv/linux/sh/be/libanl.abilist  |   1 +
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  76 ++++++++++
 sysdeps/unix/sysv/linux/sh/be/librt.abilist   |   5 +
 sysdeps/unix/sysv/linux/sh/le/libanl.abilist  |   1 +
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  76 ++++++++++
 sysdeps/unix/sysv/linux/sh/le/librt.abilist   |   5 +
 sysdeps/unix/sysv/linux/sh/time64-compat.h    |   2 +
 .../unix/sysv/linux/socket-constants-time64.h |  35 +++++
 .../sysv/linux/sparc/bits/socket-constants.h  |  36 ++++-
 .../linux/sparc/bits/types/struct_msqid_ds.h  |  12 +-
 .../linux/sparc/bits/types/struct_semid_ds.h  |  10 +-
 .../linux/sparc/bits/types/struct_shmid_ds.h  |  10 +-
 .../linux/sparc/socket-constants-time64.h     |  35 +++++
 .../sysv/linux/sparc/sparc32/libanl.abilist   |   1 +
 .../sysv/linux/sparc/sparc32/libc.abilist     |  76 ++++++++++
 .../sysv/linux/sparc/sparc32/librt.abilist    |   5 +
 .../sysv/linux/sparc/sparc32/time64-compat.h  |   2 +
 sysdeps/unix/sysv/linux/struct_stat_time64.h  |  59 +-------
 sysdeps/unix/sysv/linux/sys/timerfd.h         |  22 +++
 sysdeps/unix/sysv/linux/sys/timex.h           |  27 +++-
 sysdeps/unix/sysv/linux/tst-adjtimex-time64.c |   1 +
 .../sysv/linux/tst-clock_adjtime-time64.c     |   1 +
 .../unix/sysv/linux/tst-ntp_adjtime-time64.c  |   1 +
 .../unix/sysv/linux/tst-ntp_gettime-time64.c  |   1 +
 .../unix/sysv/linux/tst-ntp_gettimex-time64.c |   1 +
 sysdeps/unix/sysv/linux/tst-ppoll-time64.c    |   1 +
 .../unix/sysv/linux/tst-sigtimedwait-time64.c |   1 +
 sysdeps/unix/sysv/linux/tst-timerfd-time64.c  |   1 +
 .../unix/sysv/linux/x86/bits/struct_stat.h    |  90 ++++++------
 .../linux/x86/bits/types/struct_semid_ds.h    |   4 +
 sysvipc/Makefile                              |   2 +
 sysvipc/sys/msg.h                             |  10 ++
 sysvipc/sys/sem.h                             |  21 +++
 sysvipc/sys/shm.h                             |  10 ++
 sysvipc/test-sysvmsg-time64.c                 |   1 +
 sysvipc/test-sysvsem-time64.c                 |   1 +
 sysvipc/test-sysvshm-time64.c                 |   1 +
 time/Makefile                                 |  18 +++
 time/bits/types/struct_timespec.h             |  12 +-
 time/bits/types/struct_timeval.h              |   5 +
 time/bits/types/time_t.h                      |   4 +
 time/getdate.c                                |  22 ++-
 time/sys/time.h                               |  71 +++++++++
 time/time.h                                   | 138 +++++++++++++++++-
 time/tst-adjtime-time64.c                     |   1 +
 time/tst-clock-time64.c                       |   1 +
 time/tst-clock2-time64.c                      |   1 +
 time/tst-clock_nanosleep-time64.c             |   1 +
 time/tst-clock_settime-time64.c               |   1 +
 time/tst-cpuclock1-time64.c                   |   1 +
 time/tst-ctime-time64.c                       |   1 +
 time/tst-ctime.c                              |  16 ++
 time/tst-difftime-time64.c                    |   1 +
 time/tst-getdate.c                            |  14 +-
 time/tst-gmtime-time64.c                      |   1 +
 time/tst-itimer-time64.c                      |   1 +
 time/tst-mktime4-time64.c                     |   1 +
 time/tst-settimeofday-time64.c                |   1 +
 time/tst-timegm-time64.c                      |   1 +
 time/tst-timespec_get-time64.c                |   1 +
 time/tst-timespec_getres-time64.c             |   1 +
 time/tst-y2039-time64.c                       |   1 +
 time/tst-y2039.c                              |  10 ++
 291 files changed, 5048 insertions(+), 537 deletions(-)
 create mode 100644 include/features-time64.h
 create mode 100644 io/fts64-time64.c
 create mode 100644 io/ftw64-time64.c
 create mode 100644 io/ftwtest-time64.c
 create mode 100644 io/tst-fts-time64.c
 create mode 100644 io/tst-futimens-time64.c
 create mode 100644 io/tst-futimes-time64.c
 create mode 100644 io/tst-futimesat-time64.c
 create mode 100644 io/tst-lutimes-time64.c
 create mode 100644 io/tst-stat-time64.c
 create mode 100644 io/tst-utime-time64.c
 create mode 100644 io/tst-utimensat-time64.c
 create mode 100644 io/tst-utimes-time64.c
 create mode 100644 misc/tst-pselect-time64.c
 create mode 100644 misc/tst-select-time64.c
 create mode 100644 nptl/tst-cancel4_2-time64.c
 create mode 100644 posix/glob64-time64.c
 create mode 100644 posix/globfree64-time64.c
 create mode 100644 posix/tst-gnuglob64-time64.c
 create mode 100644 posix/tst-sched_rr_get_interval-time64.c
 create mode 100644 posix/tst-wait3-time64.c
 create mode 100644 posix/tst-wait4-time64.c
 create mode 100644 rt/tst-aio6-time64.c
 create mode 100644 rt/tst-cpuclock2-time64.c
 create mode 100644 rt/tst-mqueue1-time64.c
 create mode 100644 rt/tst-mqueue2-time64.c
 create mode 100644 rt/tst-mqueue4-time64.c
 create mode 100644 rt/tst-mqueue8-time64.c
 create mode 100644 rt/tst-timer4-time64.c
 create mode 100644 support/support-xfstat-time64.c
 create mode 100644 support/support-xstat-time64.c
 create mode 100644 support/timespec-add-time64.c
 create mode 100644 support/timespec-sub-time64.c
 create mode 100644 support/timespec-time64.c
 create mode 100644 support/xclock_gettime_time64.c
 create mode 100644 support/xclock_settime_time64.c
 create mode 100644 support/xlstat-time64.c
 create mode 100644 sysdeps/generic/features-time64.h
 create mode 100644 sysdeps/generic/time64-compat.h
 create mode 100644 sysdeps/pthread/tst-abstime-time64.c
 create mode 100644 sysdeps/pthread/tst-cnd-timedwait-time64.c
 create mode 100644 sysdeps/pthread/tst-cond11-time64.c
 create mode 100644 sysdeps/pthread/tst-join14-time64.c
 create mode 100644 sysdeps/pthread/tst-mtx-timedlock-time64.c
 create mode 100644 sysdeps/pthread/tst-rwlock14-time64.c
 create mode 100644 sysdeps/pthread/tst-sem5-time64.c
 create mode 100644 sysdeps/pthread/tst-thrd-sleep-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/arm/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
 create mode 100644 sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds_helper.h
 create mode 100644 sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds_helper.h
 create mode 100644 sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds_helper.h
 create mode 100644 sysdeps/unix/sysv/linux/convert_scm_timestamps.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/features-time64.h
 create mode 100644 sysdeps/unix/sysv/linux/glob64-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/globfree64-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h
 create mode 100644 sysdeps/unix/sysv/linux/hppa/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/i386/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/m68k/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/microblaze/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips32/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/time64-compat.h
 rename sysdeps/unix/sysv/linux/mips/mips64/{ => n64}/libanl.abilist (100%)
 rename sysdeps/unix/sysv/linux/mips/mips64/{ => n64}/librt.abilist (100%)
 create mode 100644 sysdeps/unix/sysv/linux/mips/socket-constants-time64.h
 create mode 100644 sysdeps/unix/sysv/linux/nios2/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/time64-compat.h
 rename sysdeps/unix/sysv/linux/s390/{ => s390-64}/libanl.abilist (100%)
 create mode 100644 sysdeps/unix/sysv/linux/sh/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/socket-constants-time64.h
 create mode 100644 sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/tst-adjtimex-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-ppoll-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-timerfd-time64.c
 create mode 100644 sysvipc/test-sysvmsg-time64.c
 create mode 100644 sysvipc/test-sysvsem-time64.c
 create mode 100644 sysvipc/test-sysvshm-time64.c
 create mode 100644 time/tst-adjtime-time64.c
 create mode 100644 time/tst-clock-time64.c
 create mode 100644 time/tst-clock2-time64.c
 create mode 100644 time/tst-clock_nanosleep-time64.c
 create mode 100644 time/tst-clock_settime-time64.c
 create mode 100644 time/tst-cpuclock1-time64.c
 create mode 100644 time/tst-ctime-time64.c
 create mode 100644 time/tst-difftime-time64.c
 create mode 100644 time/tst-gmtime-time64.c
 create mode 100644 time/tst-itimer-time64.c
 create mode 100644 time/tst-mktime4-time64.c
 create mode 100644 time/tst-settimeofday-time64.c
 create mode 100644 time/tst-timegm-time64.c
 create mode 100644 time/tst-timespec_get-time64.c
 create mode 100644 time/tst-timespec_getres-time64.c
 create mode 100644 time/tst-y2039-time64.c

-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 01/24] linux: mips: Split librt.abilist in n32 and n64
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
@ 2021-06-07 20:35 ` Adhemerval Zanella
  2021-06-07 20:35 ` [PATCH v3 02/24] linux: mips: Split libanl.abilist " Adhemerval Zanella
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:35 UTC (permalink / raw)
  To: libc-alpha

The n32 will require the 64-bit time symbols for y2038 support.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 .../linux/mips/mips64/{ => n32}/librt.abilist |  0
 .../sysv/linux/mips/mips64/n64/librt.abilist  | 37 +++++++++++++++++++
 2 files changed, 37 insertions(+)
 rename sysdeps/unix/sysv/linux/mips/mips64/{ => n32}/librt.abilist (100%)
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/librt.abilist

diff --git a/sysdeps/unix/sysv/linux/mips/mips64/librt.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/librt.abilist
similarity index 100%
rename from sysdeps/unix/sysv/linux/mips/mips64/librt.abilist
rename to sysdeps/unix/sysv/linux/mips/mips64/n32/librt.abilist
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/librt.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/librt.abilist
new file mode 100644
index 0000000000..1539c1cef9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/librt.abilist
@@ -0,0 +1,37 @@
+GLIBC_2.2 aio_cancel F
+GLIBC_2.2 aio_cancel64 F
+GLIBC_2.2 aio_error F
+GLIBC_2.2 aio_error64 F
+GLIBC_2.2 aio_fsync F
+GLIBC_2.2 aio_fsync64 F
+GLIBC_2.2 aio_init F
+GLIBC_2.2 aio_read F
+GLIBC_2.2 aio_read64 F
+GLIBC_2.2 aio_return F
+GLIBC_2.2 aio_return64 F
+GLIBC_2.2 aio_suspend F
+GLIBC_2.2 aio_suspend64 F
+GLIBC_2.2 aio_write F
+GLIBC_2.2 aio_write64 F
+GLIBC_2.2 lio_listio F
+GLIBC_2.2 lio_listio64 F
+GLIBC_2.2 shm_open F
+GLIBC_2.2 shm_unlink F
+GLIBC_2.2 timer_create F
+GLIBC_2.2 timer_delete F
+GLIBC_2.2 timer_getoverrun F
+GLIBC_2.2 timer_gettime F
+GLIBC_2.2 timer_settime F
+GLIBC_2.3.4 mq_close F
+GLIBC_2.3.4 mq_getattr F
+GLIBC_2.3.4 mq_notify F
+GLIBC_2.3.4 mq_open F
+GLIBC_2.3.4 mq_receive F
+GLIBC_2.3.4 mq_send F
+GLIBC_2.3.4 mq_setattr F
+GLIBC_2.3.4 mq_timedreceive F
+GLIBC_2.3.4 mq_timedsend F
+GLIBC_2.3.4 mq_unlink F
+GLIBC_2.4 lio_listio F
+GLIBC_2.4 lio_listio64 F
+GLIBC_2.7 __mq_open_2 F
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 02/24] linux: mips: Split libanl.abilist in n32 and n64
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
  2021-06-07 20:35 ` [PATCH v3 01/24] linux: mips: Split librt.abilist in n32 and n64 Adhemerval Zanella
@ 2021-06-07 20:35 ` Adhemerval Zanella
  2021-06-07 20:35 ` [PATCH v3 03/24] linux: s390: Add libanl.abilist in s390 and s390x Adhemerval Zanella
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:35 UTC (permalink / raw)
  To: libc-alpha

The n32 will require the 64-bit time symbols for y2038 support.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 sysdeps/unix/sysv/linux/mips/mips64/{ => n32}/libanl.abilist | 0
 sysdeps/unix/sysv/linux/mips/mips64/n64/libanl.abilist       | 4 ++++
 2 files changed, 4 insertions(+)
 rename sysdeps/unix/sysv/linux/mips/mips64/{ => n32}/libanl.abilist (100%)
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/libanl.abilist

diff --git a/sysdeps/unix/sysv/linux/mips/mips64/libanl.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libanl.abilist
similarity index 100%
rename from sysdeps/unix/sysv/linux/mips/mips64/libanl.abilist
rename to sysdeps/unix/sysv/linux/mips/mips64/n32/libanl.abilist
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libanl.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libanl.abilist
new file mode 100644
index 0000000000..d9a5ed015d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libanl.abilist
@@ -0,0 +1,4 @@
+GLIBC_2.2.3 gai_cancel F
+GLIBC_2.2.3 gai_error F
+GLIBC_2.2.3 gai_suspend F
+GLIBC_2.2.3 getaddrinfo_a F
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 03/24] linux: s390: Add libanl.abilist in s390 and s390x
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
  2021-06-07 20:35 ` [PATCH v3 01/24] linux: mips: Split librt.abilist in n32 and n64 Adhemerval Zanella
  2021-06-07 20:35 ` [PATCH v3 02/24] linux: mips: Split libanl.abilist " Adhemerval Zanella
@ 2021-06-07 20:35 ` Adhemerval Zanella
  2021-06-07 20:35 ` [PATCH v3 04/24] linux: Add fallback for 64-bit time_t SO_{RCV, SND}TIMEO Adhemerval Zanella
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:35 UTC (permalink / raw)
  To: libc-alpha

The s390 will require the 64-bit time symbols for y2038 support.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 sysdeps/unix/sysv/linux/s390/{ => s390-32}/libanl.abilist | 0
 sysdeps/unix/sysv/linux/s390/s390-64/libanl.abilist       | 4 ++++
 2 files changed, 4 insertions(+)
 rename sysdeps/unix/sysv/linux/s390/{ => s390-32}/libanl.abilist (100%)
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/libanl.abilist

diff --git a/sysdeps/unix/sysv/linux/s390/libanl.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libanl.abilist
similarity index 100%
rename from sysdeps/unix/sysv/linux/s390/libanl.abilist
rename to sysdeps/unix/sysv/linux/s390/s390-32/libanl.abilist
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libanl.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libanl.abilist
new file mode 100644
index 0000000000..d9a5ed015d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libanl.abilist
@@ -0,0 +1,4 @@
+GLIBC_2.2.3 gai_cancel F
+GLIBC_2.2.3 gai_error F
+GLIBC_2.2.3 gai_suspend F
+GLIBC_2.2.3 getaddrinfo_a F
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 04/24] linux: Add fallback for 64-bit time_t SO_{RCV, SND}TIMEO
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2021-06-07 20:35 ` [PATCH v3 03/24] linux: s390: Add libanl.abilist in s390 and s390x Adhemerval Zanella
@ 2021-06-07 20:35 ` Adhemerval Zanella
  2021-06-14 14:52   ` [PATCH v3 04/24] linux: Add fallback for 64-bit time_t SO_{RCV,SND}TIMEO Carlos O'Donell
  2021-06-07 20:35 ` [PATCH v3 05/24] linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS} Adhemerval Zanella
                   ` (19 subsequent siblings)
  23 siblings, 1 reply; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:35 UTC (permalink / raw)
  To: libc-alpha

The constant values will be changed for __TIMESIZE=64, so binaries built
with 64-bit time support might fail to work properly on old kernels.
Both {get,set}sockopt will retry the syscall with the old constant
values and the timeout value adjusted when kernel returns ENOTPROTOPT.

It also adds an internal only SO_{RCV,SND}TIMEO where
COMPAT_SO_{RCV,SND}TIMEO_OLD indicates pre 32 bit time support and
COMPAT_SO_{RCV,SND}TIMEO_NEW indicates time64 support.  It allows to
refer to constant independently of the time_t ABI and kernel version
used.

Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
kernel).
---
 sysdeps/unix/sysv/linux/getsockopt.c          | 70 ++++++++++++++++--
 .../sysv/linux/hppa/socket-constants-time64.h | 30 ++++++++
 .../sysv/linux/mips/socket-constants-time64.h | 30 ++++++++
 .../linux/powerpc/socket-constants-time64.h   | 30 ++++++++
 sysdeps/unix/sysv/linux/setsockopt.c          | 71 ++++++++++++++++---
 .../unix/sysv/linux/socket-constants-time64.h | 30 ++++++++
 .../linux/sparc/socket-constants-time64.h     | 30 ++++++++
 7 files changed, 276 insertions(+), 15 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h
 create mode 100644 sysdeps/unix/sysv/linux/mips/socket-constants-time64.h
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h
 create mode 100644 sysdeps/unix/sysv/linux/socket-constants-time64.h
 create mode 100644 sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h

diff --git a/sysdeps/unix/sysv/linux/getsockopt.c b/sysdeps/unix/sysv/linux/getsockopt.c
index 76ee8a94d6..688a7de087 100644
--- a/sysdeps/unix/sysv/linux/getsockopt.c
+++ b/sysdeps/unix/sysv/linux/getsockopt.c
@@ -15,16 +15,15 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <signal.h>
 #include <sys/socket.h>
-
+#include <time.h>
+#include <sysdep.h>
 #include <socketcall.h>
-#include <kernel-features.h>
-#include <sys/syscall.h>
+#include <socket-constants-time64.h>
 
-int
-__getsockopt (int fd, int level, int optname, void *optval, socklen_t *len)
+static int
+getsockopt_syscall (int fd, int level, int optname, void *optval,
+		    socklen_t *len)
 {
 #ifdef __ASSUME_GETSOCKOPT_SYSCALL
   return INLINE_SYSCALL (getsockopt, 5, fd, level, optname, optval, len);
@@ -32,4 +31,61 @@ __getsockopt (int fd, int level, int optname, void *optval, socklen_t *len)
   return SOCKETCALL (getsockopt, fd, level, optname, optval, len);
 #endif
 }
+
+#ifndef __ASSUME_TIME64_SYSCALLS
+static int
+getsockopt32 (int fd, int level, int optname, void *optval,
+	      socklen_t *len)
+{
+  int r = -1;
+
+  if (level != SOL_SOCKET)
+    return r;
+
+  switch (optname)
+    {
+    case COMPAT_SO_RCVTIMEO_NEW:
+    case COMPAT_SO_SNDTIMEO_NEW:
+      {
+	if (optname == COMPAT_SO_RCVTIMEO_NEW)
+	  optname = COMPAT_SO_RCVTIMEO_OLD;
+	if (optname == COMPAT_SO_SNDTIMEO_NEW)
+	  optname = COMPAT_SO_SNDTIMEO_OLD;
+
+	struct __timeval32 tv32;
+	r = getsockopt_syscall (fd, level, optname, &tv32,
+				(socklen_t[]) { sizeof tv32 });
+	if (r < 0)
+	  break;
+
+	/* POSIX states that if the size of the option value is greater than
+	   then option length, the option value argument shall be silently
+	   truncated.  */
+	if (*len >= sizeof (struct __timeval64))
+	  {
+	    struct __timeval64 *tv64 = (struct __timeval64 *) optval;
+	    *tv64 = valid_timeval32_to_timeval64 (tv32);
+	    *len = sizeof (*tv64);
+	  }
+	else
+	  memcpy (optval, &tv32, sizeof tv32);
+      }
+    }
+
+  return r;
+}
+#endif
+
+int
+__getsockopt (int fd, int level, int optname, void *optval, socklen_t *len)
+{
+  int r = getsockopt_syscall (fd, level, optname, optval, len);
+
+#ifndef __ASSUME_TIME64_SYSCALLS
+  if (r == -1 && errno == ENOPROTOOPT)
+    r = getsockopt32 (fd, level, optname, optval, len);
+#endif
+
+ return r;
+}
 weak_alias (__getsockopt, getsockopt)
diff --git a/sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h b/sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h
new file mode 100644
index 0000000000..9fe7576aaa
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h
@@ -0,0 +1,30 @@
+/* Compat socket constants used in 64-bit compat code.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _SOCKET_CONSTANTS_TIME64_H
+#define _SOCKET_CONSTANTS_TIME64_H
+
+/* The compat code requires the SO_* constants used for both 32 and 64-bit
+   time_t, however they were only added on v5.1 kernel.  */
+
+#define COMPAT_SO_RCVTIMEO_OLD 4102
+#define COMPAT_SO_SNDTIMEO_OLD 4101
+#define COMPAT_SO_RCVTIMEO_NEW 16448
+#define COMPAT_SO_SNDTIMEO_NEW 16449
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/socket-constants-time64.h b/sysdeps/unix/sysv/linux/mips/socket-constants-time64.h
new file mode 100644
index 0000000000..1252a8a23b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/socket-constants-time64.h
@@ -0,0 +1,30 @@
+/* Compat socket constants used in 64-bit compat code.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _SOCKET_CONSTANTS_TIME64_H
+#define _SOCKET_CONSTANTS_TIME64_H
+
+/* The compat code requires the SO_* constants used for both 32 and 64-bit
+   time_t, however they were only added on v5.1 kernel.  */
+
+#define COMPAT_SO_RCVTIMEO_OLD 4102
+#define COMPAT_SO_SNDTIMEO_OLD 4101
+#define COMPAT_SO_RCVTIMEO_NEW 66
+#define COMPAT_SO_SNDTIMEO_NEW 67
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h b/sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h
new file mode 100644
index 0000000000..26e8b710ab
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h
@@ -0,0 +1,30 @@
+/* Compat socket constants used in 64-bit compat code.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _SOCKET_CONSTANTS_TIME64_H
+#define _SOCKET_CONSTANTS_TIME64_H
+
+/* The compat code requires the SO_* constants used for both 32 and 64-bit
+   time_t, however they were only added on v5.1 kernel.  */
+
+#define COMPAT_SO_RCVTIMEO_OLD 18
+#define COMPAT_SO_SNDTIMEO_OLD 19
+#define COMPAT_SO_RCVTIMEO_NEW 66
+#define COMPAT_SO_SNDTIMEO_NEW 67
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/setsockopt.c b/sysdeps/unix/sysv/linux/setsockopt.c
index 12fd7bdcde..6505202265 100644
--- a/sysdeps/unix/sysv/linux/setsockopt.c
+++ b/sysdeps/unix/sysv/linux/setsockopt.c
@@ -15,21 +15,76 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <signal.h>
 #include <sys/socket.h>
-
+#include <time.h>
+#include <sysdep.h>
 #include <socketcall.h>
-#include <kernel-features.h>
-#include <sys/syscall.h>
+#include <socket-constants-time64.h>
 
-int
-setsockopt (int fd, int level, int optname, const void *optval, socklen_t len)
+static int
+setsockopt_syscall (int fd, int level, int optname, const void *optval,
+		    socklen_t len)
 {
 #ifdef __ASSUME_SETSOCKOPT_SYSCALL
-  return INLINE_SYSCALL (setsockopt, 5, fd, level, optname, optval, len);
+  return INLINE_SYSCALL_CALL (setsockopt, fd, level, optname, optval, len);
 #else
   return SOCKETCALL (setsockopt, fd, level, optname, optval, len);
 #endif
 }
+
+#ifndef __ASSUME_TIME64_SYSCALLS
+static int
+setsockopt32 (int fd, int level, int optname, const void *optval,
+	      socklen_t len)
+{
+  int r = -1;
+
+  if (level != SOL_SOCKET)
+    return r;
+
+  switch (optname)
+    {
+    case COMPAT_SO_RCVTIMEO_NEW:
+    case COMPAT_SO_SNDTIMEO_NEW:
+      {
+        if (len < sizeof (struct __timeval64))
+	  {
+	    __set_errno (EINVAL);
+	    break;
+	  }
+
+	struct __timeval64 *tv64 = (struct __timeval64 *) optval;
+	if (! in_time_t_range (tv64->tv_sec))
+	  {
+	    __set_errno (EOVERFLOW);
+	    break;
+	  }
+
+	if (optname == COMPAT_SO_RCVTIMEO_NEW)
+	  optname = COMPAT_SO_RCVTIMEO_OLD;
+	if (optname == COMPAT_SO_SNDTIMEO_NEW)
+	  optname = COMPAT_SO_SNDTIMEO_OLD;
+
+	struct __timeval32 tv32 = valid_timeval64_to_timeval32 (*tv64);
+
+	r = setsockopt_syscall (fd, level, optname, &tv32, sizeof (tv32));
+      }
+    }
+
+  return r;
+}
+#endif
+
+int
+setsockopt (int fd, int level, int optname, const void *optval, socklen_t len)
+{
+  int r = setsockopt_syscall (fd, level, optname, optval, len);
+
+#ifndef __ASSUME_TIME64_SYSCALLS
+  if (r == -1 && errno == ENOPROTOOPT)
+    r = setsockopt32 (fd, level, optname, optval, len);
+#endif
+
+  return r;
+}
 weak_alias (setsockopt, __setsockopt)
diff --git a/sysdeps/unix/sysv/linux/socket-constants-time64.h b/sysdeps/unix/sysv/linux/socket-constants-time64.h
new file mode 100644
index 0000000000..d09c39d6c2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/socket-constants-time64.h
@@ -0,0 +1,30 @@
+/* Compat socket constants used in 64-bit compat code.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _SOCKET_CONSTANTS_TIME64_H
+#define _SOCKET_CONSTANTS_TIME64_H
+
+/* The compat code requires the SO_* constants used for both 32 and 64-bit
+   time_t, however they were only added on v5.1 kernel.  */
+
+#define COMPAT_SO_RCVTIMEO_OLD 20
+#define COMPAT_SO_SNDTIMEO_OLD 21
+#define COMPAT_SO_RCVTIMEO_NEW 66
+#define COMPAT_SO_SNDTIMEO_NEW 67
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h b/sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h
new file mode 100644
index 0000000000..f4668db537
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h
@@ -0,0 +1,30 @@
+/* Compat socket constants used in 64-bit compat code.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _SOCKET_CONSTANTS_TIME64_H
+#define _SOCKET_CONSTANTS_TIME64_H
+
+/* The compat code requires the SO_* constants used for both 32 and 64-bit
+   time_t, however they were only added on v5.1 kernel.  */
+
+#define COMPAT_SO_RCVTIMEO_OLD 8192
+#define COMPAT_SO_SNDTIMEO_OLD 16384
+#define COMPAT_SO_RCVTIMEO_NEW 68
+#define COMPAT_SO_SNDTIMEO_NEW 69
+
+#endif
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 05/24] linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS}
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2021-06-07 20:35 ` [PATCH v3 04/24] linux: Add fallback for 64-bit time_t SO_{RCV, SND}TIMEO Adhemerval Zanella
@ 2021-06-07 20:35 ` Adhemerval Zanella
  2021-06-25 15:20   ` Florian Weimer
  2021-06-07 20:35 ` [PATCH v3 06/24] linux: Add recvvmsg " Adhemerval Zanella
                   ` (18 subsequent siblings)
  23 siblings, 1 reply; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:35 UTC (permalink / raw)
  To: libc-alpha

The recvmsg handling is more complicated because it requires check the
returned kernel control message and make some convertions.  For
!__ASSUME_TIME64_SYSCALLS it converts the first 32-bit time SO_TIMESTAMP
or SO_TIMESTAMPNS and appends it to the control buffer if has extra
space or returns MSG_CTRUNC otherwise.  The 32-bit time field is kept
as-is.

Calls with __TIMESIZE=32 will see the converted 64-bit time control
messages as spurious control message of unknown type.  Calls with
__TIMESIZE=64 running on pre-time64 kernels will see the original
message as a spurious control ones of unknown typ while running on
kernel with native 64-bit time support will only see the time64 version
of the control message.

Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
kernel).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 include/sys/socket.h                          |  5 +
 sysdeps/unix/sysv/linux/Makefile              |  2 +-
 sysdeps/unix/sysv/linux/Versions              |  1 +
 .../unix/sysv/linux/convert_scm_timestamps.c  | 96 +++++++++++++++++++
 sysdeps/unix/sysv/linux/getsockopt.c          | 12 +++
 .../sysv/linux/hppa/socket-constants-time64.h |  5 +
 .../sysv/linux/mips/socket-constants-time64.h |  5 +
 .../linux/powerpc/socket-constants-time64.h   |  5 +
 sysdeps/unix/sysv/linux/recvmsg.c             | 23 +++--
 sysdeps/unix/sysv/linux/setsockopt.c          | 12 +++
 .../unix/sysv/linux/socket-constants-time64.h |  5 +
 .../linux/sparc/socket-constants-time64.h     |  5 +
 12 files changed, 169 insertions(+), 7 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/convert_scm_timestamps.c

diff --git a/include/sys/socket.h b/include/sys/socket.h
index 0e39dd2a3a..15d4a62b26 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -164,5 +164,10 @@ libc_hidden_proto (__libc_sa_len)
 
 libc_hidden_proto (__cmsg_nxthdr)
 
+#ifndef __ASSUME_TIME64_SYSCALLS
+extern void __convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize) ;
+libc_hidden_proto (__convert_scm_timestamps)
+#endif
+
 #endif
 #endif
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index bc14f20274..36d5ae020c 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -64,7 +64,7 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
 		   time64-support pselect32 \
 		   xstat fxstat lxstat xstat64 fxstat64 lxstat64 \
 		   fxstatat fxstatat64 \
-		   xmknod xmknodat
+		   xmknod xmknodat convert_scm_timestamps
 
 CFLAGS-gethostid.c = -fexceptions
 CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index c864ad38ca..4637fd651d 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -194,6 +194,7 @@ libc {
     __pread64_nocancel;
     __close_nocancel;
     __sigtimedwait;
+    __convert_scm_timestamps;
     # functions used by nscd
     __netlink_assert_response;
   }
diff --git a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
new file mode 100644
index 0000000000..3c123c28ce
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
@@ -0,0 +1,96 @@
+/* Socket timestamp conversion routines.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <kernel-features.h>
+
+#ifndef __ASSUME_TIME64_SYSCALLS
+# include <stdint.h>
+# include <string.h>
+# include <sys/socket.h>
+# include <socket-constants-time64.h>
+
+/* It converts the first SO_TIMESTAMP or SO_TIMESTAMPNS with 32-bit time and
+   appends it to the control buffer.  The 32-bit time field is kept as-is.
+
+   Calls with __TIMESIZE=32 will see the converted 64-bit time control
+   messages as spurious control message of unknown type.
+
+   Calls with __TIMESIZE=64 running on pre-time64 kernels will see the
+   original message as a spurious control ones of unknown typ while running
+   on kernel with native 64-bit time support will only see the time64 version
+   of the control message.  */
+void
+__convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize)
+{
+  if (msg->msg_control == NULL || msg->msg_controllen == 0)
+    return;
+
+  /* The returned control message format for SO_TIMESTAMP_NEW is a
+     'struct __kernel_sock_timeval' while for SO_TIMESTAMPNS_NEW is a
+     'struct __kernel_timespec'.  In either case it is two uint64_t
+     members.  */
+  uint64_t tvts[2];
+
+  struct cmsghdr *cmsg, *last = NULL;
+  int type = 0;
+
+  for (cmsg = CMSG_FIRSTHDR (msg);
+       cmsg != NULL;
+       cmsg = CMSG_NXTHDR (msg, cmsg))
+    {
+      if (cmsg->cmsg_level != SOL_SOCKET)
+	continue;
+
+      switch (cmsg->cmsg_type)
+	{
+	case COMPAT_SO_TIMESTAMP_OLD:
+	  if (type != 0)
+	    break;
+	  type = COMPAT_SO_TIMESTAMP_NEW;
+	  goto common;
+
+	case COMPAT_SO_TIMESTAMPNS_OLD:
+	  type = COMPAT_SO_TIMESTAMPNS_NEW;
+
+	/* fallthrough  */
+	common:
+	  memcpy (tvts, CMSG_DATA (cmsg), sizeof (tvts));
+	  break;
+	}
+
+      last = cmsg;
+    }
+
+  if (last == NULL || type == 0)
+    return;
+
+  if (CMSG_SPACE (sizeof tvts) > msgsize - msg->msg_controllen)
+    {
+      msg->msg_flags |= MSG_CTRUNC;
+      return;
+    }
+
+  msg->msg_controllen += CMSG_SPACE (sizeof tvts);
+  cmsg = CMSG_NXTHDR(msg, last);
+  cmsg->cmsg_level = SOL_SOCKET;
+  cmsg->cmsg_type = type;
+  cmsg->cmsg_len = CMSG_LEN (sizeof tvts);
+  memcpy (CMSG_DATA (cmsg), tvts, sizeof tvts);
+}
+libc_hidden_def (__convert_scm_timestamps)
+#endif
diff --git a/sysdeps/unix/sysv/linux/getsockopt.c b/sysdeps/unix/sysv/linux/getsockopt.c
index 688a7de087..f86b06dec6 100644
--- a/sysdeps/unix/sysv/linux/getsockopt.c
+++ b/sysdeps/unix/sysv/linux/getsockopt.c
@@ -70,6 +70,18 @@ getsockopt32 (int fd, int level, int optname, void *optval,
 	else
 	  memcpy (optval, &tv32, sizeof tv32);
       }
+      break;
+
+    case COMPAT_SO_TIMESTAMP_NEW:
+    case COMPAT_SO_TIMESTAMPNS_NEW:
+      {
+	if (optname == COMPAT_SO_TIMESTAMP_NEW)
+	  optname = COMPAT_SO_TIMESTAMP_OLD;
+	if (optname == COMPAT_SO_TIMESTAMPNS_NEW)
+	  optname = COMPAT_SO_TIMESTAMPNS_OLD;
+	r = getsockopt_syscall (fd, level, optname, optval, len);
+      }
+      break;
     }
 
   return r;
diff --git a/sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h b/sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h
index 9fe7576aaa..0a48990ad8 100644
--- a/sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h
+++ b/sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h
@@ -27,4 +27,9 @@
 #define COMPAT_SO_RCVTIMEO_NEW 16448
 #define COMPAT_SO_SNDTIMEO_NEW 16449
 
+#define COMPAT_SO_TIMESTAMP_OLD 0x4012
+#define COMPAT_SO_TIMESTAMPNS_OLD 0x4013
+#define COMPAT_SO_TIMESTAMP_NEW 0x4038
+#define COMPAT_SO_TIMESTAMPNS_NEW 0x4039
+
 #endif
diff --git a/sysdeps/unix/sysv/linux/mips/socket-constants-time64.h b/sysdeps/unix/sysv/linux/mips/socket-constants-time64.h
index 1252a8a23b..728f7aa456 100644
--- a/sysdeps/unix/sysv/linux/mips/socket-constants-time64.h
+++ b/sysdeps/unix/sysv/linux/mips/socket-constants-time64.h
@@ -27,4 +27,9 @@
 #define COMPAT_SO_RCVTIMEO_NEW 66
 #define COMPAT_SO_SNDTIMEO_NEW 67
 
+#define COMPAT_SO_TIMESTAMP_OLD 29
+#define COMPAT_SO_TIMESTAMPNS_OLD 35
+#define COMPAT_SO_TIMESTAMP_NEW 63
+#define COMPAT_SO_TIMESTAMPNS_NEW 64
+
 #endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h b/sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h
index 26e8b710ab..c231b7285a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h
+++ b/sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h
@@ -27,4 +27,9 @@
 #define COMPAT_SO_RCVTIMEO_NEW 66
 #define COMPAT_SO_SNDTIMEO_NEW 67
 
+#define COMPAT_SO_TIMESTAMP_OLD 29
+#define COMPAT_SO_TIMESTAMPNS_OLD 35
+#define COMPAT_SO_TIMESTAMP_NEW 63
+#define COMPAT_SO_TIMESTAMPNS_NEW 64
+
 #endif
diff --git a/sysdeps/unix/sysv/linux/recvmsg.c b/sysdeps/unix/sysv/linux/recvmsg.c
index b209b4ad99..a2a600228b 100644
--- a/sysdeps/unix/sysv/linux/recvmsg.c
+++ b/sysdeps/unix/sysv/linux/recvmsg.c
@@ -19,16 +19,27 @@
 #include <sys/socket.h>
 #include <sysdep-cancel.h>
 #include <socketcall.h>
-#include <shlib-compat.h>
 
 ssize_t
 __libc_recvmsg (int fd, struct msghdr *msg, int flags)
 {
-# ifdef __ASSUME_RECVMSG_SYSCALL
-  return SYSCALL_CANCEL (recvmsg, fd, msg, flags);
-# else
-  return SOCKETCALL_CANCEL (recvmsg, fd, msg, flags);
-# endif
+  ssize_t r;
+#ifndef __ASSUME_TIME64_SYSCALLS
+  socklen_t orig_controllen = msg->msg_controllen;
+#endif
+
+#ifdef __ASSUME_RECVMSG_SYSCALL
+  r = SYSCALL_CANCEL (recvmsg, fd, msg, flags);
+#else
+  r = SOCKETCALL_CANCEL (recvmsg, fd, msg, flags);
+#endif
+
+#ifndef __ASSUME_TIME64_SYSCALLS
+  if (r >= 0)
+    __convert_scm_timestamps (msg, orig_controllen);
+#endif
+
+  return r;
 }
 weak_alias (__libc_recvmsg, recvmsg)
 weak_alias (__libc_recvmsg, __recvmsg)
diff --git a/sysdeps/unix/sysv/linux/setsockopt.c b/sysdeps/unix/sysv/linux/setsockopt.c
index 6505202265..a4780a9d33 100644
--- a/sysdeps/unix/sysv/linux/setsockopt.c
+++ b/sysdeps/unix/sysv/linux/setsockopt.c
@@ -69,6 +69,18 @@ setsockopt32 (int fd, int level, int optname, const void *optval,
 
 	r = setsockopt_syscall (fd, level, optname, &tv32, sizeof (tv32));
       }
+      break;
+
+    case COMPAT_SO_TIMESTAMP_NEW:
+    case COMPAT_SO_TIMESTAMPNS_NEW:
+      {
+	if (optname == COMPAT_SO_TIMESTAMP_NEW)
+	  optname = COMPAT_SO_TIMESTAMP_OLD;
+	if (optname == COMPAT_SO_TIMESTAMPNS_NEW)
+	  optname = COMPAT_SO_TIMESTAMPNS_OLD;
+	r = setsockopt_syscall (fd, level, optname, NULL, 0);
+      }
+      break;
     }
 
   return r;
diff --git a/sysdeps/unix/sysv/linux/socket-constants-time64.h b/sysdeps/unix/sysv/linux/socket-constants-time64.h
index d09c39d6c2..6cb249cc32 100644
--- a/sysdeps/unix/sysv/linux/socket-constants-time64.h
+++ b/sysdeps/unix/sysv/linux/socket-constants-time64.h
@@ -27,4 +27,9 @@
 #define COMPAT_SO_RCVTIMEO_NEW 66
 #define COMPAT_SO_SNDTIMEO_NEW 67
 
+#define COMPAT_SO_TIMESTAMP_OLD 29
+#define COMPAT_SO_TIMESTAMPNS_OLD 35
+#define COMPAT_SO_TIMESTAMP_NEW 63
+#define COMPAT_SO_TIMESTAMPNS_NEW 64
+
 #endif
diff --git a/sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h b/sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h
index f4668db537..4242cb6d19 100644
--- a/sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h
+++ b/sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h
@@ -27,4 +27,9 @@
 #define COMPAT_SO_RCVTIMEO_NEW 68
 #define COMPAT_SO_SNDTIMEO_NEW 69
 
+#define COMPAT_SO_TIMESTAMP_OLD 0x001d
+#define COMPAT_SO_TIMESTAMPNS_OLD 0x0021
+#define COMPAT_SO_TIMESTAMP_NEW 0x0046
+#define COMPAT_SO_TIMESTAMPNS_NEW 0x0042
+
 #endif
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 06/24] linux: Add recvvmsg fallback for 64-bit time_t SO_TIMESTAMP{NS}
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2021-06-07 20:35 ` [PATCH v3 05/24] linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS} Adhemerval Zanella
@ 2021-06-07 20:35 ` Adhemerval Zanella
  2021-06-07 20:35 ` [PATCH v3 07/24] y2038: Add __USE_TIME_BITS64 support for time_t Adhemerval Zanella
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:35 UTC (permalink / raw)
  To: libc-alpha

Handle the SO_TIMESTAMP{NS} similar to recvmsg: for
!__ASSUME_TIME64_SYSCALLS it converts the first 32-bit time SO_TIMESTAMP
or SO_TIMESTAMPNS and appends it to the control buffer if has extra
space or returns MSG_CTRUNC otherwise.  The 32-bit time field is kept
as-is.

Also for !__ASSUME_TIME64_SYSCALLS it limits the maximum number of
'struct mmsghdr *' to IOV_MAX (and also increases the stack size
requirement to IOV_MAX times sizeof (socklen_t)).  The Linux imposes
a similar limit to sendmmsg, so bound the array size on recvmmsg is not
unreasonable.  And this will be used only on older when building with
32-bit time support.

Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
kernel).

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 sysdeps/unix/sysv/linux/recvmmsg.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
index 672ba20332..5cd107ffa9 100644
--- a/sysdeps/unix/sysv/linux/recvmmsg.c
+++ b/sysdeps/unix/sysv/linux/recvmmsg.c
@@ -44,13 +44,26 @@ __recvmmsg64 (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
       ts32 = valid_timespec64_to_timespec (*timeout);
       pts32 = &ts32;
     }
+
+  socklen_t csize[IOV_MAX];
+  if (vlen > IOV_MAX)
+    vlen = IOV_MAX;
+  for (int i = 0; i < vlen; i++)
+    csize[i] = vmessages[i].msg_hdr.msg_controllen;
+
 # ifdef __ASSUME_RECVMMSG_SYSCALL
   r = SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, pts32);
 # else
   r = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, pts32);
 # endif
-  if (r >= 0 && timeout != NULL)
-    *timeout = valid_timespec_to_timespec64 (ts32);
+  if (r >= 0)
+    {
+      if (timeout != NULL)
+        *timeout = valid_timespec_to_timespec64 (ts32);
+
+      for (int i=0; i < r; i++)
+        __convert_scm_timestamps (&vmessages[i].msg_hdr, csize[i]);
+    }
 #endif /* __ASSUME_TIME64_SYSCALLS  */
   return r;
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 07/24] y2038: Add __USE_TIME_BITS64 support for time_t
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (5 preceding siblings ...)
  2021-06-07 20:35 ` [PATCH v3 06/24] linux: Add recvvmsg " Adhemerval Zanella
@ 2021-06-07 20:35 ` Adhemerval Zanella
  2021-06-07 20:35 ` [PATCH v3 08/24] y2038: Add __USE_TIME_BITS64 support for struct timeval Adhemerval Zanella
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:35 UTC (permalink / raw)
  To: libc-alpha

The __USE_TIME_BITS64 is not defined internally yet.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 time/bits/types/time_t.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/time/bits/types/time_t.h b/time/bits/types/time_t.h
index ab8287c6fe..84d67f6ac3 100644
--- a/time/bits/types/time_t.h
+++ b/time/bits/types/time_t.h
@@ -4,6 +4,10 @@
 #include <bits/types.h>
 
 /* Returned by `time'.  */
+#ifdef __USE_TIME_BITS64
+typedef __time64_t time_t;
+#else
 typedef __time_t time_t;
+#endif
 
 #endif
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 08/24] y2038: Add __USE_TIME_BITS64 support for struct timeval
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (6 preceding siblings ...)
  2021-06-07 20:35 ` [PATCH v3 07/24] y2038: Add __USE_TIME_BITS64 support for time_t Adhemerval Zanella
@ 2021-06-07 20:35 ` Adhemerval Zanella
  2021-06-07 20:35 ` [PATCH v3 09/24] y2038: Add __USE_TIME_BITS64 support for struct timespec Adhemerval Zanella
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:35 UTC (permalink / raw)
  To: libc-alpha

The __USE_TIME_BITS64 is not defined internally yet.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 time/bits/types/struct_timeval.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/time/bits/types/struct_timeval.h b/time/bits/types/struct_timeval.h
index 70394ce886..3466137c35 100644
--- a/time/bits/types/struct_timeval.h
+++ b/time/bits/types/struct_timeval.h
@@ -7,7 +7,12 @@
    microsecond but also has a range of years.  */
 struct timeval
 {
+#ifdef __USE_TIME_BITS64
+  __time64_t tv_sec;		/* Seconds.  */
+  __suseconds64_t tv_usec;	/* Microseconds.  */
+#else
   __time_t tv_sec;		/* Seconds.  */
   __suseconds_t tv_usec;	/* Microseconds.  */
+#endif
 };
 #endif
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 09/24] y2038: Add __USE_TIME_BITS64 support for struct timespec
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (7 preceding siblings ...)
  2021-06-07 20:35 ` [PATCH v3 08/24] y2038: Add __USE_TIME_BITS64 support for struct timeval Adhemerval Zanella
@ 2021-06-07 20:35 ` Adhemerval Zanella
  2021-06-07 20:35 ` [PATCH v3 10/24] y2038: Add __USE_TIME_BITS64 support for struct utimbuf Adhemerval Zanella
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:35 UTC (permalink / raw)
  To: libc-alpha

The __USE_TIME_BITS64 is not defined internally yet.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 time/bits/types/struct_timespec.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/time/bits/types/struct_timespec.h b/time/bits/types/struct_timespec.h
index d11c69cfd3..4fe47a0d25 100644
--- a/time/bits/types/struct_timespec.h
+++ b/time/bits/types/struct_timespec.h
@@ -1,18 +1,22 @@
-/* NB: Include guard matches what <linux/time.h> uses.  */
-#ifndef _STRUCT_TIMESPEC
-#define _STRUCT_TIMESPEC 1
+#ifndef __struct_timespec_defined
+#define __struct_timespec_defined 1
 
 #include <bits/types.h>
 #include <bits/endian.h>
+#include <bits/types/time_t.h>
 
 /* POSIX.1b structure for a time value.  This is like a `struct timeval' but
    has nanoseconds instead of microseconds.  */
 struct timespec
 {
+#ifdef __USE_TIME_BITS64
+  __time64_t tv_sec;		/* Seconds.  */
+#else
   __time_t tv_sec;		/* Seconds.  */
+#endif
 #if __WORDSIZE == 64 \
   || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \
-  || __TIMESIZE == 32
+  || (__TIMESIZE == 32 && !defined __USE_TIME_BITS64)
   __syscall_slong_t tv_nsec;	/* Nanoseconds.  */
 #else
 # if __BYTE_ORDER == __BIG_ENDIAN
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 10/24] y2038: Add __USE_TIME_BITS64 support for struct utimbuf
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (8 preceding siblings ...)
  2021-06-07 20:35 ` [PATCH v3 09/24] y2038: Add __USE_TIME_BITS64 support for struct timespec Adhemerval Zanella
@ 2021-06-07 20:35 ` Adhemerval Zanella
  2021-06-07 20:36 ` [PATCH v3 11/24] y2038: linux: Add __USE_TIME_BITS64 support for struct timex Adhemerval Zanella
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:35 UTC (permalink / raw)
  To: libc-alpha

The __USE_TIME_BITS64 is not defined internally yet.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 io/utime.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/io/utime.h b/io/utime.h
index df2299e406..c7612d0838 100644
--- a/io/utime.h
+++ b/io/utime.h
@@ -35,8 +35,13 @@ __BEGIN_DECLS
 /* Structure describing file times.  */
 struct utimbuf
   {
+#ifdef __USE_TIME_BITS64
+    __time64_t actime;		/* Access time.  */
+    __time64_t modtime;		/* Modification time.  */
+#else
     __time_t actime;		/* Access time.  */
     __time_t modtime;		/* Modification time.  */
+#endif
   };
 
 /* Set the access and modification times of FILE to those given in
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 11/24] y2038: linux: Add __USE_TIME_BITS64 support for struct timex
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (9 preceding siblings ...)
  2021-06-07 20:35 ` [PATCH v3 10/24] y2038: Add __USE_TIME_BITS64 support for struct utimbuf Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-07 20:36 ` [PATCH v3 12/24] y2038: Use a common definition for stat Adhemerval Zanella
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

The __USE_TIME_BITS64 is not defined internally yet.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 sysdeps/unix/sysv/linux/bits/timex.h | 31 ++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/bits/timex.h b/sysdeps/unix/sysv/linux/bits/timex.h
index 9b2e30f3e0..ee37694e8f 100644
--- a/sysdeps/unix/sysv/linux/bits/timex.h
+++ b/sysdeps/unix/sysv/linux/bits/timex.h
@@ -25,6 +25,36 @@
 
 struct timex
 {
+# ifdef __USE_TIME_BITS64
+  unsigned int modes;          /* mode selector */
+  int :32;                     /* pad */
+  long long offset;            /* time offset (usec) */
+  long long freq;              /* frequency offset (scaled ppm) */
+  long long maxerror;          /* maximum error (usec) */
+  long long esterror;          /* estimated error (usec) */
+  int status;                  /* clock command/status */
+  int :32;                     /* pad */
+  long long constant;          /* pll time constant */
+  long long precision;         /* clock precision (usec) (read only) */
+  long long tolerance;         /* clock frequency tolerance (ppm) (ro) */
+  struct timeval time;     /* (read only, except for ADJ_SETOFFSET) */
+  long long tick;              /* (modified) usecs between clock ticks */
+  long long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
+  long long jitter;            /* pps jitter (us) (ro) */
+  int shift;                   /* interval duration (s) (shift) (ro) */
+  int :32;                     /* pad */
+  long long stabil;            /* pps stability (scaled ppm) (ro) */
+  long long jitcnt;            /* jitter limit exceeded (ro) */
+  long long calcnt;            /* calibration intervals (ro) */
+  long long errcnt;            /* calibration errors (ro) */
+  long long stbcnt;            /* stability limit exceeded (ro) */
+
+  int tai;                     /* TAI offset (ro) */
+
+  int  :32; int  :32; int  :32; int  :32;
+  int  :32; int  :32; int  :32; int  :32;
+  int  :32; int  :32; int  :32;
+# else
   unsigned int modes;		/* mode selector */
   __syscall_slong_t offset;	/* time offset (usec) */
   __syscall_slong_t freq;	/* frequency offset (scaled ppm) */
@@ -51,6 +81,7 @@ struct timex
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32;
+# endif
 };
 
 /* Mode codes (timex.mode) */
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 12/24] y2038: Use a common definition for stat
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (10 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 11/24] y2038: linux: Add __USE_TIME_BITS64 support for struct timex Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-14 14:52   ` Carlos O'Donell
  2021-06-07 20:36 ` [PATCH v3 13/24] y2038: Use a common definition for msqid_ds Adhemerval Zanella
                   ` (11 subsequent siblings)
  23 siblings, 1 reply; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

From: Lukasz Majewski <lukma@denx.de>

Instead of replicate the same definitions from struct_stat_time64.h
on the multiple struct_stat.h, use a common header which is included
when required (struct_stat_time64_helper.h).  The 64-bit time support
is added only for LFS support.

The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit stat implementations.
---
 sysdeps/unix/sysv/linux/Makefile              |  3 +-
 sysdeps/unix/sysv/linux/bits/struct_stat.h    | 50 ++++++-----
 .../linux/bits/struct_stat_time64_helper.h    | 66 ++++++++++++++
 .../unix/sysv/linux/m68k/bits/struct_stat.h   | 50 ++++++-----
 .../sysv/linux/microblaze/bits/struct_stat.h  | 48 ++++++----
 .../unix/sysv/linux/mips/bits/struct_stat.h   | 89 ++++++++++--------
 .../sysv/linux/powerpc/bits/struct_stat.h     | 52 ++++++-----
 .../unix/sysv/linux/s390/bits/struct_stat.h   | 56 +++++++-----
 sysdeps/unix/sysv/linux/struct_stat_time64.h  | 59 +-----------
 .../unix/sysv/linux/x86/bits/struct_stat.h    | 90 ++++++++++---------
 10 files changed, 320 insertions(+), 243 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 36d5ae020c..c343d8c7d0 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -100,7 +100,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
 		  bits/types/struct_msqid_ds.h \
 		  bits/types/struct_shmid_ds.h \
 		  bits/ipc-perm.h \
-		  bits/struct_stat.h
+		  bits/struct_stat.h \
+		  bits/struct_stat_time64_helper.h
 
 tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
diff --git a/sysdeps/unix/sysv/linux/bits/struct_stat.h b/sysdeps/unix/sysv/linux/bits/struct_stat.h
index b852ee256e..298418966f 100644
--- a/sysdeps/unix/sysv/linux/bits/struct_stat.h
+++ b/sysdeps/unix/sysv/linux/bits/struct_stat.h
@@ -28,32 +28,35 @@
 
 struct stat
   {
+#ifdef __USE_TIME_BITS64
+# include <bits/struct_stat_time64_helper.h>
+#else
     __dev_t st_dev;			/* Device.  */
     unsigned short int __pad1;
-#ifndef __USE_FILE_OFFSET64
+# ifndef __USE_FILE_OFFSET64
     __ino_t st_ino;			/* File serial number.	*/
-#else
+# else
     __ino_t __st_ino;			/* 32bit file serial number.	*/
-#endif
+# endif
     __mode_t st_mode;			/* File mode.  */
     __nlink_t st_nlink;			/* Link count.  */
     __uid_t st_uid;			/* User ID of the file's owner.	*/
     __gid_t st_gid;			/* Group ID of the file's group.*/
     __dev_t st_rdev;			/* Device number, if device.  */
     unsigned short int __pad2;
-#ifndef __USE_FILE_OFFSET64
+# ifndef __USE_FILE_OFFSET64
     __off_t st_size;			/* Size of file, in bytes.  */
-#else
+# else
     __off64_t st_size;			/* Size of file, in bytes.  */
-#endif
+# endif
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */
 
-#ifndef __USE_FILE_OFFSET64
+# ifndef __USE_FILE_OFFSET64
     __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
-#else
+# else
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#endif
-#ifdef __USE_XOPEN2K8
+# endif
+# ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -63,28 +66,32 @@ struct stat
     struct timespec st_atim;		/* Time of last access.  */
     struct timespec st_mtim;		/* Time of last modification.  */
     struct timespec st_ctim;		/* Time of last status change.  */
-# define st_atime st_atim.tv_sec	/* Backward compatibility.  */
-# define st_mtime st_mtim.tv_sec
-# define st_ctime st_ctim.tv_sec
-#else
+#  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+#  define st_mtime st_mtim.tv_sec
+#  define st_ctime st_ctim.tv_sec
+# else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-#endif
-#ifndef __USE_FILE_OFFSET64
+# endif
+# ifndef __USE_FILE_OFFSET64
     unsigned long int __glibc_reserved4;
     unsigned long int __glibc_reserved5;
-#else
+# else
     __ino64_t st_ino;			/* File serial number.	*/
-#endif
+# endif
+#endif /* __USE_TIME_BITS64  */
   };
 
 #ifdef __USE_LARGEFILE64
 struct stat64
   {
+# ifdef __USE_TIME_BITS64
+#  include <bits/struct_stat_time64_helper.h>
+# else
     __dev_t st_dev;			/* Device.  */
     unsigned int __pad1;
 
@@ -99,7 +106,7 @@ struct stat64
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */
 
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-# ifdef __USE_XOPEN2K8
+#  ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -109,15 +116,16 @@ struct stat64
     struct timespec st_atim;		/* Time of last access.  */
     struct timespec st_mtim;		/* Time of last modification.  */
     struct timespec st_ctim;		/* Time of last status change.  */
-# else
+#  else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-# endif
+#  endif
     __ino64_t st_ino;			/* File serial number.		*/
+# endif /* __USE_TIME_BITS64  */
   };
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h b/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
new file mode 100644
index 0000000000..04e0ca7386
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
@@ -0,0 +1,66 @@
+/* Definition for helper to define struct stat with 64-bit time.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+  /* Content of internal __stat64_t64 struct.  */
+  __dev_t st_dev;		/* Device.  */
+  __ino64_t st_ino;		/* file serial number.	*/
+  __mode_t st_mode;		/* File mode.  */
+  __nlink_t st_nlink;		/* Link count.  */
+  __uid_t st_uid;		/* User ID of the file's owner.  */
+  __gid_t st_gid;		/* Group ID of the file's group.  */
+  __dev_t st_rdev;		/* Device number, if device.  */
+  __off64_t st_size;		/* Size of file, in bytes.  */
+  __blksize_t st_blksize;	/* Optimal block size for I/O.  */
+  __blkcnt64_t st_blocks;	/* Number 512-byte blocks allocated. */
+#ifdef __USE_XOPEN2K8
+# ifndef __struct_timespec
+#  define __struct_timespec struct timespec
+# endif
+  /* Nanosecond resolution timestamps are stored in a format
+     equivalent to 'struct timespec'.  This is the type used
+     whenever possible but the Unix namespace rules do not allow the
+     identifier 'timespec' to appear in the <sys/stat.h> header.
+     Therefore we have to handle the use of this header in strictly
+     standard-compliant sources special.  */
+  __struct_timespec st_atim;
+  __struct_timespec st_mtim;
+  __struct_timespec st_ctim;
+# define st_atime st_atim.tv_sec
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+# undef __struct_timespec
+#else
+/* The definition should be equal to the 'struct __timespec64' internal
+   layout.  */
+# if __BYTE_ORDER == __BIG_ENDIAN
+#  define __fieldts64(name)					\
+   __time64_t name; __int32_t :32; __int32_t name ## nsec
+# else
+#  define __fieldts64(name)					\
+   __time64_t name; __int32_t name ## nsec; __int32_t :32
+# endif
+
+  __fieldts64 (st_atime);
+  __fieldts64 (st_mtime);
+  __fieldts64 (st_ctime);
+
+  unsigned long int __glibc_reserved4;
+  unsigned long int __glibc_reserved5;
+
+# undef __fieldts64
+#endif
diff --git a/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h b/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h
index 4ae7506eb5..0512ecc3bc 100644
--- a/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h
+++ b/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h
@@ -25,32 +25,35 @@
 
 struct stat
   {
+#ifdef __USE_TIME_BITS64
+# include <bits/struct_stat_time64_helper.h>
+#else
     __dev_t st_dev;			/* Device.  */
     unsigned short int __pad1;
-#ifndef __USE_FILE_OFFSET64
+# ifndef __USE_FILE_OFFSET64
     __ino_t st_ino;			/* File serial number.	*/
-#else
+# else
     __ino_t __st_ino;			/* 32bit file serial number.	*/
-#endif
+# endif
     __mode_t st_mode;			/* File mode.  */
     __nlink_t st_nlink;			/* Link count.  */
     __uid_t st_uid;			/* User ID of the file's owner.	*/
     __gid_t st_gid;			/* Group ID of the file's group.*/
     __dev_t st_rdev;			/* Device number, if device.  */
     unsigned short int __pad2;
-#ifndef __USE_FILE_OFFSET64
+# ifndef __USE_FILE_OFFSET64
     __off_t st_size;			/* Size of file, in bytes.  */
-#else
+# else
     __off64_t st_size;			/* Size of file, in bytes.  */
-#endif
+# endif
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */
 
-#ifndef __USE_FILE_OFFSET64
+# ifndef __USE_FILE_OFFSET64
     __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
-#else
+# else
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#endif
-#ifdef __USE_XOPEN2K8
+# endif
+# ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -60,28 +63,32 @@ struct stat
     struct timespec st_atim;		/* Time of last access.  */
     struct timespec st_mtim;		/* Time of last modification.  */
     struct timespec st_ctim;		/* Time of last status change.  */
-# define st_atime st_atim.tv_sec	/* Backward compatibility.  */
-# define st_mtime st_mtim.tv_sec
-# define st_ctime st_ctim.tv_sec
-#else
+#  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+#  define st_mtime st_mtim.tv_sec
+#  define st_ctime st_ctim.tv_sec
+# else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-#endif
-#ifndef __USE_FILE_OFFSET64
+# endif
+# ifndef __USE_FILE_OFFSET64
     unsigned long int __glibc_reserved4;
     unsigned long int __glibc_reserved5;
-#else
+# else
     __ino64_t st_ino;			/* File serial number.	*/
-#endif
+# endif
+#endif /* __USE_TIME_BITS64  */
   };
 
 #ifdef __USE_LARGEFILE64
 struct stat64
   {
+# ifdef __USE_TIME_BITS64
+#  include <bits/struct_stat_time64_helper.h>
+# else
     __dev_t st_dev;			/* Device.  */
     unsigned short int __pad1;
 
@@ -96,7 +103,7 @@ struct stat64
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */
 
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-# ifdef __USE_XOPEN2K8
+#  ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -106,15 +113,16 @@ struct stat64
     struct timespec st_atim;		/* Time of last access.  */
     struct timespec st_mtim;		/* Time of last modification.  */
     struct timespec st_ctim;		/* Time of last status change.  */
-# else
+#  else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-# endif
+#  endif
     __ino64_t st_ino;			/* File serial number.		*/
+# endif /* __USE_TIME_BITS64 */
   };
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h b/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h
index be1bdc3557..0284d4b2b2 100644
--- a/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h
+++ b/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h
@@ -26,6 +26,9 @@
 #ifndef __USE_FILE_OFFSET64
 struct stat
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/struct_stat_time64_helper.h>
+#else
         __dev_t         st_dev;     /* Device.  */
         __ino_t         st_ino;     /* File serial number.  */
         __mode_t        st_mode;    /* File mode.  */
@@ -38,7 +41,7 @@ struct stat
         __blksize_t     st_blksize; /* Optimal block size for I/O.  */
         int             __pad3;
         __blkcnt_t      st_blocks;  /* Number 512-byte blocks allocated.  */
-#ifdef __USE_XOPEN2K8
+# ifdef __USE_XOPEN2K8
         /* Nanosecond resolution timestamps are stored in a format
          * equivalent to 'struct timespec'. This is the type used
          * whenever possible but the Unix namespace rules do not allow the
@@ -48,19 +51,20 @@ struct stat
         struct timespec         st_atim; /* Time of last access.  */
         struct timespec         st_mtim; /* Time of last modification.  */
         struct timespec         st_ctim; /* Time of last status change.  */
-# define st_atime st_atim.tv_sec         /* Backward compatibility.  */
-# define st_mtime st_mtim.tv_sec
-# define st_ctime st_ctim.tv_sec
-#else
+#  define st_atime st_atim.tv_sec         /* Backward compatibility.  */
+#  define st_mtime st_mtim.tv_sec
+#  define st_ctime st_ctim.tv_sec
+# else
         __time_t                st_atime;     /* Time of last access.  */
         unsigned long int       st_atimensec; /* Nscecs of last access.  */
         __time_t                st_mtime;     /* Time of last modification.  */
         unsigned long int       st_mtimensec; /* Nsecs of last modification.  */
         __time_t                st_ctime;     /* Time of last status change.  */
         unsigned long int       st_ctimensec; /* Nsecs of last status change.  */
-#endif
+# endif
         unsigned int            __glibc_reserved4;
         unsigned int            __glibc_reserved5;
+#endif /* __USE_TIME_BITS64  */
 };
 #else /* __USE_FILE_OFFSET64 */
 /* MS: If __USE_FILE_OFFSET64 is setup then struct stat should match stat64
@@ -70,6 +74,9 @@ struct stat
  * create one ifdef to separate stats structures.  */
 struct stat
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/struct_stat_time64_helper.h>
+#else
         unsigned long long      st_dev;     /* Device.  */
         __ino64_t               st_ino;     /* 32bit file serial number.  */
         __mode_t                st_mode;    /* File mode.  */
@@ -82,7 +89,7 @@ struct stat
         __blksize_t             st_blksize; /* Optimal block size for I/O.  */
         int                     __pad3;
         __blkcnt64_t            st_blocks;  /* Number 512-byte blocks allocated.  */
-#ifdef __USE_MISC
+# ifdef __USE_MISC
         /* Nanosecond resolution timestamps are stored in a format
          * equivalent to 'struct timespec'. This is the type used
          * whenever possible but the Unix namespace rules do not allow the
@@ -92,25 +99,29 @@ struct stat
         struct timespec         st_atim;      /* Time of last access.  */
         struct timespec         st_mtim;      /* Time of last modification.  */
         struct timespec         st_ctim;      /* Time of last status change.  */
-# define st_atime st_atim.tv_sec              /* Backward compatibility.  */
-# define st_mtime st_mtim.tv_sec
-# define st_ctime st_ctim.tv_sec
-#else
+#  define st_atime st_atim.tv_sec              /* Backward compatibility.  */
+#  define st_mtime st_mtim.tv_sec
+#  define st_ctime st_ctim.tv_sec
+# else
         __time_t                st_atime;     /* Time of last access.  */
         unsigned long int       st_atimensec; /* Nscecs of last access.  */
         __time_t                st_mtime;     /* Time of last modification.  */
         unsigned long int       st_mtimensec; /* Nsecs of last modification.  */
         __time_t                st_ctime;     /* Time of last status change.  */
         unsigned long int       st_ctimensec; /* Nsecs of last status change.  */
-#endif
+# endif
         unsigned int            __glibc_reserved4;
         unsigned int            __glibc_reserved5;
+# endif /* __USE_TIME_BITS64 */
 };
 #endif /* __USE_FILE_OFFSET64 */
 
 #ifdef __USE_LARGEFILE64
 struct stat64
 {
+# ifdef __USE_TIME_BITS64
+#  include <bits/struct_stat_time64_helper.h>
+# else
         unsigned long long      st_dev;     /* Device.  */
         __ino64_t               st_ino;     /* 32bit file serial number.  */
         __mode_t                st_mode;    /* File mode.  */
@@ -123,7 +134,7 @@ struct stat64
         __blksize_t             st_blksize; /* Optimal block size for I/O.  */
         int                     __pad3;
         __blkcnt64_t            st_blocks;  /* Number 512-byte blocks allocated.  */
-#ifdef __USE_XOPEN2K8
+#  ifdef __USE_XOPEN2K8
         /* Nanosecond resolution timestamps are stored in a format
          * equivalent to 'struct timespec'. This is the type used
          * whenever possible but the Unix namespace rules do not allow the
@@ -133,19 +144,20 @@ struct stat64
         struct timespec         st_atim;    /* Time of last access.  */
         struct timespec         st_mtim;    /* Time of last modification.  */
         struct timespec         st_ctim;    /* Time of last status change.  */
-# define st_atime st_atim.tv_sec            /* Backward compatibility.  */
-# define st_mtime st_mtim.tv_sec
-# define st_ctime st_ctim.tv_sec
-#else
+#   define st_atime st_atim.tv_sec           /* Backward compatibility.  */
+#   define st_mtime st_mtim.tv_sec
+#   define st_ctime st_ctim.tv_sec
+#  else
         __time_t                st_atime;     /* Time of last access.  */
         unsigned long int       st_atimensec; /* Nscecs of last access.  */
         __time_t                st_mtime;     /* Time of last modification.  */
         unsigned long int       st_mtimensec; /* Nsecs of last modification.  */
         __time_t                st_ctime;     /* Time of last status change.  */
         unsigned long int       st_ctimensec; /* Nsecs of last status change.  */
-#endif
+#  endif
         unsigned int            __glibc_reserved4;
         unsigned int            __glibc_reserved5;
+# endif /* __USE_TIME_BITS64 */
 };
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h b/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
index 7ae4c10827..ab9f474cbc 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
@@ -29,28 +29,31 @@
 /* Structure describing file characteristics.  */
 struct stat
   {
+# ifdef __USE_TIME_BITS64
+#  include <bits/struct_stat_time64_helper.h>
+# else
     unsigned long int st_dev;
     long int st_pad1[3];
-#ifndef __USE_FILE_OFFSET64
+#  ifndef __USE_FILE_OFFSET64
     __ino_t st_ino;		/* File serial number.		*/
-#else
+#  else
     __ino64_t st_ino;		/* File serial number.		*/
-#endif
+#  endif
     __mode_t st_mode;		/* File mode.  */
     __nlink_t st_nlink;		/* Link count.  */
     __uid_t st_uid;		/* User ID of the file's owner.	*/
     __gid_t st_gid;		/* Group ID of the file's group.*/
     unsigned long int st_rdev;	/* Device number, if device.  */
-#ifndef __USE_FILE_OFFSET64
+#  ifndef __USE_FILE_OFFSET64
     long int st_pad2[2];
     __off_t st_size;		/* Size of file, in bytes.  */
     /* SVR4 added this extra long to allow for expansion of off_t.  */
     long int st_pad3;
-#else
+#  else
     long int st_pad2[3];
     __off64_t st_size;		/* Size of file, in bytes.  */
-#endif
-#ifdef __USE_XOPEN2K8
+#  endif
+#  ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -60,30 +63,34 @@ struct stat
     struct timespec st_atim;            /* Time of last access.  */
     struct timespec st_mtim;            /* Time of last modification.  */
     struct timespec st_ctim;            /* Time of last status change.  */
-# define st_atime st_atim.tv_sec        /* Backward compatibility.  */
-# define st_mtime st_mtim.tv_sec
-# define st_ctime st_ctim.tv_sec
-#else
+#   define st_atime st_atim.tv_sec        /* Backward compatibility.  */
+#   define st_mtime st_mtim.tv_sec
+#   define st_ctime st_ctim.tv_sec
+#  else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-#endif
+#  endif
     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
-#ifndef __USE_FILE_OFFSET64
+#  ifndef __USE_FILE_OFFSET64
     __blkcnt_t st_blocks;	/* Number of 512-byte blocks allocated.  */
-#else
+#  else
     long int st_pad4;
     __blkcnt64_t st_blocks;	/* Number of 512-byte blocks allocated.  */
-#endif
+#  endif
     long int st_pad5[14];
+# endif /* __USE_TIME_BITS64  */
   };
 
-#ifdef __USE_LARGEFILE64
+# ifdef __USE_LARGEFILE64
 struct stat64
   {
+#  ifdef __USE_TIME_BITS64
+#   include <bits/struct_stat_time64_helper.h>
+#  else
     unsigned long int st_dev;
     long int st_pad1[3];
     __ino64_t st_ino;		/* File serial number.		*/
@@ -94,7 +101,7 @@ struct stat64
     unsigned long int st_rdev;	/* Device number, if device.  */
     long int st_pad2[3];
     __off64_t st_size;		/* Size of file, in bytes.  */
-# ifdef __USE_XOPEN2K8
+#   ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -104,44 +111,47 @@ struct stat64
     struct timespec st_atim;            /* Time of last access.  */
     struct timespec st_mtim;            /* Time of last modification.  */
     struct timespec st_ctim;            /* Time of last status change.  */
-# else
+#   else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-# endif
+#   endif
     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
     long int st_pad3;
     __blkcnt64_t st_blocks;	/* Number of 512-byte blocks allocated.  */
     long int st_pad4[14];
+#  endif /* __USE_TIME_BITS64  */
   };
-#endif
-#else
+# endif /* __USE_LARGEFILE64  */
+
+#else /* _MIPS_SIM != _ABIO32  */
+
 struct stat
   {
     __dev_t st_dev;
     int	st_pad1[3];		/* Reserved for st_dev expansion  */
-#ifndef __USE_FILE_OFFSET64
+# ifndef __USE_FILE_OFFSET64
     __ino_t st_ino;
-#else
+# else
     __ino64_t st_ino;
-#endif
+# endif
     __mode_t st_mode;
     __nlink_t st_nlink;
     __uid_t st_uid;
     __gid_t st_gid;
     __dev_t st_rdev;
-#if !defined __USE_FILE_OFFSET64
+# if !defined __USE_FILE_OFFSET64
     unsigned int st_pad2[2];	/* Reserved for st_rdev expansion  */
     __off_t st_size;
     int st_pad3;
-#else
+# else
     unsigned int st_pad2[3];	/* Reserved for st_rdev expansion  */
     __off64_t st_size;
-#endif
-#ifdef __USE_XOPEN2K8
+# endif
+# ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -151,24 +161,24 @@ struct stat
     struct timespec st_atim;            /* Time of last access.  */
     struct timespec st_mtim;            /* Time of last modification.  */
     struct timespec st_ctim;            /* Time of last status change.  */
-# define st_atime st_atim.tv_sec        /* Backward compatibility.  */
-# define st_mtime st_mtim.tv_sec
-# define st_ctime st_ctim.tv_sec
-#else
+#  define st_atime st_atim.tv_sec        /* Backward compatibility.  */
+#  define st_mtime st_mtim.tv_sec
+#  define st_ctime st_ctim.tv_sec
+# else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-#endif
+# endif
     __blksize_t st_blksize;
     unsigned int st_pad4;
-#ifndef __USE_FILE_OFFSET64
+# ifndef __USE_FILE_OFFSET64
     __blkcnt_t st_blocks;
-#else
+# else
     __blkcnt64_t st_blocks;
-#endif
+# endif
     int st_pad5[14];
   };
 
@@ -185,7 +195,7 @@ struct stat64
     __dev_t st_rdev;
     unsigned int st_pad2[3];	/* Reserved for st_rdev expansion  */
     __off64_t st_size;
-# ifdef __USE_XOPEN2K8
+#  ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -195,20 +205,21 @@ struct stat64
     struct timespec st_atim;            /* Time of last access.  */
     struct timespec st_mtim;            /* Time of last modification.  */
     struct timespec st_ctim;            /* Time of last status change.  */
-# else
+#  else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-# endif
+#  endif
     __blksize_t st_blksize;
     unsigned int st_pad3;
     __blkcnt64_t st_blocks;
     int st_pad4[14];
 };
 #endif
+
 #endif
 
 /* Tell code we have these members.  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h b/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h
index 12caab2790..f55eb658a2 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h
@@ -26,35 +26,37 @@
 #include <bits/wordsize.h>
 
 #if __WORDSIZE == 32
-
 struct stat
   {
+# ifdef __USE_TIME_BITS64
+#  include <bits/struct_stat_time64_helper.h>
+# else
     __dev_t st_dev;			/* Device.  */
-# ifndef __USE_FILE_OFFSET64
+#  ifndef __USE_FILE_OFFSET64
     unsigned short int __pad1;
     __ino_t st_ino;			/* File serial number.	*/
-# else
+#  else
     __ino64_t st_ino;			/* File serial number.	*/
-# endif
+#  endif
     __mode_t st_mode;			/* File mode.  */
     __nlink_t st_nlink;			/* Link count.  */
     __uid_t st_uid;			/* User ID of the file's owner.	*/
     __gid_t st_gid;			/* Group ID of the file's group.*/
     __dev_t st_rdev;			/* Device number, if device.  */
     unsigned short int __pad2;
-# ifndef __USE_FILE_OFFSET64
+#  ifndef __USE_FILE_OFFSET64
     __off_t st_size;			/* Size of file, in bytes.  */
-# else
+#  else
     __off64_t st_size;			/* Size of file, in bytes.  */
-# endif
+#  endif
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */
 
-# ifndef __USE_FILE_OFFSET64
+#  ifndef __USE_FILE_OFFSET64
     __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
-# else
+#  else
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-# endif
-# ifdef __USE_XOPEN2K8
+#  endif
+#  ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -64,25 +66,28 @@ struct stat
     struct timespec st_atim;		/* Time of last access.  */
     struct timespec st_mtim;		/* Time of last modification.  */
     struct timespec st_ctim;		/* Time of last status change.  */
-#  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
-#  define st_mtime st_mtim.tv_sec
-#  define st_ctime st_ctim.tv_sec
-# else
+#   define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+#   define st_mtime st_mtim.tv_sec
+#   define st_ctime st_ctim.tv_sec
+#  else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-# endif
+#  endif
     unsigned long int __glibc_reserved4;
     unsigned long int __glibc_reserved5;
+# endif /* __USE_TIME_BITS64 */
   };
 
-
 # ifdef __USE_LARGEFILE64
 struct stat64
   {
+#  ifdef __USE_TIME_BITS64
+#   include <bits/struct_stat_time64_helper.h>
+#  else
     __dev_t st_dev;			/* Device.  */
     __ino64_t st_ino;			/* File serial number.	*/
     __mode_t st_mode;			/* File mode.  */
@@ -94,7 +99,7 @@ struct stat64
     __off64_t st_size;			/* Size of file, in bytes.  */
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#  ifdef __USE_XOPEN2K8
+#   ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -104,19 +109,20 @@ struct stat64
     struct timespec st_atim;		/* Time of last access.  */
     struct timespec st_mtim;		/* Time of last modification.  */
     struct timespec st_ctim;		/* Time of last status change.  */
-#   define st_atime st_atim.tv_sec	/* Backward compatibility.  */
-#   define st_mtime st_mtim.tv_sec
-#   define st_ctime st_ctim.tv_sec
-#  else
+#    define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+#    define st_mtime st_mtim.tv_sec
+#    define st_ctime st_ctim.tv_sec
+#   else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-#  endif
+#   endif
     unsigned long int __glibc_reserved4;
     unsigned long int __glibc_reserved5;
+#  endif /* __USE_TIME_BITS64 */
   };
 # endif /* __USE_LARGEFILE64 */
 
diff --git a/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h b/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h
index a733622cf5..f2933b8b12 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h
@@ -65,32 +65,35 @@ struct stat
 #else
 struct stat
   {
+# ifdef __USE_TIME_BITS64
+#  include <bits/struct_stat_time64_helper.h>
+# else
     __dev_t st_dev;			/* Device.  */
     unsigned int __pad1;
-# ifndef __USE_FILE_OFFSET64
+#  ifndef __USE_FILE_OFFSET64
     __ino_t st_ino;			/* File serial number.	*/
-# else
+#  else
     __ino_t __st_ino;			/* 32bit file serial number.	*/
-# endif
+#  endif
     __mode_t st_mode;			/* File mode.  */
     __nlink_t st_nlink;			/* Link count.  */
     __uid_t st_uid;			/* User ID of the file's owner.	*/
     __gid_t st_gid;			/* Group ID of the file's group.*/
     __dev_t st_rdev;			/* Device number, if device.  */
     unsigned int __pad2;
-# ifndef __USE_FILE_OFFSET64
+#  ifndef __USE_FILE_OFFSET64
     __off_t st_size;			/* Size of file, in bytes.  */
-# else
+#  else
     __off64_t st_size;			/* Size of file, in bytes.  */
-# endif
+#  endif
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */
 
-# ifndef __USE_FILE_OFFSET64
+#  ifndef __USE_FILE_OFFSET64
     __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
-# else
+#  else
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-# endif
-# ifdef __USE_XOPEN2K8
+#  endif
+#  ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -100,25 +103,26 @@ struct stat
     struct timespec st_atim;		/* Time of last access.  */
     struct timespec st_mtim;		/* Time of last modification.  */
     struct timespec st_ctim;		/* Time of last status change.  */
-#  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
-#  define st_mtime st_mtim.tv_sec
-#  define st_ctime st_ctim.tv_sec
-# else
+#   define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+#   define st_mtime st_mtim.tv_sec
+#   define st_ctime st_ctim.tv_sec
+#  else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-# endif
-# ifndef __USE_FILE_OFFSET64
+#  endif
+#  ifndef __USE_FILE_OFFSET64
     unsigned long int __glibc_reserved4;
     unsigned long int __glibc_reserved5;
-# else
+#  else
     __ino64_t st_ino;			/* File serial number.	*/
+#  endif
 # endif
   };
-#endif
+# endif
 
 #ifdef __USE_LARGEFILE64
 # if __WORDSIZE == 64
@@ -162,6 +166,9 @@ struct stat64
 # else
 struct stat64
   {
+#  ifdef __USE_TIME_BITS64
+#   include <bits/struct_stat_time64_helper.h>
+#  else
     __dev_t st_dev;			/* Device.  */
     unsigned int __pad1;
 
@@ -176,7 +183,7 @@ struct stat64
     __blksize_t st_blksize;		/* Optimal block size for I/O.  */
 
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#  ifdef __USE_XOPEN2K8
+#   ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -186,18 +193,19 @@ struct stat64
     struct timespec st_atim;		/* Time of last access.  */
     struct timespec st_mtim;		/* Time of last modification.  */
     struct timespec st_ctim;		/* Time of last status change.  */
-#   define st_atime st_atim.tv_sec	/* Backward compatibility.  */
-#   define st_mtime st_mtim.tv_sec
-#   define st_ctime st_ctim.tv_sec
-#  else
+#    define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+#    define st_mtime st_mtim.tv_sec
+#    define st_ctime st_ctim.tv_sec
+#   else
     __time_t st_atime;			/* Time of last access.  */
     unsigned long int st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
-#  endif
+#   endif
     __ino64_t st_ino;			/* File serial number.		*/
+#  endif
   };
 # endif
 #endif
diff --git a/sysdeps/unix/sysv/linux/struct_stat_time64.h b/sysdeps/unix/sysv/linux/struct_stat_time64.h
index f0a29d7fe5..260d1812be 100644
--- a/sysdeps/unix/sysv/linux/struct_stat_time64.h
+++ b/sysdeps/unix/sysv/linux/struct_stat_time64.h
@@ -22,64 +22,13 @@
 #if __TIMESIZE == 64
 # define __stat64_t64 stat64
 #else
-# ifdef __USE_LARGEFILE64
-#  include <endian.h>
-
-/* The definition should be equal to the 'struct __timespec64' internal
-   layout.  */
-#  if BYTE_ORDER == BIG_ENDIAN
-#   define __fieldts64(name) 					\
-     __time64_t name; __int32_t :32; __int32_t name ## nsec
-#  else
-#   define __fieldts64(name)					\
-     __time64_t name; __int32_t name ## nsec; __int32_t :32
-#  endif
-
-/* Workaround for the definition from struct_stat.h  */
-#  undef st_atime
-#  undef st_mtime
-#  undef st_ctime
+# include <struct___timespec64.h>
 
 struct __stat64_t64
   {
-    __dev_t st_dev;			/* Device.  */
-    __ino64_t st_ino;			/* file serial number.	*/
-    __mode_t st_mode;			/* File mode.  */
-    __nlink_t st_nlink;			/* Link count.  */
-    __uid_t st_uid;			/* User ID of the file's owner.	*/
-    __gid_t st_gid;			/* Group ID of the file's group.*/
-    __dev_t st_rdev;			/* Device number, if device.  */
-    __off64_t st_size;			/* Size of file, in bytes.  */
-    __blksize_t st_blksize;		/* Optimal block size for I/O.  */
-    __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#   ifdef __USE_XOPEN2K8
-    /* Nanosecond resolution timestamps are stored in a format
-       equivalent to 'struct timespec'.  This is the type used
-       whenever possible but the Unix namespace rules do not allow the
-       identifier 'timespec' to appear in the <sys/stat.h> header.
-       Therefore we have to handle the use of this header in strictly
-       standard-compliant sources special.  */
-    struct __timespec64 st_atim;	/* Time of last access.  */
-    struct __timespec64 st_mtim;	/* Time of last modification.  */
-    struct __timespec64 st_ctim;	/* Time of last status change.  */
-#    define st_atime st_atim.tv_sec	/* Backward compatibility.  */
-#    define st_mtime st_mtim.tv_sec
-#    define st_ctime st_ctim.tv_sec
-#   else
-    __fieldts64 (st_atime);
-    __fieldts64 (st_mtime);
-    __fieldts64 (st_ctime);
-#   endif /* __USE_XOPEN2K8  */
+# define __struct_timespec struct __timespec64
+# include <bits/struct_stat_time64_helper.h>
   };
-
-#   define _STATBUF_ST_BLKSIZE
-#   define _STATBUF_ST_RDEV
-#   define _STATBUF_ST_NSEC
-
-#   undef __fieldts64
-
-#  endif /* __USE_LARGEFILE64  */
-
-# endif /* __TIMESIZE == 64  */
+#endif /* __TIMESIZE == 64  */
 
 #endif /* _BITS_STRUCT_STAT_TIME64_H  */
diff --git a/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h b/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h
index 6ddd01db46..01ee7ff6b3 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h
@@ -25,43 +25,46 @@
 
 struct stat
   {
+#ifdef __USE_TIME_BITS64
+# include <bits/struct_stat_time64_helper.h>
+#else
     __dev_t st_dev;		/* Device.  */
-#ifndef __x86_64__
+# ifndef __x86_64__
     unsigned short int __pad1;
-#endif
-#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
+# endif
+# if defined __x86_64__ || !defined __USE_FILE_OFFSET64
     __ino_t st_ino;		/* File serial number.	*/
-#else
+# else
     __ino_t __st_ino;			/* 32bit file serial number.	*/
-#endif
-#ifndef __x86_64__
+# endif
+# ifndef __x86_64__
     __mode_t st_mode;			/* File mode.  */
     __nlink_t st_nlink;			/* Link count.  */
-#else
+# else
     __nlink_t st_nlink;		/* Link count.  */
     __mode_t st_mode;		/* File mode.  */
-#endif
+# endif
     __uid_t st_uid;		/* User ID of the file's owner.	*/
     __gid_t st_gid;		/* Group ID of the file's group.*/
-#ifdef __x86_64__
+# ifdef __x86_64__
     int __pad0;
-#endif
+# endif
     __dev_t st_rdev;		/* Device number, if device.  */
-#ifndef __x86_64__
+# ifndef __x86_64__
     unsigned short int __pad2;
-#endif
-#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
+# endif
+# if defined __x86_64__ || !defined __USE_FILE_OFFSET64
     __off_t st_size;			/* Size of file, in bytes.  */
-#else
+# else
     __off64_t st_size;			/* Size of file, in bytes.  */
-#endif
+# endif
     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
-#if defined __x86_64__  || !defined __USE_FILE_OFFSET64
+# if defined __x86_64__  || !defined __USE_FILE_OFFSET64
     __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
-#else
+# else
     __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
-#endif
-#ifdef __USE_XOPEN2K8
+# endif
+# ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -71,58 +74,62 @@ struct stat
     struct timespec st_atim;		/* Time of last access.  */
     struct timespec st_mtim;		/* Time of last modification.  */
     struct timespec st_ctim;		/* Time of last status change.  */
-# define st_atime st_atim.tv_sec	/* Backward compatibility.  */
-# define st_mtime st_mtim.tv_sec
-# define st_ctime st_ctim.tv_sec
-#else
+#  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
+#  define st_mtime st_mtim.tv_sec
+#  define st_ctime st_ctim.tv_sec
+# else
     __time_t st_atime;			/* Time of last access.  */
     __syscall_ulong_t st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     __syscall_ulong_t st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     __syscall_ulong_t st_ctimensec;	/* Nsecs of last status change.  */
-#endif
-#ifdef __x86_64__
+# endif
+# ifdef __x86_64__
     __syscall_slong_t __glibc_reserved[3];
-#else
-# ifndef __USE_FILE_OFFSET64
+# else
+#  ifndef __USE_FILE_OFFSET64
     unsigned long int __glibc_reserved4;
     unsigned long int __glibc_reserved5;
-# else
+#  else
     __ino64_t st_ino;			/* File serial number.	*/
+#  endif
 # endif
-#endif
+#endif /* __USE_TIME_BITS64  */
   };
 
 #ifdef __USE_LARGEFILE64
 /* Note stat64 has the same shape as stat for x86-64.  */
 struct stat64
   {
+# ifdef __USE_TIME_BITS64
+#  include <bits/struct_stat_time64_helper.h>
+# else
     __dev_t st_dev;		/* Device.  */
-# ifdef __x86_64__
+#  ifdef __x86_64__
     __ino64_t st_ino;		/* File serial number.  */
     __nlink_t st_nlink;		/* Link count.  */
     __mode_t st_mode;		/* File mode.  */
-# else
+#  else
     unsigned int __pad1;
     __ino_t __st_ino;			/* 32bit file serial number.	*/
     __mode_t st_mode;			/* File mode.  */
     __nlink_t st_nlink;			/* Link count.  */
-# endif
+#  endif
     __uid_t st_uid;		/* User ID of the file's owner.	*/
     __gid_t st_gid;		/* Group ID of the file's group.*/
-# ifdef __x86_64__
+#  ifdef __x86_64__
     int __pad0;
     __dev_t st_rdev;		/* Device number, if device.  */
     __off_t st_size;		/* Size of file, in bytes.  */
-# else
+#  else
     __dev_t st_rdev;			/* Device number, if device.  */
     unsigned int __pad2;
     __off64_t st_size;			/* Size of file, in bytes.  */
-# endif
+#  endif
     __blksize_t st_blksize;	/* Optimal block size for I/O.  */
     __blkcnt64_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
-# ifdef __USE_XOPEN2K8
+#  ifdef __USE_XOPEN2K8
     /* Nanosecond resolution timestamps are stored in a format
        equivalent to 'struct timespec'.  This is the type used
        whenever possible but the Unix namespace rules do not allow the
@@ -132,19 +139,20 @@ struct stat64
     struct timespec st_atim;		/* Time of last access.  */
     struct timespec st_mtim;		/* Time of last modification.  */
     struct timespec st_ctim;		/* Time of last status change.  */
-# else
+#  else
     __time_t st_atime;			/* Time of last access.  */
     __syscall_ulong_t st_atimensec;	/* Nscecs of last access.  */
     __time_t st_mtime;			/* Time of last modification.  */
     __syscall_ulong_t st_mtimensec;	/* Nsecs of last modification.  */
     __time_t st_ctime;			/* Time of last status change.  */
     __syscall_ulong_t st_ctimensec;	/* Nsecs of last status change.  */
-# endif
-# ifdef __x86_64__
+#  endif
+#  ifdef __x86_64__
     __syscall_slong_t __glibc_reserved[3];
-# else
+#  else
     __ino64_t st_ino;			/* File serial number.		*/
-# endif
+#  endif
+# endif /* __USE_TIME_BITS64  */
   };
 #endif
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 13/24] y2038: Use a common definition for msqid_ds
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (11 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 12/24] y2038: Use a common definition for stat Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-14 14:52   ` Carlos O'Donell
  2021-06-07 20:36 ` [PATCH v3 14/24] y2038: Use a common definition for semid_ds Adhemerval Zanella
                   ` (10 subsequent siblings)
  23 siblings, 1 reply; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

From: Lukasz Majewski <lukma@denx.de>

Instead of replicate the same definitions from struct_msqid64_ds.h
on the multiple struct_msqid_ds.h, use a common header which is included
when required (struct_msqid64_ds_helper.h).

The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit stat implementations.
---
 sysdeps/unix/sysv/linux/Makefile              |  3 +-
 .../sysv/linux/bits/types/struct_msqid64_ds.h | 10 +------
 .../bits/types/struct_msqid64_ds_helper.h     | 30 +++++++++++++++++++
 .../sysv/linux/bits/types/struct_msqid_ds.h   | 12 ++++++--
 .../linux/hppa/bits/types/struct_msqid_ds.h   | 12 ++++++--
 .../linux/mips/bits/types/struct_msqid_ds.h   | 18 +++++++----
 .../powerpc/bits/types/struct_msqid_ds.h      | 12 ++++++--
 .../linux/sparc/bits/types/struct_msqid_ds.h  | 12 ++++++--
 8 files changed, 81 insertions(+), 28 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds_helper.h

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index c343d8c7d0..6715a4b623 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -101,7 +101,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
 		  bits/types/struct_shmid_ds.h \
 		  bits/ipc-perm.h \
 		  bits/struct_stat.h \
-		  bits/struct_stat_time64_helper.h
+		  bits/struct_stat_time64_helper.h \
+		  bits/types/struct_msqid64_ds_helper.h
 
 tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h
index 43e8cd7cfc..992734914a 100644
--- a/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h
+++ b/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h
@@ -25,14 +25,6 @@
 #else
 struct __msqid64_ds
 {
-  struct ipc_perm msg_perm;	/* structure describing operation permission */
-  __time64_t msg_stime;		/* time of last msgsnd command */
-  __time64_t msg_rtime;		/* time of last msgsnd command */
-  __time64_t msg_ctime;		/* time of last change */
-  __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
-  msgqnum_t msg_qnum;		/* number of messages currently on queue */
-  msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
-  __pid_t msg_lspid;		/* pid of last msgsnd() */
-  __pid_t msg_lrpid;		/* pid of last msgrcv() */
+# include <bits/types/struct_msqid64_ds_helper.h>
 };
 #endif
diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds_helper.h b/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds_helper.h
new file mode 100644
index 0000000000..58da9f223b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds_helper.h
@@ -0,0 +1,30 @@
+/* Common definitions for struct msqid_ds with 64-bit time.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+  /* Content of internal __msqid64_ds.  */
+  struct ipc_perm msg_perm;	/* structure describing operation permission */
+  __time64_t msg_stime;		/* time of last msgsnd command */
+  __time64_t msg_rtime;		/* time of last msgsnd command */
+  __time64_t msg_ctime;		/* time of last change */
+  __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
+  msgqnum_t msg_qnum;		/* number of messages currently on queue */
+  msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
+  __pid_t msg_lspid;		/* pid of last msgsnd() */
+  __pid_t msg_lrpid;		/* pid of last msgrcv() */
+  unsigned long int __glibc_reserved4;
+  unsigned long int __glibc_reserved5;
diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_msqid_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_msqid_ds.h
index 1ed041ae30..ae10a48452 100644
--- a/sysdeps/unix/sysv/linux/bits/types/struct_msqid_ds.h
+++ b/sysdeps/unix/sysv/linux/bits/types/struct_msqid_ds.h
@@ -20,23 +20,28 @@
 # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
 #endif
 
+#include <bits/types/time_t.h>
+
 /* Structure of record for one message inside the kernel.
    The type `struct msg' is opaque.  */
 struct msqid_ds
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_msqid64_ds_helper.h>
+#else
   struct ipc_perm msg_perm;	/* structure describing operation permission */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
   __time_t msg_stime;		/* time of last msgsnd command */
   unsigned long int __msg_stime_high;
   __time_t msg_rtime;		/* time of last msgsnd command */
   unsigned long int __msg_rtime_high;
   __time_t msg_ctime;		/* time of last change */
   unsigned long int __msg_ctime_high;
-#else
+# else
   __time_t msg_stime;		/* time of last msgsnd command */
   __time_t msg_rtime;		/* time of last msgsnd command */
   __time_t msg_ctime;		/* time of last change */
-#endif
+# endif
   __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
   msgqnum_t msg_qnum;		/* number of messages currently on queue */
   msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
@@ -44,4 +49,5 @@ struct msqid_ds
   __pid_t msg_lrpid;		/* pid of last msgrcv() */
   __syscall_ulong_t __glibc_reserved4;
   __syscall_ulong_t __glibc_reserved5;
+#endif
 };
diff --git a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_msqid_ds.h b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_msqid_ds.h
index d943edeb78..5b82dd7f5e 100644
--- a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_msqid_ds.h
+++ b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_msqid_ds.h
@@ -20,23 +20,28 @@
 # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
 #endif
 
+#include <bits/types/time_t.h>
+
 /* Structure of record for one message inside the kernel.
    The type `struct msg' is opaque.  */
 struct msqid_ds
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_msqid64_ds_helper.h>
+#else
   struct ipc_perm msg_perm;	/* structure describing operation permission */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
   unsigned long int __msg_stime_high;
   __time_t msg_stime;		/* time of last msgsnd command */
   unsigned long int __msg_rtime_high;
   __time_t msg_rtime;		/* time of last msgsnd command */
   unsigned long int __msg_ctime_high;
   __time_t msg_ctime;		/* time of last change */
-#else
+# else
   __time_t msg_stime;		/* time of last msgsnd command */
   __time_t msg_rtime;		/* time of last msgsnd command */
   __time_t msg_ctime;		/* time of last change */
-#endif
+# endif
   __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
   msgqnum_t msg_qnum;		/* number of messages currently on queue */
   msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
@@ -44,4 +49,5 @@ struct msqid_ds
   __pid_t msg_lrpid;		/* pid of last msgrcv() */
   __syscall_ulong_t __glibc_reserved4;
   __syscall_ulong_t __glibc_reserved5;
+#endif
 };
diff --git a/sysdeps/unix/sysv/linux/mips/bits/types/struct_msqid_ds.h b/sysdeps/unix/sysv/linux/mips/bits/types/struct_msqid_ds.h
index bdca5e5fe2..00c1804245 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/types/struct_msqid_ds.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/types/struct_msqid_ds.h
@@ -20,32 +20,37 @@
 # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
 #endif
 
+#include <bits/types/time_t.h>
+
 /* Structure of record for one message inside the kernel.
    The type `struct msg' is opaque.  */
 struct msqid_ds
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_msqid64_ds_helper.h>
+#else
   struct ipc_perm msg_perm;	/* structure describing operation permission */
-#if __TIMESIZE == 32
-# ifdef __MIPSEL__
+# if __TIMESIZE == 32
+#  ifdef __MIPSEL__
   __time_t msg_stime;		/* time of last msgsnd command */
   unsigned long int __msg_stime_high;
   __time_t msg_rtime;		/* time of last msgsnd command */
   unsigned long int __msg_rtime_high;
   __time_t msg_ctime;		/* time of last change */
   unsigned long int __msg_ctime_high;
-# else
+#  else
   unsigned long int __msg_stime_high;
   __time_t msg_stime;		/* time of last msgsnd command */
   unsigned long int __msg_rtime_high;
   __time_t msg_rtime;		/* time of last msgsnd command */
   unsigned long int __msg_ctime_high;
   __time_t msg_ctime;		/* time of last change */
-# endif
-#else
+#  endif
+# else
   __time_t msg_stime;		/* time of last msgsnd command */
   __time_t msg_rtime;		/* time of last msgsnd command */
   __time_t msg_ctime;		/* time of last change */
-#endif
+# endif
   __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
   msgqnum_t msg_qnum;		/* number of messages currently on queue */
   msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
@@ -53,4 +58,5 @@ struct msqid_ds
   __pid_t msg_lrpid;		/* pid of last msgrcv() */
   __syscall_ulong_t __glibc_reserved4;
   __syscall_ulong_t __glibc_reserved5;
+#endif
 };
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_msqid_ds.h b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_msqid_ds.h
index 72842ed747..8c296d2342 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_msqid_ds.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_msqid_ds.h
@@ -20,23 +20,28 @@
 # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
 #endif
 
+#include <bits/types/time_t.h>
+
 /* Structure of record for one message inside the kernel.
    The type `struct msg' is opaque.  */
 struct msqid_ds
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_msqid64_ds_helper.h>
+#else
   struct ipc_perm msg_perm;	/* structure describing operation permission */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
   unsigned long int __msg_stime_high;
   __time_t msg_stime;		/* time of last msgsnd command */
   unsigned long int __msg_rtime_high;
   __time_t msg_rtime;		/* time of last msgsnd command */
   unsigned long int __msg_ctime_high;
   __time_t msg_ctime;		/* time of last change */
-#else
+# else
   __time_t msg_stime;		/* time of last msgsnd command */
   __time_t msg_rtime;		/* time of last msgsnd command */
   __time_t msg_ctime;		/* time of last change */
-#endif
+# endif
   __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
   msgqnum_t msg_qnum;		/* number of messages currently on queue */
   msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
@@ -44,4 +49,5 @@ struct msqid_ds
   __pid_t msg_lrpid;		/* pid of last msgrcv() */
   __syscall_ulong_t __glibc_reserved4;
   __syscall_ulong_t __glibc_reserved5;
+#endif
 };
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_msqid_ds.h b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_msqid_ds.h
index 22e1839de1..3c1b68ccc0 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_msqid_ds.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_msqid_ds.h
@@ -20,23 +20,28 @@
 # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
 #endif
 
+#include <bits/types/time_t.h>
+
 /* Structure of record for one message inside the kernel.
    The type `struct msg' is opaque.  */
 struct msqid_ds
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_msqid64_ds_helper.h>
+#else
   struct ipc_perm msg_perm;	/* structure describing operation permission */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
   unsigned long int __msg_stime_high;
   __time_t msg_stime;		/* time of last msgsnd command */
   unsigned long int __msg_rtime_high;
   __time_t msg_rtime;		/* time of last msgsnd command */
   unsigned long int __msg_ctime_high;
   __time_t msg_ctime;		/* time of last change */
-#else
+# else
   __time_t msg_stime;		/* time of last msgsnd command */
   __time_t msg_rtime;		/* time of last msgsnd command */
   __time_t msg_ctime;		/* time of last change */
-#endif
+# endif
   __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
   msgqnum_t msg_qnum;		/* number of messages currently on queue */
   msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
@@ -44,4 +49,5 @@ struct msqid_ds
   __pid_t msg_lrpid;		/* pid of last msgrcv() */
   __syscall_ulong_t __glibc_reserved4;
   __syscall_ulong_t __glibc_reserved5;
+#endif
 };
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 14/24] y2038: Use a common definition for semid_ds
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (12 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 13/24] y2038: Use a common definition for msqid_ds Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-14 14:52   ` Carlos O'Donell
  2021-06-07 20:36 ` [PATCH v3 15/24] y2038: Use a common definition for shmid_ds Adhemerval Zanella
                   ` (9 subsequent siblings)
  23 siblings, 1 reply; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

Instead of replicate the same definitions from struct_semid64_ds.h
on the multiple struct_semid_ds.h, use a common header which is included
when required (struct_semid64_ds_helper.h).

The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit semctl implementation.
---
 sysdeps/unix/sysv/linux/Makefile              |  3 ++-
 .../sysv/linux/bits/types/struct_semid64_ds.h |  5 +---
 .../bits/types/struct_semid64_ds_helper.h     | 25 +++++++++++++++++++
 .../sysv/linux/bits/types/struct_semid_ds.h   | 10 +++++---
 .../linux/hppa/bits/types/struct_semid_ds.h   |  4 +++
 .../linux/mips/bits/types/struct_semid_ds.h   |  4 +++
 .../powerpc/bits/types/struct_semid_ds.h      | 10 +++++---
 .../linux/sparc/bits/types/struct_semid_ds.h  | 10 +++++---
 .../linux/x86/bits/types/struct_semid_ds.h    |  4 +++
 9 files changed, 61 insertions(+), 14 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds_helper.h

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 6715a4b623..b6abcb1365 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -102,7 +102,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
 		  bits/ipc-perm.h \
 		  bits/struct_stat.h \
 		  bits/struct_stat_time64_helper.h \
-		  bits/types/struct_msqid64_ds_helper.h
+		  bits/types/struct_msqid64_ds_helper.h \
+		  bits/types/struct_semid64_ds_helper.h
 
 tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds.h
index 7263e50bbf..adaee3eb9e 100644
--- a/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds.h
+++ b/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds.h
@@ -25,9 +25,6 @@
 #else
 struct __semid64_ds
 {
-  struct ipc_perm sem_perm;		/* operation permission struct */
-  __time64_t sem_otime;			/* last semop() time */
-  __time64_t sem_ctime;			/* last time changed by semctl() */
-  __syscall_ulong_t sem_nsems;		/* number of semaphores in set */
+# include <bits/types/struct_semid64_ds_helper.h>
 };
 #endif
diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds_helper.h b/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds_helper.h
new file mode 100644
index 0000000000..e6592e6c3f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds_helper.h
@@ -0,0 +1,25 @@
+/* Common definitions for struct semid_ds with 64-bit time.
+   Copyright (C) 2020-2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+  /* Content of internal __semid64_ds.  */
+  struct ipc_perm sem_perm;		/* operation permission struct */
+  __time64_t sem_otime;			/* last semop() time */
+  __time64_t sem_ctime;			/* last time changed by semctl() */
+  __syscall_ulong_t sem_nsems;		/* number of semaphores in set */
+  unsigned long int __glibc_reserved3;
+  unsigned long int __glibc_reserved4;
diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_semid_ds.h
index 2f32fa500e..a7b2c9022e 100644
--- a/sysdeps/unix/sysv/linux/bits/types/struct_semid_ds.h
+++ b/sysdeps/unix/sysv/linux/bits/types/struct_semid_ds.h
@@ -23,17 +23,21 @@
 /* Data structure describing a set of semaphores.  */
 struct semid_ds
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_semid64_ds_helper.h>
+#else
   struct ipc_perm sem_perm;        /* operation permission struct */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
   __time_t sem_otime;              /* last semop() time */
   __syscall_ulong_t __sem_otime_high;
   __time_t sem_ctime;             /* last time changed by semctl() */
   __syscall_ulong_t __sem_ctime_high;
-#else
+# else
   __time_t sem_otime;
   __time_t sem_ctime;
-#endif
+# endif
   __syscall_ulong_t sem_nsems;    /* number of semaphores in set */
   __syscall_ulong_t __glibc_reserved3;
   __syscall_ulong_t __glibc_reserved4;
+#endif
 };
diff --git a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_semid_ds.h
index 16a9735e7b..5067fb1572 100644
--- a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_semid_ds.h
+++ b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_semid_ds.h
@@ -23,6 +23,9 @@
 /* Data structure describing a set of semaphores.  */
 struct semid_ds
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_semid64_ds_helper.h>
+#else
   struct ipc_perm sem_perm;   /* operation permission struct */
   __syscall_ulong_t __sem_otime_high;
   __time_t sem_otime;         /* last semop() time */
@@ -31,4 +34,5 @@ struct semid_ds
   __syscall_ulong_t sem_nsems;    /* number of semaphores in set */
   __syscall_ulong_t __glibc_reserved3;
   __syscall_ulong_t __glibc_reserved4;
+#endif
 };
diff --git a/sysdeps/unix/sysv/linux/mips/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/mips/bits/types/struct_semid_ds.h
index 73587ea634..ee9a1e5e61 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/types/struct_semid_ds.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/types/struct_semid_ds.h
@@ -23,10 +23,14 @@
 /* Data structure describing a set of semaphores.  */
 struct semid_ds
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_semid64_ds_helper.h>
+#else
   struct ipc_perm sem_perm;		/* operation permission struct */
   __time_t sem_otime;	/* last semop() time */
   __time_t sem_ctime;	/* last time changed by semctl() */
   __syscall_ulong_t sem_nsems;		/* number of semaphores in set */
   __syscall_ulong_t __sem_otime_high;
   __syscall_ulong_t __sem_ctime_high;
+#endif
 };
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_semid_ds.h
index 8fdbc5d776..0c080fed61 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_semid_ds.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_semid_ds.h
@@ -23,17 +23,21 @@
 /* Data structure describing a set of semaphores.  */
 struct semid_ds
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_semid64_ds_helper.h>
+#else
   struct ipc_perm sem_perm;   /* operation permission struct */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
   __syscall_ulong_t __sem_otime_high;
   __time_t sem_otime;         /* last semop() time */
   __syscall_ulong_t __sem_ctime_high;
   __time_t sem_ctime;        /* last time changed by semctl() */
-#else
+# else
   __time_t sem_otime;         /* last semop() time */
   __time_t sem_ctime;         /* last time changed by semctl() */
-#endif
+# endif
   __syscall_ulong_t sem_nsems;    /* number of semaphores in set */
   __syscall_ulong_t __glibc_reserved3;
   __syscall_ulong_t __glibc_reserved4;
+#endif
 };
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_semid_ds.h
index 6b9b3639b2..76810427f6 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_semid_ds.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_semid_ds.h
@@ -23,17 +23,21 @@
 /* Data structure describing a set of semaphores.  */
 struct semid_ds
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_semid64_ds_helper.h>
+#else
   struct ipc_perm sem_perm;   /* operation permission struct */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
   __syscall_ulong_t __sem_otime_high;
   __time_t sem_otime;         /* last semop() time */
   __syscall_ulong_t __sem_ctime_high;
   __time_t sem_ctime;        /* last time changed by semctl() */
-#else
+# else
   __time_t sem_otime;         /* last semop() time */
   __time_t sem_ctime;         /* last time changed by semctl() */
-#endif
+# endif
   __syscall_ulong_t sem_nsems;    /* number of semaphores in set */
   __syscall_ulong_t __glibc_reserved3;
   __syscall_ulong_t __glibc_reserved4;
+#endif
 };
diff --git a/sysdeps/unix/sysv/linux/x86/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/x86/bits/types/struct_semid_ds.h
index 90f03b2407..affd38b6bd 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/types/struct_semid_ds.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/types/struct_semid_ds.h
@@ -23,6 +23,9 @@
 /* Data structure describing a set of semaphores.  */
 struct semid_ds
 {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_semid64_ds_helper.h>
+#else
   struct ipc_perm sem_perm;   /* operation permission struct */
   __time_t sem_otime;  /* last semop() time */
   __syscall_ulong_t __sem_otime_high;
@@ -31,4 +34,5 @@ struct semid_ds
   __syscall_ulong_t sem_nsems;    /* number of semaphores in set */
   __syscall_ulong_t __glibc_reserved3;
   __syscall_ulong_t __glibc_reserved4;
+#endif
 };
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 15/24] y2038: Use a common definition for shmid_ds
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (13 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 14/24] y2038: Use a common definition for semid_ds Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-14 14:59   ` Carlos O'Donell
  2021-06-07 20:36 ` [PATCH v3 16/24] y2038: Add __USE_TIME_BITS64 support for socket-constants.h Adhemerval Zanella
                   ` (8 subsequent siblings)
  23 siblings, 1 reply; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

Instead of replicate the same definitions from struct_shmid64_ds.h
on the multiple struct_shmid_ds.h, use a common header which is included
when required (struct_shmid64_ds_helper.h).

The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit semctl implementation.
---
 sysdeps/unix/sysv/linux/Makefile              |  3 +-
 .../sysv/linux/bits/types/struct_shmid64_ds.h |  9 +-----
 .../bits/types/struct_shmid64_ds_helper.h     | 28 +++++++++++++++++++
 .../sysv/linux/bits/types/struct_shmid_ds.h   | 10 +++++--
 .../linux/hppa/bits/types/struct_shmid_ds.h   | 10 +++++--
 .../linux/mips/bits/types/struct_shmid_ds.h   | 14 ++++++----
 .../powerpc/bits/types/struct_shmid_ds.h      | 10 +++++--
 .../linux/sparc/bits/types/struct_shmid_ds.h  | 10 +++++--
 8 files changed, 68 insertions(+), 26 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds_helper.h

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index b6abcb1365..8b4d3a6a54 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -103,7 +103,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
 		  bits/struct_stat.h \
 		  bits/struct_stat_time64_helper.h \
 		  bits/types/struct_msqid64_ds_helper.h \
-		  bits/types/struct_semid64_ds_helper.h
+		  bits/types/struct_semid64_ds_helper.h \
+		  bits/types/struct_shmid64_ds_helper.h
 
 tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds.h
index 71100db1b5..a4af8cc5f4 100644
--- a/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds.h
+++ b/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds.h
@@ -25,13 +25,6 @@
 #else
 struct __shmid64_ds
 {
-  struct ipc_perm shm_perm;	/* operation permission struct */
-  size_t shm_segsz;		/* size of segment in bytes */
-  __time64_t shm_atime;		/* time of last shmat() */
-  __time64_t shm_dtime;		/* time of last shmdt() */
-  __time64_t shm_ctime;		/* time of last change by shmctl() */
-  __pid_t shm_cpid;		/* pid of creator */
-  __pid_t shm_lpid;		/* pid of last shmop */
-  shmatt_t shm_nattch;		/* number of current attaches */
+# include <bits/types/struct_shmid64_ds_helper.h>
 };
 #endif
diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds_helper.h b/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds_helper.h
new file mode 100644
index 0000000000..945e7ce63e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds_helper.h
@@ -0,0 +1,28 @@
+/* Common definitions for struct semid_ds with 64-bit time.
+   Copyright (C) 2020-2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+  struct ipc_perm shm_perm;	/* operation permission struct */
+  size_t shm_segsz;		/* size of segment in bytes */
+  __time64_t shm_atime;		/* time of last shmat() */
+  __time64_t shm_dtime;		/* time of last shmdt() */
+  __time64_t shm_ctime;		/* time of last change by shmctl() */
+  __pid_t shm_cpid;		/* pid of creator */
+  __pid_t shm_lpid;		/* pid of last shmop */
+  shmatt_t shm_nattch;		/* number of current attaches */
+  unsigned long int __glibc_reserved5;
+  unsigned long int __glibc_reserved6;
diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_shmid_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_shmid_ds.h
index 2bd587d2b0..5f8ac6257b 100644
--- a/sysdeps/unix/sysv/linux/bits/types/struct_shmid_ds.h
+++ b/sysdeps/unix/sysv/linux/bits/types/struct_shmid_ds.h
@@ -23,23 +23,27 @@
 /* Data structure describing a shared memory segment.  */
 struct shmid_ds
   {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_shmid64_ds_helper.h>
+#else
     struct ipc_perm shm_perm;		/* operation permission struct */
     size_t shm_segsz;			/* size of segment in bytes */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
     __time_t shm_atime;			/* time of last shmat() */
     unsigned long int __shm_atime_high;
     __time_t shm_dtime;			/* time of last shmdt() */
     unsigned long int __shm_dtime_high;
     __time_t shm_ctime;			/* time of last change by shmctl() */
     unsigned long int __shm_ctime_high;
-#else
+# else
     __time_t shm_atime;			/* time of last shmat() */
     __time_t shm_dtime;			/* time of last shmdt() */
     __time_t shm_ctime;			/* time of last change by shmctl() */
-#endif
+# endif
     __pid_t shm_cpid;			/* pid of creator */
     __pid_t shm_lpid;			/* pid of last shmop */
     shmatt_t shm_nattch;		/* number of current attaches */
     __syscall_ulong_t __glibc_reserved5;
     __syscall_ulong_t __glibc_reserved6;
+#endif
   };
diff --git a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_shmid_ds.h b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_shmid_ds.h
index 47ff80ebb0..7831fd7340 100644
--- a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_shmid_ds.h
+++ b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_shmid_ds.h
@@ -23,8 +23,11 @@
 /* Data structure describing a shared memory segment.  */
 struct shmid_ds
   {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_shmid64_ds_helper.h>
+#else
     struct ipc_perm shm_perm;		/* operation permission struct */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
     unsigned long int __shm_atime_high;
     __time_t shm_atime;			/* time of last shmat() */
     unsigned long int __shm_dtime_high;
@@ -32,15 +35,16 @@ struct shmid_ds
     unsigned long int __shm_ctime_high;
     __time_t shm_ctime;			/* time of last change by shmctl() */
     unsigned long int __glibc_reserved4;
-#else
+# else
     __time_t shm_atime;			/* time of last shmat() */
     __time_t shm_dtime;			/* time of last shmdt() */
     __time_t shm_ctime;			/* time of last change by shmctl() */
-#endif
+# endif
     size_t shm_segsz;			/* size of segment in bytes */
     __pid_t shm_cpid;			/* pid of creator */
     __pid_t shm_lpid;			/* pid of last shmop */
     shmatt_t shm_nattch;		/* number of current attaches */
     __syscall_ulong_t __glibc_reserved5;
     __syscall_ulong_t __glibc_reserved6;
+#endif
   };
diff --git a/sysdeps/unix/sysv/linux/mips/bits/types/struct_shmid_ds.h b/sysdeps/unix/sysv/linux/mips/bits/types/struct_shmid_ds.h
index 7f8f3b9c51..0691a610ae 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/types/struct_shmid_ds.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/types/struct_shmid_ds.h
@@ -23,27 +23,31 @@
 /* Data structure describing a shared memory segment.  */
 struct shmid_ds
   {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_shmid64_ds_helper.h>
+#else
     struct ipc_perm shm_perm;		/* operation permission struct */
     size_t shm_segsz;			/* size of segment in bytes */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
     __time_t shm_atime;			/* time of last shmat() */
     __time_t shm_dtime;			/* time of last shmdt() */
     __time_t shm_ctime;			/* time of last change by shmctl() */
-#else
+# else
     __time_t shm_atime;			/* time of last shmat() */
     __time_t shm_dtime;			/* time of last shmdt() */
     __time_t shm_ctime;			/* time of last change by shmctl() */
-#endif
+# endif
     __pid_t shm_cpid;			/* pid of creator */
     __pid_t shm_lpid;			/* pid of last shmop */
     shmatt_t shm_nattch;		/* number of current attaches */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
     unsigned short int __shm_atime_high;
     unsigned short int __shm_dtime_high;
     unsigned short int __shm_ctime_high;
     unsigned short int __glibc_reserved4;
-#else
+# else
     __syscall_ulong_t __glibc_reserved5;
     __syscall_ulong_t __glibc_reserved6;
+# endif
 #endif
   };
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_shmid_ds.h b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_shmid_ds.h
index d71bdf1ecf..316d43ec99 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_shmid_ds.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_shmid_ds.h
@@ -23,8 +23,11 @@
 /* Data structure describing a shared memory segment.  */
 struct shmid_ds
   {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_shmid64_ds_helper.h>
+#else
     struct ipc_perm shm_perm;		/* operation permission struct */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
     unsigned long int __shm_atime_high;
     __time_t shm_atime;			/* time of last shmat() */
     unsigned long int __shm_dtime_high;
@@ -32,15 +35,16 @@ struct shmid_ds
     unsigned long int __shm_ctime_high;
     __time_t shm_ctime;			/* time of last change by shmctl() */
     unsigned long int __glibc_reserved4;
-#else
+# else
     __time_t shm_atime;			/* time of last shmat() */
     __time_t shm_dtime;			/* time of last shmdt() */
     __time_t shm_ctime;			/* time of last change by shmctl() */
-#endif
+# endif
     size_t shm_segsz;			/* size of segment in bytes */
     __pid_t shm_cpid;			/* pid of creator */
     __pid_t shm_lpid;			/* pid of last shmop */
     shmatt_t shm_nattch;		/* number of current attaches */
     __syscall_ulong_t __glibc_reserved5;
     __syscall_ulong_t __glibc_reserved6;
+#endif
   };
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_shmid_ds.h b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_shmid_ds.h
index 767099803f..86f0cedac3 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_shmid_ds.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_shmid_ds.h
@@ -23,23 +23,27 @@
 /* Data structure describing a shared memory segment.  */
 struct shmid_ds
   {
+#ifdef __USE_TIME_BITS64
+# include <bits/types/struct_shmid64_ds_helper.h>
+#else
     struct ipc_perm shm_perm;		/* operation permission struct */
-#if __TIMESIZE == 32
+# if __TIMESIZE == 32
     unsigned long int __shm_atime_high;
     __time_t shm_atime;			/* time of last shmat() */
     unsigned long int __shm_dtime_high;
     __time_t shm_dtime;			/* time of last shmdt() */
     unsigned long int __shm_ctime_high;
     __time_t shm_ctime;			/* time of last change by shmctl() */
-#else
+# else
     __time_t shm_atime;			/* time of last shmat() */
     __time_t shm_dtime;			/* time of last shmdt() */
     __time_t shm_ctime;			/* time of last change by shmctl() */
-#endif
+# endif
     size_t shm_segsz;			/* size of segment in bytes */
     __pid_t shm_cpid;			/* pid of creator */
     __pid_t shm_lpid;			/* pid of last shmop */
     shmatt_t shm_nattch;		/* number of current attaches */
     __syscall_ulong_t __glibc_reserved5;
     __syscall_ulong_t __glibc_reserved6;
+#endif
   };
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 16/24] y2038: Add __USE_TIME_BITS64 support for socket-constants.h
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (14 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 15/24] y2038: Use a common definition for shmid_ds Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-07 20:36 ` [PATCH v3 17/24] time: Add 64-bit time support for getdate Adhemerval Zanella
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

It is only used for !__USE_MISC, the default way uses the kernel
headers.  The patch also adds the SO_TIMESTAMP, SO_TIMESTAMPNS, and
SO_TIMESTAMPING which uses new values for 64-bit time_t kernel
interfaces.

The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit stat implementations.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 .../unix/sysv/linux/bits/socket-constants.h   | 47 +++++++++++++++----
 .../sysv/linux/hppa/bits/socket-constants.h   | 36 +++++++++++++-
 .../sysv/linux/mips/bits/socket-constants.h   | 36 +++++++++++++-
 .../linux/powerpc/bits/socket-constants.h     | 36 +++++++++++++-
 .../sysv/linux/sparc/bits/socket-constants.h  | 36 +++++++++++++-
 5 files changed, 175 insertions(+), 16 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/bits/socket-constants.h b/sysdeps/unix/sysv/linux/bits/socket-constants.h
index 84f7a333a2..c52e72bb73 100644
--- a/sysdeps/unix/sysv/linux/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/bits/socket-constants.h
@@ -32,19 +32,50 @@
 #define SO_OOBINLINE 10
 #define SO_RCVBUF 8
 #define SO_RCVLOWAT 18
-#if (__TIMESIZE == 64 && __WORDSIZE == 32 \
-     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
-# define SO_RCVTIMEO 66
-#else
-# define SO_RCVTIMEO 20
-#endif
 #define SO_REUSEADDR 2
 #define SO_SNDBUF 7
 #define SO_SNDLOWAT 19
+#define SO_TYPE 3
+
 #if (__TIMESIZE == 64 && __WORDSIZE == 32 \
      && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
+# define SO_RCVTIMEO 66
 # define SO_SNDTIMEO 67
+# define SO_TIMESTAMP 63
+# define SO_TIMESTAMPNS 64
+# define SO_TIMESTAMPING 65
 #else
-# define SO_SNDTIMEO 21
+# if __TIMESIZE == 64
+#  define SO_RCVTIMEO 20
+#  define SO_SNDTIMEO 21
+#  define SO_TIMESTAMP 29
+#  define SO_TIMESTAMPNS 35
+#  define SO_TIMESTAMPING 37
+# else
+#  define SO_RCVTIMEO_OLD 20
+#  define SO_SNDTIMEO_OLD 21
+#  define SO_RCVTIMEO_NEW 66
+#  define SO_SNDTIMEO_NEW 67
+
+#  define SO_TIMESTAMP_OLD 29
+#  define SO_TIMESTAMPNS_OLD 35
+#  define SO_TIMESTAMPING_OLD 37
+#  define SO_TIMESTAMP_NEW 63
+#  define SO_TIMESTAMPNS_NEW 64
+#  define SO_TIMESTAMPING_NEW 65
+
+#  ifdef __USE_TIME_BITS64
+#   define SO_RCVTIMEO SO_RCVTIMEO_NEW
+#   define SO_SNDTIMEO SO_SNDTIMEO_NEW
+#   define SO_TIMESTAMP SO_TIMESTAMP_NEW
+#   define SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW
+#   define SO_TIMESTAMPING SO_TIMESTAMPING_NEW
+#  else
+#   define SO_RCVTIMEO SO_RCVTIMEO_OLD
+#   define SO_SNDTIMEO SO_SNDTIMEO_OLD
+#   define SO_TIMESTAMP SO_TIMESTAMP_OLD
+#   define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
+#   define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
+#  endif
+# endif
 #endif
-#define SO_TYPE 3
diff --git a/sysdeps/unix/sysv/linux/hppa/bits/socket-constants.h b/sysdeps/unix/sysv/linux/hppa/bits/socket-constants.h
index b4fb65b9f1..68b42d4606 100644
--- a/sysdeps/unix/sysv/linux/hppa/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/hppa/bits/socket-constants.h
@@ -30,9 +30,41 @@
 #define SO_OOBINLINE 256
 #define SO_RCVBUF 4098
 #define SO_RCVLOWAT 4100
-#define SO_RCVTIMEO 4102
 #define SO_REUSEADDR 4
 #define SO_SNDBUF 4097
 #define SO_SNDLOWAT 4099
-#define SO_SNDTIMEO 4101
 #define SO_TYPE 4104
+
+#if __TIMESIZE == 64
+# define SO_RCVTIMEO 4102
+# define SO_SNDTIMEO 4101
+# define SO_TIMESTAMP 16402
+# define SO_TIMESTAMPNS 16403
+# define SO_TIMESTAMPING 16416
+#else
+# define SO_RCVTIMEO_OLD 4102
+# define SO_SNDTIMEO_OLD 4101
+# define SO_RCVTIMEO_NEW 16448
+# define SO_SNDTIMEO_NEW 16449
+
+# define SO_TIMESTAMP_OLD 0x4012
+# define SO_TIMESTAMPNS_OLD 0x4013
+# define SO_TIMESTAMPING_OLD 0x4020
+# define SO_TIMESTAMP_NEW 0x4038
+# define SO_TIMESTAMPNS_NEW 0x4039
+# define SO_TIMESTAMPING_NEW 0x403A
+
+# ifdef __USE_TIME_BITS64
+#  define SO_RCVTIMEO SO_RCVTIMEO_NEW
+#  define SO_SNDTIMEO SO_SNDTIMEO_NEW
+#  define SO_TIMESTAMP SO_TIMESTAMP_NEW
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_NEW
+# else
+#  define SO_RCVTIMEO SO_RCVTIMEO_OLD
+#  define SO_SNDTIMEO SO_SNDTIMEO_OLD
+#  define SO_TIMESTAMP SO_TIMESTAMP_OLD
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
+# endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/bits/socket-constants.h b/sysdeps/unix/sysv/linux/mips/bits/socket-constants.h
index a5264536e9..b18a854e99 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/socket-constants.h
@@ -30,9 +30,41 @@
 #define SO_OOBINLINE 256
 #define SO_RCVBUF 4098
 #define SO_RCVLOWAT 4100
-#define SO_RCVTIMEO 4102
 #define SO_REUSEADDR 4
 #define SO_SNDBUF 4097
 #define SO_SNDLOWAT 4099
-#define SO_SNDTIMEO 4101
 #define SO_TYPE 4104
+
+#if __TIMESIZE == 64
+# define SO_RCVTIMEO 4102
+# define SO_SNDTIMEO 4101
+# define SO_TIMESTAMP 29
+# define SO_TIMESTAMPNS 35
+# define SO_TIMESTAMPING 37
+#else
+# define SO_RCVTIMEO_OLD 4102
+# define SO_SNDTIMEO_OLD 4101
+# define SO_RCVTIMEO_NEW 66
+# define SO_SNDTIMEO_NEW 67
+
+# define SO_TIMESTAMP_OLD 29
+# define SO_TIMESTAMPNS_OLD 35
+# define SO_TIMESTAMPING_OLD 37
+# define SO_TIMESTAMP_NEW 63
+# define SO_TIMESTAMPNS_NEW 64
+# define SO_TIMESTAMPING_NEW 65
+
+# ifdef __USE_TIME_BITS64
+#  define SO_RCVTIMEO SO_RCVTIMEO_NEW
+#  define SO_SNDTIMEO SO_SNDTIMEO_NEW
+#  define SO_TIMESTAMP SO_TIMESTAMP_NEW
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_NEW
+# else
+#  define SO_RCVTIMEO SO_RCVTIMEO_OLD
+#  define SO_SNDTIMEO SO_SNDTIMEO_OLD
+#  define SO_TIMESTAMP SO_TIMESTAMP_OLD
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
+# endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/socket-constants.h b/sysdeps/unix/sysv/linux/powerpc/bits/socket-constants.h
index f35488b375..c03141bb8c 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/socket-constants.h
@@ -30,9 +30,41 @@
 #define SO_OOBINLINE 10
 #define SO_RCVBUF 8
 #define SO_RCVLOWAT 16
-#define SO_RCVTIMEO 18
 #define SO_REUSEADDR 2
 #define SO_SNDBUF 7
 #define SO_SNDLOWAT 17
-#define SO_SNDTIMEO 19
 #define SO_TYPE 3
+
+#if __TIMESIZE == 64
+# define SO_RCVTIMEO 18
+# define SO_SNDTIMEO 19
+# define SO_TIMESTAMP 29
+# define SO_TIMESTAMPNS 35
+# define SO_TIMESTAMPING 37
+#else
+# define SO_RCVTIMEO_OLD 18
+# define SO_SNDTIMEO_OLD 19
+# define SO_RCVTIMEO_NEW 66
+# define SO_SNDTIMEO_NEW 67
+
+# define SO_TIMESTAMP_OLD 29
+# define SO_TIMESTAMPNS_OLD 35
+# define SO_TIMESTAMPING_OLD 37
+# define SO_TIMESTAMP_NEW 63
+# define SO_TIMESTAMPNS_NEW 64
+# define SO_TIMESTAMPING_NEW 65
+
+# ifdef __USE_TIME_BITS64
+#  define SO_RCVTIMEO SO_RCVTIMEO_NEW
+#  define SO_SNDTIMEO SO_SNDTIMEO_NEW
+#  define SO_TIMESTAMP SO_TIMESTAMP_NEW
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_NEW
+# else
+#  define SO_RCVTIMEO SO_RCVTIMEO_OLD
+#  define SO_SNDTIMEO SO_SNDTIMEO_OLD
+#  define SO_TIMESTAMP SO_TIMESTAMP_OLD
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
+# endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/socket-constants.h b/sysdeps/unix/sysv/linux/sparc/bits/socket-constants.h
index a58d0b5f96..5c4ed76c8c 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/socket-constants.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/socket-constants.h
@@ -30,9 +30,41 @@
 #define SO_OOBINLINE 256
 #define SO_RCVBUF 4098
 #define SO_RCVLOWAT 2048
-#define SO_RCVTIMEO 8192
 #define SO_REUSEADDR 4
 #define SO_SNDBUF 4097
 #define SO_SNDLOWAT 4096
-#define SO_SNDTIMEO 16384
 #define SO_TYPE 4104
+
+#if __TIMESIZE == 64
+# define SO_RCVTIMEO 8192
+# define SO_SNDTIMEO 16384
+# define SO_TIMESTAMP 29
+# define SO_TIMESTAMPNS 33
+# define SO_TIMESTAMPING 35
+#else
+# define SO_RCVTIMEO_OLD 8192
+# define SO_SNDTIMEO_OLD 16384
+# define SO_RCVTIMEO_NEW 68
+# define SO_SNDTIMEO_NEW 69
+
+# define SO_TIMESTAMP_OLD 0x001d
+# define SO_TIMESTAMPNS_OLD 0x0021
+# define SO_TIMESTAMPING_OLD 0x0023
+# define SO_TIMESTAMP_NEW 0x0046
+# define SO_TIMESTAMPNS_NEW 0x0042
+# define SO_TIMESTAMPING_NEW 0x0043
+
+# ifdef __USE_TIME_BITS64
+#  define SO_RCVTIMEO SO_RCVTIMEO_NEW
+#  define SO_SNDTIMEO SO_SNDTIMEO_NEW
+#  define SO_TIMESTAMP SO_TIMESTAMP_NEW
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_NEW
+# else
+#  define SO_RCVTIMEO SO_RCVTIMEO_OLD
+#  define SO_SNDTIMEO SO_SNDTIMEO_OLD
+#  define SO_TIMESTAMP SO_TIMESTAMP_OLD
+#  define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD
+#  define SO_TIMESTAMPING SO_TIMESTAMPING_OLD
+# endif
+#endif
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 17/24] time: Add 64-bit time support for getdate
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (15 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 16/24] y2038: Add __USE_TIME_BITS64 support for socket-constants.h Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-07 20:36 ` [PATCH v3 18/24] y2038: Add support for 64-bit time on legacy ABIs Adhemerval Zanella
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

The getdate is basically a wrapper localtime and mktime.  The 64-bit
time support is done calling the 64-bit internal functions, there is
no need to add a new symbol version.

Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 include/sys/stat.h |  2 +-
 include/time.h     | 12 ++++++++++--
 time/getdate.c     | 22 ++++++++++------------
 time/tst-getdate.c | 14 ++++----------
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/include/sys/stat.h b/include/sys/stat.h
index b4c9344628..13e777b3c7 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -46,7 +46,7 @@ hidden_proto (__lstat64)
 hidden_proto (__fstatat64)
 # endif
 
-# if __TIMESIZE == 64
+# if __TIMESIZE == 64 || defined NO_RTLD_HIDDEN
 #  define __stat64_time64  __stat64
 #  define __fstat64_time64  __fstat64
 #  define __lstat64_time64  __lstat64
diff --git a/include/time.h b/include/time.h
index 4372bfbd96..980c6bd924 100644
--- a/include/time.h
+++ b/include/time.h
@@ -283,8 +283,8 @@ hidden_proto (__nanosleep64)
 #endif
 
 
-extern int __getdate_r (const char *__string, struct tm *__resbufp)
-  attribute_hidden;
+extern int __getdate_r (const char *__string, struct tm *__resbufp);
+libc_hidden_proto (__getdate_r);
 
 
 /* Determine CLK_TCK value.  */
@@ -509,6 +509,14 @@ time_now (void)
   return ts.tv_sec;
 }
 
+static inline __time64_t
+time64_now (void)
+{
+  struct __timespec64 ts;
+  __clock_gettime64 (TIME_CLOCK_GETTIME_CLOCKID, &ts);
+  return ts.tv_sec;
+}
+
 #define NSEC_PER_SEC    1000000000L  /* Nanoseconds per second.  */
 #define USEC_PER_SEC    1000000L     /* Microseconds per second.  */
 #define NSEC_PER_USEC   1000L        /* Nanoseconds per microsecond.  */
diff --git a/time/getdate.c b/time/getdate.c
index 6e2f75566b..cdcc898517 100644
--- a/time/getdate.c
+++ b/time/getdate.c
@@ -112,16 +112,16 @@ __getdate_r (const char *string, struct tm *tp)
   size_t len;
   char *datemsk;
   char *result = NULL;
-  time_t timer;
+  __time64_t timer;
   struct tm tm;
-  struct stat64 st;
-  int mday_ok = 0;
+  struct __stat64_t64 st;
+  bool mday_ok = false;
 
   datemsk = getenv ("DATEMSK");
   if (datemsk == NULL || *datemsk == '\0')
     return 1;
 
-  if (__stat64 (datemsk, &st) < 0)
+  if (__stat64_time64 (datemsk, &st) < 0)
     return 3;
 
   if (!S_ISREG (st.st_mode))
@@ -219,8 +219,8 @@ __getdate_r (const char *string, struct tm *tp)
     return 7;
 
   /* Get current time.  */
-  timer = time_now ();
-  __localtime_r (&timer, &tm);
+  timer = time64_now ();
+  __localtime64_r (&timer, &tm);
 
   /* If only the weekday is given, today is assumed if the given day
      is equal to the current day and next week if it is less.  */
@@ -230,7 +230,7 @@ __getdate_r (const char *string, struct tm *tp)
       tp->tm_year = tm.tm_year;
       tp->tm_mon = tm.tm_mon;
       tp->tm_mday = tm.tm_mday + (tp->tm_wday - tm.tm_wday + 7) % 7;
-      mday_ok = 1;
+      mday_ok = true;
     }
 
   /* If only the month is given, the current month is assumed if the
@@ -242,7 +242,7 @@ __getdate_r (const char *string, struct tm *tp)
       if (tp->tm_year == INT_MIN)
 	tp->tm_year = tm.tm_year + (((tp->tm_mon - tm.tm_mon) < 0) ? 1 : 0);
       tp->tm_mday = first_wday (tp->tm_year, tp->tm_mon, tp->tm_wday);
-      mday_ok = 1;
+      mday_ok = true;
     }
 
   /* If no hour, minute and second are given the current hour, minute
@@ -285,15 +285,13 @@ __getdate_r (const char *string, struct tm *tp)
      call normalizes the struct tm.  */
   if ((!mday_ok && !check_mday (TM_YEAR_BASE + tp->tm_year, tp->tm_mon,
 				tp->tm_mday))
-      || mktime (tp) == (time_t) -1)
+      || __mktime64 (tp) == (time_t) -1)
     return 8;
 
   return 0;
 }
-#ifdef weak_alias
 weak_alias (__getdate_r, getdate_r)
-#endif
-
+libc_hidden_def (__getdate_r)
 
 struct tm *
 getdate (const char *string)
diff --git a/time/tst-getdate.c b/time/tst-getdate.c
index c37ba3083a..3bb0e96707 100644
--- a/time/tst-getdate.c
+++ b/time/tst-getdate.c
@@ -115,20 +115,14 @@ do_test (void)
     {
       setenv ("TZ", tests[i].tz, 1);
 
-      int expected_err;
-      if (sizeof (time_t) == 4 && tests[i].time64)
-	expected_err = 8;
-      else
-	expected_err = 0;
-
       tm = getdate (tests[i].str);
-      TEST_COMPARE (getdate_err, expected_err);
-      if (getdate_err != expected_err)
+      TEST_COMPARE (getdate_err, 0);
+      if (getdate_err != 0)
 	{
 	  support_record_failure ();
 	  printf ("%s\n", report_date_error ());
 	}
-      else if (getdate_err == 0)
+      else
 	{
 	  TEST_COMPARE (tests[i].tm.tm_mon, tm->tm_mon);
 	  TEST_COMPARE (tests[i].tm.tm_year, tm->tm_year);
@@ -139,7 +133,7 @@ do_test (void)
 	}
 
       struct tm tms;
-      TEST_COMPARE (getdate_r (tests[i].str, &tms), expected_err);
+      TEST_COMPARE (getdate_r (tests[i].str, &tms), 0);
       if (getdate_err == 0)
 	{
 	  TEST_COMPARE (tests[i].tm.tm_mon, tms.tm_mon);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 18/24] y2038: Add support for 64-bit time on legacy ABIs
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (16 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 17/24] time: Add 64-bit time support for getdate Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-10-13 11:44   ` Stafford Horne
  2021-06-07 20:36 ` [PATCH v3 19/24] posix: Add glob64 with 64-bit time_t support Adhemerval Zanella
                   ` (5 subsequent siblings)
  23 siblings, 1 reply; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

A new build flag, _TIME_BITS, enables the usage of the newer 64-bit
time symbols for legacy ABI (where 32 bit time_t is default).  The 64
bit time support is only enabled if LFS (_FILE_OFFSET_BITS=64) is
also used.

Different than LFS support, the y2038 symbols are added only for the
required ABIs (armhf, csky, hppa, i386, m68k, microblaze, mips32,
mips64-n32, nios2, powerpc32, sparc32, s390-32, and sh).  The ABIs with
64-bit time support are unchanged, both for symbol and types
redirection.

On Linux the full 64-bit time support requires a minimum of kernel
version v5.1.  Otherwise, the 32 bit fallbacks are used and might
results in error with overflow return code (EOVERFLOW).

The i686-gnu does not yet support 64-bit time.

This patch exports following rediretions to support 64-bit time:

  * libc:
    adjtime
    adjtimex
    clock_adjtime
    clock_getres
    clock_gettime
    clock_nanosleep
    clock_settime
    cnd_timedwait
    ctime
    ctime_r
    difftime
    fstat
    fstatat
    futimens
    futimes
    futimesat
    getitimer
    getrusage
    gettimeofday
    gmtime
    gmtime_r
    localtime
    localtime_r
    lstat_time
    lutimes
    mktime
    msgctl
    mtx_timedlock
    nanosleep
    nanosleep
    ntp_gettime
    ntp_gettimex
    ppoll
    pselec
    pselect
    pthread_clockjoin_np
    pthread_cond_clockwait
    pthread_cond_timedwait
    pthread_mutex_clocklock
    pthread_mutex_timedlock
    pthread_rwlock_clockrdlock
    pthread_rwlock_clockwrlock
    pthread_rwlock_timedrdlock
    pthread_rwlock_timedwrlock
    pthread_timedjoin_np
    recvmmsg
    sched_rr_get_interval
    select
    sem_clockwait
    semctl
    semtimedop
    sem_timedwait
    setitimer
    settimeofday
    shmctl
    sigtimedwait
    stat
    thrd_sleep
    time
    timegm
    timerfd_gettime
    timerfd_settime
    timespec_get
    utime
    utimensat
    utimes
    utimes
    wait3
    wait4

  * librt:
    aio_suspend
    mq_timedreceive
    mq_timedsend
    timer_gettime
    timer_settime

  * libanl:
    gai_suspend

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 Makefile                                      |   2 +-
 NEWS                                          |   5 +
 include/features-time64.h                     |   1 +
 include/features.h                            |   2 +
 io/sys/poll.h                                 |  11 ++
 io/sys/stat.h                                 | 113 ++++++++++++--
 io/utime.h                                    |  11 ++
 manual/creature.texi                          |  44 ++++++
 misc/sys/select.h                             |  27 ++++
 nptl/pthread_clockjoin.c                      |   3 +-
 nptl/pthread_cond_wait.c                      |   9 +-
 nptl/pthread_mutex_timedlock.c                |   8 +-
 nptl/pthread_rwlock_clockrdlock.c             |   4 +-
 nptl/pthread_rwlock_clockwrlock.c             |   4 +-
 nptl/pthread_rwlock_timedrdlock.c             |   4 +-
 nptl/pthread_rwlock_timedwrlock.c             |   4 +-
 nptl/pthread_timedjoin.c                      |   3 +-
 nptl/sem_clockwait.c                          |   3 +-
 nptl/sem_timedwait.c                          |   4 +-
 posix/sched.h                                 |  11 +-
 posix/sys/wait.h                              |  20 +++
 resolv/netdb.h                                |  11 ++
 resource/sys/resource.h                       |  10 ++
 rt/aio.h                                      |  15 +-
 rt/mqueue.h                                   |  22 +++
 signal/signal.h                               |  13 ++
 socket/sys/socket.h                           |  11 ++
 sysdeps/generic/features-time64.h             |  19 +++
 sysdeps/generic/time64-compat.h               |   3 +
 sysdeps/nptl/pthread.h                        | 119 +++++++++++++++
 sysdeps/pthread/semaphore.h                   |  25 ++++
 sysdeps/pthread/threads.h                     |  33 +++++
 sysdeps/unix/sysv/linux/Makefile              |   3 +
 sysdeps/unix/sysv/linux/Versions              |  97 ++++++++++++
 sysdeps/unix/sysv/linux/arm/be/libanl.abilist |   1 +
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |  67 +++++++++
 sysdeps/unix/sysv/linux/arm/be/librt.abilist  |   5 +
 sysdeps/unix/sysv/linux/arm/le/libanl.abilist |   1 +
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  67 +++++++++
 sysdeps/unix/sysv/linux/arm/le/librt.abilist  |   5 +
 sysdeps/unix/sysv/linux/arm/time64-compat.h   |   2 +
 sysdeps/unix/sysv/linux/bits/msq.h            |   1 +
 sysdeps/unix/sysv/linux/bits/sem.h            |   1 +
 sysdeps/unix/sysv/linux/bits/shm.h            |   1 +
 sysdeps/unix/sysv/linux/bits/time.h           |  10 ++
 sysdeps/unix/sysv/linux/cnd_timedwait.c       |   8 +-
 sysdeps/unix/sysv/linux/csky/libanl.abilist   |   1 +
 sysdeps/unix/sysv/linux/csky/libc.abilist     |  67 +++++++++
 sysdeps/unix/sysv/linux/csky/librt.abilist    |   5 +
 sysdeps/unix/sysv/linux/csky/time64-compat.h  |   2 +
 sysdeps/unix/sysv/linux/features-time64.h     |  37 +++++
 sysdeps/unix/sysv/linux/hppa/libanl.abilist   |   1 +
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |  67 +++++++++
 sysdeps/unix/sysv/linux/hppa/librt.abilist    |   5 +
 sysdeps/unix/sysv/linux/hppa/time64-compat.h  |   2 +
 sysdeps/unix/sysv/linux/i386/libanl.abilist   |   1 +
 sysdeps/unix/sysv/linux/i386/libc.abilist     |  67 +++++++++
 sysdeps/unix/sysv/linux/i386/librt.abilist    |   5 +
 sysdeps/unix/sysv/linux/i386/time64-compat.h  |   2 +
 sysdeps/unix/sysv/linux/include/sys/msg.h     |   2 -
 sysdeps/unix/sysv/linux/include/sys/shm.h     |   2 -
 sysdeps/unix/sysv/linux/include/sys/timex.h   |   2 +
 .../sysv/linux/m68k/coldfire/libanl.abilist   |   1 +
 .../sysv/linux/m68k/coldfire/libc.abilist     |  67 +++++++++
 .../sysv/linux/m68k/coldfire/librt.abilist    |   5 +
 .../sysv/linux/m68k/m680x0/libanl.abilist     |   1 +
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  67 +++++++++
 .../unix/sysv/linux/m68k/m680x0/librt.abilist |   5 +
 sysdeps/unix/sysv/linux/m68k/time64-compat.h  |   2 +
 .../sysv/linux/microblaze/be/libanl.abilist   |   1 +
 .../sysv/linux/microblaze/be/libc.abilist     |  67 +++++++++
 .../sysv/linux/microblaze/be/librt.abilist    |   5 +
 .../sysv/linux/microblaze/le/libanl.abilist   |   1 +
 .../sysv/linux/microblaze/le/libc.abilist     |  67 +++++++++
 .../sysv/linux/microblaze/le/librt.abilist    |   5 +
 .../sysv/linux/microblaze/time64-compat.h     |   2 +
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  67 +++++++++
 .../sysv/linux/mips/mips32/libanl.abilist     |   1 +
 .../unix/sysv/linux/mips/mips32/librt.abilist |   5 +
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |  67 +++++++++
 .../sysv/linux/mips/mips32/time64-compat.h    |   2 +
 .../sysv/linux/mips/mips64/n32/libanl.abilist |   1 +
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  67 +++++++++
 .../sysv/linux/mips/mips64/n32/librt.abilist  |   5 +
 .../linux/mips/mips64/n32/time64-compat.h     |   2 +
 sysdeps/unix/sysv/linux/mtx_timedlock.c       |   8 +-
 sysdeps/unix/sysv/linux/nios2/libanl.abilist  |   1 +
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |  67 +++++++++
 sysdeps/unix/sysv/linux/nios2/librt.abilist   |   5 +
 sysdeps/unix/sysv/linux/nios2/time64-compat.h |   2 +
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  67 +++++++++
 .../linux/powerpc/powerpc32/libanl.abilist    |   1 +
 .../linux/powerpc/powerpc32/librt.abilist     |   5 +
 .../powerpc/powerpc32/nofpu/libc.abilist      |  67 +++++++++
 .../linux/powerpc/powerpc32/time64-compat.h   |   2 +
 .../sysv/linux/s390/s390-32/libanl.abilist    |   1 +
 .../unix/sysv/linux/s390/s390-32/libc.abilist |  67 +++++++++
 .../sysv/linux/s390/s390-32/librt.abilist     |   5 +
 .../sysv/linux/s390/s390-32/time64-compat.h   |   2 +
 sysdeps/unix/sysv/linux/semctl.c              |   1 -
 sysdeps/unix/sysv/linux/sh/be/libanl.abilist  |   1 +
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  67 +++++++++
 sysdeps/unix/sysv/linux/sh/be/librt.abilist   |   5 +
 sysdeps/unix/sysv/linux/sh/le/libanl.abilist  |   1 +
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  67 +++++++++
 sysdeps/unix/sysv/linux/sh/le/librt.abilist   |   5 +
 sysdeps/unix/sysv/linux/sh/time64-compat.h    |   2 +
 .../sysv/linux/sparc/sparc32/libanl.abilist   |   1 +
 .../sysv/linux/sparc/sparc32/libc.abilist     |  67 +++++++++
 .../sysv/linux/sparc/sparc32/librt.abilist    |   5 +
 .../sysv/linux/sparc/sparc32/time64-compat.h  |   2 +
 sysdeps/unix/sysv/linux/sys/timerfd.h         |  22 +++
 sysdeps/unix/sysv/linux/sys/timex.h           |  27 +++-
 sysvipc/sys/msg.h                             |  10 ++
 sysvipc/sys/sem.h                             |  21 +++
 sysvipc/sys/shm.h                             |  10 ++
 time/sys/time.h                               |  71 +++++++++
 time/time.h                                   | 138 +++++++++++++++++-
 118 files changed, 2387 insertions(+), 60 deletions(-)
 create mode 100644 include/features-time64.h
 create mode 100644 sysdeps/generic/features-time64.h
 create mode 100644 sysdeps/generic/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/arm/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/csky/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/features-time64.h
 create mode 100644 sysdeps/unix/sysv/linux/hppa/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/i386/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/m68k/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/microblaze/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips32/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/nios2/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/sh/time64-compat.h
 create mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/time64-compat.h

diff --git a/Makefile b/Makefile
index 242d36de91..0157b53cb8 100644
--- a/Makefile
+++ b/Makefile
@@ -68,7 +68,7 @@ endif # $(AUTOCONF) = no
 		   subdir_objs subdir_stubs subdir_testclean		\
 		   $(addprefix install-, no-libc.a bin lib data headers others)
 \f
-headers := limits.h values.h features.h gnu-versions.h \
+headers := limits.h values.h features.h features-time64.h gnu-versions.h \
 	   bits/xopen_lim.h gnu/libc-version.h stdc-predef.h \
 	   bits/libc-header-start.h
 
diff --git a/NEWS b/NEWS
index 1bf3daa502..d03831978f 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,11 @@ Major new features:
   __STDC_WANT_IEC_60559_BFP_EXT__, as specified in TS 18661-1, is
   defined, and when _GNU_SOURCE is defined.
 
+* Add support for 64-bit time_t for ABIs with defaults to 32 bit time_t.
+  This is enabled with the _TIME_BITS preprocessor set to 64 and only
+  supported when LFS (_FILE_OFFSET_BITS=64) is also enabled.  It is only
+  enabled for Linux and the full support requires a minimum version of 5.1.
+
 Deprecated and removed features, and other changes affecting compatibility:
 
 * The function pthread_mutex_consistent_np has been deprecated; programs
diff --git a/include/features-time64.h b/include/features-time64.h
new file mode 100644
index 0000000000..06115b7c86
--- /dev/null
+++ b/include/features-time64.h
@@ -0,0 +1 @@
+#include_next <features-time64.h>
diff --git a/include/features.h b/include/features.h
index fcd1a9502f..039bcb112b 100644
--- a/include/features.h
+++ b/include/features.h
@@ -389,6 +389,8 @@
 # define __USE_FILE_OFFSET64	1
 #endif
 
+#include <features-time64.h>
+
 #if defined _DEFAULT_SOURCE
 # define __USE_MISC	1
 #endif
diff --git a/io/sys/poll.h b/io/sys/poll.h
index 08f29df540..e640efb2bc 100644
--- a/io/sys/poll.h
+++ b/io/sys/poll.h
@@ -66,6 +66,17 @@ extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
 		  const __sigset_t *__ss)
     __attr_access ((__write_only__, 1, 2));
 
+# ifdef __USE_TIME_BITS64
+#  ifdef __REDIRECT
+extern int __REDIRECT (ppoll, (struct pollfd *__fds, nfds_t __nfds,
+                               const struct timespec *__timeout,
+                               const __sigset_t *__ss),
+                       __ppoll64)
+    __attr_access ((__write_only__, 1, 2));
+#  else
+#  define ppoll __ppoll64
+#  endif
+# endif
 #endif
 
 __END_DECLS
diff --git a/io/sys/stat.h b/io/sys/stat.h
index 549375c087..f7874ec5ba 100644
--- a/io/sys/stat.h
+++ b/io/sys/stat.h
@@ -209,21 +209,51 @@ extern int stat (const char *__restrict __file,
    that file descriptor FD is open on and put them in BUF.  */
 extern int fstat (int __fd, struct stat *__buf) __THROW __nonnull ((2));
 #else
-# ifdef __REDIRECT_NTH
+# ifdef __USE_TIME_BITS64
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
+				  struct stat *__restrict __buf),
+				  __stat64_time64)
+     __nonnull ((1, 2));
+extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf),
+				   __fstat64_time64)
+     __nonnull ((2));
+#  else
+#   define stat __stat64_time64
+#   define fstat __fstat64_time64
+#  endif
+# else
+#  ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
 				  struct stat *__restrict __buf), stat64)
      __nonnull ((1, 2));
 extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf), fstat64)
      __nonnull ((2));
-# else
-#  define stat stat64
-#  define fstat fstat64
+#  else
+#   define stat stat64
+#   define fstat fstat64
+#  endif
 # endif
 #endif
 #ifdef __USE_LARGEFILE64
+# ifndef __USE_TIME_BITS64
 extern int stat64 (const char *__restrict __file,
 		   struct stat64 *__restrict __buf) __THROW __nonnull ((1, 2));
 extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
+# else
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (stat64, (const char *__restrict __file,
+				    struct stat64 *__restrict __buf),
+			   __stat64_time64)
+     __nonnull ((1, 2));
+extern int __REDIRECT_NTH (fstat64, (int __fd, struct stat64 *__buf),
+			   __fstat64_time64)
+     __nonnull ((2));
+#  else
+#   define stat64 __stat64_time64
+#   define fstat64 __fstat64_time
+#  endif
+# endif
 #endif
 
 #ifdef __USE_ATFILE
@@ -235,20 +265,44 @@ extern int fstatat (int __fd, const char *__restrict __file,
 		    struct stat *__restrict __buf, int __flag)
      __THROW __nonnull ((2, 3));
 # else
-#  ifdef __REDIRECT_NTH
+#  ifdef __USE_TIME_BITS64
+#   ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
 				     struct stat *__restrict __buf,
 				     int __flag),
-			   fstatat64) __nonnull ((2, 3));
+			   __fstatat64_time64) __nonnull ((2, 3));
+#   else
+#    define fstatat __fstatat64_time64
+#   endif
 #  else
-#   define fstatat fstatat64
+#   ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
+				     struct stat *__restrict __buf,
+				     int __flag),
+			   fstatat64) __nonnull ((2, 3));
+#   else
+#    define fstatat fstatat64
+#   endif
 #  endif
 # endif
 
 # ifdef __USE_LARGEFILE64
+#  ifndef __USE_TIME_BITS64
 extern int fstatat64 (int __fd, const char *__restrict __file,
 		      struct stat64 *__restrict __buf, int __flag)
      __THROW __nonnull ((2, 3));
+#  else
+#   ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (fstatat64, (int __fd,
+				       const char *__restrict __file,
+				       struct stat64 *__restrict __buf,
+				       int __flag),
+			   __fstatat64_time64)
+     __nonnull ((2, 3));
+#   else
+#    define fstatat64 __fstatat64_time64
+#   endif
+#  endif
 # endif
 #endif
 
@@ -259,19 +313,37 @@ extern int fstatat64 (int __fd, const char *__restrict __file,
 extern int lstat (const char *__restrict __file,
 		  struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
 # else
-#  ifdef __REDIRECT_NTH
+#  ifdef __USE_TIME_BITS64
+#   ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (lstat,
 			   (const char *__restrict __file,
-			    struct stat *__restrict __buf), lstat64)
+			    struct stat *__restrict __buf), __lstat64_time64)
      __nonnull ((1, 2));
+#   else
+#    define lstat __lstat64_time64
+#   endif
 #  else
-#   define lstat lstat64
+#   ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (lstat,
+			   (const char *__restrict __file,
+			    struct stat *__restrict __buf), lstat64)
+     __nonnull ((1, 2));
+#   else
+#    define lstat lstat64
+#   endif
 #  endif
 # endif
 # ifdef __USE_LARGEFILE64
+#  ifndef __USE_TIME_BITS64
 extern int lstat64 (const char *__restrict __file,
 		    struct stat64 *__restrict __buf)
      __THROW __nonnull ((1, 2));
+#  else
+extern int __REDIRECT_NTH (lstat64, (const char *__restrict __file,
+				     struct stat64 *__restrict __buf),
+			   __lstat64_time64)
+     __nonnull ((1, 2));
+#  endif
 # endif
 #endif
 
@@ -355,17 +427,38 @@ extern int mkfifoat (int __fd, const char *__path, __mode_t __mode)
 #endif
 \f
 #ifdef __USE_ATFILE
+# ifndef __USE_TIME_BITS64
 /* Set file access and modification times relative to directory file
    descriptor.  */
 extern int utimensat (int __fd, const char *__path,
 		      const struct timespec __times[2],
 		      int __flags)
      __THROW __nonnull ((2));
+# else
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (utimensat, (int fd, const char *__path,
+                                       const struct timespec __times[2],
+                                       int flags),
+                           __utimensat64) __nonnull ((2));
+#  else
+#   define utimensat __utimensat64
+#  endif
+# endif
 #endif
 
 #ifdef __USE_XOPEN2K8
+# ifndef __USE_TIME_BITS64
 /* Set file access and modification times of the file associated with FD.  */
 extern int futimens (int __fd, const struct timespec __times[2]) __THROW;
+
+# else
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (futimens, (int fd, const struct timespec __times[2]),
+                           __futimens64);
+#  else
+#   define futimens __futimens64
+#  endif
+# endif
 #endif
 
 #ifdef __USE_GNU
diff --git a/io/utime.h b/io/utime.h
index c7612d0838..1a645a3fff 100644
--- a/io/utime.h
+++ b/io/utime.h
@@ -46,10 +46,21 @@ struct utimbuf
 
 /* Set the access and modification times of FILE to those given in
    *FILE_TIMES.  If FILE_TIMES is NULL, set them to the current time.  */
+#ifndef __USE_TIME_BITS64
 extern int utime (const char *__file,
 		  const struct utimbuf *__file_times)
      __THROW __nonnull ((1));
 
+#else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (utime, (const char *__file,
+                                   const struct utimbuf *__file_times),
+                           __utime64);
+# else
+#  define utime __utime64
+# endif
+#endif
+
 __END_DECLS
 
 #endif /* utime.h */
diff --git a/manual/creature.texi b/manual/creature.texi
index 705a949089..9fa658e9a7 100644
--- a/manual/creature.texi
+++ b/manual/creature.texi
@@ -165,6 +165,50 @@ This macro was introduced as part of the Large File Support extension
 (LFS).
 @end defvr
 
+@defvr Macro _TIME_BITS
+This macro determines the bit size of @code{time_t} (and therefore the
+bit size of all @code{time_t} derived types and the prototypes of all
+related functions).  If @code{_TIME_BITS} is undefined, the bit size of
+@code{time_t} is architecture dependent.
+
+Possible values of @code{_TIME_BITS}:
+@enumerate
+@item
+@code{_TIME_BITS=64} and port from the outset uses 64-bit
+@code{time_t} and word size equals to @w{64 bits} (e.g. x86_64) - no
+action
+
+@item
+@code{_TIME_BITS=32} and port from the outset uses 32-bit
+@code{time_t} and word size equals to @w{64 bits} (e.g. ARM) - no
+action
+
+@item
+@code{_TIME_BITS=64} and port from the outset uses 64-bit
+@code{time_t} and word size equals to @w{32 bits} (e.g. ARC, RV32)
+- no action
+
+@item
+@code{_TIME_BITS=64} and port from the outset uses 32-bit
+@code{time_t} and word size equals to @w{32 bits} (e.g. ARM)
+- the @code{time_t} is modified to be able to hold 64-bit time.
+
+@item
+For any other use case the compile-time error is emitted.
+@end enumerate
+
+The @code{_TIME_BITS} can be only used when @code{_FILE_OFFSET_BITS=64}
+is also defined.
+
+For the point @b{4} above, calls to proper syscalls depend on the
+Linux kernel version on which the system is running. For Linux kernel
+version above @b{5.1} syscalls supporting 64-bit time are used. Otherwise,
+a fallback code is used with legacy (i.e. 32-bit) syscalls.
+
+By using this macro certain ports gain support for 64-bit time and as
+a result become immune to Y2038 problem.
+@end defvr
+
 @defvr Macro _ISOC99_SOURCE
 @standards{GNU, (none)}
 If this macro is defined, features from ISO C99 are included.  Since
diff --git a/misc/sys/select.h b/misc/sys/select.h
index 188a7fe607..e9c0e8fc20 100644
--- a/misc/sys/select.h
+++ b/misc/sys/select.h
@@ -98,10 +98,23 @@ __BEGIN_DECLS
 
    This function is a cancellation point and therefore not marked with
    __THROW.  */
+#ifndef __USE_TIME_BITS64
 extern int select (int __nfds, fd_set *__restrict __readfds,
 		   fd_set *__restrict __writefds,
 		   fd_set *__restrict __exceptfds,
 		   struct timeval *__restrict __timeout);
+#else
+# ifdef __REDIRECT
+extern int __REDIRECT (select,
+                       (int __nfds, fd_set *__restrict __readfds,
+                        fd_set *__restrict __writefds,
+                        fd_set *__restrict __exceptfds,
+                        struct timeval *__restrict __timeout),
+                       __select64);
+# else
+#  define select __select64
+# endif
+#endif
 
 #ifdef __USE_XOPEN2K
 /* Same as above only that the TIMEOUT value is given with higher
@@ -110,11 +123,25 @@ extern int select (int __nfds, fd_set *__restrict __readfds,
 
    This function is a cancellation point and therefore not marked with
    __THROW.  */
+# ifndef __USE_TIME_BITS64
 extern int pselect (int __nfds, fd_set *__restrict __readfds,
 		    fd_set *__restrict __writefds,
 		    fd_set *__restrict __exceptfds,
 		    const struct timespec *__restrict __timeout,
 		    const __sigset_t *__restrict __sigmask);
+# else
+#  ifdef __REDIRECT
+extern int __REDIRECT (pselect,
+                       (int __nfds, fd_set *__restrict __readfds,
+                        fd_set *__restrict __writefds,
+                        fd_set *__restrict __exceptfds,
+                        const struct timespec *__restrict __timeout,
+                        const __sigset_t *__restrict __sigmask),
+                       __pselect64);
+#  else
+#   define pselect __pselect64
+#  endif
+# endif
 #endif
 
 
diff --git a/nptl/pthread_clockjoin.c b/nptl/pthread_clockjoin.c
index f5007d7831..2d01ba03a2 100644
--- a/nptl/pthread_clockjoin.c
+++ b/nptl/pthread_clockjoin.c
@@ -36,7 +36,8 @@ ___pthread_clockjoin_np64 (pthread_t threadid, void **thread_return,
 #if __TIMESIZE == 64
 strong_alias (___pthread_clockjoin_np64, ___pthread_clockjoin_np)
 #else /* __TIMESPEC64 != 64 */
-libc_hidden_ver (___pthread_clockjoin_np64, __pthread_clockjoin_np64)
+strong_alias (___pthread_clockjoin_np64, __pthread_clockjoin_np64)
+libc_hidden_def (__pthread_clockjoin_np64)
 
 int
 ___pthread_clockjoin_np (pthread_t threadid, void **thread_return,
diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
index 409a99ecb7..daba8600fe 100644
--- a/nptl/pthread_cond_wait.c
+++ b/nptl/pthread_cond_wait.c
@@ -647,10 +647,8 @@ ___pthread_cond_timedwait64 (pthread_cond_t *cond, pthread_mutex_t *mutex,
 #if __TIMESIZE == 64
 strong_alias (___pthread_cond_timedwait64, ___pthread_cond_timedwait)
 #else
-libc_hidden_ver (___pthread_cond_timedwait64, __pthread_cond_timedwait64)
-#ifndef SHARED
 strong_alias (___pthread_cond_timedwait64, __pthread_cond_timedwait64)
-#endif
+libc_hidden_def (__pthread_cond_timedwait64)
 
 int
 ___pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
@@ -688,9 +686,8 @@ ___pthread_cond_clockwait64 (pthread_cond_t *cond, pthread_mutex_t *mutex,
 #if __TIMESIZE == 64
 strong_alias (___pthread_cond_clockwait64, ___pthread_cond_clockwait)
 #else
-versioned_symbol (libc, ___pthread_cond_clockwait64,
-		  __pthread_cond_clockwait64, GLIBC_PRIVATE);
-libc_hidden_ver (___pthread_cond_clockwait64, __pthread_cond_clockwait64)
+strong_alias (___pthread_cond_clockwait64, __pthread_cond_clockwait64);
+libc_hidden_def (__pthread_cond_clockwait64)
 
 int
 ___pthread_cond_clockwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
index acd78131b2..5afd6222d6 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -585,7 +585,8 @@ ___pthread_mutex_clocklock64 (pthread_mutex_t *mutex,
 #if __TIMESIZE == 64
 strong_alias (___pthread_mutex_clocklock64, ___pthread_mutex_clocklock)
 #else /* __TIMESPEC64 != 64 */
-libc_hidden_ver (___pthread_mutex_clocklock64, __pthread_mutex_clocklock64)
+strong_alias (___pthread_mutex_clocklock64, __pthread_mutex_clocklock64)
+libc_hidden_def (__pthread_mutex_clocklock64)
 
 int
 ___pthread_mutex_clocklock (pthread_mutex_t *mutex,
@@ -618,9 +619,8 @@ ___pthread_mutex_timedlock64 (pthread_mutex_t *mutex,
 #if __TIMESIZE == 64
 strong_alias (___pthread_mutex_timedlock64, ___pthread_mutex_timedlock)
 #else /* __TIMESPEC64 != 64 */
-versioned_symbol (libc, ___pthread_mutex_timedlock64,
-		  __pthread_mutex_timedlock64, GLIBC_PRIVATE);
-libc_hidden_ver (___pthread_mutex_timedlock64, __pthread_mutex_timedlock64)
+strong_alias (___pthread_mutex_timedlock64, __pthread_mutex_timedlock64);
+libc_hidden_def (__pthread_mutex_timedlock64)
 
 int
 ___pthread_mutex_timedlock (pthread_mutex_t *mutex,
diff --git a/nptl/pthread_rwlock_clockrdlock.c b/nptl/pthread_rwlock_clockrdlock.c
index 9db96b9904..83ae1d1823 100644
--- a/nptl/pthread_rwlock_clockrdlock.c
+++ b/nptl/pthread_rwlock_clockrdlock.c
@@ -31,8 +31,8 @@ ___pthread_rwlock_clockrdlock64 (pthread_rwlock_t *rwlock, clockid_t clockid,
 #if __TIMESIZE == 64
 strong_alias (___pthread_rwlock_clockrdlock64, ___pthread_rwlock_clockrdlock)
 #else /* __TIMESPEC64 != 64 */
-libc_hidden_ver (___pthread_rwlock_clockrdlock64,
-		 __pthread_rwlock_clockrdlock64)
+strong_alias (___pthread_rwlock_clockrdlock64, __pthread_rwlock_clockrdlock64)
+libc_hidden_def (__pthread_rwlock_clockrdlock64)
 
 int
 ___pthread_rwlock_clockrdlock (pthread_rwlock_t *rwlock, clockid_t clockid,
diff --git a/nptl/pthread_rwlock_clockwrlock.c b/nptl/pthread_rwlock_clockwrlock.c
index ca0ebe2a65..08a2276da5 100644
--- a/nptl/pthread_rwlock_clockwrlock.c
+++ b/nptl/pthread_rwlock_clockwrlock.c
@@ -31,8 +31,8 @@ ___pthread_rwlock_clockwrlock64 (pthread_rwlock_t *rwlock, clockid_t clockid,
 #if __TIMESIZE == 64
 strong_alias (___pthread_rwlock_clockwrlock64, ___pthread_rwlock_clockwrlock)
 #else /* __TIMESPEC64 != 64 */
-libc_hidden_ver (___pthread_rwlock_clockwrlock64,
-		 __pthread_rwlock_clockwrlock64)
+strong_alias (___pthread_rwlock_clockwrlock64, __pthread_rwlock_clockwrlock64)
+libc_hidden_def (__pthread_rwlock_clockwrlock64)
 
 int
 ___pthread_rwlock_clockwrlock (pthread_rwlock_t *rwlock, clockid_t clockid,
diff --git a/nptl/pthread_rwlock_timedrdlock.c b/nptl/pthread_rwlock_timedrdlock.c
index dd9b7cb0a2..8c73af26fb 100644
--- a/nptl/pthread_rwlock_timedrdlock.c
+++ b/nptl/pthread_rwlock_timedrdlock.c
@@ -30,8 +30,8 @@ ___pthread_rwlock_timedrdlock64 (pthread_rwlock_t *rwlock,
 #if __TIMESIZE == 64
 strong_alias (___pthread_rwlock_timedrdlock64, ___pthread_rwlock_timedrdlock)
 #else /* __TIMESPEC64 != 64 */
-libc_hidden_ver (___pthread_rwlock_timedrdlock64,
-		 __pthread_rwlock_timedrdlock64)
+strong_alias (___pthread_rwlock_timedrdlock64, __pthread_rwlock_timedrdlock64)
+libc_hidden_def (__pthread_rwlock_timedrdlock64)
 
 int
 ___pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock,
diff --git a/nptl/pthread_rwlock_timedwrlock.c b/nptl/pthread_rwlock_timedwrlock.c
index e660a544cd..890da92968 100644
--- a/nptl/pthread_rwlock_timedwrlock.c
+++ b/nptl/pthread_rwlock_timedwrlock.c
@@ -30,8 +30,8 @@ ___pthread_rwlock_timedwrlock64 (pthread_rwlock_t *rwlock,
 #if __TIMESIZE == 64
 strong_alias (___pthread_rwlock_timedwrlock64, ___pthread_rwlock_timedwrlock)
 #else /* __TIMESPEC64 != 64 */
-libc_hidden_ver (___pthread_rwlock_timedwrlock64,
-		 __pthread_rwlock_timedwrlock64)
+strong_alias (___pthread_rwlock_timedwrlock64, __pthread_rwlock_timedwrlock64)
+libc_hidden_def (__pthread_rwlock_timedwrlock64)
 
 int
 ___pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock,
diff --git a/nptl/pthread_timedjoin.c b/nptl/pthread_timedjoin.c
index ebc31f935a..0b4026612f 100644
--- a/nptl/pthread_timedjoin.c
+++ b/nptl/pthread_timedjoin.c
@@ -31,7 +31,8 @@ ___pthread_timedjoin_np64 (pthread_t threadid, void **thread_return,
 #if __TIMESIZE == 64
 strong_alias (___pthread_timedjoin_np64, ___pthread_timedjoin_np)
 #else /* __TIMESPEC64 != 64 */
-libc_hidden_ver (___pthread_timedjoin_np64, __pthread_timedjoin_np64)
+strong_alias (___pthread_timedjoin_np64, __pthread_timedjoin_np64)
+libc_hidden_def (__pthread_timedjoin_np64)
 
 int
   ___pthread_timedjoin_np (pthread_t threadid, void **thread_return,
diff --git a/nptl/sem_clockwait.c b/nptl/sem_clockwait.c
index 2739799e26..19751aff04 100644
--- a/nptl/sem_clockwait.c
+++ b/nptl/sem_clockwait.c
@@ -49,7 +49,8 @@ ___sem_clockwait64 (sem_t *sem, clockid_t clockid,
 #if __TIMESIZE == 64
 strong_alias (___sem_clockwait64, ___sem_clockwait)
 #else /* __TIMESPEC64 != 64 */
-libc_hidden_ver (___sem_clockwait64, __sem_clockwait64)
+strong_alias (___sem_clockwait64, __sem_clockwait64)
+libc_hidden_def (__sem_clockwait64)
 
 int
 ___sem_clockwait (sem_t *sem, clockid_t clockid, const struct timespec *abstime)
diff --git a/nptl/sem_timedwait.c b/nptl/sem_timedwait.c
index 584546c706..5c8f37d3bb 100644
--- a/nptl/sem_timedwait.c
+++ b/nptl/sem_timedwait.c
@@ -45,10 +45,8 @@ ___sem_timedwait64 (sem_t *sem, const struct __timespec64 *abstime)
 #if __TIMESIZE == 64
 strong_alias (___sem_timedwait64, ___sem_timedwait)
 #else /* __TIMESPEC64 != 64 */
-libc_hidden_ver (___sem_timedwait64, __sem_timedwait64)
-#ifndef SHARED
 strong_alias (___sem_timedwait64, __sem_timedwait64)
-#endif
+libc_hidden_def (__sem_timedwait64)
 
 int
 ___sem_timedwait (sem_t *sem, const struct timespec *abstime)
diff --git a/posix/sched.h b/posix/sched.h
index d8ce08a3ea..7dd97a49b2 100644
--- a/posix/sched.h
+++ b/posix/sched.h
@@ -74,8 +74,17 @@ extern int sched_get_priority_max (int __algorithm) __THROW;
 extern int sched_get_priority_min (int __algorithm) __THROW;
 
 /* Get the SCHED_RR interval for the named process.  */
+#ifndef __USE_TIME_BITS64
 extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
-
+#else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (sched_rr_get_interval,
+                           (__pid_t __pid, struct timespec *__t),
+                           __sched_rr_get_interval64);
+# else
+#  define sched_rr_get_interval __sched_rr_get_interval64
+# endif
+#endif
 
 #ifdef __USE_GNU
 /* Access macros for `cpu_set'.  */
diff --git a/posix/sys/wait.h b/posix/sys/wait.h
index 9e7bb7f154..5325bfa4d2 100644
--- a/posix/sys/wait.h
+++ b/posix/sys/wait.h
@@ -144,14 +144,34 @@ struct rusage;
    nil, store information about the child's resource usage there.  If the
    WUNTRACED bit is set in OPTIONS, return status for stopped children;
    otherwise don't.  */
+# ifndef __USE_TIME_BITS64
 extern __pid_t wait3 (int *__stat_loc, int __options,
 		      struct rusage * __usage) __THROWNL;
+# else
+#  ifdef __REDIRECT_NTHNL
+extern __pid_t __REDIRECT_NTHNL (wait3, (int *__stat_loc, int __options,
+                                         struct rusage * __usage),
+                                 __wait3_time64);
+#  else
+#   define wait3 __wait3_time64
+#  endif
+# endif
 #endif
 
 #ifdef __USE_MISC
+# ifndef __USE_TIME_BITS64
 /* PID is like waitpid.  Other args are like wait3.  */
 extern __pid_t wait4 (__pid_t __pid, int *__stat_loc, int __options,
 		      struct rusage *__usage) __THROWNL;
+# else
+#  ifdef __REDIRECT_NTHNL
+extern __pid_t __REDIRECT_NTHNL (wait4, (__pid_t __pid, int *__stat_loc,
+                                         int __options, struct rusage *__usage),
+                                 __wait4_time64);
+#  else
+#   define wait4 __wait4_time64
+#  endif
+# endif
 #endif /* Use misc.  */
 
 
diff --git a/resolv/netdb.h b/resolv/netdb.h
index 1f36f25d4a..9b242ce3d1 100644
--- a/resolv/netdb.h
+++ b/resolv/netdb.h
@@ -701,6 +701,17 @@ extern int getaddrinfo_a (int __mode, struct gaicb *__list[__restrict_arr],
 extern int gai_suspend (const struct gaicb *const __list[], int __ent,
 			const struct timespec *__timeout);
 
+# ifdef __USE_TIME_BITS64
+#  if defined(__REDIRECT)
+extern int __REDIRECT (gai_suspend, (const struct gaicb *const __list[],
+                                     int __ent,
+                                     const struct timespec *__timeout),
+                       __gai_suspend_time64);
+#  else
+#   define gai_suspend __gai_suspend_time64
+#  endif
+# endif
+
 /* Get the error status of the request REQ.  */
 extern int gai_error (struct gaicb *__req) __THROW;
 
diff --git a/resource/sys/resource.h b/resource/sys/resource.h
index d30379d085..551d25e275 100644
--- a/resource/sys/resource.h
+++ b/resource/sys/resource.h
@@ -88,6 +88,16 @@ extern int setrlimit64 (__rlimit_resource_t __resource,
    and put it in *USAGE.  Returns 0 for success, -1 for failure.  */
 extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW;
 
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT_NTH)
+extern int __REDIRECT_NTH (getrusage, (__rusage_who_t __who,
+                                       struct rusage *__usage),
+                           __getrusage64);
+# else
+# define getrusage __getrusage64
+# endif
+#endif
+
 /* Return the highest priority of any process specified by WHICH and WHO
    (see above); if WHO is zero, the current process, process group, or user
    (as specified by WHO) is used.  A lower priority number means higher
diff --git a/rt/aio.h b/rt/aio.h
index 3a107b2783..72cf626690 100644
--- a/rt/aio.h
+++ b/rt/aio.h
@@ -193,12 +193,17 @@ extern __ssize_t __REDIRECT_NTH (aio_return, (struct aiocb *__aiocbp),
 extern int __REDIRECT_NTH (aio_cancel,
 			   (int __fildes, struct aiocb *__aiocbp),
 			   aio_cancel64);
-
+#  ifdef __USE_TIME_BITS64
+extern int __REDIRECT_NTH (aio_suspend,
+			   (const struct aiocb *const __list[], int __nent,
+			    const struct timespec *__restrict __timeout),
+			   __aio_suspend_time64) __nonnull ((1));
+#  else
 extern int __REDIRECT_NTH (aio_suspend,
 			   (const struct aiocb *const __list[], int __nent,
 			    const struct timespec *__restrict __timeout),
 			   aio_suspend64) __nonnull ((1));
-
+#  endif
 extern int __REDIRECT_NTH (aio_fsync,
 			   (int __operation, struct aiocb *__aiocbp),
 			   aio_fsync64) __nonnull ((2));
@@ -210,7 +215,11 @@ extern int __REDIRECT_NTH (aio_fsync,
 #  define aio_error aio_error64
 #  define aio_return aio_return64
 #  define aio_cancel aio_cancel64
-#  define aio_suspend aio_suspend64
+#  ifdef __USE_TIME_BITS64
+#   define aio_suspend __aio_suspend_time64
+#  else
+#   define aio_suspend aio_suspend64
+#  endif
 #  define aio_fsync aio_fsync64
 # endif
 #endif
diff --git a/rt/mqueue.h b/rt/mqueue.h
index 8a62d99f50..e8a85637e4 100644
--- a/rt/mqueue.h
+++ b/rt/mqueue.h
@@ -71,6 +71,7 @@ extern int mq_send (mqd_t __mqdes, const char *__msg_ptr, size_t __msg_len,
 		    unsigned int __msg_prio) __nonnull ((2));
 
 #ifdef __USE_XOPEN2K
+# ifndef __USE_TIME_BITS64
 /* Receive the oldest from highest priority messages in message queue
    MQDES, stop waiting if ABS_TIMEOUT expires.  */
 extern ssize_t mq_timedreceive (mqd_t __mqdes, char *__restrict __msg_ptr,
@@ -85,6 +86,27 @@ extern int mq_timedsend (mqd_t __mqdes, const char *__msg_ptr,
 			 size_t __msg_len, unsigned int __msg_prio,
 			 const struct timespec *__abs_timeout)
   __nonnull ((2, 5));
+# else
+#  ifdef __REDIRECT
+extern int __REDIRECT (mq_timedreceive, (mqd_t __mqdes,
+                               char *__restrict __msg_ptr,
+                               size_t __msg_len,
+                               unsigned int *__restrict __msg_prio,
+                               const struct timespec *__restrict __abs_timeout),
+                       __mq_timedreceive_time64)
+  __nonnull ((2, 5));
+
+extern int __REDIRECT (mq_timedsend, (mqd_t __mqdes,
+                       const char *__msg_ptr, size_t __msg_len,
+                       unsigned int __msg_prio,
+                       const struct timespec *__abs_timeout),
+		       __mq_timedsend_time64)
+  __nonnull ((2, 5));
+#  else
+#   define mq_timedreceive __mq_timedreceive_time64
+#   define mq_timedsend __mq_timedsend_time64
+#  endif
+# endif
 #endif
 
 /* Define some inlines helping to catch common problems.  */
diff --git a/signal/signal.h b/signal/signal.h
index b17203c99c..5fd93382fc 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -269,10 +269,23 @@ extern int sigwaitinfo (const sigset_t *__restrict __set,
 
    This function is a cancellation point and therefore not marked with
    __THROW.  */
+#  ifndef __USE_TIME_BITS64
 extern int sigtimedwait (const sigset_t *__restrict __set,
 			 siginfo_t *__restrict __info,
 			 const struct timespec *__restrict __timeout)
      __nonnull ((1));
+#  else
+#   ifdef __REDIRECT
+extern int __REDIRECT (sigtimedwait,
+                       (const sigset_t *__restrict __set,
+                        siginfo_t *__restrict __info,
+                        const struct timespec *__restrict __timeout),
+                       __sigtimedwait64)
+     __nonnull ((1));
+#   else
+#    define sigtimedwait __sigtimedwait64
+#   endif
+#  endif
 
 /* Send signal SIG to the process PID.  Associate data in VAL with the
    signal.  */
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 949851a6ce..5577e75b80 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -196,9 +196,20 @@ extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
 
    This function is a cancellation point and therefore not marked with
    __THROW.  */
+# ifndef __USE_TIME_BITS64
 extern int recvmmsg (int __fd, struct mmsghdr *__vmessages,
 		     unsigned int __vlen, int __flags,
 		     struct timespec *__tmo);
+# else
+#  ifdef __REDIRECT
+extern int __REDIRECT (recvmmsg, (int __fd, struct mmsghdr *__vmessages,
+                                  unsigned int __vlen, int __flags,
+                                  struct timespec *__tmo),
+                       __recvmmsg64);
+#  else
+#   define recvmmsg __recvmmsg64
+#  endif
+# endif
 #endif
 
 
diff --git a/sysdeps/generic/features-time64.h b/sysdeps/generic/features-time64.h
new file mode 100644
index 0000000000..a5a677f837
--- /dev/null
+++ b/sysdeps/generic/features-time64.h
@@ -0,0 +1,19 @@
+/* Features part to handle 64-bit time_t support.  Generic version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* The generic configuration only support _TIME_BITS=32.  */
diff --git a/sysdeps/generic/time64-compat.h b/sysdeps/generic/time64-compat.h
new file mode 100644
index 0000000000..6f0bf9dd08
--- /dev/null
+++ b/sysdeps/generic/time64-compat.h
@@ -0,0 +1,3 @@
+/* Header included by Versions to generate the 64-bit time_t compat symbols.
+   Legacy ABIs with default 32 bit time support define TIME64_NON_DEFAULT to
+   generate the 64-bit symbols.  */
diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
index 22e037dcb4..52e2eadbfc 100644
--- a/sysdeps/nptl/pthread.h
+++ b/sysdeps/nptl/pthread.h
@@ -221,6 +221,7 @@ extern int pthread_join (pthread_t __th, void **__thread_return);
    the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL.  */
 extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
 
+# ifndef __USE_TIME_BITS64
 /* Make calling thread wait for termination of the thread TH, but only
    until TIMEOUT.  The exit status of the thread is stored in
    *THREAD_RETURN, if THREAD_RETURN is not NULL.
@@ -240,6 +241,23 @@ extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
 extern int pthread_clockjoin_np (pthread_t __th, void **__thread_return,
                                  clockid_t __clockid,
 				 const struct timespec *__abstime);
+# else
+#  ifdef __REDIRECT
+extern int __REDIRECT (pthread_timedjoin_np,
+                       (pthread_t __th, void **__thread_return,
+                        const struct timespec *__abstime),
+                       __pthread_timedjoin_np64);
+
+extern int __REDIRECT (pthread_clockjoin_np,
+                       (pthread_t __th, void **__thread_return,
+                        clockid_t __clockid,
+                        const struct timespec *__abstime),
+                       __pthread_clockjoin_np64);
+#  else
+#   define pthread_timedjoin_np __pthread_timedjoin_np64
+#   define pthread_clockjoin_np __pthread_clockjoin_np64
+#  endif
+# endif
 #endif
 
 /* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
@@ -776,16 +794,39 @@ extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
 
 #ifdef __USE_XOPEN2K
 /* Wait until lock becomes available, or specified time passes. */
+# ifndef __USE_TIME_BITS64
 extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
 				    const struct timespec *__restrict
 				    __abstime) __THROWNL __nonnull ((1, 2));
+# else
+#  ifdef __REDIRECT_NTHNL
+extern int __REDIRECT_NTHNL (pthread_mutex_timedlock,
+                             (pthread_mutex_t *__restrict __mutex,
+                              const struct timespec *__restrict __abstime),
+                             __pthread_mutex_timedlock64) __nonnull ((1, 2));
+#  else
+#   define pthread_mutex_timedlock __pthread_mutex_timedlock64
+#  endif
+# endif
 #endif
 
 #ifdef __USE_GNU
+# ifndef __USE_TIME_BITS64
 extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex,
 				    clockid_t __clockid,
 				    const struct timespec *__restrict
 				    __abstime) __THROWNL __nonnull ((1, 3));
+# else
+#  ifdef __REDIRECT_NTHNL
+extern int __REDIRECT_NTHNL (pthread_mutex_clocklock,
+                             (pthread_mutex_t *__restrict __mutex,
+                              clockid_t __clockid,
+                              const struct timespec *__restrict __abstime),
+                             __pthread_mutex_clocklock64) __nonnull ((1, 3));
+#  else
+#   define pthread_mutex_clocklock __pthread_mutex_clocklock64
+#  endif
+# endif
 #endif
 
 /* Unlock a mutex.  */
@@ -939,16 +980,41 @@ extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
 
 # ifdef __USE_XOPEN2K
 /* Try to acquire read lock for RWLOCK or return after specfied time.  */
+#  ifndef __USE_TIME_BITS64
 extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
 				       const struct timespec *__restrict
 				       __abstime) __THROWNL __nonnull ((1, 2));
+#  else
+#   ifdef __REDIRECT_NTHNL
+extern int __REDIRECT_NTHNL (pthread_rwlock_timedrdlock,
+                             (pthread_rwlock_t *__restrict __rwlock,
+                              const struct timespec *__restrict __abstime),
+                             __pthread_rwlock_timedrdlock64)
+    __nonnull ((1, 2));
+#   else
+#    define pthread_rwlock_timedrdlock __pthread_rwlock_timedrdlock64
+#   endif
+#  endif
 # endif
 
 # ifdef __USE_GNU
+#  ifndef __USE_TIME_BITS64
 extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock,
 				       clockid_t __clockid,
 				       const struct timespec *__restrict
 				       __abstime) __THROWNL __nonnull ((1, 3));
+#  else
+#   ifdef __REDIRECT_NTHNL
+extern int __REDIRECT_NTHNL (pthread_rwlock_clockrdlock,
+                             (pthread_rwlock_t *__restrict __rwlock,
+                              clockid_t __clockid,
+                              const struct timespec *__restrict __abstime),
+                             __pthread_rwlock_clockrdlock64)
+    __nonnull ((1, 3));
+#   else
+#    define pthread_rwlock_clockrdlock __pthread_rwlock_clockrdlock64
+#   endif
+#  endif
 # endif
 
 /* Acquire write lock for RWLOCK.  */
@@ -961,16 +1027,42 @@ extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
 
 # ifdef __USE_XOPEN2K
 /* Try to acquire write lock for RWLOCK or return after specfied time.  */
+#  ifndef __USE_TIME_BITS64
 extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
 				       const struct timespec *__restrict
 				       __abstime) __THROWNL __nonnull ((1, 2));
+#  else
+#   ifdef __REDIRECT_NTHNL
+extern int __REDIRECT_NTHNL (pthread_rwlock_timedwrlock,
+                             (pthread_rwlock_t *__restrict __rwlock,
+                              const struct timespec *__restrict __abstime),
+                             __pthread_rwlock_timedwrlock64)
+    __nonnull ((1, 2));
+#   else
+#    define pthread_rwlock_timedwrlock __pthread_rwlock_timedwrlock64
+#   endif
+#  endif
 # endif
 
 # ifdef __USE_GNU
+#  ifndef __USE_TIME_BITS64
 extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock,
 				       clockid_t __clockid,
 				       const struct timespec *__restrict
 				       __abstime) __THROWNL __nonnull ((1, 3));
+
+#  else
+#   ifdef __REDIRECT_NTHNL
+extern int __REDIRECT_NTHNL (pthread_rwlock_clockwrlock,
+                             (pthread_rwlock_t *__restrict __rwlock,
+                              clockid_t __clockid,
+                              const struct timespec *__restrict __abstime),
+                             __pthread_rwlock_clockwrlock64)
+    __nonnull ((1, 3));
+#   else
+#    define pthread_rwlock_clockwrlock __pthread_rwlock_clockwrlock64
+#   endif
+#  endif
 # endif
 
 /* Unlock RWLOCK.  */
@@ -1047,10 +1139,23 @@ extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
 
    This function is a cancellation point and therefore not marked with
    __THROW.  */
+# ifndef __USE_TIME_BITS64
 extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
 				   pthread_mutex_t *__restrict __mutex,
 				   const struct timespec *__restrict __abstime)
      __nonnull ((1, 2, 3));
+# else
+#  ifdef __REDIRECT
+extern int __REDIRECT (pthread_cond_timedwait,
+                       (pthread_cond_t *__restrict __cond,
+                        pthread_mutex_t *__restrict __mutex,
+                        const struct timespec *__restrict __abstime),
+                       __pthread_cond_timedwait64)
+     __nonnull ((1, 2, 3));
+#  else
+#   define pthread_cond_timedwait __pthread_cond_timedwait64
+#  endif
+# endif
 
 # ifdef __USE_GNU
 /* Wait for condition variable COND to be signaled or broadcast until
@@ -1060,11 +1165,25 @@ extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
 
    This function is a cancellation point and therefore not marked with
    __THROW. */
+#  ifndef __USE_TIME_BITS64
 extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond,
 				   pthread_mutex_t *__restrict __mutex,
 				   __clockid_t __clock_id,
 				   const struct timespec *__restrict __abstime)
      __nonnull ((1, 2, 4));
+#  else
+#   ifdef __REDIRECT
+extern int __REDIRECT (pthread_cond_clockwait,
+                       (pthread_cond_t *__restrict __cond,
+                        pthread_mutex_t *__restrict __mutex,
+                        __clockid_t __clock_id,
+                        const struct timespec *__restrict __abstime),
+                       __pthread_cond_clockwait64)
+     __nonnull ((1, 2, 4));
+#   else
+#    define pthread_cond_clockwait __pthread_cond_clockwait64
+#   endif
+#  endif
 # endif
 
 /* Functions for handling condition variable attributes.  */
diff --git a/sysdeps/pthread/semaphore.h b/sysdeps/pthread/semaphore.h
index 7fb0e5c103..35780e7c4e 100644
--- a/sysdeps/pthread/semaphore.h
+++ b/sysdeps/pthread/semaphore.h
@@ -59,16 +59,41 @@ extern int sem_wait (sem_t *__sem) __nonnull ((1));
 
    This function is a cancellation point and therefore not marked with
    __THROW.  */
+# ifndef __USE_TIME_BITS64
 extern int sem_timedwait (sem_t *__restrict __sem,
 			  const struct timespec *__restrict __abstime)
   __nonnull ((1, 2));
+# else
+#  ifdef __REDIRECT
+extern int __REDIRECT (sem_timedwait,
+                       (sem_t *__restrict __sem,
+                        const struct timespec *__restrict __abstime),
+                        __sem_timedwait64)
+  __nonnull ((1, 2));
+#  else
+#   define sem_timedwait __sem_timedwait64
+#  endif
+# endif
 #endif
 
 #ifdef __USE_GNU
+# ifndef __USE_TIME_BITS64
 extern int sem_clockwait (sem_t *__restrict __sem,
 			  clockid_t clock,
 			  const struct timespec *__restrict __abstime)
   __nonnull ((1, 3));
+# else
+#  ifdef __REDIRECT
+extern int __REDIRECT (sem_clockwait,
+                       (sem_t *__restrict __sem,
+                        clockid_t clock,
+                        const struct timespec *__restrict __abstime),
+                        __sem_clockwait64)
+  __nonnull ((1, 3));
+#  else
+#   define sem_clockwait __sem_clockwait64
+#  endif
+# endif
 #endif
 
 /* Test whether SEM is posted.  */
diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h
index 46929a025e..bf251c9db4 100644
--- a/sysdeps/pthread/threads.h
+++ b/sysdeps/pthread/threads.h
@@ -88,8 +88,18 @@ extern thrd_t thrd_current (void);
    __TIME_POINT.  The current thread may resume if receives a signal.  In
    that case, if __REMAINING is not NULL, the remaining time is stored in
    the object pointed by it.  */
+#ifndef __USE_TIME_BITS64
 extern int thrd_sleep (const struct timespec *__time_point,
 		       struct timespec *__remaining);
+#else
+# ifdef __REDIRECT
+extern int __REDIRECT (thrd_sleep, (const struct timespec *__time_point,
+                                    struct timespec *__remaining),
+                       __thrd_sleep64);
+# else
+#  define thrd_sleep __thrd_sleep64
+# endif
+#endif
 
 /* Terminate current thread execution, cleaning up any thread local
    storage and freeing resources.  Returns the value specified in __RES.  */
@@ -131,8 +141,19 @@ extern int mtx_lock (mtx_t *__mutex);
 /* Block the current thread until the mutex pointed by __MUTEX is unlocked
    or time pointed by __TIME_POINT is reached.  In case the mutex is unlock,
    the current thread will not be blocked.  */
+#ifndef __USE_TIME_BITS64
 extern int mtx_timedlock (mtx_t *__restrict __mutex,
 			  const struct timespec *__restrict __time_point);
+#else
+# ifdef __REDIRECT
+extern int __REDIRECT (mtx_timedlock, (mtx_t *__restrict __mutex,
+                                       const struct timespec *__restrict
+                                       __time_point),
+                       __mtx_timedlock64);
+# else
+#  define mtx_timedlock __mtx_timedlock64
+# endif
+#endif
 
 /* Try to lock the mutex pointed by __MUTEX without blocking.  If the mutex
    is free the current threads takes control of it, otherwise it returns
@@ -171,9 +192,21 @@ extern int cnd_wait (cnd_t *__cond, mtx_t *__mutex);
 /* Block current thread on the condition variable until condition variable
    pointed by __COND is signaled or time pointed by __TIME_POINT is
    reached.  */
+#ifndef __USE_TIME_BITS64
 extern int cnd_timedwait (cnd_t *__restrict __cond,
 			  mtx_t *__restrict __mutex,
 			  const struct timespec *__restrict __time_point);
+#else
+# ifdef __REDIRECT
+extern int __REDIRECT (cnd_timedwait, (cnd_t *__restrict __cond,
+                                       mtx_t *__restrict __mutex,
+                                       const struct timespec *__restrict
+                                       __time_point),
+                       __cnd_timedwait64);
+# else
+#  define cnd_timedwait __cnd_timedwait64
+# endif
+#endif
 
 /* Destroy condition variable pointed by __cond and free all of its
    resources.  */
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 8b4d3a6a54..aedd02fd55 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -102,8 +102,11 @@ sysdep_headers += sys/mount.h sys/acct.h \
 		  bits/ipc-perm.h \
 		  bits/struct_stat.h \
 		  bits/struct_stat_time64_helper.h \
+		  bits/types/struct_msqid64_ds.h \
 		  bits/types/struct_msqid64_ds_helper.h \
+		  bits/types/struct_semid64_ds.h \
 		  bits/types/struct_semid64_ds_helper.h \
+		  bits/types/struct_shmid64_ds.h \
 		  bits/types/struct_shmid64_ds_helper.h
 
 tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index 4637fd651d..0aa2ef8559 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -1,3 +1,4 @@
+%include <time64-compat.h>
 libc {
   GLIBC_2.0 {
     # functions used in inline functions or macros
@@ -185,6 +186,81 @@ libc {
     getdents64; gettid; tgkill;
   }
   GLIBC_2.32 {
+  }
+  GLIBC_2.34 {
+%ifdef TIME64_NON_DEFAULT
+    # 64-bit time_t support
+    __adjtime64;
+    ___adjtimex64;
+    __clock_adjtime64;
+    __clock_getres64;
+    __clock_gettime64;
+    __clock_nanosleep_time64;
+    __clock_settime64;
+    __cnd_timedwait64;
+    __ctime64;
+    __ctime64_r;
+    __difftime64;
+    __fstat64_time64;
+    __fstatat64_time64;
+    __futimens64;
+    __futimes64;
+    __futimesat64;
+    __getitimer64;
+    __getrusage64;
+    __gettimeofday64;
+    __gmtime64;
+    __gmtime64_r;
+    __localtime64;
+    __localtime64_r;
+    __lstat64_time64;
+    __lutimes64;
+    __mktime64;
+    __msgctl64;
+    __mtx_timedlock64;
+    __nanosleep64;
+    __nanosleep64;
+    __ntp_gettime64;
+    __ntp_gettimex64;
+    __ppoll64;
+    __pselec64;
+    __pselect64;
+    __pthread_clockjoin_np64;
+    __pthread_cond_clockwait64;
+    __pthread_cond_timedwait64;
+    __pthread_mutex_clocklock64;
+    __pthread_mutex_timedlock64;
+    __pthread_rwlock_clockrdlock64;
+    __pthread_rwlock_clockwrlock64;
+    __pthread_rwlock_timedrdlock64;
+    __pthread_rwlock_timedwrlock64;
+    __pthread_timedjoin_np64;
+    __recvmmsg64;
+    __sched_rr_get_interval64;
+    __select64;
+    __sem_clockwait64;
+    __semctl64;
+    __semtimedop64;
+    __sem_timedwait64;
+    __setitimer64;
+    __settimeofday64;
+    __shmctl64;
+    __sigtimedwait64;
+    __stat64_time64;
+    __thrd_sleep64;
+    __time64;
+    __timegm64;
+    __timerfd_gettime64;
+    __timerfd_settime64;
+    __timespec_get64;
+    __timespec_getres64;
+    __utime64;
+    __utimensat64;
+    __utimes64;
+    __utimes64;
+    __wait3_time64;
+    __wait4_time64;
+%endif
   }
   GLIBC_PRIVATE {
     # functions used in other libraries
@@ -205,3 +281,24 @@ ld {
     __nptl_change_stack_perm;
   }
 }
+
+librt {
+  GLIBC_2.34 {
+%ifdef TIME64_NON_DEFAULT
+    # 64-bit time_t support
+    __aio_suspend_time64;
+    __mq_timedsend_time64;
+    __mq_timedreceive_time64;
+    __timer_gettime64;
+    __timer_settime64;
+%endif
+  }
+}
+
+libanl {
+%ifdef TIME64_NON_DEFAULT
+  GLIBC_2.34 {
+    __gai_suspend_time64;
+  }
+%endif
+}
diff --git a/sysdeps/unix/sysv/linux/arm/be/libanl.abilist b/sysdeps/unix/sysv/linux/arm/be/libanl.abilist
index a8fafedb66..37f9b49e52 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libanl.abilist
@@ -1,3 +1,4 @@
+GLIBC_2.34 __gai_suspend_time64 F
 GLIBC_2.4 gai_cancel F
 GLIBC_2.4 gai_error F
 GLIBC_2.4 gai_suspend F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index f66ee7aab1..1d32514579 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -190,16 +190,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/arm/be/librt.abilist b/sysdeps/unix/sysv/linux/arm/be/librt.abilist
index 3c0647b251..8cb1ed626c 100644
--- a/sysdeps/unix/sysv/linux/arm/be/librt.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/librt.abilist
@@ -1,3 +1,8 @@
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 aio_cancel F
 GLIBC_2.4 aio_cancel64 F
 GLIBC_2.4 aio_error F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libanl.abilist b/sysdeps/unix/sysv/linux/arm/le/libanl.abilist
index a8fafedb66..37f9b49e52 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libanl.abilist
@@ -1,3 +1,4 @@
+GLIBC_2.34 __gai_suspend_time64 F
 GLIBC_2.4 gai_cancel F
 GLIBC_2.4 gai_error F
 GLIBC_2.4 gai_suspend F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index 3798b32830..05d0878232 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -187,16 +187,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/arm/le/librt.abilist b/sysdeps/unix/sysv/linux/arm/le/librt.abilist
index 3c0647b251..8cb1ed626c 100644
--- a/sysdeps/unix/sysv/linux/arm/le/librt.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/librt.abilist
@@ -1,3 +1,8 @@
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 aio_cancel F
 GLIBC_2.4 aio_cancel64 F
 GLIBC_2.4 aio_error F
diff --git a/sysdeps/unix/sysv/linux/arm/time64-compat.h b/sysdeps/unix/sysv/linux/arm/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arm/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/bits/msq.h b/sysdeps/unix/sysv/linux/bits/msq.h
index 3313b69d78..7c9c479551 100644
--- a/sysdeps/unix/sysv/linux/bits/msq.h
+++ b/sysdeps/unix/sysv/linux/bits/msq.h
@@ -26,6 +26,7 @@ typedef __syscall_ulong_t msgqnum_t;
 typedef __syscall_ulong_t msglen_t;
 
 #include <bits/types/struct_msqid_ds.h>
+#include <bits/types/struct_msqid64_ds.h>
 
 /* Define options for message queue functions.  */
 #define MSG_NOERROR	010000	/* no error if message is too big */
diff --git a/sysdeps/unix/sysv/linux/bits/sem.h b/sysdeps/unix/sysv/linux/bits/sem.h
index ad13287e66..776524b876 100644
--- a/sysdeps/unix/sysv/linux/bits/sem.h
+++ b/sysdeps/unix/sysv/linux/bits/sem.h
@@ -22,6 +22,7 @@
 #include <sys/types.h>
 #include <bits/timesize.h>
 #include <bits/types/struct_semid_ds.h>
+#include <bits/types/struct_semid64_ds.h>
 
 /* Flags for `semop'.  */
 #define SEM_UNDO	0x1000		/* undo the operation on exit */
diff --git a/sysdeps/unix/sysv/linux/bits/shm.h b/sysdeps/unix/sysv/linux/bits/shm.h
index a50c79d7be..454fc3f366 100644
--- a/sysdeps/unix/sysv/linux/bits/shm.h
+++ b/sysdeps/unix/sysv/linux/bits/shm.h
@@ -43,6 +43,7 @@ __BEGIN_DECLS
 typedef __syscall_ulong_t shmatt_t;
 
 #include <bits/types/struct_shmid_ds.h>
+#include <bits/types/struct_shmid64_ds.h>
 
 #ifdef __USE_MISC
 
diff --git a/sysdeps/unix/sysv/linux/bits/time.h b/sysdeps/unix/sysv/linux/bits/time.h
index ee5a8b3ef4..d0c98a7864 100644
--- a/sysdeps/unix/sysv/linux/bits/time.h
+++ b/sysdeps/unix/sysv/linux/bits/time.h
@@ -77,6 +77,16 @@ __BEGIN_DECLS
 /* Tune a POSIX clock.  */
 extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW;
 
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT_NTH)
+extern int __REDIRECT_NTH (clock_adjtime, (__clockid_t __clock_id,
+                                           struct timex *__utx),
+                           __clock_adjtime64);
+# else
+# define clock_adjtime __clock_adjtime64
+# endif
+#endif
+
 __END_DECLS
 #endif /* use GNU */
 
diff --git a/sysdeps/unix/sysv/linux/cnd_timedwait.c b/sysdeps/unix/sysv/linux/cnd_timedwait.c
index 0415c683f9..6e8ce3d61b 100644
--- a/sysdeps/unix/sysv/linux/cnd_timedwait.c
+++ b/sysdeps/unix/sysv/linux/cnd_timedwait.c
@@ -21,8 +21,8 @@
 #include "thrd_priv.h"
 
 int
-___cnd_timedwait64 (cnd_t *restrict cond, mtx_t *restrict mutex,
-                    const struct __timespec64 *restrict time_point)
+__cnd_timedwait64 (cnd_t *restrict cond, mtx_t *restrict mutex,
+                   const struct __timespec64 *restrict time_point)
 {
   int err_code = __pthread_cond_timedwait64 ((pthread_cond_t *) cond,
                                              (pthread_mutex_t *) mutex,
@@ -31,9 +31,9 @@ ___cnd_timedwait64 (cnd_t *restrict cond, mtx_t *restrict mutex,
 }
 
 #if __TIMESIZE == 64
-strong_alias (___cnd_timedwait64, ___cnd_timedwait)
+strong_alias (__cnd_timedwait64, ___cnd_timedwait)
 #else
-libc_hidden_ver (___cnd_timedwait64, __cnd_timedwait64)
+libc_hidden_def (__cnd_timedwait64)
 
 int
 ___cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex,
diff --git a/sysdeps/unix/sysv/linux/csky/libanl.abilist b/sysdeps/unix/sysv/linux/csky/libanl.abilist
index 416a6f8ddb..01f2e6cbf0 100644
--- a/sysdeps/unix/sysv/linux/csky/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.29 gai_cancel F
 GLIBC_2.29 gai_error F
 GLIBC_2.29 gai_suspend F
 GLIBC_2.29 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index ba53b61ea6..ac9f009f38 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2277,16 +2277,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/csky/librt.abilist b/sysdeps/unix/sysv/linux/csky/librt.abilist
index c6690ef7c1..b60deca65a 100644
--- a/sysdeps/unix/sysv/linux/csky/librt.abilist
+++ b/sysdeps/unix/sysv/linux/csky/librt.abilist
@@ -33,3 +33,8 @@ GLIBC_2.29 timer_delete F
 GLIBC_2.29 timer_getoverrun F
 GLIBC_2.29 timer_gettime F
 GLIBC_2.29 timer_settime F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
diff --git a/sysdeps/unix/sysv/linux/csky/time64-compat.h b/sysdeps/unix/sysv/linux/csky/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/features-time64.h b/sysdeps/unix/sysv/linux/features-time64.h
new file mode 100644
index 0000000000..1f786f903b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/features-time64.h
@@ -0,0 +1,37 @@
+/* Features part to handle 64-bit time_t support.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* We need to know the word size in order to check the time size.  */
+#include <bits/wordsize.h>
+#include <bits/timesize.h>
+
+#if defined _TIME_BITS
+# if _TIME_BITS == 64
+#  if ! defined (_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64
+#   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
+#  elif __TIMESIZE == 32
+#   define __USE_TIME_BITS64	1
+#  endif
+# elif _TIME_BITS == 32
+#  if __TIMESIZE > 32
+#   error "_TIME_BITS=32 is not compatible with __TIMESIZE > 32"
+#  endif
+# else
+#  error Invalid _TIME_BITS value (can only be 32 or 64-bit)
+# endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/libanl.abilist b/sysdeps/unix/sysv/linux/hppa/libanl.abilist
index d9a5ed015d..ff719e7605 100644
--- a/sysdeps/unix/sysv/linux/hppa/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2.3 gai_cancel F
 GLIBC_2.2.3 gai_error F
 GLIBC_2.2.3 gai_suspend F
 GLIBC_2.2.3 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index 9783504c93..d2770a4874 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2231,16 +2231,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/hppa/librt.abilist b/sysdeps/unix/sysv/linux/hppa/librt.abilist
index bb03781dcc..463a88a1df 100644
--- a/sysdeps/unix/sysv/linux/hppa/librt.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/librt.abilist
@@ -32,6 +32,11 @@ GLIBC_2.3.4 mq_setattr F
 GLIBC_2.3.4 mq_timedreceive F
 GLIBC_2.3.4 mq_timedsend F
 GLIBC_2.3.4 mq_unlink F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.7 __mq_open_2 F
diff --git a/sysdeps/unix/sysv/linux/hppa/time64-compat.h b/sysdeps/unix/sysv/linux/hppa/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/hppa/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/i386/libanl.abilist b/sysdeps/unix/sysv/linux/i386/libanl.abilist
index d9a5ed015d..ff719e7605 100644
--- a/sysdeps/unix/sysv/linux/i386/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2.3 gai_cancel F
 GLIBC_2.2.3 gai_error F
 GLIBC_2.2.3 gai_suspend F
 GLIBC_2.2.3 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index c223c360ff..eb20d66c28 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2414,17 +2414,84 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __isnanf128 F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/i386/librt.abilist b/sysdeps/unix/sysv/linux/i386/librt.abilist
index bb03781dcc..463a88a1df 100644
--- a/sysdeps/unix/sysv/linux/i386/librt.abilist
+++ b/sysdeps/unix/sysv/linux/i386/librt.abilist
@@ -32,6 +32,11 @@ GLIBC_2.3.4 mq_setattr F
 GLIBC_2.3.4 mq_timedreceive F
 GLIBC_2.3.4 mq_timedsend F
 GLIBC_2.3.4 mq_unlink F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.7 __mq_open_2 F
diff --git a/sysdeps/unix/sysv/linux/i386/time64-compat.h b/sysdeps/unix/sysv/linux/i386/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/include/sys/msg.h b/sysdeps/unix/sysv/linux/include/sys/msg.h
index 522903f818..c460be0dc9 100644
--- a/sysdeps/unix/sysv/linux/include/sys/msg.h
+++ b/sysdeps/unix/sysv/linux/include/sys/msg.h
@@ -7,8 +7,6 @@ extern ssize_t __libc_msgrcv (int msqid, void *msgp, size_t msgsz,
 extern int __libc_msgsnd (int msqid, const void *msgp, size_t msgsz,
 			  int msgflg);
 
-# include <bits/types/struct_msqid64_ds.h>
-
 # if __TIMESIZE == 64
 #  define __msgctl64 __msgctl
 # else
diff --git a/sysdeps/unix/sysv/linux/include/sys/shm.h b/sysdeps/unix/sysv/linux/include/sys/shm.h
index 530a1cdfc9..85177a632d 100644
--- a/sysdeps/unix/sysv/linux/include/sys/shm.h
+++ b/sysdeps/unix/sysv/linux/include/sys/shm.h
@@ -3,8 +3,6 @@
 
 #ifndef _ISOMAC
 
-# include <bits/types/struct_shmid64_ds.h>
-
 # if __TIMESIZE == 64
 #  define __shmctl64 __shmctl
 # else
diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
index e136ed172e..c554248ed9 100644
--- a/sysdeps/unix/sysv/linux/include/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
@@ -23,10 +23,12 @@
 
 # ifndef _ISOMAC
 
+extern int __adjtimex (struct timex *__ntx);
 libc_hidden_proto (__adjtimex)
 
 #  include <time.h>
 #  include <struct___timeval64.h>
+
 /* Local definition of 64 bit time supporting timex struct */
 #  if __TIMESIZE == 64
 #   define __timex64 timex
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libanl.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libanl.abilist
index a8fafedb66..37f9b49e52 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libanl.abilist
@@ -1,3 +1,4 @@
+GLIBC_2.34 __gai_suspend_time64 F
 GLIBC_2.4 gai_cancel F
 GLIBC_2.4 gai_error F
 GLIBC_2.4 gai_suspend F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index 3cb4279b41..044cec51fc 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -191,16 +191,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/librt.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/librt.abilist
index 3c0647b251..8cb1ed626c 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/librt.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/librt.abilist
@@ -1,3 +1,8 @@
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 aio_cancel F
 GLIBC_2.4 aio_cancel64 F
 GLIBC_2.4 aio_error F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libanl.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libanl.abilist
index d9a5ed015d..ff719e7605 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2.3 gai_cancel F
 GLIBC_2.2.3 gai_error F
 GLIBC_2.2.3 gai_suspend F
 GLIBC_2.2.3 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 94a718ff58..3a6463a3ef 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2358,16 +2358,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/librt.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/librt.abilist
index bb03781dcc..463a88a1df 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/librt.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/librt.abilist
@@ -32,6 +32,11 @@ GLIBC_2.3.4 mq_setattr F
 GLIBC_2.3.4 mq_timedreceive F
 GLIBC_2.3.4 mq_timedsend F
 GLIBC_2.3.4 mq_unlink F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.7 __mq_open_2 F
diff --git a/sysdeps/unix/sysv/linux/m68k/time64-compat.h b/sysdeps/unix/sysv/linux/m68k/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/m68k/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libanl.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libanl.abilist
index 67c7554803..c06e33a1cf 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.18 gai_cancel F
 GLIBC_2.18 gai_error F
 GLIBC_2.18 gai_suspend F
 GLIBC_2.18 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 5823bf18ef..612d7f1c58 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2328,16 +2328,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/librt.abilist b/sysdeps/unix/sysv/linux/microblaze/be/librt.abilist
index 889dfbc0ee..1b8fc10087 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/librt.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/librt.abilist
@@ -33,3 +33,8 @@ GLIBC_2.18 timer_delete F
 GLIBC_2.18 timer_getoverrun F
 GLIBC_2.18 timer_gettime F
 GLIBC_2.18 timer_settime F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libanl.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libanl.abilist
index 67c7554803..c06e33a1cf 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.18 gai_cancel F
 GLIBC_2.18 gai_error F
 GLIBC_2.18 gai_suspend F
 GLIBC_2.18 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index 723c4bcb09..685cb974c3 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2325,16 +2325,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/librt.abilist b/sysdeps/unix/sysv/linux/microblaze/le/librt.abilist
index 889dfbc0ee..1b8fc10087 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/librt.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/librt.abilist
@@ -33,3 +33,8 @@ GLIBC_2.18 timer_delete F
 GLIBC_2.18 timer_getoverrun F
 GLIBC_2.18 timer_gettime F
 GLIBC_2.18 timer_settime F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/time64-compat.h b/sysdeps/unix/sysv/linux/microblaze/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/microblaze/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index f67da8f37a..d17b5a02a5 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2323,16 +2323,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/libanl.abilist b/sysdeps/unix/sysv/linux/mips/mips32/libanl.abilist
index d9a5ed015d..ff719e7605 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2.3 gai_cancel F
 GLIBC_2.2.3 gai_error F
 GLIBC_2.2.3 gai_suspend F
 GLIBC_2.2.3 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/librt.abilist b/sysdeps/unix/sysv/linux/mips/mips32/librt.abilist
index 1539c1cef9..c4dd28e3b2 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/librt.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/librt.abilist
@@ -32,6 +32,11 @@ GLIBC_2.3.4 mq_setattr F
 GLIBC_2.3.4 mq_timedreceive F
 GLIBC_2.3.4 mq_timedsend F
 GLIBC_2.3.4 mq_unlink F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.7 __mq_open_2 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index e44a6be8aa..aba6bd2e3c 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2321,16 +2321,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/time64-compat.h b/sysdeps/unix/sysv/linux/mips/mips32/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips32/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libanl.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libanl.abilist
index d9a5ed015d..ff719e7605 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2.3 gai_cancel F
 GLIBC_2.2.3 gai_error F
 GLIBC_2.2.3 gai_suspend F
 GLIBC_2.2.3 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index 21cbe39166..88d8e2af38 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2329,16 +2329,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/librt.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/librt.abilist
index 1539c1cef9..c4dd28e3b2 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/librt.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/librt.abilist
@@ -32,6 +32,11 @@ GLIBC_2.3.4 mq_setattr F
 GLIBC_2.3.4 mq_timedreceive F
 GLIBC_2.3.4 mq_timedsend F
 GLIBC_2.3.4 mq_unlink F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.7 __mq_open_2 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/time64-compat.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/mtx_timedlock.c b/sysdeps/unix/sysv/linux/mtx_timedlock.c
index 7715ebb315..8983eb8556 100644
--- a/sysdeps/unix/sysv/linux/mtx_timedlock.c
+++ b/sysdeps/unix/sysv/linux/mtx_timedlock.c
@@ -21,8 +21,8 @@
 #include "thrd_priv.h"
 
 int
-___mtx_timedlock64 (mtx_t *restrict mutex,
-                    const struct __timespec64 *restrict time_point)
+__mtx_timedlock64 (mtx_t *restrict mutex,
+                   const struct __timespec64 *restrict time_point)
 {
   int err_code = __pthread_mutex_timedlock64 ((pthread_mutex_t *)mutex,
                                               time_point);
@@ -30,9 +30,9 @@ ___mtx_timedlock64 (mtx_t *restrict mutex,
 }
 
 #if __TIMESIZE == 64
-strong_alias (___mtx_timedlock64, ___mtx_timedlock)
+strong_alias (__mtx_timedlock64, ___mtx_timedlock)
 #else
-libc_hidden_ver (___mtx_timedlock64, __mtx_timedlock64)
+libc_hidden_def (__mtx_timedlock64)
 
 int
 ___mtx_timedlock (mtx_t *restrict mutex,
diff --git a/sysdeps/unix/sysv/linux/nios2/libanl.abilist b/sysdeps/unix/sysv/linux/nios2/libanl.abilist
index 6ff9c2d94e..6b080bd075 100644
--- a/sysdeps/unix/sysv/linux/nios2/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.21 gai_cancel F
 GLIBC_2.21 gai_error F
 GLIBC_2.21 gai_suspend F
 GLIBC_2.21 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 9429209215..3b64e2cf51 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2367,16 +2367,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/nios2/librt.abilist b/sysdeps/unix/sysv/linux/nios2/librt.abilist
index b4ae7a2dc2..2458614125 100644
--- a/sysdeps/unix/sysv/linux/nios2/librt.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/librt.abilist
@@ -33,3 +33,8 @@ GLIBC_2.21 timer_delete F
 GLIBC_2.21 timer_getoverrun F
 GLIBC_2.21 timer_gettime F
 GLIBC_2.21 timer_settime F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
diff --git a/sysdeps/unix/sysv/linux/nios2/time64-compat.h b/sysdeps/unix/sysv/linux/nios2/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index eaca8e4b0c..5404fdea4a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2385,16 +2385,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libanl.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libanl.abilist
index d9a5ed015d..ff719e7605 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2.3 gai_cancel F
 GLIBC_2.2.3 gai_error F
 GLIBC_2.2.3 gai_suspend F
 GLIBC_2.2.3 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist
index bb03781dcc..463a88a1df 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist
@@ -32,6 +32,11 @@ GLIBC_2.3.4 mq_setattr F
 GLIBC_2.3.4 mq_timedreceive F
 GLIBC_2.3.4 mq_timedsend F
 GLIBC_2.3.4 mq_unlink F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.7 __mq_open_2 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index c754a181da..506fa3619f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2418,16 +2418,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/time64-compat.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libanl.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libanl.abilist
index d9a5ed015d..ff719e7605 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2.3 gai_cancel F
 GLIBC_2.2.3 gai_error F
 GLIBC_2.2.3 gai_suspend F
 GLIBC_2.2.3 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index 963e27571d..99b6d6d1ce 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2383,16 +2383,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/librt.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/librt.abilist
index bb03781dcc..463a88a1df 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/librt.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/librt.abilist
@@ -32,6 +32,11 @@ GLIBC_2.3.4 mq_setattr F
 GLIBC_2.3.4 mq_timedreceive F
 GLIBC_2.3.4 mq_timedsend F
 GLIBC_2.3.4 mq_unlink F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.7 __mq_open_2 F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/time64-compat.h b/sysdeps/unix/sysv/linux/s390/s390-32/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c
index 1043b2b80d..bb2690d30f 100644
--- a/sysdeps/unix/sysv/linux/semctl.c
+++ b/sysdeps/unix/sysv/linux/semctl.c
@@ -21,7 +21,6 @@
 #include <ipc_priv.h>
 #include <sysdep.h>
 #include <shlib-compat.h>
-#include <bits/types/struct_semid64_ds.h>  /* For __semid64_ds.  */
 #include <linux/posix_types.h>             /* For __kernel_mode_t.  */
 
 /* The struct used to issue the syscall.  For architectures that assume
diff --git a/sysdeps/unix/sysv/linux/sh/be/libanl.abilist b/sysdeps/unix/sysv/linux/sh/be/libanl.abilist
index d9a5ed015d..ff719e7605 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2.3 gai_cancel F
 GLIBC_2.2.3 gai_error F
 GLIBC_2.2.3 gai_suspend F
 GLIBC_2.2.3 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index 456abfb5bb..68a631b161 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2238,16 +2238,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/sh/be/librt.abilist b/sysdeps/unix/sysv/linux/sh/be/librt.abilist
index bb03781dcc..463a88a1df 100644
--- a/sysdeps/unix/sysv/linux/sh/be/librt.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/librt.abilist
@@ -32,6 +32,11 @@ GLIBC_2.3.4 mq_setattr F
 GLIBC_2.3.4 mq_timedreceive F
 GLIBC_2.3.4 mq_timedsend F
 GLIBC_2.3.4 mq_unlink F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.7 __mq_open_2 F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libanl.abilist b/sysdeps/unix/sysv/linux/sh/le/libanl.abilist
index d9a5ed015d..ff719e7605 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2.3 gai_cancel F
 GLIBC_2.2.3 gai_error F
 GLIBC_2.2.3 gai_suspend F
 GLIBC_2.2.3 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index 45e59f1821..61a29e643a 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2235,16 +2235,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/sh/le/librt.abilist b/sysdeps/unix/sysv/linux/sh/le/librt.abilist
index bb03781dcc..463a88a1df 100644
--- a/sysdeps/unix/sysv/linux/sh/le/librt.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/librt.abilist
@@ -32,6 +32,11 @@ GLIBC_2.3.4 mq_setattr F
 GLIBC_2.3.4 mq_timedreceive F
 GLIBC_2.3.4 mq_timedsend F
 GLIBC_2.3.4 mq_unlink F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.7 __mq_open_2 F
diff --git a/sysdeps/unix/sysv/linux/sh/time64-compat.h b/sysdeps/unix/sysv/linux/sh/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sh/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libanl.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libanl.abilist
index d9a5ed015d..ff719e7605 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libanl.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libanl.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2.3 gai_cancel F
 GLIBC_2.2.3 gai_error F
 GLIBC_2.2.3 gai_suspend F
 GLIBC_2.2.3 getaddrinfo_a F
+GLIBC_2.34 __gai_suspend_time64 F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index 734e1f38b6..fa3ae954c1 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2376,16 +2376,83 @@ GLIBC_2.33 mknod F
 GLIBC_2.33 mknodat F
 GLIBC_2.33 stat F
 GLIBC_2.33 stat64 F
+GLIBC_2.34 ___adjtimex64 F
+GLIBC_2.34 __adjtime64 F
+GLIBC_2.34 __clock_adjtime64 F
+GLIBC_2.34 __clock_getres64 F
+GLIBC_2.34 __clock_gettime64 F
+GLIBC_2.34 __clock_nanosleep_time64 F
+GLIBC_2.34 __clock_settime64 F
+GLIBC_2.34 __cnd_timedwait64 F
+GLIBC_2.34 __ctime64 F
+GLIBC_2.34 __ctime64_r F
+GLIBC_2.34 __difftime64 F
+GLIBC_2.34 __fstat64_time64 F
+GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __futimens64 F
+GLIBC_2.34 __futimes64 F
+GLIBC_2.34 __futimesat64 F
+GLIBC_2.34 __getitimer64 F
+GLIBC_2.34 __getrusage64 F
+GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __gmtime64 F
+GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
+GLIBC_2.34 __localtime64 F
+GLIBC_2.34 __localtime64_r F
+GLIBC_2.34 __lstat64_time64 F
+GLIBC_2.34 __lutimes64 F
+GLIBC_2.34 __mktime64 F
+GLIBC_2.34 __msgctl64 F
+GLIBC_2.34 __mtx_timedlock64 F
+GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __ntp_gettime64 F
+GLIBC_2.34 __ntp_gettimex64 F
+GLIBC_2.34 __ppoll64 F
+GLIBC_2.34 __pselect64 F
 GLIBC_2.34 __pthread_cleanup_routine F
+GLIBC_2.34 __pthread_clockjoin_np64 F
+GLIBC_2.34 __pthread_cond_clockwait64 F
+GLIBC_2.34 __pthread_cond_timedwait64 F
 GLIBC_2.34 __pthread_key_create F
+GLIBC_2.34 __pthread_mutex_clocklock64 F
 GLIBC_2.34 __pthread_mutex_lock F
+GLIBC_2.34 __pthread_mutex_timedlock64 F
 GLIBC_2.34 __pthread_mutex_unlock F
 GLIBC_2.34 __pthread_register_cancel F
 GLIBC_2.34 __pthread_register_cancel_defer F
+GLIBC_2.34 __pthread_rwlock_clockrdlock64 F
+GLIBC_2.34 __pthread_rwlock_clockwrlock64 F
+GLIBC_2.34 __pthread_rwlock_timedrdlock64 F
+GLIBC_2.34 __pthread_rwlock_timedwrlock64 F
+GLIBC_2.34 __pthread_timedjoin_np64 F
 GLIBC_2.34 __pthread_unregister_cancel F
 GLIBC_2.34 __pthread_unregister_cancel_restore F
 GLIBC_2.34 __pthread_unwind_next F
+GLIBC_2.34 __recvmmsg64 F
+GLIBC_2.34 __sched_rr_get_interval64 F
+GLIBC_2.34 __select64 F
+GLIBC_2.34 __sem_clockwait64 F
+GLIBC_2.34 __sem_timedwait64 F
+GLIBC_2.34 __semctl64 F
+GLIBC_2.34 __semtimedop64 F
+GLIBC_2.34 __setitimer64 F
+GLIBC_2.34 __settimeofday64 F
+GLIBC_2.34 __shmctl64 F
+GLIBC_2.34 __sigtimedwait64 F
+GLIBC_2.34 __stat64_time64 F
+GLIBC_2.34 __thrd_sleep64 F
+GLIBC_2.34 __time64 F
+GLIBC_2.34 __timegm64 F
+GLIBC_2.34 __timerfd_gettime64 F
+GLIBC_2.34 __timerfd_settime64 F
+GLIBC_2.34 __timespec_get64 F
+GLIBC_2.34 __timespec_getres64 F
+GLIBC_2.34 __utime64 F
+GLIBC_2.34 __utimensat64 F
+GLIBC_2.34 __utimes64 F
+GLIBC_2.34 __wait3_time64 F
+GLIBC_2.34 __wait4_time64 F
 GLIBC_2.34 call_once F
 GLIBC_2.34 cnd_broadcast F
 GLIBC_2.34 cnd_destroy F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/librt.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/librt.abilist
index 38f0aad791..fb2769e87b 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/librt.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/librt.abilist
@@ -34,6 +34,11 @@ GLIBC_2.3.4 mq_setattr F
 GLIBC_2.3.4 mq_timedreceive F
 GLIBC_2.3.4 mq_timedsend F
 GLIBC_2.3.4 mq_unlink F
+GLIBC_2.34 __aio_suspend_time64 F
+GLIBC_2.34 __mq_timedreceive_time64 F
+GLIBC_2.34 __mq_timedsend_time64 F
+GLIBC_2.34 __timer_gettime64 F
+GLIBC_2.34 __timer_settime64 F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.7 __mq_open_2 F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/time64-compat.h b/sysdeps/unix/sysv/linux/sparc/sparc32/time64-compat.h
new file mode 100644
index 0000000000..700f854597
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/time64-compat.h
@@ -0,0 +1,2 @@
+/* ABI support 64-bit in non-default mode.  */
+#define TIME64_NON_DEFAULT
diff --git a/sysdeps/unix/sysv/linux/sys/timerfd.h b/sysdeps/unix/sysv/linux/sys/timerfd.h
index 4ad64c2259..790b9d5be6 100644
--- a/sysdeps/unix/sysv/linux/sys/timerfd.h
+++ b/sysdeps/unix/sysv/linux/sys/timerfd.h
@@ -47,9 +47,31 @@ extern int timerfd_settime (int __ufd, int __flags,
 			    const struct itimerspec *__utmr,
 			    struct itimerspec *__otmr) __THROW;
 
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT_NTH)
+extern int __REDIRECT_NTH (timerfd_settime,
+                           (int __ufd, int __flags,
+                            const struct itimerspec *__restrict __value,
+                            struct itimerspec *__restrict __ovalue),
+                           __timerfd_settime64);
+# else
+# define timerfd_settime __timerfd_settime64
+# endif
+#endif
+
 /* Return the next expiration time of UFD.  */
 extern int timerfd_gettime (int __ufd, struct itimerspec *__otmr) __THROW;
 
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT_NTH)
+extern int __REDIRECT_NTH (timerfd_gettime, (int __ufd,
+                                             struct itimerspec *__otmr),
+                           __timerfd_gettime64);
+# else
+# define timerfd_gettime __timerfd_gettime64
+# endif
+#endif
+
 __END_DECLS
 
 #endif /* sys/timerfd.h */
diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
index eb8d15a806..e17265c607 100644
--- a/sysdeps/unix/sysv/linux/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/sys/timex.h
@@ -54,17 +54,34 @@ struct ntptimeval
 
 __BEGIN_DECLS
 
-extern int __adjtimex (struct timex *__ntx) __THROW;
+#ifndef __USE_TIME_BITS64
 extern int adjtimex (struct timex *__ntx) __THROW;
 extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
 
-#ifdef __REDIRECT_NTH
+# ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
-			   ntp_gettimex);
+                           ntp_gettimex);
+# else
+#  define ntp_gettime ntp_gettimex
+# endif
+extern int ntp_adjtime (struct timex *__tntx) __THROW;
 #else
-# define ntp_gettime ntp_gettimex
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (adjtimex, (struct timex *__ntx),
+                           ___adjtimex64);
+extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
+                           __ntp_gettime64);
+extern int __REDIRECT_NTH (ntp_gettimex, (struct ntptimeval *__ntv),
+                           __ntp_gettimex64);
+extern int __REDIRECT_NTH (ntp_adjtime, (struct timex *__ntx),
+                           ___adjtimex64);
+# else
+#  define adjtimex ___adjtimex64
+#  define ntp_adjtime ___adjtimex64
+#  define ntp_gettime __ntp_gettime64
+#  define ntp_gettimex __ntp_gettimex64
+# endif
 #endif
-extern int ntp_adjtime (struct timex *__tntx) __THROW;
 
 __END_DECLS
 
diff --git a/sysvipc/sys/msg.h b/sysvipc/sys/msg.h
index 9ddedf5e15..f31a43757d 100644
--- a/sysvipc/sys/msg.h
+++ b/sysvipc/sys/msg.h
@@ -58,7 +58,17 @@ struct msgbuf
 __BEGIN_DECLS
 
 /* Message queue control operation.  */
+#ifndef __USE_TIME_BITS64
 extern int msgctl (int __msqid, int __cmd, struct msqid_ds *__buf) __THROW;
+#else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (msgctl,
+                           (int __msqid, int __cmd, struct msqid_ds *__buf),
+                           __msgctl64);
+# else
+#  define msgctl __msgctl64
+# endif
+#endif
 
 /* Get messages queue.  */
 extern int msgget (key_t __key, int __msgflg) __THROW;
diff --git a/sysvipc/sys/sem.h b/sysvipc/sys/sem.h
index 03b65dff21..4eb4c51bbe 100644
--- a/sysvipc/sys/sem.h
+++ b/sysvipc/sys/sem.h
@@ -48,7 +48,17 @@ struct sembuf
 __BEGIN_DECLS
 
 /* Semaphore control operation.  */
+#ifndef __USE_TIME_BITS64
 extern int semctl (int __semid, int __semnum, int __cmd, ...) __THROW;
+#else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (semctl,
+                           (int __semid, int __semnum, int __cmd, ...),
+                           __semctl64);
+# else
+#  define semctl __semctl64
+# endif
+#endif
 
 /* Get semaphore.  */
 extern int semget (key_t __key, int __nsems, int __semflg) __THROW;
@@ -58,8 +68,19 @@ extern int semop (int __semid, struct sembuf *__sops, size_t __nsops) __THROW;
 
 #ifdef __USE_GNU
 /* Operate on semaphore with timeout.  */
+# ifndef __USE_TIME_BITS64
 extern int semtimedop (int __semid, struct sembuf *__sops, size_t __nsops,
 		       const struct timespec *__timeout) __THROW;
+# else
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (semtimedop, (int __semid, struct sembuf *__sops,
+                                        size_t __nsops,
+                                        const struct timespec *__timeout),
+                           __semtimedop64);
+#  else
+#   define semtimedop __semtimedop64
+#  endif
+# endif
 #endif
 
 __END_DECLS
diff --git a/sysvipc/sys/shm.h b/sysvipc/sys/shm.h
index 7506ba67bf..b09e0497e6 100644
--- a/sysvipc/sys/shm.h
+++ b/sysvipc/sys/shm.h
@@ -46,7 +46,17 @@ __BEGIN_DECLS
    facility.  The definition is found in XPG4.2.  */
 
 /* Shared memory control operation.  */
+#ifndef __USE_TIME_BITS64
 extern int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf) __THROW;
+#else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (shmctl,
+                           (int __shmid, int __cmd, struct shmid_ds *__buf),
+                           __shmctl64);
+# else
+#  define shmctl __shmctl64
+# endif
+#endif
 
 /* Get shared memory segment.  */
 extern int shmget (key_t __key, size_t __size, int __shmflg) __THROW;
diff --git a/time/sys/time.h b/time/sys/time.h
index 42f91f186b..d21411c0b4 100644
--- a/time/sys/time.h
+++ b/time/sys/time.h
@@ -63,10 +63,21 @@ struct timezone
    use localtime etc. instead.
    This function itself is semi-obsolete;
    most callers should use time or clock_gettime instead. */
+#ifndef __USE_TIME_BITS64
 extern int gettimeofday (struct timeval *__restrict __tv,
 			 void *__restrict __tz) __THROW __nonnull ((1));
+#else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (gettimeofday, (struct timeval *__restrict __tv,
+                                          void *__restrict __tz),
+                           __gettimeofday64) __nonnull ((1));
+# else
+#  define gettimeofday __gettimeofday64
+# endif
+#endif
 
 #ifdef __USE_MISC
+# ifndef __USE_TIME_BITS64
 /* Set the current time of day and timezone information.
    This call is restricted to the super-user.
    Setting the timezone in this way is obsolete, but we don't yet
@@ -82,6 +93,20 @@ extern int settimeofday (const struct timeval *__tv,
    This call is restricted to the super-user.  */
 extern int adjtime (const struct timeval *__delta,
 		    struct timeval *__olddelta) __THROW;
+# else
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (settimeofday, (const struct timeval *__tv,
+                                          const struct timezone *__tz),
+                           __settimeofday64);
+
+extern int __REDIRECT_NTH (adjtime, (const struct timeval *__delta,
+                                     struct timeval *__olddelta),
+                           __adjtime64);
+#  else
+#   define settimeofday __settimeofday64
+#   define adjtime __adjtime64
+#  endif
+# endif
 #endif
 
 
@@ -118,6 +143,7 @@ typedef enum __itimer_which __itimer_which_t;
 typedef int __itimer_which_t;
 #endif
 
+#ifndef __USE_TIME_BITS64
 /* Set *VALUE to the current setting of timer WHICH.
    Return 0 on success, -1 on errors.  */
 extern int getitimer (__itimer_which_t __which,
@@ -136,21 +162,66 @@ extern int setitimer (__itimer_which_t __which,
 extern int utimes (const char *__file, const struct timeval __tvp[2])
      __THROW __nonnull ((1));
 
+#else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (getitimer, (__itimer_which_t __which,
+                                       struct itimerval *__value),
+                           __getitimer64);
+
+extern int __REDIRECT_NTH (setitimer, (__itimer_which_t __which,
+                                       const struct itimerval *__restrict __new,
+                                       struct itimerval *__restrict __old),
+                           __setitimer64);
+
+extern int __REDIRECT_NTH (utimes, (const char *__file,
+                                    const struct timeval __tvp[2]),
+                           __utimes64) __nonnull ((1));
+# else
+#  define getitimer __getitimer64
+#  define setitimer __setitimer64
+#  define utimes __utimes64
+# endif
+#endif
+
 #ifdef __USE_MISC
+# ifndef __USE_TIME_BITS64
 /* Same as `utimes', but does not follow symbolic links.  */
 extern int lutimes (const char *__file, const struct timeval __tvp[2])
      __THROW __nonnull ((1));
 
 /* Same as `utimes', but takes an open file descriptor instead of a name.  */
 extern int futimes (int __fd, const struct timeval __tvp[2]) __THROW;
+# else
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (lutimes, (const char *__file,
+                                     const struct timeval __tvp[2]),
+                           __lutimes64) __nonnull ((1));
+
+extern int __REDIRECT_NTH (futimes, (int __fd, const struct timeval __tvp[2]),
+                           __futimes64);
+#  else
+#   define lutimes __lutimes64
+#   define futimes __futimes64
+#  endif
+# endif
 #endif
 
 #ifdef __USE_GNU
+# ifndef __USE_TIME_BITS64
 /* Change the access time of FILE relative to FD to TVP[0] and the
    modification time of FILE to TVP[1].  If TVP is a null pointer, use
    the current time instead.  Returns 0 on success, -1 on errors.  */
 extern int futimesat (int __fd, const char *__file,
 		      const struct timeval __tvp[2]) __THROW;
+# else
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (futimesat, (int __fd, const char *__file,
+                                       const struct timeval __tvp[2]),
+                           __futimesat64);
+#  else
+#   define futimesat __futimesat64
+#  endif
+# endif
 #endif
 
 
diff --git a/time/time.h b/time/time.h
index e255db9772..bde870c934 100644
--- a/time/time.h
+++ b/time/time.h
@@ -71,6 +71,7 @@ __BEGIN_DECLS
    The result / CLOCKS_PER_SEC is program time in seconds.  */
 extern clock_t clock (void) __THROW;
 
+#ifndef __USE_TIME_BITS64
 /* Return the current time and put it in *TIMER if TIMER is not NULL.  */
 extern time_t time (time_t *__timer) __THROW;
 
@@ -80,7 +81,18 @@ extern double difftime (time_t __time1, time_t __time0)
 
 /* Return the `time_t' representation of TP and normalize TP.  */
 extern time_t mktime (struct tm *__tp) __THROW;
-
+#else
+# ifdef __REDIRECT_NTH
+extern time_t __REDIRECT_NTH (time, (time_t *__timer), __time64);
+extern double __REDIRECT_NTH (difftime, (time_t __time1, time_t __time0),
+                              __difftime64) __attribute__ ((__const__));
+extern time_t __REDIRECT_NTH (mktime, (struct tm *__tp), __mktime64);
+# else
+#  define time __time64
+#  define difftime __difftime64
+#  define mktime __mktime64
+# endif
+#endif
 
 /* Format TP into S according to FORMAT.
    Write no more than MAXSIZE characters and return the number
@@ -114,6 +126,7 @@ extern char *strptime_l (const char *__restrict __s,
 #endif
 
 
+#ifndef __USE_TIME_BITS64
 /* Return the `struct tm' representation of *TIMER
    in Universal Coordinated Time (aka Greenwich Mean Time).  */
 extern struct tm *gmtime (const time_t *__timer) __THROW;
@@ -122,7 +135,20 @@ extern struct tm *gmtime (const time_t *__timer) __THROW;
    of *TIMER in the local timezone.  */
 extern struct tm *localtime (const time_t *__timer) __THROW;
 
+#else
+# ifdef __REDIRECT_NTH
+extern struct tm*__REDIRECT_NTH (gmtime, (const time_t *__timer), __gmtime64);
+extern struct tm *__REDIRECT_NTH (localtime, (const time_t *__timer),
+				  __localtime64);
+# else
+#  define gmtime __gmtime64
+#  define localtime __localtime64
+# endif
+#endif
+
+
 #if defined __USE_POSIX || __GLIBC_USE (ISOC2X)
+# ifndef __USE_TIME_BITS64
 /* Return the `struct tm' representation of *TIMER in UTC,
    using *TP to store the result.  */
 extern struct tm *gmtime_r (const time_t *__restrict __timer,
@@ -132,6 +158,20 @@ extern struct tm *gmtime_r (const time_t *__restrict __timer,
    using *TP to store the result.  */
 extern struct tm *localtime_r (const time_t *__restrict __timer,
 			       struct tm *__restrict __tp) __THROW;
+# else
+#  ifdef __REDIRECT_NTH
+extern struct tm*__REDIRECT_NTH (gmtime_r, (const time_t *__restrict __timer,
+                                            struct tm *__restrict __tp),
+                                 __gmtime64_r);
+
+extern struct tm*__REDIRECT_NTH (localtime_r, (const time_t *__restrict __t,
+                                               struct tm *__restrict __tp),
+                                 __localtime64_r);
+#  else
+#   define gmtime_r __gmtime64_r
+#   define localtime_r __localtime_r
+#  endif
+# endif
 #endif	/* POSIX || C2X */
 
 /* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
@@ -139,7 +179,15 @@ extern struct tm *localtime_r (const time_t *__restrict __timer,
 extern char *asctime (const struct tm *__tp) __THROW;
 
 /* Equivalent to `asctime (localtime (timer))'.  */
+#ifndef __USE_TIME_BITS64
 extern char *ctime (const time_t *__timer) __THROW;
+#else
+# ifdef __REDIRECT_NTH
+extern char *__REDIRECT_NTH (ctime, (const time_t *__timer), __ctime64);
+# else
+#  define ctime __ctime64
+# endif
+#endif
 
 #ifdef __USE_POSIX
 /* Reentrant versions of the above functions.  */
@@ -150,8 +198,18 @@ extern char *asctime_r (const struct tm *__restrict __tp,
 			char *__restrict __buf) __THROW;
 
 /* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'.  */
+#ifndef __USE_TIME_BITS64
 extern char *ctime_r (const time_t *__restrict __timer,
 		      char *__restrict __buf) __THROW;
+#else
+# ifdef __REDIRECT_NTH
+extern char *__REDIRECT_NTH (ctime_r, (const time_t *__restrict __timer,
+                                       char *__restrict __buf), __ctime64_r);
+# else
+#  define ctime_r __ctime64_r
+# endif
+#endif
+
 #endif	/* POSIX */
 
 
@@ -186,11 +244,19 @@ extern long int timezone;
 /* Miscellaneous functions many Unices inherited from the public domain
    localtime package.  These are included only for compatibility.  */
 
+#ifndef __USE_TIME_BITS64
 /* Like `mktime', but for TP represents Universal Time, not local time.  */
 extern time_t timegm (struct tm *__tp) __THROW;
-
 /* Another name for `mktime'.  */
 extern time_t timelocal (struct tm *__tp) __THROW;
+#else
+# ifdef __REDIRECT_NTH
+extern time_t __REDIRECT_NTH (timegm, (struct tm *__tp), __timegm64);
+extern time_t __REDIRECT_NTH (timelocal, (struct tm *__tp), __mktime64);
+# else
+#  define timegm __timegm64
+# endif
+#endif
 
 /* Return the number of days in YEAR.  */
 extern int dysize (int __year) __THROW  __attribute__ ((__const__));
@@ -198,6 +264,7 @@ extern int dysize (int __year) __THROW  __attribute__ ((__const__));
 
 
 #ifdef __USE_POSIX199309
+# ifndef __USE_TIME_BITS64
 /* Pause execution for a number of nanoseconds.
 
    This function is a cancellation point and therefore not marked with
@@ -205,7 +272,6 @@ extern int dysize (int __year) __THROW  __attribute__ ((__const__));
 extern int nanosleep (const struct timespec *__requested_time,
 		      struct timespec *__remaining);
 
-
 /* Get resolution of clock CLOCK_ID.  */
 extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW;
 
@@ -215,15 +281,46 @@ extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
 /* Set clock CLOCK_ID to value TP.  */
 extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
      __THROW;
+# else
+#  ifdef __REDIRECT
+extern int __REDIRECT (nanosleep, (const struct timespec *__requested_time,
+                                   struct timespec *__remaining),
+                       __nanosleep64);
+extern int __REDIRECT_NTH (clock_getres, (clockid_t __clock_id,
+                                          struct timespec *__res),
+                           __clock_getres64);
+extern int __REDIRECT_NTH (clock_gettime, (clockid_t __clock_id, struct
+                                           timespec *__tp), __clock_gettime64);
+extern int __REDIRECT_NTH (clock_settime, (clockid_t __clock_id, const struct
+                                           timespec *__tp), __clock_settime64);
+#  else
+#   define nanosleep __nanosleep64
+#   define clock_getres __clock_getres64
+#   define clock_gettime __clock_gettime64
+#   define clock_settime __clock_settime64
+#  endif
+# endif
+
 
 # ifdef __USE_XOPEN2K
 /* High-resolution sleep with the specified clock.
 
    This function is a cancellation point and therefore not marked with
    __THROW.  */
+#  ifndef __USE_TIME_BITS64
 extern int clock_nanosleep (clockid_t __clock_id, int __flags,
 			    const struct timespec *__req,
 			    struct timespec *__rem);
+#  else
+#   ifdef __REDIRECT
+extern int __REDIRECT (clock_nanosleep, (clockid_t __clock_id, int __flags,
+                                         const struct timespec *__req,
+                                         struct timespec *__rem),
+                       __clock_nanosleep_time64);
+#   else
+#    define clock_nanosleep __clock_nanosleep_time64
+#   endif
+#  endif
 
 /* Return clock ID for CPU-time clock.  */
 extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW;
@@ -239,6 +336,7 @@ extern int timer_create (clockid_t __clock_id,
 extern int timer_delete (timer_t __timerid) __THROW;
 
 /* Set timer TIMERID to VALUE, returning old value in OVALUE.  */
+# ifndef __USE_TIME_BITS64
 extern int timer_settime (timer_t __timerid, int __flags,
 			  const struct itimerspec *__restrict __value,
 			  struct itimerspec *__restrict __ovalue) __THROW;
@@ -246,6 +344,21 @@ extern int timer_settime (timer_t __timerid, int __flags,
 /* Get current value of timer TIMERID and store it in VALUE.  */
 extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
      __THROW;
+# else
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (timer_settime, (timer_t __timerid, int __flags,
+     const struct itimerspec *__restrict __value,
+     struct itimerspec *__restrict __ovalue),
+                          __timer_settime64);
+
+extern int __REDIRECT_NTH (timer_gettime, (timer_t __timerid,
+                                           struct itimerspec *__value),
+                           __timer_gettime64);
+#  else
+#   define timer_settime __timer_settime64
+#   define timer_gettime __timer_gettime64
+#  endif
+# endif
 
 /* Get expiration overrun for timer TIMERID.  */
 extern int timer_getoverrun (timer_t __timerid) __THROW;
@@ -253,16 +366,35 @@ extern int timer_getoverrun (timer_t __timerid) __THROW;
 
 
 #ifdef __USE_ISOC11
+# ifndef __USE_TIME_BITS64
 /* Set TS to calendar time based in time base BASE.  */
 extern int timespec_get (struct timespec *__ts, int __base)
      __THROW __nonnull ((1));
+# else
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (timespec_get, (struct timespec *__ts, int __base),
+                           __timespec_get64) __nonnull ((1));
+#  else
+#   define timespec_get __timespec_get64
+#  endif
+# endif
 #endif
 
 
 #if __GLIBC_USE (ISOC2X)
+# ifndef __USE_TIME_BITS64
 /* Set TS to resolution of time base BASE.  */
 extern int timespec_getres (struct timespec *__ts, int __base)
      __THROW;
+# else
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (timespec_getres, (struct timespec *__ts,
+                                             int __base),
+                           __timespec_getres64);
+#  else
+#   define timespec_getres __timespec_getres64
+#  endif
+# endif
 #endif
 
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 19/24] posix: Add glob64 with 64-bit time_t support
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (17 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 18/24] y2038: Add support for 64-bit time on legacy ABIs Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-14 14:52   ` Carlos O'Donell
  2021-06-07 20:36 ` [PATCH v3 20/24] io: Add fts64 " Adhemerval Zanella
                   ` (4 subsequent siblings)
  23 siblings, 1 reply; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

The glob might pass a different stat struct for gl_stat and gl_lstat
when GLOB_ALTDIRFUNC is used.  This requires add a new 64-bit time
version that also uses 64-bit time stat functions.

Checked on i686-linux-gnu and x86_64-linux-gnu.
---
 include/glob.h                                | 28 +++++++++++
 posix/Makefile                                |  4 +-
 posix/glob.c                                  | 46 +++++++++--------
 posix/glob.h                                  | 22 +++++++++
 posix/glob64-lstat-compat.c                   |  3 +-
 posix/glob64-time64.c                         | 49 +++++++++++++++++++
 posix/globfree64-time64.c                     | 30 ++++++++++++
 sysdeps/gnu/glob64-lstat-compat.c             |  3 +-
 sysdeps/unix/sysv/linux/Versions              |  2 +
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |  2 +
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  2 +
 sysdeps/unix/sysv/linux/csky/libc.abilist     |  2 +
 sysdeps/unix/sysv/linux/glob-lstat-compat.c   |  6 ++-
 sysdeps/unix/sysv/linux/glob.c                |  6 +++
 sysdeps/unix/sysv/linux/glob64-lstat-compat.c | 12 ++---
 sysdeps/unix/sysv/linux/glob64-time64.c       | 44 +++++++++++++++++
 sysdeps/unix/sysv/linux/glob64.c              |  8 +--
 sysdeps/unix/sysv/linux/globfree64-time64.c   | 35 +++++++++++++
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |  2 +
 sysdeps/unix/sysv/linux/i386/libc.abilist     |  2 +
 .../sysv/linux/m68k/coldfire/libc.abilist     |  2 +
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  2 +
 .../sysv/linux/microblaze/be/libc.abilist     |  2 +
 .../sysv/linux/microblaze/le/libc.abilist     |  2 +
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  2 +
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |  2 +
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  2 +
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |  2 +
 sysdeps/unix/sysv/linux/oldglob.c             | 11 ++---
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  2 +
 .../powerpc/powerpc32/nofpu/libc.abilist      |  2 +
 .../unix/sysv/linux/s390/s390-32/libc.abilist |  2 +
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  2 +
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  2 +
 .../sysv/linux/sparc/sparc32/libc.abilist     |  2 +
 35 files changed, 307 insertions(+), 40 deletions(-)
 create mode 100644 posix/glob64-time64.c
 create mode 100644 posix/globfree64-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/glob64-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/globfree64-time64.c

diff --git a/include/glob.h b/include/glob.h
index 1d2f78793e..f48c71960d 100644
--- a/include/glob.h
+++ b/include/glob.h
@@ -2,11 +2,39 @@
 #include <posix/glob.h>
 
 #ifndef _ISOMAC
+# include <sys/types.h>
+
 libc_hidden_proto (glob)
 libc_hidden_proto (glob64)
 libc_hidden_proto (globfree)
 libc_hidden_proto (globfree64)
 
+# if __TIMESIZE == 64
+#  define glob64_time64_t glob64_t
+# else
+# include <sys/stat.h>
+
+typedef struct
+  {
+    size_t gl_pathc;
+    char **gl_pathv;
+    size_t gl_offs;
+    int gl_flags;
+
+    void (*gl_closedir) (void *);
+    struct dirent64 *(*gl_readdir) (void *);
+    void *(*gl_opendir) (const char *);
+    int (*gl_lstat) (const char *__restrict, struct __stat64_t64 *__restrict);
+    int (*gl_stat) (const char *__restrict, struct __stat64_t64 *__restrict);
+  } glob64_time64_t;
+
+extern int __glob64_time64 (const char *pattern, int flags,
+			    int (*errfunc) (const char *, int),
+			    glob64_time64_t *pglob);
+void __globfree64_time64 (glob64_time64_t *pglob);
+libc_hidden_proto (__globfree64_time64)
+# endif
+
 /* Now define the internal interfaces.  */
 extern int __glob_pattern_p (const char *__pattern, int __quote);
 extern int __glob64 (const char *__pattern, int __flags,
diff --git a/posix/Makefile b/posix/Makefile
index fa0dc0ea20..c8c538fcee 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -67,7 +67,9 @@ routines :=								      \
 	get_child_max sched_cpucount sched_cpualloc sched_cpufree \
 	streams-compat \
 	shm-directory                                                         \
-	execveat
+	execveat \
+	glob64-time64 \
+	globfree64-time64
 
 aux		:= init-posix environ
 tests		:= test-errno tstgetopt testfnm runtests runptests \
diff --git a/posix/glob.c b/posix/glob.c
index 32c88e5d15..593a4c358f 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -59,25 +59,37 @@
 # define readdir(str) __readdir64 (str)
 # define getpwnam_r(name, bufp, buf, len, res) \
     __getpwnam_r (name, bufp, buf, len, res)
-# define struct_stat64          struct stat64
 # define FLEXIBLE_ARRAY_MEMBER
+# ifndef struct_stat
+#  define struct_stat           struct stat
+# endif
+# ifndef struct_stat64
+#  define struct_stat64         struct stat64
+# endif
+# ifndef GLOB_LSTAT
+#  define GLOB_LSTAT            gl_lstat
+# endif
+# ifndef GLOB_STAT64
+#  define GLOB_STAT64           __stat64
+# endif
+# ifndef GLOB_LSTAT64
+#  define GLOB_LSTAT64          __lstat64
+# endif
 # include <shlib-compat.h>
 #else /* !_LIBC */
 # define __glob                 glob
 # define __getlogin_r(buf, len) getlogin_r (buf, len)
-# define __lstat64(fname, buf)  lstat (fname, buf)
-# if defined _WIN32 && !defined __CYGWIN__
-   /* Avoid GCC or clang warning.  The original __stat64 macro is unused.  */
-#  undef __stat64
-# endif
-# define __stat64(fname, buf)   stat (fname, buf)
 # define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag)
-# define struct_stat64          struct stat
 # ifndef __MVS__
 #  define __alloca              alloca
 # endif
 # define __readdir              readdir
 # define COMPILE_GLOB64
+# define struct_stat            struct stat
+# define struct_stat64          struct stat
+# define GLOB_LSTAT             gl_lstat
+# define GLOB_STAT64            stat
+# define GLOB_LSTAT64           lstat
 #endif /* _LIBC */
 
 #include <fnmatch.h>
@@ -196,22 +208,14 @@ glob_lstat (glob_t *pglob, int flags, const char *fullname)
 {
 /* Use on glob-lstat-compat.c to provide a compat symbol which does not
    use lstat / gl_lstat.  */
-#ifdef GLOB_NO_LSTAT
-# define GL_LSTAT gl_stat
-# define LSTAT64 __stat64
-#else
-# define GL_LSTAT gl_lstat
-# define LSTAT64 __lstat64
-#endif
-
   union
   {
-    struct stat st;
+    struct_stat st;
     struct_stat64 st64;
   } ust;
   return (__glibc_unlikely (flags & GLOB_ALTDIRFUNC)
-          ? pglob->GL_LSTAT (fullname, &ust.st)
-          : LSTAT64 (fullname, &ust.st64));
+          ? pglob->GLOB_LSTAT (fullname, &ust.st)
+          : GLOB_LSTAT64 (fullname, &ust.st64));
 }
 
 /* Set *R = A + B.  Return true if the answer is mathematically
@@ -249,11 +253,11 @@ static int collated_compare (const void *, const void *) __THROWNL;
 static bool
 is_dir (char const *filename, int flags, glob_t const *pglob)
 {
-  struct stat st;
+  struct_stat st;
   struct_stat64 st64;
   return (__glibc_unlikely (flags & GLOB_ALTDIRFUNC)
           ? pglob->gl_stat (filename, &st) == 0 && S_ISDIR (st.st_mode)
-          : __stat64 (filename, &st64) == 0 && S_ISDIR (st64.st_mode));
+          : GLOB_STAT64 (filename, &st64) == 0 && S_ISDIR (st64.st_mode));
 }
 
 /* Find the end of the sub-pattern in a brace expression.  */
diff --git a/posix/glob.h b/posix/glob.h
index b5686600c7..700aeb2392 100644
--- a/posix/glob.h
+++ b/posix/glob.h
@@ -150,20 +150,42 @@ extern int glob (const char *__restrict __pattern, int __flags,
 /* Free storage allocated in PGLOB by a previous `glob' call.  */
 extern void globfree (glob_t *__pglob) __THROW;
 #else
+# ifdef __USE_TIME_BITS64
+extern int __REDIRECT_NTHNL (glob, (const char *__restrict __pattern,
+				    int __flags,
+				    int (*__errfunc) (const char *, int),
+				    glob_t *__restrict __pglob),
+			     __glob64_time64);
+
+extern void __REDIRECT_NTH (globfree, (glob_t *__pglob),
+			    __globfree64_time64);
+# else
 extern int __REDIRECT_NTHNL (glob, (const char *__restrict __pattern,
 				    int __flags,
 				    int (*__errfunc) (const char *, int),
 				    glob_t *__restrict __pglob), glob64);
 
 extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
+# endif
 #endif
 
 #ifdef __USE_LARGEFILE64
+# ifdef __USE_TIME_BITS64
+extern int __REDIRECT_NTHNL (glob64, (const char *__restrict __pattern,
+				      int __flags,
+				      int (*__errfunc) (const char *, int),
+				      glob64_t *__restrict __pglob),
+			     __glob64_time64);
+
+extern void __REDIRECT_NTH (globfree64, (glob64_t *__pglob),
+			    __globfree64_time64);
+# else
 extern int glob64 (const char *__restrict __pattern, int __flags,
 		   int (*__errfunc) (const char *, int),
 		   glob64_t *__restrict __pglob) __THROWNL;
 
 extern void globfree64 (glob64_t *__pglob) __THROW;
+# endif
 #endif
 
 
diff --git a/posix/glob64-lstat-compat.c b/posix/glob64-lstat-compat.c
index bd81a1e390..e90d4ae93e 100644
--- a/posix/glob64-lstat-compat.c
+++ b/posix/glob64-lstat-compat.c
@@ -28,7 +28,8 @@
 # define GLOB_ATTRIBUTE attribute_compat_text_section
 
 /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
-# define GLOB_NO_LSTAT
+# define GLOB_LSTAT   gl_stat
+# define GLOB_LSTAT64 __stat64
 
 # include <posix/glob64.c>
 
diff --git a/posix/glob64-time64.c b/posix/glob64-time64.c
new file mode 100644
index 0000000000..b0f8facd84
--- /dev/null
+++ b/posix/glob64-time64.c
@@ -0,0 +1,49 @@
+/* Long File Support glob with 64-bit time support.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <glob.h>
+#include <stddef.h>
+
+#if __TIMESIZE != 64
+
+/* Do glob searching for PATTERN, placing results in PGLOB.
+   The bits defined above may be set in FLAGS.
+   If a directory cannot be opened or read and ERRFUNC is not nil,
+   it is called with the pathname that caused the error, and the
+   `errno' value from the failing call; if it returns non-zero
+   `glob' returns GLOB_ABORTED; if it returns zero, the error is ignored.
+   If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
+   Otherwise, `glob' returns zero.  */
+int
+__glob64_time64 (const char *pattern, int flags,
+		 int (*errfunc) (const char *, int), glob64_time64_t *pglob)
+{
+  if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  __set_errno (ENOSYS);
+  return GLOB_NOSYS;
+}
+
+stub_warning (glob64)
+
+#endif
diff --git a/posix/globfree64-time64.c b/posix/globfree64-time64.c
new file mode 100644
index 0000000000..1fc2085f3f
--- /dev/null
+++ b/posix/globfree64-time64.c
@@ -0,0 +1,30 @@
+/* Long File Support globfree with 64-bit time support.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <glob.h>
+
+#if __TIMESIZE != 64
+
+/* Free storage allocated in PGLOB by a previous `glob' call.  */
+void
+__globfree64_time64 (glob64_time64_t *pglob)
+{
+}
+libc_hidden_def (__globfree64_time64)
+
+#endif
diff --git a/sysdeps/gnu/glob64-lstat-compat.c b/sysdeps/gnu/glob64-lstat-compat.c
index 6764f1d062..ade4ccac8a 100644
--- a/sysdeps/gnu/glob64-lstat-compat.c
+++ b/sysdeps/gnu/glob64-lstat-compat.c
@@ -39,7 +39,8 @@
 #define GLOB_ATTRIBUTE attribute_compat_text_section
 
 /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
-#define GLOB_NO_LSTAT
+#define GLOB_LSTAT   gl_stat
+#define GLOB_LSTAT64 __stat64
 
 #include <posix/glob.c>
 
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index 0aa2ef8559..f045604ad6 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -209,6 +209,8 @@ libc {
     __getitimer64;
     __getrusage64;
     __gettimeofday64;
+    __glob64_time64;
+    __globfree64_time64;
     __gmtime64;
     __gmtime64_r;
     __localtime64;
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index 1d32514579..8e3101b1c2 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -209,6 +209,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index 05d0878232..b29a0e324e 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -206,6 +206,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index ac9f009f38..5f5427cb46 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2296,6 +2296,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/glob-lstat-compat.c b/sysdeps/unix/sysv/linux/glob-lstat-compat.c
index 1f502e3299..7729e0dc12 100644
--- a/sysdeps/unix/sysv/linux/glob-lstat-compat.c
+++ b/sysdeps/unix/sysv/linux/glob-lstat-compat.c
@@ -30,7 +30,11 @@
 #define GLOB_ATTRIBUTE attribute_compat_text_section
 
 /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
-#define GLOB_NO_LSTAT
+#define struct_stat    struct stat
+#define struct_stat64  struct stat64
+#define GLOB_LSTAT     gl_stat
+#define GLOB_STAT64    __stat64
+#define GLOB_LSTAT64   __stat64
 
 #include <posix/glob.c>
 
diff --git a/sysdeps/unix/sysv/linux/glob.c b/sysdeps/unix/sysv/linux/glob.c
index 1be4885b96..89c287d01d 100644
--- a/sysdeps/unix/sysv/linux/glob.c
+++ b/sysdeps/unix/sysv/linux/glob.c
@@ -19,6 +19,12 @@
 #include <sys/stat.h>
 #include <kernel_stat.h>
 
+#define struct_stat    struct stat
+#define struct_stat64  struct stat64
+#define GLOB_LSTAT     gl_lstat
+#define GLOB_STAT64    __stat64
+#define GLOB_LSTAT64   __lstat64
+
 #define glob64 __no_glob64_decl
 #define __glob64 __no___glob64_decl
 #include <posix/glob.c>
diff --git a/sysdeps/unix/sysv/linux/glob64-lstat-compat.c b/sysdeps/unix/sysv/linux/glob64-lstat-compat.c
index 40ad625f58..302a44d3a4 100644
--- a/sysdeps/unix/sysv/linux/glob64-lstat-compat.c
+++ b/sysdeps/unix/sysv/linux/glob64-lstat-compat.c
@@ -33,15 +33,15 @@
 # define __glob __glob64_lstat_compat
 # define globfree globfree64
 
-# undef stat
-# define stat stat64
-
-# define COMPILE_GLOB64	1
-
 # define GLOB_ATTRIBUTE attribute_compat_text_section
 
 /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
-# define GLOB_NO_LSTAT
+# define COMPILE_GLOB64	1
+# define struct_stat    struct stat64
+# define struct_stat64  struct stat64
+# define GLOB_LSTAT     gl_stat
+# define GLOB_STAT64    __stat64
+# define GLOB_LSTAT64   __stat64
 
 # include <posix/glob.c>
 
diff --git a/sysdeps/unix/sysv/linux/glob64-time64.c b/sysdeps/unix/sysv/linux/glob64-time64.c
new file mode 100644
index 0000000000..260f067fa4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/glob64-time64.c
@@ -0,0 +1,44 @@
+/* Find pathnames matching a pattern.  Linux version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sys/stat.h>
+
+#if __TIMESIZE != 64
+# include <glob.h>
+# include <dirent.h>
+# include <sys/stat.h>
+
+# define dirent dirent64
+# define __readdir(dirp) __readdir64 (dirp)
+
+# define glob_t glob64_time64_t
+# define __glob __glob64_time64
+
+# define globfree(pglob) __globfree64_time64 (pglob)
+
+# define COMPILE_GLOB64  1
+# define struct_stat     struct __stat64_t64
+# define struct_stat64   struct __stat64_t64
+# define GLOB_LSTAT      gl_lstat
+# define GLOB_STAT64     __stat64_time64
+# define GLOB_LSTAT64    __lstat64_time64
+
+# define COMPILE_GLOB64	1
+
+# include <posix/glob.c>
+#endif
diff --git a/sysdeps/unix/sysv/linux/glob64.c b/sysdeps/unix/sysv/linux/glob64.c
index 3cbadf34fb..572ca215df 100644
--- a/sysdeps/unix/sysv/linux/glob64.c
+++ b/sysdeps/unix/sysv/linux/glob64.c
@@ -31,10 +31,12 @@
 # define __glob __glob64
 # define globfree(pglob) globfree64 (pglob)
 
-# undef stat
-# define stat stat64
-
 # define COMPILE_GLOB64	1
+# define struct_stat    struct stat64
+# define struct_stat64  struct stat64
+# define GLOB_LSTAT     gl_lstat
+# define GLOB_STAT64    __stat64
+# define GLOB_LSTAT64   __lstat64
 
 # include <posix/glob.c>
 
diff --git a/sysdeps/unix/sysv/linux/globfree64-time64.c b/sysdeps/unix/sysv/linux/globfree64-time64.c
new file mode 100644
index 0000000000..d6b1e6ac49
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/globfree64-time64.c
@@ -0,0 +1,35 @@
+/* Frees the dynamically allocated storage from an earlier call to glob.
+   Linux version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sys/stat.h>
+
+#if __TIMESIZE != 64
+# include <glob.h>
+# include <dirent.h>
+# include <sys/stat.h>
+
+# define glob_t glob64_time64_t
+# define globfree(pglob) __globfree64_time64 (pglob)
+
+# undef stat
+# define stat __stat64_t64
+
+# include <posix/globfree.c>
+libc_hidden_def (__globfree64_time64)
+#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index d2770a4874..ca8f7c3dbb 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2250,6 +2250,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index eb20d66c28..d2b7b4d4b6 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2433,6 +2433,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __isnanf128 F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index 044cec51fc..515e383d50 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -210,6 +210,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 3a6463a3ef..6915fa115f 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2377,6 +2377,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 612d7f1c58..9293872f80 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2347,6 +2347,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index 685cb974c3..cb671c56be 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2344,6 +2344,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index d17b5a02a5..f5effe36e1 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2342,6 +2342,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index aba6bd2e3c..2b66d26931 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2340,6 +2340,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index 88d8e2af38..bd76490d97 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2348,6 +2348,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 3b64e2cf51..e62a2a5729 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2386,6 +2386,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/oldglob.c b/sysdeps/unix/sysv/linux/oldglob.c
index 59bf89dc1d..a9a4439ddb 100644
--- a/sysdeps/unix/sysv/linux/oldglob.c
+++ b/sysdeps/unix/sysv/linux/oldglob.c
@@ -28,13 +28,12 @@ libc_hidden_proto (__old_glob64);
 #define convert_dirent __old_convert_dirent
 #define glob_in_dir __old_glob_in_dir
 
-#undef stat
-#define stat stat64
-#undef __stat
-#define __stat(file, buf) __stat64 (file, buf)
-
 /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
-#define GLOB_NO_LSTAT
+#define struct_stat    struct stat64
+#define struct_stat64  struct stat64
+#define GLOB_LSTAT     gl_stat
+#define GLOB_STAT64    __stat64
+#define GLOB_LSTAT64   __stat64
 
 #define GLOB_ATTRIBUTE attribute_compat_text_section
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 5404fdea4a..bc5b23c818 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2404,6 +2404,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 506fa3619f..f9421c7777 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2437,6 +2437,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index 99b6d6d1ce..7581354bf4 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2402,6 +2402,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index 68a631b161..0e45f7fb0a 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2257,6 +2257,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index 61a29e643a..ece6721841 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2254,6 +2254,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index fa3ae954c1..6073443a3d 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2395,6 +2395,8 @@ GLIBC_2.34 __futimesat64 F
 GLIBC_2.34 __getitimer64 F
 GLIBC_2.34 __getrusage64 F
 GLIBC_2.34 __gettimeofday64 F
+GLIBC_2.34 __glob64_time64 F
+GLIBC_2.34 __globfree64_time64 F
 GLIBC_2.34 __gmtime64 F
 GLIBC_2.34 __gmtime64_r F
 GLIBC_2.34 __libc_start_main F
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 20/24] io: Add fts64 with 64-bit time_t support
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (18 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 19/24] posix: Add glob64 with 64-bit time_t support Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-07 20:36 ` [PATCH v3 21/24] io: Add ftw64 " Adhemerval Zanella
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

Similar to glob, fts routines passes a stat pointer that might
differ of size and layout when 64-bit time API is used.

Checked on i686-linux-gnu and x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 include/fts.h                                 | 51 +++++++++++++++++++
 io/Makefile                                   |  4 +-
 io/fts.h                                      | 43 ++++++++++++++--
 io/fts64-time64.c                             | 35 +++++++++++++
 sysdeps/unix/sysv/linux/Versions              |  5 ++
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |  5 ++
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  5 ++
 sysdeps/unix/sysv/linux/csky/libc.abilist     |  5 ++
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |  5 ++
 sysdeps/unix/sysv/linux/i386/libc.abilist     |  5 ++
 .../sysv/linux/m68k/coldfire/libc.abilist     |  5 ++
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  5 ++
 .../sysv/linux/microblaze/be/libc.abilist     |  5 ++
 .../sysv/linux/microblaze/le/libc.abilist     |  5 ++
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  5 ++
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |  5 ++
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  5 ++
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |  5 ++
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  5 ++
 .../powerpc/powerpc32/nofpu/libc.abilist      |  5 ++
 .../unix/sysv/linux/s390/s390-32/libc.abilist |  5 ++
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  5 ++
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  5 ++
 .../sysv/linux/sparc/sparc32/libc.abilist     |  5 ++
 24 files changed, 227 insertions(+), 6 deletions(-)
 create mode 100644 io/fts64-time64.c

diff --git a/include/fts.h b/include/fts.h
index 145dce6779..ea36a9b9be 100644
--- a/include/fts.h
+++ b/include/fts.h
@@ -1 +1,52 @@
+#ifndef _FTS_H
 #include <io/fts.h>
+
+#ifndef _ISOMAC
+# if __TIMESIZE != 64
+#  include <sys/stat.h>
+
+typedef struct
+{
+  struct _ftsent64_time64 *fts_cur;
+  struct _ftsent64_time64 *fts_child;
+  struct _ftsent64_time64 **fts_array;
+  dev_t fts_dev;
+  char *fts_path;
+  int fts_rfd;
+  int fts_pathlen;
+  int fts_nitems;
+  int (*fts_compar) (const void *, const void *);
+  int fts_options;
+} FTS64_TIME64;
+
+typedef struct _ftsent64_time64
+{
+  struct _ftsent64_time64 *fts_cycle;
+  struct _ftsent64_time64 *fts_parent;
+  struct _ftsent64_time64 *fts_link;
+  long fts_number;
+  void *fts_pointer;
+  char *fts_accpath;
+  char *fts_path;
+  int fts_errno;
+  int fts_symfd;
+  unsigned short fts_pathlen;
+  unsigned short fts_namelen;
+
+  ino64_t fts_ino;
+  dev_t fts_dev;
+  nlink_t fts_nlink;
+
+  short fts_level;
+  unsigned short fts_info;
+  unsigned short fts_flags;
+  unsigned short fts_instr;
+
+  struct __stat64_t64 *fts_statp;
+  char fts_name[1];
+} FSTENT64_TIME64;
+
+# endif
+#endif
+
+#endif /* _FTS_H  */
diff --git a/io/Makefile b/io/Makefile
index a22492f3f3..12c832cfcb 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -54,7 +54,8 @@ routines :=								\
 	posix_fadvise posix_fadvise64					\
 	posix_fallocate posix_fallocate64				\
 	sendfile sendfile64 copy_file_range 				\
-	utimensat futimens file_change_detection
+	utimensat futimens file_change_detection			\
+	fts64-time64
 
 others		:= pwd
 test-srcs	:= ftwtest
@@ -102,6 +103,7 @@ CFLAGS-statvfs.c += -fexceptions
 CFLAGS-fstatvfs.c += -fexceptions
 CFLAGS-fts.c += -Wno-uninitialized $(uses-callbacks) -fexceptions
 CFLAGS-fts64.c += -Wno-uninitialized $(uses-callbacks) -fexceptions
+CFLAGS-fts64-time64.c += -Wno-uninitialized $(uses-callbacks) -fexceptions
 CFLAGS-ftw.c += $(uses-callbacks) -fexceptions
 CFLAGS-ftw64.c += $(uses-callbacks) -fexceptions
 CFLAGS-posix_fallocate.c += -fexceptions
diff --git a/io/fts.h b/io/fts.h
index 867677a27e..8d3395fa31 100644
--- a/io/fts.h
+++ b/io/fts.h
@@ -187,6 +187,7 @@ FTSENT	*fts_read (FTS *);
 int	 fts_set (FTS *, FTSENT *, int) __THROW;
 #else
 # ifdef __REDIRECT
+#  ifndef __USE_TIME_BITS64
 FTSENT	*__REDIRECT (fts_children, (FTS *, int), fts64_children);
 int	 __REDIRECT (fts_close, (FTS *), fts64_close);
 FTS	*__REDIRECT (fts_open, (char * const *, int,
@@ -194,21 +195,53 @@ FTS	*__REDIRECT (fts_open, (char * const *, int,
 		     fts64_open);
 FTSENT	*__REDIRECT (fts_read, (FTS *), fts64_read);
 int	 __REDIRECT_NTH (fts_set, (FTS *, FTSENT *, int), fts64_set);
+#  else
+FTSENT	*__REDIRECT (fts_children, (FTS *, int), __fts64_children_time64);
+int	 __REDIRECT (fts_close, (FTS *), __fts64_close_time64);
+FTS	*__REDIRECT (fts_open, (char * const *, int,
+				int (*)(const FTSENT **, const FTSENT **)),
+		     __fts64_open_time64);
+FTSENT	*__REDIRECT (fts_read, (FTS *), __fts64_read_time64);
+int	 __REDIRECT_NTH (fts_set, (FTS *, FTSENT *, int),
+			 __fts64_set_time64);
+#  endif
 # else
-#  define fts_children fts64_children
-#  define fts_close fts64_close
-#  define fts_open fts64_open
-#  define fts_read fts64_read
-#  define fts_set fts64_set
+#  ifndef __USE_TIME_BITS64
+#   define fts_children fts64_children
+#   define fts_close fts64_close
+#   define fts_open fts64_open
+#   define fts_read fts64_read
+#   define fts_set fts64_set
+#  else
+#  endif
 # endif
 #endif
 #ifdef __USE_LARGEFILE64
+# ifndef __USE_TIME_BITS64
 FTSENT64 *fts64_children (FTS64 *, int);
 int	  fts64_close (FTS64 *);
 FTS64	 *fts64_open (char * const *, int,
 		      int (*)(const FTSENT64 **, const FTSENT64 **));
 FTSENT64 *fts64_read (FTS64 *);
 int	 fts64_set (FTS64 *, FTSENT64 *, int) __THROW;
+# else
+#  ifdef __REDIRECT
+FTSENT	*__REDIRECT (fts64_children, (FTS64 *, int), __fts64_children_time64);
+int	 __REDIRECT (fts64_close, (FTS64 *), __fts64_close_time64);
+FTS	*__REDIRECT (fts64_open, (char * const *, int,
+				int (*)(const FTSENT64 **, const FTSENT64 **)),
+		     __fts64_open_time64);
+FTSENT	*__REDIRECT (fts64_read, (FTS64 *), __fts64_read_time64);
+int	 __REDIRECT_NTH (fts64_set, (FTS64 *, FTSENT64 *, int),
+			 __fts64_set_time64);
+#  else
+#   define fts_children __fts64_children_time64
+#   define fts_close __fts64_close_time64
+#   define fts_open __fts64_open_time64
+#   define fts_read __fts64_read_time64
+#   define fts_set __fts64_set_time64
+#  endif
+# endif
 #endif
 __END_DECLS
 
diff --git a/io/fts64-time64.c b/io/fts64-time64.c
new file mode 100644
index 0000000000..c8885ca79b
--- /dev/null
+++ b/io/fts64-time64.c
@@ -0,0 +1,35 @@
+/* File tree traversal functions LFS version.
+   Copyright (C) 2015-2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <time.h>
+
+#if __TIMESIZE != 64
+# define FTS_OPEN __fts64_open_time64
+# define FTS_CLOSE __fts64_close_time64
+# define FTS_READ __fts64_read_time64
+# define FTS_SET __fts64_set_time64
+# define FTS_CHILDREN __fts64_children_time64
+# define FTSOBJ FTS64_TIME64
+# define FTSENTRY FSTENT64_TIME64
+# define INO_T ino64_t
+# define STRUCT_STAT __stat64_t64
+# define STAT __stat64_time64
+# define LSTAT __lstat64_time64
+
+# include "fts.c"
+#endif
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index f045604ad6..b4513f64da 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -206,6 +206,11 @@ libc {
     __futimens64;
     __futimes64;
     __futimesat64;
+    __fts64_open_time64;
+    __fts64_close_time64;
+    __fts64_read_time64;
+    __fts64_set_time64;
+    __fts64_children_time64;
     __getitimer64;
     __getrusage64;
     __gettimeofday64;
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index 8e3101b1c2..49fa140d7a 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -203,6 +203,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index b29a0e324e..60e3da1b8a 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -200,6 +200,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 5f5427cb46..a694b01087 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2290,6 +2290,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index ca8f7c3dbb..d40edc659c 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2244,6 +2244,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index d2b7b4d4b6..cd975e36a7 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2427,6 +2427,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index 515e383d50..77c15fda91 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -204,6 +204,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 6915fa115f..0e1ab1544e 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2371,6 +2371,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 9293872f80..26641a9573 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2341,6 +2341,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index cb671c56be..dc50753be0 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2338,6 +2338,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index f5effe36e1..3d89c7457b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2336,6 +2336,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index 2b66d26931..6bfac13584 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2334,6 +2334,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index bd76490d97..09c884ac9b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2342,6 +2342,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index e62a2a5729..fd64cce1da 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2380,6 +2380,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index bc5b23c818..306a572a38 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2398,6 +2398,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index f9421c7777..86d4a96c20 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2431,6 +2431,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index 7581354bf4..8f0716c6f6 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2396,6 +2396,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index 0e45f7fb0a..9c0b91f70b 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2251,6 +2251,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index ece6721841..280984fcc8 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2248,6 +2248,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index 6073443a3d..d46f749d1a 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2389,6 +2389,11 @@ GLIBC_2.34 __ctime64_r F
 GLIBC_2.34 __difftime64 F
 GLIBC_2.34 __fstat64_time64 F
 GLIBC_2.34 __fstatat64_time64 F
+GLIBC_2.34 __fts64_children_time64 F
+GLIBC_2.34 __fts64_close_time64 F
+GLIBC_2.34 __fts64_open_time64 F
+GLIBC_2.34 __fts64_read_time64 F
+GLIBC_2.34 __fts64_set_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 21/24] io: Add ftw64 with 64-bit time_t support
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (19 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 20/24] io: Add fts64 " Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-07 20:36 ` [PATCH v3 22/24] libsupport: Add 64-bit time_t support for time functions Adhemerval Zanella
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

Similar to fts, ftw routines passes a stat pointer that might
differ of size and layout when 64-bit time API is used.

Checked on i686-linux-gnu and x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 include/ftw.h                                 | 18 ++++++++
 io/Makefile                                   |  4 +-
 io/ftw.c                                      |  5 +-
 io/ftw.h                                      | 46 ++++++++++++++++++-
 io/ftw64-time64.c                             | 34 ++++++++++++++
 sysdeps/unix/sysv/linux/Versions              |  2 +
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |  2 +
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  2 +
 sysdeps/unix/sysv/linux/csky/libc.abilist     |  2 +
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |  2 +
 sysdeps/unix/sysv/linux/i386/libc.abilist     |  2 +
 .../sysv/linux/m68k/coldfire/libc.abilist     |  2 +
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  2 +
 .../sysv/linux/microblaze/be/libc.abilist     |  2 +
 .../sysv/linux/microblaze/le/libc.abilist     |  2 +
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  2 +
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |  2 +
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  2 +
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |  2 +
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  2 +
 .../powerpc/powerpc32/nofpu/libc.abilist      |  2 +
 .../unix/sysv/linux/s390/s390-32/libc.abilist |  2 +
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  2 +
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  2 +
 .../sysv/linux/sparc/sparc32/libc.abilist     |  2 +
 25 files changed, 141 insertions(+), 6 deletions(-)
 create mode 100644 io/ftw64-time64.c

diff --git a/include/ftw.h b/include/ftw.h
index 4fb654cf22..8fb89c4046 100644
--- a/include/ftw.h
+++ b/include/ftw.h
@@ -1 +1,19 @@
+#ifndef _FTW_H
 #include <io/ftw.h>
+
+#ifndef _ISOMAC
+# if __TIMESIZE != 64
+#  include <sys/stat.h>
+
+typedef int (*__ftw64_time64_func_t) (const char *,
+				      const struct __stat64_t64 *, int);
+typedef int (*__nftw64_time64_func_t) (const char *,
+				       const struct __stat64_t64 *, int,
+				       struct FTW *);
+
+extern int __ftw64_time64 (const char *, __ftw64_time64_func_t, int);
+extern int __nftw64_time64 (const char *, __nftw64_time64_func_t, int, int);
+# endif
+#endif
+
+#endif /* _FTW_H  */
diff --git a/io/Makefile b/io/Makefile
index 12c832cfcb..d35e966258 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -55,7 +55,8 @@ routines :=								\
 	posix_fallocate posix_fallocate64				\
 	sendfile sendfile64 copy_file_range 				\
 	utimensat futimens file_change_detection			\
-	fts64-time64
+	fts64-time64							\
+	ftw64-time64
 
 others		:= pwd
 test-srcs	:= ftwtest
@@ -106,6 +107,7 @@ CFLAGS-fts64.c += -Wno-uninitialized $(uses-callbacks) -fexceptions
 CFLAGS-fts64-time64.c += -Wno-uninitialized $(uses-callbacks) -fexceptions
 CFLAGS-ftw.c += $(uses-callbacks) -fexceptions
 CFLAGS-ftw64.c += $(uses-callbacks) -fexceptions
+CFLAGS-ftw64-time64.c += $(uses-callbacks) -fexceptions
 CFLAGS-posix_fallocate.c += -fexceptions
 CFLAGS-posix_fallocate64.c += -fexceptions
 CFLAGS-fallocate.c += -fexceptions
diff --git a/io/ftw.c b/io/ftw.c
index baca3deeee..ce1c6a14a3 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -821,7 +821,7 @@ FTW_NAME (const char *path, FTW_FUNC_T func, int descriptors)
   return ftw_startup (path, 0, func, descriptors, 0);
 }
 
-#ifndef _LIBC
+#ifndef NFTW_OLD_NAME
 int
 NFTW_NAME (const char *path, NFTW_FUNC_T func, int descriptors, int flags)
 {
@@ -844,7 +844,6 @@ NFTW_NEW_NAME (const char *path, NFTW_FUNC_T func, int descriptors, int flags)
     }
   return ftw_startup (path, 1, func, descriptors, flags);
 }
-
 versioned_symbol (libc, NFTW_NEW_NAME, NFTW_NAME, GLIBC_2_3_3);
 
 # if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_3_3)
@@ -863,4 +862,4 @@ NFTW_OLD_NAME (const char *path, NFTW_FUNC_T func, int descriptors, int flags)
 
 compat_symbol (libc, NFTW_OLD_NAME, NFTW_NAME, GLIBC_2_1);
 # endif
-#endif
+#endif /* NFTW_OLD_NAME  */
diff --git a/io/ftw.h b/io/ftw.h
index 751d689cdb..446498856d 100644
--- a/io/ftw.h
+++ b/io/ftw.h
@@ -137,15 +137,36 @@ extern int ftw (const char *__dir, __ftw_func_t __func, int __descriptors)
      __nonnull ((1, 2));
 #else
 # ifdef __REDIRECT
+#  ifndef __USE_TIME_BITS64
 extern int __REDIRECT (ftw, (const char *__dir, __ftw_func_t __func,
 			     int __descriptors), ftw64) __nonnull ((1, 2));
+#  else
+extern int __REDIRECT (ftw, (const char *__dir, __ftw_func_t __func,
+			     int __descriptors), __ftw64_time64)
+     __nonnull ((1, 2));
+#  endif
 # else
-#  define ftw ftw64
+#  ifndef __USE_TIME_BITS64
+#   define ftw ftw64
+#  else
+#   define ftw __ftw64_time64
+#  endif
 # endif
 #endif
 #ifdef __USE_LARGEFILE64
+# ifndef __USE_TIME_BITS64
 extern int ftw64 (const char *__dir, __ftw64_func_t __func,
 		  int __descriptors) __nonnull ((1, 2));
+# else
+#  ifdef __REDIRECT
+extern int __REDIRECT (ftw64, (const char *__dir, __ftw64_func_t __func,
+			       int __descriptors),
+		       __ftw64_time64)
+     __nonnull ((1, 2));
+#  else
+#   define nftw64 __nftw64_time64
+#  endif
+# endif
 #endif
 
 #ifdef __USE_XOPEN_EXTENDED
@@ -159,16 +180,37 @@ extern int nftw (const char *__dir, __nftw_func_t __func, int __descriptors,
 		 int __flag) __nonnull ((1, 2));
 # else
 #  ifdef __REDIRECT
+#   ifndef __USE_TIME_BITS64
 extern int __REDIRECT (nftw, (const char *__dir, __nftw_func_t __func,
 			      int __descriptors, int __flag), nftw64)
      __nonnull ((1, 2));
+#   else
+extern int __REDIRECT (nftw, (const char *__dir, __nftw_func_t __func,
+			      int __descriptors, int __flag), __nftw64_time64)
+     __nonnull ((1, 2));
+#   endif
 #  else
-#   define nftw nftw64
+#   ifndef __USE_TIME_BITS64
+#    define nftw nftw64
+#   else
+#    define nftw __nftw64_time64
+#   endif
 #  endif
 # endif
 # ifdef __USE_LARGEFILE64
+#  ifndef __USE_TIME_BITS64
 extern int nftw64 (const char *__dir, __nftw64_func_t __func,
 		   int __descriptors, int __flag) __nonnull ((1, 2));
+#  else
+#   ifdef __REDIRECT
+extern int __REDIRECT (nftw64, (const char *__dir, __nftw64_func_t __func,
+				int __descriptors, int __flag),
+		       __nftw64_time64)
+     __nonnull ((1, 2));
+#   else
+#    define nftw64 __nftw64_time64
+#   endif
+#  endif
 # endif
 #endif
 
diff --git a/io/ftw64-time64.c b/io/ftw64-time64.c
new file mode 100644
index 0000000000..7c9db5448a
--- /dev/null
+++ b/io/ftw64-time64.c
@@ -0,0 +1,34 @@
+/* File tree walker functions.  LFS version.
+   Copyright (C) 1996-2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sys/types.h>
+
+#if __TIMESIZE != 64
+# define FTW_NAME       __ftw64_time64
+# define NFTW_NAME      __nftw64_time64
+# define INO_T          ino64_t
+# define STRUCT_STAT    __stat64_t64
+# define LSTAT          __lstat64_time64
+# define STAT           __stat64_time64
+# define FSTATAT        __fstatat64_time64
+# define FTW_FUNC_T     __ftw64_time64_func_t
+# define NFTW_FUNC_T    __nftw64_time64_func_t
+
+# include "ftw.c"
+#endif
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index b4513f64da..aeb5c1f0b4 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -211,6 +211,8 @@ libc {
     __fts64_read_time64;
     __fts64_set_time64;
     __fts64_children_time64;
+    __ftw64_time64;
+    __nftw64_time64;
     __getitimer64;
     __getrusage64;
     __gettimeofday64;
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index 49fa140d7a..9cb72fe04b 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -208,6 +208,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -227,6 +228,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index 60e3da1b8a..5b0c9ff0f3 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -205,6 +205,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -224,6 +225,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index a694b01087..3049001346 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2295,6 +2295,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2314,6 +2315,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index d40edc659c..92629e1630 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2249,6 +2249,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2268,6 +2269,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index cd975e36a7..4cd1c26d0a 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2432,6 +2432,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2452,6 +2453,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index 77c15fda91..85b909706c 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -209,6 +209,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -228,6 +229,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 0e1ab1544e..7212e6ee9d 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2376,6 +2376,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2395,6 +2396,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 26641a9573..3103e95dd8 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2346,6 +2346,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2365,6 +2366,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index dc50753be0..d081a8c55a 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2343,6 +2343,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2362,6 +2363,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 3d89c7457b..bca2a3b05e 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2341,6 +2341,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2360,6 +2361,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index 6bfac13584..6284a0b4f9 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2339,6 +2339,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2358,6 +2359,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index 09c884ac9b..83578c8899 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2347,6 +2347,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2366,6 +2367,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index fd64cce1da..89d9c50b9e 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2385,6 +2385,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2404,6 +2405,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 306a572a38..f9cb8f1c24 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2403,6 +2403,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2422,6 +2423,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 86d4a96c20..4936a2ee5a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2436,6 +2436,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2455,6 +2456,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index 8f0716c6f6..4dd86819df 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2401,6 +2401,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2420,6 +2421,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index 9c0b91f70b..a53b86b1df 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2256,6 +2256,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2275,6 +2276,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index 280984fcc8..31d321a82c 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2253,6 +2253,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2272,6 +2273,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index d46f749d1a..a9540a7082 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2394,6 +2394,7 @@ GLIBC_2.34 __fts64_close_time64 F
 GLIBC_2.34 __fts64_open_time64 F
 GLIBC_2.34 __fts64_read_time64 F
 GLIBC_2.34 __fts64_set_time64 F
+GLIBC_2.34 __ftw64_time64 F
 GLIBC_2.34 __futimens64 F
 GLIBC_2.34 __futimes64 F
 GLIBC_2.34 __futimesat64 F
@@ -2413,6 +2414,7 @@ GLIBC_2.34 __mktime64 F
 GLIBC_2.34 __msgctl64 F
 GLIBC_2.34 __mtx_timedlock64 F
 GLIBC_2.34 __nanosleep64 F
+GLIBC_2.34 __nftw64_time64 F
 GLIBC_2.34 __ntp_gettime64 F
 GLIBC_2.34 __ntp_gettimex64 F
 GLIBC_2.34 __ppoll64 F
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 22/24] libsupport: Add 64-bit time_t support for time functions
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (20 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 21/24] io: Add ftw64 " Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-14 14:52   ` Carlos O'Donell
  2021-06-07 20:36 ` [PATCH v3 23/24] libsupport: Add 64-bit time_t support for stat functions Adhemerval Zanella
  2021-06-07 20:36 ` [PATCH v3 24/24] y2038: Add test coverage Adhemerval Zanella
  23 siblings, 1 reply; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

The patch adds redirections for xclock_gettime, xclock_settime,
timespec_add, timespec_sub, test_timespec_before_impl,
test_timespec_equal_or_after_impl, support_timespec_ns,
support_timespec_normalize, and support_timespec_check_in_range when
_TIME_BITS=64 is defined.

Co-authored-by: Lukasz Majewski <lukma@denx.de>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 support/Makefile                |  6 ++++
 support/timespec-add-time64.c   | 27 +++++++++++++++++
 support/timespec-add.c          |  2 +-
 support/timespec-sub-time64.c   | 27 +++++++++++++++++
 support/timespec-sub.c          |  2 +-
 support/timespec-time64.c       | 40 +++++++++++++++++++++++++
 support/timespec.c              |  9 +++---
 support/timespec.h              | 52 +++++++++++++++++++++++++--------
 support/xclock_gettime_time64.c | 26 +++++++++++++++++
 support/xclock_settime_time64.c | 26 +++++++++++++++++
 support/xtime.h                 |  7 +++++
 11 files changed, 205 insertions(+), 19 deletions(-)
 create mode 100644 support/timespec-add-time64.c
 create mode 100644 support/timespec-sub-time64.c
 create mode 100644 support/timespec-time64.c
 create mode 100644 support/xclock_gettime_time64.c
 create mode 100644 support/xclock_settime_time64.c

diff --git a/support/Makefile b/support/Makefile
index 0a4b057db5..e27b9b164e 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -83,8 +83,11 @@ libsupport-routines = \
   support_test_verify_impl \
   temp_file \
   timespec \
+  timespec-time64 \
   timespec-add \
+  timespec-add-time64 \
   timespec-sub \
+  timespec-sub-time64 \
   write_message \
   xaccept \
   xaccept4 \
@@ -94,7 +97,9 @@ libsupport-routines = \
   xchdir \
   xchroot \
   xclock_gettime \
+  xclock_gettime_time64 \
   xclock_settime \
+  xclock_settime_time64 \
   xclose \
   xchmod \
   xconnect \
@@ -216,6 +221,7 @@ CFLAGS-support_paths.c = \
 # in support_timespec_check_in_range and for that computation we use
 # -fexcess-precision=standard.
 CFLAGS-timespec.c += -fexcess-precision=standard
+CFLAGS-timespec-time64.c += -fexcess-precision=standard
 
 ifeq (,$(CXX))
 LINKS_DSO_PROGRAM = links-dso-program-c
diff --git a/support/timespec-add-time64.c b/support/timespec-add-time64.c
new file mode 100644
index 0000000000..a25a3c8d34
--- /dev/null
+++ b/support/timespec-add-time64.c
@@ -0,0 +1,27 @@
+/* Add two struct __timespec64 values.  64-bit time support.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library and is also part of gnulib.
+   Patches to this file should be submitted to both projects.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <time.h>
+
+#if __TIMESIZE != 64
+# define timespec      __timespec64
+# define time_t        __time64_t
+# define timespec_add  timespec_add_time64
+# include "timespec-add.c"
+#endif
diff --git a/support/timespec-add.c b/support/timespec-add.c
index cf8bd91291..8ed3acef6d 100644
--- a/support/timespec-add.c
+++ b/support/timespec-add.c
@@ -61,5 +61,5 @@ timespec_add (struct timespec a, struct timespec b)
         }
     }
 
-  return make_timespec (rs, rns);
+  return (struct timespec) { .tv_sec = rs, .tv_nsec = rns };
 }
diff --git a/support/timespec-sub-time64.c b/support/timespec-sub-time64.c
new file mode 100644
index 0000000000..dcbb79211a
--- /dev/null
+++ b/support/timespec-sub-time64.c
@@ -0,0 +1,27 @@
+/* Subtract two struct __timespec64 values.  64-bit time support.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library and is also part of gnulib.
+   Patches to this file should be submitted to both projects.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <time.h>
+
+#if __TIMESIZE != 64
+# define timespec      __timespec64
+# define time_t        __time64_t
+# define timespec_sub  timespec_sub_time64
+# include "timespec-sub.c"
+#endif
diff --git a/support/timespec-sub.c b/support/timespec-sub.c
index 08cc233086..0b8fea042d 100644
--- a/support/timespec-sub.c
+++ b/support/timespec-sub.c
@@ -61,5 +61,5 @@ timespec_sub (struct timespec a, struct timespec b)
         }
     }
 
-  return make_timespec (rs, rns);
+  return (struct timespec) { .tv_sec = rs, .tv_nsec = rns };
 }
diff --git a/support/timespec-time64.c b/support/timespec-time64.c
new file mode 100644
index 0000000000..d780658ec3
--- /dev/null
+++ b/support/timespec-time64.c
@@ -0,0 +1,40 @@
+/* Support code for timespec checks.  64-bit time support.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <support/timespec.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <assert.h>
+#include <intprops.h>
+
+#if __TIMESIZE != 64
+struct __timespec64 timespec_sub_time64 (struct __timespec64,
+					 struct __timespec64);
+
+#define test_timespec_before_impl          test_timespec_before_impl_time64
+#define test_timespec_equal_or_after_impl  \
+  test_timespec_equal_or_after_impl_time64
+#define support_timespec_ns                support_timespec_ns_time64
+#define support_timespec_normalize         support_timespec_normalize_time64
+#define support_timespec_check_in_range    \
+  support_timespec_check_in_range_time64
+#define timespec                           __timespec64
+#define timespec_sub                       timespec_sub_time64
+
+#include "timespec.c"
+#endif
diff --git a/support/timespec.c b/support/timespec.c
index b02afad9d3..fcc54861b1 100644
--- a/support/timespec.c
+++ b/support/timespec.c
@@ -23,9 +23,8 @@
 #include <intprops.h>
 
 void
-test_timespec_before_impl (const char *file, int line,
-			   const struct timespec left,
-			   const struct timespec right)
+test_timespec_before_impl (const char *file, int line, struct timespec left,
+			   struct timespec right)
 {
   if (left.tv_sec > right.tv_sec
       || (left.tv_sec == right.tv_sec
@@ -43,8 +42,8 @@ test_timespec_before_impl (const char *file, int line,
 
 void
 test_timespec_equal_or_after_impl (const char *file, int line,
-				   const struct timespec left,
-				   const struct timespec right)
+				   struct timespec left,
+				   struct timespec right)
 {
   if (left.tv_sec < right.tv_sec
       || (left.tv_sec == right.tv_sec
diff --git a/support/timespec.h b/support/timespec.h
index a3eb72aa01..0478aef51f 100644
--- a/support/timespec.h
+++ b/support/timespec.h
@@ -24,11 +24,6 @@
 #include <support/check.h>
 #include <support/xtime.h>
 
-struct timespec timespec_add (struct timespec, struct timespec)
-  __attribute__((const));
-struct timespec timespec_sub (struct timespec, struct timespec)
-  __attribute__((const));
-
 static inline struct timespec
 make_timespec (time_t s, long int ns)
 {
@@ -40,21 +35,54 @@ make_timespec (time_t s, long int ns)
 
 enum { TIMESPEC_HZ = 1000000000 };
 
+#ifndef __USE_TIME_BITS64
+struct timespec timespec_add (struct timespec, struct timespec)
+  __attribute__((const));
+struct timespec timespec_sub (struct timespec, struct timespec)
+  __attribute__((const));
+
 void test_timespec_before_impl (const char *file, int line,
-                                const struct timespec left,
-                                const struct timespec right);
+                                struct timespec left,
+                                struct timespec right);
 
 void test_timespec_equal_or_after_impl (const char *file, int line,
-                                        const struct timespec left,
-                                        const struct timespec right);
+                                        struct timespec left,
+                                        struct timespec right);
 
 time_t support_timespec_ns (struct timespec time);
 
 struct timespec support_timespec_normalize (struct timespec time);
 
-int support_timespec_check_in_range (struct timespec expected, struct timespec observed,
-				  double lower_bound, double upper_bound);
-
+int support_timespec_check_in_range (struct timespec expected,
+				     struct timespec observed,
+				     double lower_bound, double upper_bound);
+
+#else
+struct timespec __REDIRECT (timespec_add, (struct timespec, struct timespec),
+			    timespec_add_time64);
+struct timespec __REDIRECT (timespec_sub, (struct timespec, struct timespec),
+			    timespec_sub_time64);
+void __REDIRECT (test_timespec_before_impl, (const char *file, int line,
+					     struct timespec left,
+					     struct timespec right),
+		 test_timespec_before_impl_time64);
+void __REDIRECT (test_timespec_equal_or_after_impl, (const char *f, int line,
+						     struct timespec left,
+						     struct timespec right),
+		 test_timespec_equal_or_after_impl_time64);
+
+time_t __REDIRECT (support_timespec_ns, (struct timespec time),
+		   support_timespec_ns_time64);
+
+struct timespec __REDIRECT (support_timespec_normalize, (struct timespec time),
+			    support_timespec_normalize_time64);
+
+int __REDIRECT (support_timespec_check_in_range, (struct timespec expected,
+						  struct timespec observed,
+						  double lower_bound,
+						  double upper_bound),
+		support_timespec_check_in_range_time64);
+#endif
 
 /* Check that the timespec on the left represents a time before the
    time on the right. */
diff --git a/support/xclock_gettime_time64.c b/support/xclock_gettime_time64.c
new file mode 100644
index 0000000000..d2ed0f026d
--- /dev/null
+++ b/support/xclock_gettime_time64.c
@@ -0,0 +1,26 @@
+/* clock_settime with error checking.  64-bit time_t support.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <support/xtime.h>
+
+#if __TIMESIZE != 64
+# define xclock_gettime  xclock_gettime_time64
+# define timespec        __timespec64
+# define clock_gettime   __clock_gettime64
+# include "xclock_gettime.c"
+#endif
diff --git a/support/xclock_settime_time64.c b/support/xclock_settime_time64.c
new file mode 100644
index 0000000000..7f7bead876
--- /dev/null
+++ b/support/xclock_settime_time64.c
@@ -0,0 +1,26 @@
+/* clock_settime helper with error checking - 64-bit time_t support.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <support/xtime.h>
+
+#if __TIMESIZE != 64
+# define xclock_settime  xclock_settime_time64
+# define timespec        __timespec64
+# define clock_settime   __clock_settime64
+# include "xclock_settime.c"
+#endif
diff --git a/support/xtime.h b/support/xtime.h
index b4ac3b59e2..25a069d447 100644
--- a/support/xtime.h
+++ b/support/xtime.h
@@ -30,8 +30,15 @@ __BEGIN_DECLS
 /* The following functions call the corresponding libc functions and
    terminate the process on error.  */
 
+#ifndef __USE_TIME_BITS64
 void xclock_gettime (clockid_t clock, struct timespec *ts);
 void xclock_settime (clockid_t clock, const struct timespec *ts);
+#else
+void __REDIRECT (xclock_gettime, (clockid_t clock, struct timespec *ts),
+		 xclock_gettime_time64);
+void __REDIRECT (xclock_settime, (clockid_t clock, const struct timespec *ts),
+		 xclock_settime_time64);
+#endif
 
 /* This helper can often simplify tests by avoiding an explicit
    variable declaration or allowing that declaration to be const. */
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 23/24] libsupport: Add 64-bit time_t support for stat functions
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (21 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 22/24] libsupport: Add 64-bit time_t support for time functions Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  2021-06-07 20:36 ` [PATCH v3 24/24] y2038: Add test coverage Adhemerval Zanella
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

The patch adds redirections for xstat, xlstat, and xfstat when
_TIME_BITS=64 is defined.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 support/Makefile                |  3 +++
 support/support-xfstat-time64.c | 32 ++++++++++++++++++++++++++++++++
 support/support-xstat-time64.c  | 32 ++++++++++++++++++++++++++++++++
 support/xlstat-time64.c         | 32 ++++++++++++++++++++++++++++++++
 support/xunistd.h               | 13 +++++++++++++
 5 files changed, 112 insertions(+)
 create mode 100644 support/support-xfstat-time64.c
 create mode 100644 support/support-xstat-time64.c
 create mode 100644 support/xlstat-time64.c

diff --git a/support/Makefile b/support/Makefile
index e27b9b164e..f3ebaa8d2e 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -40,7 +40,9 @@ libsupport-routines = \
   resolv_test \
   set_fortify_handler \
   support-xfstat \
+  support-xfstat-time64 \
   support-xstat \
+  support-xstat-time64 \
   support_become_root \
   support_can_chroot \
   support_capture_subprocess \
@@ -117,6 +119,7 @@ libsupport-routines = \
   xlisten \
   xlseek \
   xlstat \
+  xlstat-time64 \
   xmalloc \
   xmemstream \
   xmkdir \
diff --git a/support/support-xfstat-time64.c b/support/support-xfstat-time64.c
new file mode 100644
index 0000000000..324c5d20d2
--- /dev/null
+++ b/support/support-xfstat-time64.c
@@ -0,0 +1,32 @@
+/* 64-bit time_t stat with error checking.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* NB: Non-standard file name to avoid sysdeps override for xstat.  */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+
+#if __TIMESIZE != 64
+void
+xfstat_time64 (int fd, struct __stat64_t64 *result)
+{
+  if (__fstat64_time64 (fd, result) != 0)
+    FAIL_EXIT1 ("__fstat64_time64 (%d): %m", fd);
+}
+#endif
diff --git a/support/support-xstat-time64.c b/support/support-xstat-time64.c
new file mode 100644
index 0000000000..7d0194b98a
--- /dev/null
+++ b/support/support-xstat-time64.c
@@ -0,0 +1,32 @@
+/* 64-bit time_t stat with error checking.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* NB: Non-standard file name to avoid sysdeps override for xstat.  */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+
+#if __TIMESIZE != 64
+void
+xstat_time64 (const char *path, struct __stat64_t64 *result)
+{
+  if (__stat64_time64 (path, result) != 0)
+    FAIL_EXIT1 ("__stat64_time64 (\"%s\"): %m", path);
+}
+#endif
diff --git a/support/xlstat-time64.c b/support/xlstat-time64.c
new file mode 100644
index 0000000000..ef4d922635
--- /dev/null
+++ b/support/xlstat-time64.c
@@ -0,0 +1,32 @@
+/* 64-bit time_t stat with error checking.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* NB: Non-standard file name to avoid sysdeps override for xstat.  */
+
+#include <support/check.h>
+#include <support/xunistd.h>
+#include <sys/stat.h>
+
+#if __TIMESIZE != 64
+void
+xlstat_time64 (const char *path, struct __stat64_t64 *result)
+{
+  if (__lstat64_time64 (path, result) != 0)
+    FAIL_EXIT1 ("__lstat64_time64 (\"%s\"): %m", path);
+}
+#endif
diff --git a/support/xunistd.h b/support/xunistd.h
index c642588c29..e4ade65c85 100644
--- a/support/xunistd.h
+++ b/support/xunistd.h
@@ -24,6 +24,7 @@
 
 #include <sys/cdefs.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <unistd.h>
 
 __BEGIN_DECLS
@@ -35,9 +36,21 @@ pid_t xwaitpid (pid_t, int *status, int flags);
 void xpipe (int[2]);
 void xdup2 (int, int);
 int xopen (const char *path, int flags, mode_t);
+#ifndef __USE_TIME_BITS64
+# ifdef __USE_FILE_OFFSET64
+void xstat (const char *path, struct stat *);
+void xlstat (const char *path, struct stat *);
+void xfstat (int fd, struct stat *);
+# else
 void xstat (const char *path, struct stat64 *);
 void xlstat (const char *path, struct stat64 *);
 void xfstat (int fd, struct stat64 *);
+# endif
+#else
+void __REDIRECT (xstat, (const char *path, struct stat *), xstat_time64);
+void __REDIRECT (xlstat, (const char *path, struct stat *), xlstat_time64);
+void __REDIRECT (xfstat, (int fd, struct stat *), xfstat_time64);
+#endif
 void xmkdir (const char *path, mode_t);
 void xchroot (const char *path);
 void xunlink (const char *path);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 24/24] y2038: Add test coverage
  2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
                   ` (22 preceding siblings ...)
  2021-06-07 20:36 ` [PATCH v3 23/24] libsupport: Add 64-bit time_t support for stat functions Adhemerval Zanella
@ 2021-06-07 20:36 ` Adhemerval Zanella
  23 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-07 20:36 UTC (permalink / raw)
  To: libc-alpha

It is enabled through a new rule, tests-y2038, which is built only
when the ABI supports the comapt 64-bit time_t (defined by the
header time64-compat.h, which also enables the creation of the
symbol Version for Linux).  It means the tests are not built
for ABI which already provide default 64-bit time_t.

The new rule already adds the required LFS and 64-bit time_t
compiler flags.

The current coverage is:

  * libc:
    - adjtime                       tst-adjtime-time64
    - adjtimex                      tst-adjtimex-time64
    - clock_adjtime                 tst-clock_adjtime-time64
    - clock_getres                  tst-clock-time64, tst-cpuclock1-time64
    - clock_gettime                 tst-clock-time64, tst-clock2-time64,
				    tst-cpuclock1-time64
    - clock_nanosleep               tst-clock_nanosleep-time64,
				    tst-cpuclock1-time64
    - clock_settime                 tst-clock2-time64
    - cnd_timedwait                 tst-cnd-timedwait-time64
    - ctime                         tst-ctime-time64
    - ctime_r                       tst-ctime-time64
    - difftime                      tst-difftime-time64
    - fstat                         tst-stat-time64
    - fstatat                       tst-stat-time64
    - futimens                      tst-futimens-time64
    - futimes                       tst-futimes-time64
    - futimesat                     tst-futimesat-time64
    - fts_*                         tst-fts-time64
    - getitimer                     tst-itimer-timer64
    - getrusage
    - gettimeofday                  tst-clock_nanosleep-time64
    - glob / globfree               tst-gnuglob64-time64
    - gmtime                        tst-gmtime-time64
    - gmtime_r                      tst-gmtime-time64
    - lstat                         tst-stat-time64
    - localtime                     tst-y2039-time64
    - localtime_t                   tst-y2039-time64
    - lutimes                       tst-lutimes-time64
    - mktime                        tst-mktime4-time64
    - mq_timedreceive               tst-mqueue{1248}-time64
    - mq_timedsend                  tst-mqueue{1248}-time64
    - msgctl                        test-sysvmsg-time64
    - mtx_timedlock                 tst-mtx-timedlock-time64
    - nanosleep                     tst-cpuclock{12}-time64,
				    tst-mqueue8-time64, tst-clock-time64
    - nftw / ftw                    ftwtest-time64
    - ntp_adjtime                   tst-ntp_adjtime-time64
    - ntp_gettime                   tst-ntp_gettime-time64
    - ntp_gettimex                  tst-ntp_gettimex-time64
    - ppoll                         tst-ppoll-time64
    - pselect                       tst-pselect-time64
    - pthread_clockjoin_np          tst-join14-time64
    - pthread_cond_clockwait        tst-cond11-time64
    - pthread_cond_timedwait        tst-abstime-time64
    - pthread_mutex_clocklock       tst-abstime-time64
    - pthread_mutex_timedlock       tst-abstime-time64
    - pthread_rwlock_clockrdlock    tst-abstime-time64, tst-rwlock14-time64
    - pthread_rwlock_clockwrlock    tst-abstime-time64, tst-rwlock14-time64
    - pthread_rwlock_timedrdlock    tst-abstime-time64, tst-rwlock14-time64
    - pthread_rwlock_timedwrlock    tst-abstime-time64, tst-rwlock14-time64
    - pthread_timedjoin_np          tst-join14-time64
    - recvmmsg                      tst-cancel4_2-time64
    - sched_rr_get_interval         tst-sched_rr_get_interval-time64
    - select                        tst-select-time64
    - sem_clockwait                 tst-sem5-time64
    - sem_timedwait                 tst-sem5-time64
    - semctl                        test-sysvsem-time64
    - semtimedop                    test-sysvsem-time64
    - setitimer                     tst-mqueue2-time64, tst-itimer-timer64
    - settimeofday                  tst-settimeofday-time64
    - shmctl                        test-sysvshm-time64
    - sigtimedwait                  tst-sigtimedwait-time64
    - stat                          tst-stat-time64
    - thrd_sleep                    tst-thrd-sleep-time64
    - time                          tst-mqueue{1248}-time64
    - timegm                        tst-timegm-time64
    - timer_gettime                 tst-timer4-time64
    - timer_settime                 tst-timer4-time64
    - timerfd_gettime               tst-timerfd-time64
    - timerfd_settime               tst-timerfd-time64
    - timespec_get                  tst-timespec_get-time64
    - timespec_getres               tst-timespec_getres-time64
    - utime                         tst-utime-time64
    - utimensat                     tst-utimensat-time64
    - utimes                        tst-utimes-time64
    - wait3                         tst-wait3-time64
    - wait4                         tst-wait4-time64

  * librt:
    - aio_suspend                   tst-aio6-time64
    - mq_timedreceive               tst-mqueue{1248}-time64
    - mq_timedsend                  tst-mqueue{1248}-time64
    - timer_gettime                 tst-timer4-time64
    - timer_settime                 tst-timer4-time64

  * libanl:
    - gai_suspend

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
---
 Makeconfig                                    |  14 +++
 Makerules                                     |  18 +++-
 io/Makefile                                   |  22 +++-
 io/ftwtest-time64.c                           |   1 +
 io/tst-fts-time64.c                           |   1 +
 io/tst-futimens-time64.c                      |   2 +
 io/tst-futimens.c                             |   6 +-
 io/tst-futimes-time64.c                       |   2 +
 io/tst-futimes.c                              |   6 +-
 io/tst-futimesat-time64.c                     |   4 +
 io/tst-futimesat.c                            |  47 +++++---
 io/tst-lutimes-time64.c                       |   2 +
 io/tst-lutimes.c                              |  10 +-
 io/tst-stat-time64.c                          | 102 ++++++++++++++++++
 io/tst-utime-time64.c                         |   2 +
 io/tst-utime.c                                |   6 +-
 io/tst-utimensat-time64.c                     |   2 +
 io/tst-utimensat.c                            |  12 ++-
 io/tst-utimes-time64.c                        |   2 +
 io/tst-utimes.c                               |   6 +-
 misc/Makefile                                 |   4 +
 misc/tst-pselect-time64.c                     |   1 +
 misc/tst-select-time64.c                      |   1 +
 nptl/Makefile                                 |   3 +
 nptl/tst-cancel4_2-time64.c                   |   1 +
 posix/Makefile                                |   2 +
 posix/tst-gnuglob64-time64.c                  |   7 ++
 posix/tst-sched_rr_get_interval-time64.c      |   1 +
 posix/tst-wait3-time64.c                      |   1 +
 posix/tst-wait4-time64.c                      |   1 +
 rt/Makefile                                   |   9 ++
 rt/tst-aio6-time64.c                          |   1 +
 rt/tst-cpuclock2-time64.c                     |   1 +
 rt/tst-cpuclock2.c                            |   9 +-
 rt/tst-mqueue1-time64.c                       |   1 +
 rt/tst-mqueue2-time64.c                       |   1 +
 rt/tst-mqueue4-time64.c                       |   1 +
 rt/tst-mqueue8-time64.c                       |   1 +
 rt/tst-timer4-time64.c                        |   1 +
 sysdeps/pthread/Makefile                      |  10 ++
 sysdeps/pthread/tst-abstime-time64.c          |   1 +
 sysdeps/pthread/tst-cnd-timedwait-time64.c    |   1 +
 sysdeps/pthread/tst-cond11-time64.c           |   1 +
 sysdeps/pthread/tst-join14-time64.c           |   1 +
 sysdeps/pthread/tst-mtx-timedlock-time64.c    |   1 +
 sysdeps/pthread/tst-rwlock14-time64.c         |   1 +
 sysdeps/pthread/tst-sem5-time64.c             |   1 +
 sysdeps/pthread/tst-thrd-sleep-time64.c       |   1 +
 sysdeps/unix/sysv/linux/Makefile              |  10 ++
 sysdeps/unix/sysv/linux/tst-adjtimex-time64.c |   1 +
 .../sysv/linux/tst-clock_adjtime-time64.c     |   1 +
 .../unix/sysv/linux/tst-ntp_adjtime-time64.c  |   1 +
 .../unix/sysv/linux/tst-ntp_gettime-time64.c  |   1 +
 .../unix/sysv/linux/tst-ntp_gettimex-time64.c |   1 +
 sysdeps/unix/sysv/linux/tst-ppoll-time64.c    |   1 +
 .../unix/sysv/linux/tst-sigtimedwait-time64.c |   1 +
 sysdeps/unix/sysv/linux/tst-timerfd-time64.c  |   1 +
 sysvipc/Makefile                              |   2 +
 sysvipc/test-sysvmsg-time64.c                 |   1 +
 sysvipc/test-sysvsem-time64.c                 |   1 +
 sysvipc/test-sysvshm-time64.c                 |   1 +
 time/Makefile                                 |  18 ++++
 time/tst-adjtime-time64.c                     |   1 +
 time/tst-clock-time64.c                       |   1 +
 time/tst-clock2-time64.c                      |   1 +
 time/tst-clock_nanosleep-time64.c             |   1 +
 time/tst-clock_settime-time64.c               |   1 +
 time/tst-cpuclock1-time64.c                   |   1 +
 time/tst-ctime-time64.c                       |   1 +
 time/tst-ctime.c                              |  16 +++
 time/tst-difftime-time64.c                    |   1 +
 time/tst-gmtime-time64.c                      |   1 +
 time/tst-itimer-time64.c                      |   1 +
 time/tst-mktime4-time64.c                     |   1 +
 time/tst-settimeofday-time64.c                |   1 +
 time/tst-timegm-time64.c                      |   1 +
 time/tst-timespec_get-time64.c                |   1 +
 time/tst-timespec_getres-time64.c             |   1 +
 time/tst-y2039-time64.c                       |   1 +
 time/tst-y2039.c                              |  10 ++
 80 files changed, 385 insertions(+), 30 deletions(-)
 create mode 100644 io/ftwtest-time64.c
 create mode 100644 io/tst-fts-time64.c
 create mode 100644 io/tst-futimens-time64.c
 create mode 100644 io/tst-futimes-time64.c
 create mode 100644 io/tst-futimesat-time64.c
 create mode 100644 io/tst-lutimes-time64.c
 create mode 100644 io/tst-stat-time64.c
 create mode 100644 io/tst-utime-time64.c
 create mode 100644 io/tst-utimensat-time64.c
 create mode 100644 io/tst-utimes-time64.c
 create mode 100644 misc/tst-pselect-time64.c
 create mode 100644 misc/tst-select-time64.c
 create mode 100644 nptl/tst-cancel4_2-time64.c
 create mode 100644 posix/tst-gnuglob64-time64.c
 create mode 100644 posix/tst-sched_rr_get_interval-time64.c
 create mode 100644 posix/tst-wait3-time64.c
 create mode 100644 posix/tst-wait4-time64.c
 create mode 100644 rt/tst-aio6-time64.c
 create mode 100644 rt/tst-cpuclock2-time64.c
 create mode 100644 rt/tst-mqueue1-time64.c
 create mode 100644 rt/tst-mqueue2-time64.c
 create mode 100644 rt/tst-mqueue4-time64.c
 create mode 100644 rt/tst-mqueue8-time64.c
 create mode 100644 rt/tst-timer4-time64.c
 create mode 100644 sysdeps/pthread/tst-abstime-time64.c
 create mode 100644 sysdeps/pthread/tst-cnd-timedwait-time64.c
 create mode 100644 sysdeps/pthread/tst-cond11-time64.c
 create mode 100644 sysdeps/pthread/tst-join14-time64.c
 create mode 100644 sysdeps/pthread/tst-mtx-timedlock-time64.c
 create mode 100644 sysdeps/pthread/tst-rwlock14-time64.c
 create mode 100644 sysdeps/pthread/tst-sem5-time64.c
 create mode 100644 sysdeps/pthread/tst-thrd-sleep-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-adjtimex-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-ppoll-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c
 create mode 100644 sysdeps/unix/sysv/linux/tst-timerfd-time64.c
 create mode 100644 sysvipc/test-sysvmsg-time64.c
 create mode 100644 sysvipc/test-sysvsem-time64.c
 create mode 100644 sysvipc/test-sysvshm-time64.c
 create mode 100644 time/tst-adjtime-time64.c
 create mode 100644 time/tst-clock-time64.c
 create mode 100644 time/tst-clock2-time64.c
 create mode 100644 time/tst-clock_nanosleep-time64.c
 create mode 100644 time/tst-clock_settime-time64.c
 create mode 100644 time/tst-cpuclock1-time64.c
 create mode 100644 time/tst-ctime-time64.c
 create mode 100644 time/tst-difftime-time64.c
 create mode 100644 time/tst-gmtime-time64.c
 create mode 100644 time/tst-itimer-time64.c
 create mode 100644 time/tst-mktime4-time64.c
 create mode 100644 time/tst-settimeofday-time64.c
 create mode 100644 time/tst-timegm-time64.c
 create mode 100644 time/tst-timespec_get-time64.c
 create mode 100644 time/tst-timespec_getres-time64.c
 create mode 100644 time/tst-y2039-time64.c

diff --git a/Makeconfig b/Makeconfig
index c3496452b6..b6357d0b19 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1235,6 +1235,20 @@ $(common-objpfx)versions.stmp: $(common-objpfx)Versions.all \
 	touch $@
 endif # avoid-generated
 endif # $(build-shared) = yes
+
+-include $(common-objpfx)time64-compat.mk
+postclean-generated += time64-compat.mk
+
+$(common-objpfx)time64-compat.mk: $(sysd-versions-force) \
+				  $(common-objpfx)time64-compat.i
+	sed '/^[        ]*#/d;/^[       ]*$$/d' $< > $@T
+	mv -f $@T $@
+$(common-objpfx)time64-compat.i: $(..)Makeconfig
+	printf "#include <time64-compat.h>\n#ifdef TIME64_NON_DEFAULT\nhave-time64-compat = yes\n#endif" \
+	| $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - > $@T
+	mv -f $@T $@
+
+
 endif # sysd-sorted-done
 
 # The name under which the run-time dynamic linker is installed.
diff --git a/Makerules b/Makerules
index ca9885436e..12f1a5cb50 100644
--- a/Makerules
+++ b/Makerules
@@ -771,7 +771,8 @@ endif
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
 	     $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
 	     $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
-	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
+	     $(addsuffix .d,$(tests) $(tests-internal) $(xtests) \
+		$(test-srcs) $(tests-time64) $(xtests-time64))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
 endif
@@ -1286,6 +1287,21 @@ check: tests
 .PHONY: xcheck
 xcheck: xtests
 
+# Handle tests-time64 and xtests-time64 that should built with LFS
+# and 64-bit time support.
+include $(o-iterator)
+define o-iterator-doit
+$(foreach f,$(tests-time64) $(xtests-time64),\
+	    $(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+endef
+object-suffixes-left := $(all-object-suffixes)
+include $(o-iterator)
+
+ifeq ($(have-time64-compat),yes)
+tests += $(foreach t,$(tests-time64),$(t))
+xtests += $(foreach t,$(xtests-time64),$(t))
+endif
+
 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
 # that almost all internal declarations from config.h, libc-symbols.h, and
 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
diff --git a/io/Makefile b/io/Makefile
index d35e966258..ba8bd37355 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -59,7 +59,7 @@ routines :=								\
 	ftw64-time64
 
 others		:= pwd
-test-srcs	:= ftwtest
+test-srcs	:= ftwtest ftwtest-time64
 tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-fcntl bug-ftw1 bug-ftw2 bug-ftw3 bug-ftw4 tst-statvfs \
 		   tst-openat tst-unlinkat tst-fstatat tst-futimesat \
@@ -78,12 +78,24 @@ tests		:= test-utime test-stat test-stat2 test-lfs tst-getcwd \
 		   tst-futimens \
 		   tst-utimensat \
 
+tests-time64 := \
+  tst-futimens-time64 \
+  tst-futimes-time64\
+  tst-fts-time64 \
+  tst-lutimes-time64 \
+  tst-stat-time64 \
+  tst-futimesat-time64 \
+  tst-utime-time64 \
+  tst-utimensat-time64 \
+  tst-utimes-time64 \
+
 # Likewise for statx, but we do not need static linking here.
 tests-internal += tst-statx
 tests-static += tst-statx
 
 ifeq ($(run-built-tests),yes)
-tests-special += $(objpfx)ftwtest.out
+tests-special += $(objpfx)ftwtest.out \
+		 $(objpfx)ftwtest-time64.out
 endif
 
 include ../Rules
@@ -125,8 +137,14 @@ tst-statvfs-ARGS = $(objpfx)tst-statvfs tst-statvfs.c /tmp
 
 tst-open-tmpfile-ARGS = --test-dir=$(objpfx)
 
+CFLAGS-ftwtest-time64.c += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64
+
 ifeq ($(run-built-tests),yes)
 $(objpfx)ftwtest.out: ftwtest-sh $(objpfx)ftwtest
 	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
 	$(evaluate-test)
+
+$(objpfx)ftwtest-time64.out: ftwtest-sh $(objpfx)ftwtest-time64
+	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
+	$(evaluate-test)
 endif
diff --git a/io/ftwtest-time64.c b/io/ftwtest-time64.c
new file mode 100644
index 0000000000..67f1c46826
--- /dev/null
+++ b/io/ftwtest-time64.c
@@ -0,0 +1 @@
+#include "ftwtest.c"
diff --git a/io/tst-fts-time64.c b/io/tst-fts-time64.c
new file mode 100644
index 0000000000..a4a41fe1cf
--- /dev/null
+++ b/io/tst-fts-time64.c
@@ -0,0 +1 @@
+#include "tst-fts.c"
diff --git a/io/tst-futimens-time64.c b/io/tst-futimens-time64.c
new file mode 100644
index 0000000000..88fcb38489
--- /dev/null
+++ b/io/tst-futimens-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimens.c"
diff --git a/io/tst-futimens.c b/io/tst-futimens.c
index b3e3f3137f..4c18ede573 100644
--- a/io/tst-futimens.c
+++ b/io/tst-futimens.c
@@ -20,13 +20,17 @@
 #include <support/xunistd.h>
 #include <sys/stat.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_futimens_helper (const char *file, int fd, const struct timespec *ts)
 {
   int result = futimens (fd, ts);
   TEST_VERIFY_EXIT (result == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for atime match */
diff --git a/io/tst-futimes-time64.c b/io/tst-futimes-time64.c
new file mode 100644
index 0000000000..d489c265d1
--- /dev/null
+++ b/io/tst-futimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-futimes.c"
diff --git a/io/tst-futimes.c b/io/tst-futimes.c
index bdef38d7cb..9575a4b08e 100644
--- a/io/tst-futimes.c
+++ b/io/tst-futimes.c
@@ -21,13 +21,17 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_futimens_helper (const char *file, int fd, const struct timeval *tv)
 {
   int r = futimes (fd, tv);
   TEST_VERIFY_EXIT (r == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for atime match */
diff --git a/io/tst-futimesat-time64.c b/io/tst-futimesat-time64.c
new file mode 100644
index 0000000000..f6c0500eef
--- /dev/null
+++ b/io/tst-futimesat-time64.c
@@ -0,0 +1,4 @@
+#define struct_stat  struct stat
+#define fstat        fstat
+#define fstatat      fstatat
+#include "io/tst-futimesat.c"
diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c
index af58ad06dd..c32ab2b668 100644
--- a/io/tst-futimesat.c
+++ b/io/tst-futimesat.c
@@ -1,4 +1,23 @@
+/* futimesat basic tests.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
 #include <dirent.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -7,19 +26,19 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#include <support/test-driver.h>
+#include <support/temp_file.h>
 
-static void prepare (void);
-#define PREPARE(argc, argv) prepare ()
-
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-
-#include "../test-skeleton.c"
+#ifndef struct_stat
+# define struct_stat struct stat64
+# define fstat       fstat64
+# define fstatat     fstatat64
+#endif
 
 static int dir_fd;
 
 static void
-prepare (void)
+prepare (int argc, char *argv[])
 {
   size_t test_dir_len = strlen (test_dir);
   static const char dir_name[] = "/tst-futimesat.XXXXXX";
@@ -48,7 +67,7 @@ prepare (void)
       exit (1);
     }
 }
-
+#define PREPARE prepare
 
 static int
 do_test (void)
@@ -98,8 +117,8 @@ do_test (void)
   write (fd, "hello", 5);
   puts ("file created");
 
-  struct stat64 st1;
-  if (fstat64 (fd, &st1) != 0)
+  struct_stat st1;
+  if (fstat (fd, &st1) != 0)
     {
       puts ("fstat64 failed");
       return 1;
@@ -118,8 +137,8 @@ do_test (void)
       return 1;
     }
 
-  struct stat64 st2;
-  if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0)
+  struct_stat st2;
+  if (fstatat (dir_fd, "some-file", &st2, 0) != 0)
     {
       puts ("fstatat64 failed");
       return 1;
@@ -146,3 +165,5 @@ do_test (void)
 
   return 0;
 }
+
+#include <support/test-driver.c>
diff --git a/io/tst-lutimes-time64.c b/io/tst-lutimes-time64.c
new file mode 100644
index 0000000000..06caec0a91
--- /dev/null
+++ b/io/tst-lutimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-lutimes.c"
diff --git a/io/tst-lutimes.c b/io/tst-lutimes.c
index b2da3c5796..237a870415 100644
--- a/io/tst-lutimes.c
+++ b/io/tst-lutimes.c
@@ -21,23 +21,27 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_lutimes_helper (const char *testfile, int fd, const char *testlink,
                      const struct timeval *tv)
 {
-  struct stat64 stfile_orig;
+  struct_stat stfile_orig;
   xlstat (testfile, &stfile_orig);
 
   TEST_VERIFY_EXIT (lutimes (testlink, tv) == 0);
 
-  struct stat64 stlink;
+  struct_stat stlink;
   xlstat (testlink, &stlink);
 
   TEST_COMPARE (stlink.st_atime, tv[0].tv_sec);
   TEST_COMPARE (stlink.st_mtime, tv[1].tv_sec);
 
   /* Check if the timestamp from original file is not changed.  */
-  struct stat64 stfile;
+  struct_stat stfile;
   xlstat (testfile, &stfile);
 
   TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime);
diff --git a/io/tst-stat-time64.c b/io/tst-stat-time64.c
new file mode 100644
index 0000000000..8feded56d5
--- /dev/null
+++ b/io/tst-stat-time64.c
@@ -0,0 +1,102 @@
+/* Basic test of stat with 64-bit time_t interfaces.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <support/check.h>
+#include <support/support.h>
+#include <support/temp_file.h>
+#include <support/xunistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+/* The idea of the test is check whether the 64-bit time_t stat implementation
+   returns the expected value for comparable fields, so it does not really
+   matter whether statx uses a fallback implementation or not.  */
+
+static void
+stat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (stat (path, st), 0);
+}
+
+static void
+lstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (lstat (path, st), 0);
+}
+
+static void
+fstat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstat (fd, st), 0);
+}
+
+static void
+fstatat_check (int fd, const char *path, struct stat *st)
+{
+  TEST_COMPARE (fstatat (fd, path, st, 0), 0);
+}
+
+typedef void (*test_t)(int, const char *path, struct stat *);
+
+static int
+do_test (void)
+{
+  char *path;
+  int fd = create_temp_file ("tst-statx-", &path);
+  TEST_VERIFY_EXIT (fd >= 0);
+  support_write_file_string (path, "abc");
+
+  struct statx stx;
+  TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0);
+
+  for (test_t *test = (test_t[]) { stat_check, lstat_check, fstat_check,
+				   fstatat_check, NULL };
+       *test != NULL; test++)
+  {
+    struct stat st;
+    (*test) (fd, path, &st);
+
+    TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
+    TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
+    TEST_COMPARE (stx.stx_ino, st.st_ino);
+    TEST_COMPARE (stx.stx_mode, st.st_mode);
+    TEST_COMPARE (stx.stx_nlink, st.st_nlink);
+    TEST_COMPARE (stx.stx_uid, st.st_uid);
+    TEST_COMPARE (stx.stx_gid, st.st_gid);
+    TEST_COMPARE (stx.stx_rdev_major, major (st.st_rdev));
+    TEST_COMPARE (stx.stx_rdev_minor, minor (st.st_rdev));
+    TEST_COMPARE (stx.stx_blksize, st.st_blksize);
+    TEST_COMPARE (stx.stx_blocks, st.st_blocks);
+
+    TEST_COMPARE (stx.stx_ctime.tv_sec, st.st_ctim.tv_sec);
+    TEST_COMPARE (stx.stx_ctime.tv_nsec, st.st_ctim.tv_nsec);
+    TEST_COMPARE (stx.stx_mtime.tv_sec, st.st_mtim.tv_sec);
+    TEST_COMPARE (stx.stx_mtime.tv_nsec, st.st_mtim.tv_nsec);
+  }
+
+  xclose (fd);
+  free (path);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/io/tst-utime-time64.c b/io/tst-utime-time64.c
new file mode 100644
index 0000000000..eb62f59126
--- /dev/null
+++ b/io/tst-utime-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utime.c"
diff --git a/io/tst-utime.c b/io/tst-utime.c
index 6269ef7929..0144e2a22a 100644
--- a/io/tst-utime.c
+++ b/io/tst-utime.c
@@ -21,13 +21,17 @@
 #include <support/xunistd.h>
 #include <sys/stat.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_utime_helper (const char *file, int fd, const struct utimbuf *ut)
 {
   int result = utime (file, ut);
   TEST_VERIFY_EXIT (result == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for actime match */
diff --git a/io/tst-utimensat-time64.c b/io/tst-utimensat-time64.c
new file mode 100644
index 0000000000..7ac7d8df1d
--- /dev/null
+++ b/io/tst-utimensat-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimensat.c"
diff --git a/io/tst-utimensat.c b/io/tst-utimensat.c
index 0c7c8470bc..062abdd8d3 100644
--- a/io/tst-utimensat.c
+++ b/io/tst-utimensat.c
@@ -22,6 +22,10 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_utimesat_helper (const char *testfile, int fd, const char *testlink,
                       const struct timespec *ts)
@@ -29,7 +33,7 @@ test_utimesat_helper (const char *testfile, int fd, const char *testlink,
   {
     TEST_VERIFY_EXIT (utimensat (fd, testfile, ts, 0) == 0);
 
-    struct stat64 st;
+    struct_stat st;
     xfstat (fd, &st);
 
     /* Check if seconds for atime match */
@@ -40,20 +44,20 @@ test_utimesat_helper (const char *testfile, int fd, const char *testlink,
   }
 
   {
-    struct stat64 stfile_orig;
+    struct_stat stfile_orig;
     xlstat (testfile, &stfile_orig);
 
     TEST_VERIFY_EXIT (utimensat (0 /* ignored  */, testlink, ts,
 				 AT_SYMLINK_NOFOLLOW)
 		       == 0);
-    struct stat64 stlink;
+    struct_stat stlink;
     xlstat (testlink, &stlink);
 
     TEST_COMPARE (stlink.st_atime, ts[0].tv_sec);
     TEST_COMPARE (stlink.st_mtime, ts[1].tv_sec);
 
     /* Check if the timestamp from original file is not changed.  */
-    struct stat64 stfile;
+    struct_stat stfile;
     xlstat (testfile, &stfile);
 
     TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime);
diff --git a/io/tst-utimes-time64.c b/io/tst-utimes-time64.c
new file mode 100644
index 0000000000..234ec02541
--- /dev/null
+++ b/io/tst-utimes-time64.c
@@ -0,0 +1,2 @@
+#define struct_stat struct stat
+#include "tst-utimes.c"
diff --git a/io/tst-utimes.c b/io/tst-utimes.c
index 991ab0c7d3..e88efff45b 100644
--- a/io/tst-utimes.c
+++ b/io/tst-utimes.c
@@ -22,13 +22,17 @@
 #include <sys/time.h>
 #include <time.h>
 
+#ifndef struct_stat
+# define struct_stat struct stat64
+#endif
+
 static int
 test_utimes_helper (const char *file, int fd, const struct timeval *tv)
 {
   int result = utimes (file, tv);
   TEST_VERIFY_EXIT (result == 0);
 
-  struct stat64 st;
+  struct_stat st;
   xfstat (fd, &st);
 
   /* Check if seconds for atime match */
diff --git a/misc/Makefile b/misc/Makefile
index c103b6bff4..f34ab09fe3 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -90,6 +90,10 @@ tests := tst-dirname tst-tsearch tst-fdset tst-mntent tst-hsearch \
 	 tst-ldbl-warn tst-ldbl-error tst-dbl-efgcvt tst-ldbl-efgcvt \
 	 tst-mntent-autofs tst-syscalls tst-mntent-escape tst-select
 
+tests-time64 := \
+  tst-select-time64 \
+  tst-pselect-time64
+
 # Tests which need libdl.
 ifeq (yes,$(build-shared))
 tests += tst-gethostid
diff --git a/misc/tst-pselect-time64.c b/misc/tst-pselect-time64.c
new file mode 100644
index 0000000000..15a1e49292
--- /dev/null
+++ b/misc/tst-pselect-time64.c
@@ -0,0 +1 @@
+#include "tst-pselect.c"
diff --git a/misc/tst-select-time64.c b/misc/tst-select-time64.c
new file mode 100644
index 0000000000..13120bfe31
--- /dev/null
+++ b/misc/tst-select-time64.c
@@ -0,0 +1 @@
+#include "tst-select.c"
diff --git a/nptl/Makefile b/nptl/Makefile
index f7d7a2c7e2..727761e610 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -324,6 +324,9 @@ xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
 	tst-mutexpp5 tst-mutexpp9
 
+tests-time64 := \
+  tst-cancel4_2-time64
+
 # This test can run into task limits because of a linux kernel bug
 # and then cause the make process to fail too, see bug 24537.
 xtests += tst-eintr1
diff --git a/nptl/tst-cancel4_2-time64.c b/nptl/tst-cancel4_2-time64.c
new file mode 100644
index 0000000000..4ac086a312
--- /dev/null
+++ b/nptl/tst-cancel4_2-time64.c
@@ -0,0 +1 @@
+#include "tst-cancel4_2.c"
diff --git a/posix/Makefile b/posix/Makefile
index c8c538fcee..8d139e54f6 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -122,7 +122,9 @@ endif
 tests-internal	:= bug-regex5 bug-regex20 bug-regex33 \
 		   tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3
 tests-container := bug-ga2
+tests-time64	:= tst-wait4-time64 tst-wait3-time64 tst-gnuglob64-time64
 xtests		:= tst-getaddrinfo4 tst-getaddrinfo5 tst-sched_rr_get_interval
+xtests-time64	:= tst-sched_rr_get_interval-time64
 ifeq (yes,$(build-shared))
 test-srcs	:= globtest
 tests           += wordexp-test tst-exec tst-spawn tst-spawn2 tst-spawn3
diff --git a/posix/tst-gnuglob64-time64.c b/posix/tst-gnuglob64-time64.c
new file mode 100644
index 0000000000..00922bcdc6
--- /dev/null
+++ b/posix/tst-gnuglob64-time64.c
@@ -0,0 +1,7 @@
+#define GLOB_FUNC glob
+#define GLOB_TYPE glob_t
+#define GLOBFREE_FUNC globfree
+#define DIRENT_STRUCT dirent
+#define STAT_STRUCT stat
+
+#include "tst-gnuglob-skeleton.c"
diff --git a/posix/tst-sched_rr_get_interval-time64.c b/posix/tst-sched_rr_get_interval-time64.c
new file mode 100644
index 0000000000..f4e66d2939
--- /dev/null
+++ b/posix/tst-sched_rr_get_interval-time64.c
@@ -0,0 +1 @@
+#include "tst-sched_rr_get_interval.c"
diff --git a/posix/tst-wait3-time64.c b/posix/tst-wait3-time64.c
new file mode 100644
index 0000000000..2837bc7a9e
--- /dev/null
+++ b/posix/tst-wait3-time64.c
@@ -0,0 +1 @@
+#include "tst-wait3.c"
diff --git a/posix/tst-wait4-time64.c b/posix/tst-wait4-time64.c
new file mode 100644
index 0000000000..12543b270f
--- /dev/null
+++ b/posix/tst-wait4-time64.c
@@ -0,0 +1 @@
+#include "tst-wait4.c"
diff --git a/rt/Makefile b/rt/Makefile
index 97c9bbd9de..797f2da51e 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -51,6 +51,15 @@ tests := tst-shm tst-timer tst-timer2 \
 	 tst-shm-cancel
 tests-internal := tst-timer-sigmask
 
+tests-time64 := \
+  tst-aio6-time64 \
+  tst-cpuclock2-time64 \
+  tst-mqueue1-time64 \
+  tst-mqueue2-time64 \
+  tst-mqueue4-time64 \
+  tst-mqueue8-time64 \
+  tst-timer4-time64
+
 extra-libs := librt
 extra-libs-others := $(extra-libs)
 
diff --git a/rt/tst-aio6-time64.c b/rt/tst-aio6-time64.c
new file mode 100644
index 0000000000..a386a577ec
--- /dev/null
+++ b/rt/tst-aio6-time64.c
@@ -0,0 +1 @@
+#include "tst-aio6.c"
diff --git a/rt/tst-cpuclock2-time64.c b/rt/tst-cpuclock2-time64.c
new file mode 100644
index 0000000000..05775522bb
--- /dev/null
+++ b/rt/tst-cpuclock2-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock2.c"
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index c1c7ed2ad8..eebc3609d0 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -21,7 +21,11 @@
 
 #if (_POSIX_THREADS - 0) <= 0
 
-# define TEST_FUNCTION 0
+static int
+do_test ()
+{
+  return 0;
+}
 
 #else
 
@@ -330,7 +334,6 @@ do_test (void)
 
   return result;
 }
-# define TEST_FUNCTION do_test ()
 #endif
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/rt/tst-mqueue1-time64.c b/rt/tst-mqueue1-time64.c
new file mode 100644
index 0000000000..9c600a9a97
--- /dev/null
+++ b/rt/tst-mqueue1-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue1.c"
diff --git a/rt/tst-mqueue2-time64.c b/rt/tst-mqueue2-time64.c
new file mode 100644
index 0000000000..9d49f0b196
--- /dev/null
+++ b/rt/tst-mqueue2-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue2.c"
diff --git a/rt/tst-mqueue4-time64.c b/rt/tst-mqueue4-time64.c
new file mode 100644
index 0000000000..c23a228dc4
--- /dev/null
+++ b/rt/tst-mqueue4-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue4.c"
diff --git a/rt/tst-mqueue8-time64.c b/rt/tst-mqueue8-time64.c
new file mode 100644
index 0000000000..972637f7f5
--- /dev/null
+++ b/rt/tst-mqueue8-time64.c
@@ -0,0 +1 @@
+#include "tst-mqueue8.c"
diff --git a/rt/tst-timer4-time64.c b/rt/tst-timer4-time64.c
new file mode 100644
index 0000000000..e47a593f10
--- /dev/null
+++ b/rt/tst-timer4-time64.c
@@ -0,0 +1 @@
+#include "tst-timer4.c"
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index e4690a7bc4..9e6ed3c6f7 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -124,6 +124,16 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
 	 tst-unwind-thread \
 	 tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \
 
+tests-time64 := \
+  tst-abstime-time64 \
+  tst-cnd-timedwait-time64 \
+  tst-cond11-time64 \
+  tst-join14-time64 \
+  tst-mtx-timedlock-time64 \
+  tst-rwlock14-time64 \
+  tst-sem5-time64 \
+  tst-thrd-sleep-time64 \
+
 
 # Files which must not be linked with libpthread.
 tests-nolibpthread += tst-unload
diff --git a/sysdeps/pthread/tst-abstime-time64.c b/sysdeps/pthread/tst-abstime-time64.c
new file mode 100644
index 0000000000..2fc77cb365
--- /dev/null
+++ b/sysdeps/pthread/tst-abstime-time64.c
@@ -0,0 +1 @@
+#include "tst-abstime.c"
diff --git a/sysdeps/pthread/tst-cnd-timedwait-time64.c b/sysdeps/pthread/tst-cnd-timedwait-time64.c
new file mode 100644
index 0000000000..9b2abfd277
--- /dev/null
+++ b/sysdeps/pthread/tst-cnd-timedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-cnd-timedwait.c"
diff --git a/sysdeps/pthread/tst-cond11-time64.c b/sysdeps/pthread/tst-cond11-time64.c
new file mode 100644
index 0000000000..9bccb8ec8b
--- /dev/null
+++ b/sysdeps/pthread/tst-cond11-time64.c
@@ -0,0 +1 @@
+#include "tst-cond11.c"
diff --git a/sysdeps/pthread/tst-join14-time64.c b/sysdeps/pthread/tst-join14-time64.c
new file mode 100644
index 0000000000..bed784ee24
--- /dev/null
+++ b/sysdeps/pthread/tst-join14-time64.c
@@ -0,0 +1 @@
+#include "tst-join14.c"
diff --git a/sysdeps/pthread/tst-mtx-timedlock-time64.c b/sysdeps/pthread/tst-mtx-timedlock-time64.c
new file mode 100644
index 0000000000..b3393c99ef
--- /dev/null
+++ b/sysdeps/pthread/tst-mtx-timedlock-time64.c
@@ -0,0 +1 @@
+#include "tst-mtx-timedlock.c"
diff --git a/sysdeps/pthread/tst-rwlock14-time64.c b/sysdeps/pthread/tst-rwlock14-time64.c
new file mode 100644
index 0000000000..ae9b1912cf
--- /dev/null
+++ b/sysdeps/pthread/tst-rwlock14-time64.c
@@ -0,0 +1 @@
+#include "tst-rwlock14.c"
diff --git a/sysdeps/pthread/tst-sem5-time64.c b/sysdeps/pthread/tst-sem5-time64.c
new file mode 100644
index 0000000000..89c2a14f94
--- /dev/null
+++ b/sysdeps/pthread/tst-sem5-time64.c
@@ -0,0 +1 @@
+#include "tst-sem5.c"
diff --git a/sysdeps/pthread/tst-thrd-sleep-time64.c b/sysdeps/pthread/tst-thrd-sleep-time64.c
new file mode 100644
index 0000000000..02837bd19f
--- /dev/null
+++ b/sysdeps/pthread/tst-thrd-sleep-time64.c
@@ -0,0 +1 @@
+#include "tst-thrd-sleep.c"
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index aedd02fd55..294c366e3b 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -125,6 +125,16 @@ endif
 
 tests-internal += tst-sigcontext-get_pc
 
+tests-time64 += \
+  tst-adjtimex-time64 \
+  tst-clock_adjtime-time64 \
+  tst-ntp_adjtime-time64 \
+  tst-ntp_gettime-time64 \
+  tst-ntp_gettimex-time64 \
+  tst-ppoll-time64 \
+  tst-sigtimedwait-time64 \
+  tst-timerfd-time64 \
+
 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
 
 # Generate the list of SYS_* macros for the system calls (__NR_*
diff --git a/sysdeps/unix/sysv/linux/tst-adjtimex-time64.c b/sysdeps/unix/sysv/linux/tst-adjtimex-time64.c
new file mode 100644
index 0000000000..2b6988b7c4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-adjtimex-time64.c
@@ -0,0 +1 @@
+#include "tst-adjtimex.c"
diff --git a/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
new file mode 100644
index 0000000000..9691e81229
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-clock_adjtime-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_adjtime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c b/sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c
new file mode 100644
index 0000000000..30e7380b02
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ntp_adjtime-time64.c
@@ -0,0 +1 @@
+#include "tst-ntp_adjtime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c b/sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c
new file mode 100644
index 0000000000..42caa66301
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ntp_gettime-time64.c
@@ -0,0 +1 @@
+#include "tst-ntp_gettime.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c b/sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c
new file mode 100644
index 0000000000..3f017b3c22
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ntp_gettimex-time64.c
@@ -0,0 +1 @@
+#include "tst-ntp_gettimex.c"
diff --git a/sysdeps/unix/sysv/linux/tst-ppoll-time64.c b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
new file mode 100644
index 0000000000..96ee2faee3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ppoll-time64.c
@@ -0,0 +1 @@
+#include "tst-ppoll.c"
diff --git a/sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c b/sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c
new file mode 100644
index 0000000000..1513e81749
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-sigtimedwait-time64.c
@@ -0,0 +1 @@
+#include "tst-sigtimedwait.c"
diff --git a/sysdeps/unix/sysv/linux/tst-timerfd-time64.c b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
new file mode 100644
index 0000000000..bb17f48139
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-timerfd-time64.c
@@ -0,0 +1 @@
+#include "tst-timerfd.c"
diff --git a/sysvipc/Makefile b/sysvipc/Makefile
index a534791928..86911803b5 100644
--- a/sysvipc/Makefile
+++ b/sysvipc/Makefile
@@ -32,6 +32,8 @@ routines := ftok \
 
 tests    := test-sysvmsg test-sysvsem test-sysvshm
 
+tests-time64 := test-sysvmsg-time64 test-sysvsem-time64 test-sysvshm-time64
+
 include ../Rules
 
 CFLAGS-msgrcv.c += -fexceptions -fasynchronous-unwind-tables
diff --git a/sysvipc/test-sysvmsg-time64.c b/sysvipc/test-sysvmsg-time64.c
new file mode 100644
index 0000000000..c23e0c337e
--- /dev/null
+++ b/sysvipc/test-sysvmsg-time64.c
@@ -0,0 +1 @@
+#include "test-sysvmsg.c"
diff --git a/sysvipc/test-sysvsem-time64.c b/sysvipc/test-sysvsem-time64.c
new file mode 100644
index 0000000000..05c95068cd
--- /dev/null
+++ b/sysvipc/test-sysvsem-time64.c
@@ -0,0 +1 @@
+#include "test-sysvsem.c"
diff --git a/sysvipc/test-sysvshm-time64.c b/sysvipc/test-sysvshm-time64.c
new file mode 100644
index 0000000000..8e2963f563
--- /dev/null
+++ b/sysvipc/test-sysvshm-time64.c
@@ -0,0 +1 @@
+#include "test-sysvshm.c"
diff --git a/time/Makefile b/time/Makefile
index 805c79c4d0..c84bd5d3ec 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -52,6 +52,24 @@ tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-settimeofday tst-itimer tst-gmtime tst-timegm \
 	   tst-timespec_get tst-timespec_getres
 
+tests-time64 := \
+  tst-adjtime-time64 \
+  tst-clock-time64 \
+  tst-clock2-time64 \
+  tst-clock_nanosleep-time64 \
+  tst-clock_settime-time64 \
+  tst-cpuclock1-time64 \
+  tst-ctime-time64 \
+  tst-difftime-time64 \
+  tst-gmtime-time64 \
+  tst-itimer-time64 \
+  tst-mktime4-time64 \
+  tst-settimeofday-time64 \
+  tst-timegm-time64 \
+  tst-timespec_get-time64 \
+  tst-timespec_getres-time64 \
+  tst-y2039-time64
+
 include ../Rules
 
 ifeq ($(run-built-tests),yes)
diff --git a/time/tst-adjtime-time64.c b/time/tst-adjtime-time64.c
new file mode 100644
index 0000000000..097d6efc4b
--- /dev/null
+++ b/time/tst-adjtime-time64.c
@@ -0,0 +1 @@
+#include <tst-adjtime.c>
diff --git a/time/tst-clock-time64.c b/time/tst-clock-time64.c
new file mode 100644
index 0000000000..a1349678c8
--- /dev/null
+++ b/time/tst-clock-time64.c
@@ -0,0 +1 @@
+#include "tst-clock.c"
diff --git a/time/tst-clock2-time64.c b/time/tst-clock2-time64.c
new file mode 100644
index 0000000000..897f47b287
--- /dev/null
+++ b/time/tst-clock2-time64.c
@@ -0,0 +1 @@
+#include "tst-clock2.c"
diff --git a/time/tst-clock_nanosleep-time64.c b/time/tst-clock_nanosleep-time64.c
new file mode 100644
index 0000000000..c8638aa3d2
--- /dev/null
+++ b/time/tst-clock_nanosleep-time64.c
@@ -0,0 +1 @@
+#include "tst-clock_nanosleep.c"
diff --git a/time/tst-clock_settime-time64.c b/time/tst-clock_settime-time64.c
new file mode 100644
index 0000000000..328b04a030
--- /dev/null
+++ b/time/tst-clock_settime-time64.c
@@ -0,0 +1 @@
+#include <tst-clock_settime.c>
diff --git a/time/tst-cpuclock1-time64.c b/time/tst-cpuclock1-time64.c
new file mode 100644
index 0000000000..5a7ffa27ac
--- /dev/null
+++ b/time/tst-cpuclock1-time64.c
@@ -0,0 +1 @@
+#include "tst-cpuclock1.c"
diff --git a/time/tst-ctime-time64.c b/time/tst-ctime-time64.c
new file mode 100644
index 0000000000..24a5ae98ed
--- /dev/null
+++ b/time/tst-ctime-time64.c
@@ -0,0 +1 @@
+#include "tst-ctime.c"
diff --git a/time/tst-ctime.c b/time/tst-ctime.c
index e89a906bf8..884d69bfa0 100644
--- a/time/tst-ctime.c
+++ b/time/tst-ctime.c
@@ -24,6 +24,7 @@ static int
 do_test (void)
 {
   char *str;
+  char strb[32];
   time_t t;
 
   /* Use glibc time zone extension "TZ=:" to to guarantee that UTC
@@ -36,11 +37,21 @@ do_test (void)
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Thu Jan  1 00:00:00 1970\n");
+
   /* Check if the max time value for 32 bit time_t can be converted.  */
   t = 0x7fffffff;
   str = ctime (&t);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&t, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:07 2038\n");
+
   /* Check if we run on port with 32 bit time_t size */
   time_t tov;
   if (__builtin_add_overflow (t, 1, &tov))
@@ -50,6 +61,11 @@ do_test (void)
   str = ctime (&tov);
   TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
 
+  /* Same as before but with ctime_r.  */
+  str = ctime_r (&tov, strb);
+  TEST_VERIFY (str == strb);
+  TEST_COMPARE_STRING (str, "Tue Jan 19 03:14:08 2038\n");
+
   return 0;
 }
 
diff --git a/time/tst-difftime-time64.c b/time/tst-difftime-time64.c
new file mode 100644
index 0000000000..751ce6c483
--- /dev/null
+++ b/time/tst-difftime-time64.c
@@ -0,0 +1 @@
+#include "tst-difftime.c"
diff --git a/time/tst-gmtime-time64.c b/time/tst-gmtime-time64.c
new file mode 100644
index 0000000000..0df11c1913
--- /dev/null
+++ b/time/tst-gmtime-time64.c
@@ -0,0 +1 @@
+#include "tst-gmtime.c"
diff --git a/time/tst-itimer-time64.c b/time/tst-itimer-time64.c
new file mode 100644
index 0000000000..ddd2efa175
--- /dev/null
+++ b/time/tst-itimer-time64.c
@@ -0,0 +1 @@
+#include <time/tst-itimer.c>
diff --git a/time/tst-mktime4-time64.c b/time/tst-mktime4-time64.c
new file mode 100644
index 0000000000..bf5197c6f3
--- /dev/null
+++ b/time/tst-mktime4-time64.c
@@ -0,0 +1 @@
+#include "tst-mktime4.c"
diff --git a/time/tst-settimeofday-time64.c b/time/tst-settimeofday-time64.c
new file mode 100644
index 0000000000..185d167a22
--- /dev/null
+++ b/time/tst-settimeofday-time64.c
@@ -0,0 +1 @@
+#include <tst-settimeofday.c>
diff --git a/time/tst-timegm-time64.c b/time/tst-timegm-time64.c
new file mode 100644
index 0000000000..8e3084f74e
--- /dev/null
+++ b/time/tst-timegm-time64.c
@@ -0,0 +1 @@
+#include "tst-timegm.c"
diff --git a/time/tst-timespec_get-time64.c b/time/tst-timespec_get-time64.c
new file mode 100644
index 0000000000..48f336385d
--- /dev/null
+++ b/time/tst-timespec_get-time64.c
@@ -0,0 +1 @@
+#include "tst-timespec_get.c"
diff --git a/time/tst-timespec_getres-time64.c b/time/tst-timespec_getres-time64.c
new file mode 100644
index 0000000000..59a0f36103
--- /dev/null
+++ b/time/tst-timespec_getres-time64.c
@@ -0,0 +1 @@
+#include "tst-timespec_getres.c"
diff --git a/time/tst-y2039-time64.c b/time/tst-y2039-time64.c
new file mode 100644
index 0000000000..3c8a504186
--- /dev/null
+++ b/time/tst-y2039-time64.c
@@ -0,0 +1 @@
+#include "tst-y2039.c"
diff --git a/time/tst-y2039.c b/time/tst-y2039.c
index ef024c0a77..66a22d4c2c 100644
--- a/time/tst-y2039.c
+++ b/time/tst-y2039.c
@@ -37,6 +37,16 @@ do_test (void)
 			> 0);
       puts (buf);
       TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
+
+      /* Same as before but for localtime_r.  */
+      struct tm tmd;
+      tm = localtime_r (&ouch, &tmd);
+      TEST_VERIFY_EXIT (tm == &tmd);
+
+      TEST_VERIFY_EXIT (strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S %Z", tm)
+			> 0);
+      puts (buf);
+      TEST_VERIFY (strcmp (buf, "2039-04-30 14:00:00 PDT") == 0);
     }
   else
     FAIL_UNSUPPORTED ("32-bit time_t");
-- 
2.30.2


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 12/24] y2038: Use a common definition for stat
  2021-06-07 20:36 ` [PATCH v3 12/24] y2038: Use a common definition for stat Adhemerval Zanella
@ 2021-06-14 14:52   ` Carlos O'Donell
  0 siblings, 0 replies; 41+ messages in thread
From: Carlos O'Donell @ 2021-06-14 14:52 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 6/7/21 4:36 PM, Adhemerval Zanella wrote:
> From: Lukasz Majewski <lukma@denx.de>
> 
> Instead of replicate the same definitions from struct_stat_time64.h
> on the multiple struct_stat.h, use a common header which is included
> when required (struct_stat_time64_helper.h).  The 64-bit time support
> is added only for LFS support.
> 
> The __USE_TIME_BITS64 is not defined internally yet, although the
> internal header is used when building the 64-bit stat implementations.

No regressions on x86_64 and i686 and reviewed resulting ABI for correctness.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/unix/sysv/linux/Makefile              |  3 +-
>  sysdeps/unix/sysv/linux/bits/struct_stat.h    | 50 ++++++-----
>  .../linux/bits/struct_stat_time64_helper.h    | 66 ++++++++++++++
>  .../unix/sysv/linux/m68k/bits/struct_stat.h   | 50 ++++++-----
>  .../sysv/linux/microblaze/bits/struct_stat.h  | 48 ++++++----
>  .../unix/sysv/linux/mips/bits/struct_stat.h   | 89 ++++++++++--------
>  .../sysv/linux/powerpc/bits/struct_stat.h     | 52 ++++++-----
>  .../unix/sysv/linux/s390/bits/struct_stat.h   | 56 +++++++-----
>  sysdeps/unix/sysv/linux/struct_stat_time64.h  | 59 +-----------
>  .../unix/sysv/linux/x86/bits/struct_stat.h    | 90 ++++++++++---------
>  10 files changed, 320 insertions(+), 243 deletions(-)
>  create mode 100644 sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
> 
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index 36d5ae020c..c343d8c7d0 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -100,7 +100,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
>  		  bits/types/struct_msqid_ds.h \
>  		  bits/types/struct_shmid_ds.h \
>  		  bits/ipc-perm.h \
> -		  bits/struct_stat.h
> +		  bits/struct_stat.h \
> +		  bits/struct_stat_time64_helper.h
>  
>  tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
>  	 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
> diff --git a/sysdeps/unix/sysv/linux/bits/struct_stat.h b/sysdeps/unix/sysv/linux/bits/struct_stat.h
> index b852ee256e..298418966f 100644
> --- a/sysdeps/unix/sysv/linux/bits/struct_stat.h
> +++ b/sysdeps/unix/sysv/linux/bits/struct_stat.h
> @@ -28,32 +28,35 @@
>  
>  struct stat
>    {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/struct_stat_time64_helper.h>
> +#else
>      __dev_t st_dev;			/* Device.  */
>      unsigned short int __pad1;
> -#ifndef __USE_FILE_OFFSET64
> +# ifndef __USE_FILE_OFFSET64
>      __ino_t st_ino;			/* File serial number.	*/
> -#else
> +# else
>      __ino_t __st_ino;			/* 32bit file serial number.	*/
> -#endif
> +# endif
>      __mode_t st_mode;			/* File mode.  */
>      __nlink_t st_nlink;			/* Link count.  */
>      __uid_t st_uid;			/* User ID of the file's owner.	*/
>      __gid_t st_gid;			/* Group ID of the file's group.*/
>      __dev_t st_rdev;			/* Device number, if device.  */
>      unsigned short int __pad2;
> -#ifndef __USE_FILE_OFFSET64
> +# ifndef __USE_FILE_OFFSET64
>      __off_t st_size;			/* Size of file, in bytes.  */
> -#else
> +# else
>      __off64_t st_size;			/* Size of file, in bytes.  */
> -#endif
> +# endif
>      __blksize_t st_blksize;		/* Optimal block size for I/O.  */
>  
> -#ifndef __USE_FILE_OFFSET64
> +# ifndef __USE_FILE_OFFSET64
>      __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
> -#else
> +# else
>      __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
> -#endif
> -#ifdef __USE_XOPEN2K8
> +# endif
> +# ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -63,28 +66,32 @@ struct stat
>      struct timespec st_atim;		/* Time of last access.  */
>      struct timespec st_mtim;		/* Time of last modification.  */
>      struct timespec st_ctim;		/* Time of last status change.  */
> -# define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> -# define st_mtime st_mtim.tv_sec
> -# define st_ctime st_ctim.tv_sec
> -#else
> +#  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> +#  define st_mtime st_mtim.tv_sec
> +#  define st_ctime st_ctim.tv_sec
> +# else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -#endif
> -#ifndef __USE_FILE_OFFSET64
> +# endif
> +# ifndef __USE_FILE_OFFSET64
>      unsigned long int __glibc_reserved4;
>      unsigned long int __glibc_reserved5;
> -#else
> +# else
>      __ino64_t st_ino;			/* File serial number.	*/
> -#endif
> +# endif
> +#endif /* __USE_TIME_BITS64  */
>    };
>  
>  #ifdef __USE_LARGEFILE64
>  struct stat64
>    {
> +# ifdef __USE_TIME_BITS64
> +#  include <bits/struct_stat_time64_helper.h>
> +# else
>      __dev_t st_dev;			/* Device.  */
>      unsigned int __pad1;
>  
> @@ -99,7 +106,7 @@ struct stat64
>      __blksize_t st_blksize;		/* Optimal block size for I/O.  */
>  
>      __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
> -# ifdef __USE_XOPEN2K8
> +#  ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -109,15 +116,16 @@ struct stat64
>      struct timespec st_atim;		/* Time of last access.  */
>      struct timespec st_mtim;		/* Time of last modification.  */
>      struct timespec st_ctim;		/* Time of last status change.  */
> -# else
> +#  else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -# endif
> +#  endif
>      __ino64_t st_ino;			/* File serial number.		*/
> +# endif /* __USE_TIME_BITS64  */
>    };
>  #endif
>  
> diff --git a/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h b/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
> new file mode 100644
> index 0000000000..04e0ca7386
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
> @@ -0,0 +1,66 @@
> +/* Definition for helper to define struct stat with 64-bit time.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library.  If not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +  /* Content of internal __stat64_t64 struct.  */
> +  __dev_t st_dev;		/* Device.  */
> +  __ino64_t st_ino;		/* file serial number.	*/
> +  __mode_t st_mode;		/* File mode.  */
> +  __nlink_t st_nlink;		/* Link count.  */
> +  __uid_t st_uid;		/* User ID of the file's owner.  */
> +  __gid_t st_gid;		/* Group ID of the file's group.  */
> +  __dev_t st_rdev;		/* Device number, if device.  */
> +  __off64_t st_size;		/* Size of file, in bytes.  */
> +  __blksize_t st_blksize;	/* Optimal block size for I/O.  */
> +  __blkcnt64_t st_blocks;	/* Number 512-byte blocks allocated. */
> +#ifdef __USE_XOPEN2K8
> +# ifndef __struct_timespec
> +#  define __struct_timespec struct timespec
> +# endif
> +  /* Nanosecond resolution timestamps are stored in a format
> +     equivalent to 'struct timespec'.  This is the type used
> +     whenever possible but the Unix namespace rules do not allow the
> +     identifier 'timespec' to appear in the <sys/stat.h> header.
> +     Therefore we have to handle the use of this header in strictly
> +     standard-compliant sources special.  */
> +  __struct_timespec st_atim;
> +  __struct_timespec st_mtim;
> +  __struct_timespec st_ctim;
> +# define st_atime st_atim.tv_sec
> +# define st_mtime st_mtim.tv_sec
> +# define st_ctime st_ctim.tv_sec
> +# undef __struct_timespec
> +#else
> +/* The definition should be equal to the 'struct __timespec64' internal
> +   layout.  */
> +# if __BYTE_ORDER == __BIG_ENDIAN
> +#  define __fieldts64(name)					\
> +   __time64_t name; __int32_t :32; __int32_t name ## nsec
> +# else
> +#  define __fieldts64(name)					\
> +   __time64_t name; __int32_t name ## nsec; __int32_t :32
> +# endif
> +
> +  __fieldts64 (st_atime);
> +  __fieldts64 (st_mtime);
> +  __fieldts64 (st_ctime);
> +
> +  unsigned long int __glibc_reserved4;
> +  unsigned long int __glibc_reserved5;
> +
> +# undef __fieldts64
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h b/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h
> index 4ae7506eb5..0512ecc3bc 100644
> --- a/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h
> +++ b/sysdeps/unix/sysv/linux/m68k/bits/struct_stat.h
> @@ -25,32 +25,35 @@
>  
>  struct stat
>    {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/struct_stat_time64_helper.h>
> +#else
>      __dev_t st_dev;			/* Device.  */
>      unsigned short int __pad1;
> -#ifndef __USE_FILE_OFFSET64
> +# ifndef __USE_FILE_OFFSET64
>      __ino_t st_ino;			/* File serial number.	*/
> -#else
> +# else
>      __ino_t __st_ino;			/* 32bit file serial number.	*/
> -#endif
> +# endif
>      __mode_t st_mode;			/* File mode.  */
>      __nlink_t st_nlink;			/* Link count.  */
>      __uid_t st_uid;			/* User ID of the file's owner.	*/
>      __gid_t st_gid;			/* Group ID of the file's group.*/
>      __dev_t st_rdev;			/* Device number, if device.  */
>      unsigned short int __pad2;
> -#ifndef __USE_FILE_OFFSET64
> +# ifndef __USE_FILE_OFFSET64
>      __off_t st_size;			/* Size of file, in bytes.  */
> -#else
> +# else
>      __off64_t st_size;			/* Size of file, in bytes.  */
> -#endif
> +# endif
>      __blksize_t st_blksize;		/* Optimal block size for I/O.  */
>  
> -#ifndef __USE_FILE_OFFSET64
> +# ifndef __USE_FILE_OFFSET64
>      __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
> -#else
> +# else
>      __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
> -#endif
> -#ifdef __USE_XOPEN2K8
> +# endif
> +# ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -60,28 +63,32 @@ struct stat
>      struct timespec st_atim;		/* Time of last access.  */
>      struct timespec st_mtim;		/* Time of last modification.  */
>      struct timespec st_ctim;		/* Time of last status change.  */
> -# define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> -# define st_mtime st_mtim.tv_sec
> -# define st_ctime st_ctim.tv_sec
> -#else
> +#  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> +#  define st_mtime st_mtim.tv_sec
> +#  define st_ctime st_ctim.tv_sec
> +# else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -#endif
> -#ifndef __USE_FILE_OFFSET64
> +# endif
> +# ifndef __USE_FILE_OFFSET64
>      unsigned long int __glibc_reserved4;
>      unsigned long int __glibc_reserved5;
> -#else
> +# else
>      __ino64_t st_ino;			/* File serial number.	*/
> -#endif
> +# endif
> +#endif /* __USE_TIME_BITS64  */
>    };
>  
>  #ifdef __USE_LARGEFILE64
>  struct stat64
>    {
> +# ifdef __USE_TIME_BITS64
> +#  include <bits/struct_stat_time64_helper.h>
> +# else
>      __dev_t st_dev;			/* Device.  */
>      unsigned short int __pad1;
>  
> @@ -96,7 +103,7 @@ struct stat64
>      __blksize_t st_blksize;		/* Optimal block size for I/O.  */
>  
>      __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
> -# ifdef __USE_XOPEN2K8
> +#  ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -106,15 +113,16 @@ struct stat64
>      struct timespec st_atim;		/* Time of last access.  */
>      struct timespec st_mtim;		/* Time of last modification.  */
>      struct timespec st_ctim;		/* Time of last status change.  */
> -# else
> +#  else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -# endif
> +#  endif
>      __ino64_t st_ino;			/* File serial number.		*/
> +# endif /* __USE_TIME_BITS64 */
>    };
>  #endif
>  
> diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h b/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h
> index be1bdc3557..0284d4b2b2 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h
> +++ b/sysdeps/unix/sysv/linux/microblaze/bits/struct_stat.h
> @@ -26,6 +26,9 @@
>  #ifndef __USE_FILE_OFFSET64
>  struct stat
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/struct_stat_time64_helper.h>
> +#else
>          __dev_t         st_dev;     /* Device.  */
>          __ino_t         st_ino;     /* File serial number.  */
>          __mode_t        st_mode;    /* File mode.  */
> @@ -38,7 +41,7 @@ struct stat
>          __blksize_t     st_blksize; /* Optimal block size for I/O.  */
>          int             __pad3;
>          __blkcnt_t      st_blocks;  /* Number 512-byte blocks allocated.  */
> -#ifdef __USE_XOPEN2K8
> +# ifdef __USE_XOPEN2K8
>          /* Nanosecond resolution timestamps are stored in a format
>           * equivalent to 'struct timespec'. This is the type used
>           * whenever possible but the Unix namespace rules do not allow the
> @@ -48,19 +51,20 @@ struct stat
>          struct timespec         st_atim; /* Time of last access.  */
>          struct timespec         st_mtim; /* Time of last modification.  */
>          struct timespec         st_ctim; /* Time of last status change.  */
> -# define st_atime st_atim.tv_sec         /* Backward compatibility.  */
> -# define st_mtime st_mtim.tv_sec
> -# define st_ctime st_ctim.tv_sec
> -#else
> +#  define st_atime st_atim.tv_sec         /* Backward compatibility.  */
> +#  define st_mtime st_mtim.tv_sec
> +#  define st_ctime st_ctim.tv_sec
> +# else
>          __time_t                st_atime;     /* Time of last access.  */
>          unsigned long int       st_atimensec; /* Nscecs of last access.  */
>          __time_t                st_mtime;     /* Time of last modification.  */
>          unsigned long int       st_mtimensec; /* Nsecs of last modification.  */
>          __time_t                st_ctime;     /* Time of last status change.  */
>          unsigned long int       st_ctimensec; /* Nsecs of last status change.  */
> -#endif
> +# endif
>          unsigned int            __glibc_reserved4;
>          unsigned int            __glibc_reserved5;
> +#endif /* __USE_TIME_BITS64  */
>  };
>  #else /* __USE_FILE_OFFSET64 */
>  /* MS: If __USE_FILE_OFFSET64 is setup then struct stat should match stat64
> @@ -70,6 +74,9 @@ struct stat
>   * create one ifdef to separate stats structures.  */
>  struct stat
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/struct_stat_time64_helper.h>
> +#else
>          unsigned long long      st_dev;     /* Device.  */
>          __ino64_t               st_ino;     /* 32bit file serial number.  */
>          __mode_t                st_mode;    /* File mode.  */
> @@ -82,7 +89,7 @@ struct stat
>          __blksize_t             st_blksize; /* Optimal block size for I/O.  */
>          int                     __pad3;
>          __blkcnt64_t            st_blocks;  /* Number 512-byte blocks allocated.  */
> -#ifdef __USE_MISC
> +# ifdef __USE_MISC
>          /* Nanosecond resolution timestamps are stored in a format
>           * equivalent to 'struct timespec'. This is the type used
>           * whenever possible but the Unix namespace rules do not allow the
> @@ -92,25 +99,29 @@ struct stat
>          struct timespec         st_atim;      /* Time of last access.  */
>          struct timespec         st_mtim;      /* Time of last modification.  */
>          struct timespec         st_ctim;      /* Time of last status change.  */
> -# define st_atime st_atim.tv_sec              /* Backward compatibility.  */
> -# define st_mtime st_mtim.tv_sec
> -# define st_ctime st_ctim.tv_sec
> -#else
> +#  define st_atime st_atim.tv_sec              /* Backward compatibility.  */
> +#  define st_mtime st_mtim.tv_sec
> +#  define st_ctime st_ctim.tv_sec
> +# else
>          __time_t                st_atime;     /* Time of last access.  */
>          unsigned long int       st_atimensec; /* Nscecs of last access.  */
>          __time_t                st_mtime;     /* Time of last modification.  */
>          unsigned long int       st_mtimensec; /* Nsecs of last modification.  */
>          __time_t                st_ctime;     /* Time of last status change.  */
>          unsigned long int       st_ctimensec; /* Nsecs of last status change.  */
> -#endif
> +# endif
>          unsigned int            __glibc_reserved4;
>          unsigned int            __glibc_reserved5;
> +# endif /* __USE_TIME_BITS64 */
>  };
>  #endif /* __USE_FILE_OFFSET64 */
>  
>  #ifdef __USE_LARGEFILE64
>  struct stat64
>  {
> +# ifdef __USE_TIME_BITS64
> +#  include <bits/struct_stat_time64_helper.h>
> +# else
>          unsigned long long      st_dev;     /* Device.  */
>          __ino64_t               st_ino;     /* 32bit file serial number.  */
>          __mode_t                st_mode;    /* File mode.  */
> @@ -123,7 +134,7 @@ struct stat64
>          __blksize_t             st_blksize; /* Optimal block size for I/O.  */
>          int                     __pad3;
>          __blkcnt64_t            st_blocks;  /* Number 512-byte blocks allocated.  */
> -#ifdef __USE_XOPEN2K8
> +#  ifdef __USE_XOPEN2K8
>          /* Nanosecond resolution timestamps are stored in a format
>           * equivalent to 'struct timespec'. This is the type used
>           * whenever possible but the Unix namespace rules do not allow the
> @@ -133,19 +144,20 @@ struct stat64
>          struct timespec         st_atim;    /* Time of last access.  */
>          struct timespec         st_mtim;    /* Time of last modification.  */
>          struct timespec         st_ctim;    /* Time of last status change.  */
> -# define st_atime st_atim.tv_sec            /* Backward compatibility.  */
> -# define st_mtime st_mtim.tv_sec
> -# define st_ctime st_ctim.tv_sec
> -#else
> +#   define st_atime st_atim.tv_sec           /* Backward compatibility.  */
> +#   define st_mtime st_mtim.tv_sec
> +#   define st_ctime st_ctim.tv_sec
> +#  else
>          __time_t                st_atime;     /* Time of last access.  */
>          unsigned long int       st_atimensec; /* Nscecs of last access.  */
>          __time_t                st_mtime;     /* Time of last modification.  */
>          unsigned long int       st_mtimensec; /* Nsecs of last modification.  */
>          __time_t                st_ctime;     /* Time of last status change.  */
>          unsigned long int       st_ctimensec; /* Nsecs of last status change.  */
> -#endif
> +#  endif
>          unsigned int            __glibc_reserved4;
>          unsigned int            __glibc_reserved5;
> +# endif /* __USE_TIME_BITS64 */
>  };
>  #endif
>  
> diff --git a/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h b/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
> index 7ae4c10827..ab9f474cbc 100644
> --- a/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
> +++ b/sysdeps/unix/sysv/linux/mips/bits/struct_stat.h
> @@ -29,28 +29,31 @@
>  /* Structure describing file characteristics.  */
>  struct stat
>    {
> +# ifdef __USE_TIME_BITS64
> +#  include <bits/struct_stat_time64_helper.h>
> +# else
>      unsigned long int st_dev;
>      long int st_pad1[3];
> -#ifndef __USE_FILE_OFFSET64
> +#  ifndef __USE_FILE_OFFSET64
>      __ino_t st_ino;		/* File serial number.		*/
> -#else
> +#  else
>      __ino64_t st_ino;		/* File serial number.		*/
> -#endif
> +#  endif
>      __mode_t st_mode;		/* File mode.  */
>      __nlink_t st_nlink;		/* Link count.  */
>      __uid_t st_uid;		/* User ID of the file's owner.	*/
>      __gid_t st_gid;		/* Group ID of the file's group.*/
>      unsigned long int st_rdev;	/* Device number, if device.  */
> -#ifndef __USE_FILE_OFFSET64
> +#  ifndef __USE_FILE_OFFSET64
>      long int st_pad2[2];
>      __off_t st_size;		/* Size of file, in bytes.  */
>      /* SVR4 added this extra long to allow for expansion of off_t.  */
>      long int st_pad3;
> -#else
> +#  else
>      long int st_pad2[3];
>      __off64_t st_size;		/* Size of file, in bytes.  */
> -#endif
> -#ifdef __USE_XOPEN2K8
> +#  endif
> +#  ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -60,30 +63,34 @@ struct stat
>      struct timespec st_atim;            /* Time of last access.  */
>      struct timespec st_mtim;            /* Time of last modification.  */
>      struct timespec st_ctim;            /* Time of last status change.  */
> -# define st_atime st_atim.tv_sec        /* Backward compatibility.  */
> -# define st_mtime st_mtim.tv_sec
> -# define st_ctime st_ctim.tv_sec
> -#else
> +#   define st_atime st_atim.tv_sec        /* Backward compatibility.  */
> +#   define st_mtime st_mtim.tv_sec
> +#   define st_ctime st_ctim.tv_sec
> +#  else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -#endif
> +#  endif
>      __blksize_t st_blksize;	/* Optimal block size for I/O.  */
> -#ifndef __USE_FILE_OFFSET64
> +#  ifndef __USE_FILE_OFFSET64
>      __blkcnt_t st_blocks;	/* Number of 512-byte blocks allocated.  */
> -#else
> +#  else
>      long int st_pad4;
>      __blkcnt64_t st_blocks;	/* Number of 512-byte blocks allocated.  */
> -#endif
> +#  endif
>      long int st_pad5[14];
> +# endif /* __USE_TIME_BITS64  */
>    };
>  
> -#ifdef __USE_LARGEFILE64
> +# ifdef __USE_LARGEFILE64
>  struct stat64
>    {
> +#  ifdef __USE_TIME_BITS64
> +#   include <bits/struct_stat_time64_helper.h>
> +#  else
>      unsigned long int st_dev;
>      long int st_pad1[3];
>      __ino64_t st_ino;		/* File serial number.		*/
> @@ -94,7 +101,7 @@ struct stat64
>      unsigned long int st_rdev;	/* Device number, if device.  */
>      long int st_pad2[3];
>      __off64_t st_size;		/* Size of file, in bytes.  */
> -# ifdef __USE_XOPEN2K8
> +#   ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -104,44 +111,47 @@ struct stat64
>      struct timespec st_atim;            /* Time of last access.  */
>      struct timespec st_mtim;            /* Time of last modification.  */
>      struct timespec st_ctim;            /* Time of last status change.  */
> -# else
> +#   else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -# endif
> +#   endif
>      __blksize_t st_blksize;	/* Optimal block size for I/O.  */
>      long int st_pad3;
>      __blkcnt64_t st_blocks;	/* Number of 512-byte blocks allocated.  */
>      long int st_pad4[14];
> +#  endif /* __USE_TIME_BITS64  */
>    };
> -#endif
> -#else
> +# endif /* __USE_LARGEFILE64  */
> +
> +#else /* _MIPS_SIM != _ABIO32  */
> +
>  struct stat
>    {
>      __dev_t st_dev;
>      int	st_pad1[3];		/* Reserved for st_dev expansion  */
> -#ifndef __USE_FILE_OFFSET64
> +# ifndef __USE_FILE_OFFSET64
>      __ino_t st_ino;
> -#else
> +# else
>      __ino64_t st_ino;
> -#endif
> +# endif
>      __mode_t st_mode;
>      __nlink_t st_nlink;
>      __uid_t st_uid;
>      __gid_t st_gid;
>      __dev_t st_rdev;
> -#if !defined __USE_FILE_OFFSET64
> +# if !defined __USE_FILE_OFFSET64
>      unsigned int st_pad2[2];	/* Reserved for st_rdev expansion  */
>      __off_t st_size;
>      int st_pad3;
> -#else
> +# else
>      unsigned int st_pad2[3];	/* Reserved for st_rdev expansion  */
>      __off64_t st_size;
> -#endif
> -#ifdef __USE_XOPEN2K8
> +# endif
> +# ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -151,24 +161,24 @@ struct stat
>      struct timespec st_atim;            /* Time of last access.  */
>      struct timespec st_mtim;            /* Time of last modification.  */
>      struct timespec st_ctim;            /* Time of last status change.  */
> -# define st_atime st_atim.tv_sec        /* Backward compatibility.  */
> -# define st_mtime st_mtim.tv_sec
> -# define st_ctime st_ctim.tv_sec
> -#else
> +#  define st_atime st_atim.tv_sec        /* Backward compatibility.  */
> +#  define st_mtime st_mtim.tv_sec
> +#  define st_ctime st_ctim.tv_sec
> +# else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -#endif
> +# endif
>      __blksize_t st_blksize;
>      unsigned int st_pad4;
> -#ifndef __USE_FILE_OFFSET64
> +# ifndef __USE_FILE_OFFSET64
>      __blkcnt_t st_blocks;
> -#else
> +# else
>      __blkcnt64_t st_blocks;
> -#endif
> +# endif
>      int st_pad5[14];
>    };
>  
> @@ -185,7 +195,7 @@ struct stat64
>      __dev_t st_rdev;
>      unsigned int st_pad2[3];	/* Reserved for st_rdev expansion  */
>      __off64_t st_size;
> -# ifdef __USE_XOPEN2K8
> +#  ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -195,20 +205,21 @@ struct stat64
>      struct timespec st_atim;            /* Time of last access.  */
>      struct timespec st_mtim;            /* Time of last modification.  */
>      struct timespec st_ctim;            /* Time of last status change.  */
> -# else
> +#  else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -# endif
> +#  endif
>      __blksize_t st_blksize;
>      unsigned int st_pad3;
>      __blkcnt64_t st_blocks;
>      int st_pad4[14];
>  };
>  #endif
> +
>  #endif
>  
>  /* Tell code we have these members.  */
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h b/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h
> index 12caab2790..f55eb658a2 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/bits/struct_stat.h
> @@ -26,35 +26,37 @@
>  #include <bits/wordsize.h>
>  
>  #if __WORDSIZE == 32
> -
>  struct stat
>    {
> +# ifdef __USE_TIME_BITS64
> +#  include <bits/struct_stat_time64_helper.h>
> +# else
>      __dev_t st_dev;			/* Device.  */
> -# ifndef __USE_FILE_OFFSET64
> +#  ifndef __USE_FILE_OFFSET64
>      unsigned short int __pad1;
>      __ino_t st_ino;			/* File serial number.	*/
> -# else
> +#  else
>      __ino64_t st_ino;			/* File serial number.	*/
> -# endif
> +#  endif
>      __mode_t st_mode;			/* File mode.  */
>      __nlink_t st_nlink;			/* Link count.  */
>      __uid_t st_uid;			/* User ID of the file's owner.	*/
>      __gid_t st_gid;			/* Group ID of the file's group.*/
>      __dev_t st_rdev;			/* Device number, if device.  */
>      unsigned short int __pad2;
> -# ifndef __USE_FILE_OFFSET64
> +#  ifndef __USE_FILE_OFFSET64
>      __off_t st_size;			/* Size of file, in bytes.  */
> -# else
> +#  else
>      __off64_t st_size;			/* Size of file, in bytes.  */
> -# endif
> +#  endif
>      __blksize_t st_blksize;		/* Optimal block size for I/O.  */
>  
> -# ifndef __USE_FILE_OFFSET64
> +#  ifndef __USE_FILE_OFFSET64
>      __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
> -# else
> +#  else
>      __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
> -# endif
> -# ifdef __USE_XOPEN2K8
> +#  endif
> +#  ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -64,25 +66,28 @@ struct stat
>      struct timespec st_atim;		/* Time of last access.  */
>      struct timespec st_mtim;		/* Time of last modification.  */
>      struct timespec st_ctim;		/* Time of last status change.  */
> -#  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> -#  define st_mtime st_mtim.tv_sec
> -#  define st_ctime st_ctim.tv_sec
> -# else
> +#   define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> +#   define st_mtime st_mtim.tv_sec
> +#   define st_ctime st_ctim.tv_sec
> +#  else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -# endif
> +#  endif
>      unsigned long int __glibc_reserved4;
>      unsigned long int __glibc_reserved5;
> +# endif /* __USE_TIME_BITS64 */
>    };
>  
> -
>  # ifdef __USE_LARGEFILE64
>  struct stat64
>    {
> +#  ifdef __USE_TIME_BITS64
> +#   include <bits/struct_stat_time64_helper.h>
> +#  else
>      __dev_t st_dev;			/* Device.  */
>      __ino64_t st_ino;			/* File serial number.	*/
>      __mode_t st_mode;			/* File mode.  */
> @@ -94,7 +99,7 @@ struct stat64
>      __off64_t st_size;			/* Size of file, in bytes.  */
>      __blksize_t st_blksize;		/* Optimal block size for I/O.  */
>      __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
> -#  ifdef __USE_XOPEN2K8
> +#   ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -104,19 +109,20 @@ struct stat64
>      struct timespec st_atim;		/* Time of last access.  */
>      struct timespec st_mtim;		/* Time of last modification.  */
>      struct timespec st_ctim;		/* Time of last status change.  */
> -#   define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> -#   define st_mtime st_mtim.tv_sec
> -#   define st_ctime st_ctim.tv_sec
> -#  else
> +#    define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> +#    define st_mtime st_mtim.tv_sec
> +#    define st_ctime st_ctim.tv_sec
> +#   else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -#  endif
> +#   endif
>      unsigned long int __glibc_reserved4;
>      unsigned long int __glibc_reserved5;
> +#  endif /* __USE_TIME_BITS64 */
>    };
>  # endif /* __USE_LARGEFILE64 */
>  
> diff --git a/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h b/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h
> index a733622cf5..f2933b8b12 100644
> --- a/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h
> +++ b/sysdeps/unix/sysv/linux/s390/bits/struct_stat.h
> @@ -65,32 +65,35 @@ struct stat
>  #else
>  struct stat
>    {
> +# ifdef __USE_TIME_BITS64
> +#  include <bits/struct_stat_time64_helper.h>
> +# else
>      __dev_t st_dev;			/* Device.  */
>      unsigned int __pad1;
> -# ifndef __USE_FILE_OFFSET64
> +#  ifndef __USE_FILE_OFFSET64
>      __ino_t st_ino;			/* File serial number.	*/
> -# else
> +#  else
>      __ino_t __st_ino;			/* 32bit file serial number.	*/
> -# endif
> +#  endif
>      __mode_t st_mode;			/* File mode.  */
>      __nlink_t st_nlink;			/* Link count.  */
>      __uid_t st_uid;			/* User ID of the file's owner.	*/
>      __gid_t st_gid;			/* Group ID of the file's group.*/
>      __dev_t st_rdev;			/* Device number, if device.  */
>      unsigned int __pad2;
> -# ifndef __USE_FILE_OFFSET64
> +#  ifndef __USE_FILE_OFFSET64
>      __off_t st_size;			/* Size of file, in bytes.  */
> -# else
> +#  else
>      __off64_t st_size;			/* Size of file, in bytes.  */
> -# endif
> +#  endif
>      __blksize_t st_blksize;		/* Optimal block size for I/O.  */
>  
> -# ifndef __USE_FILE_OFFSET64
> +#  ifndef __USE_FILE_OFFSET64
>      __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
> -# else
> +#  else
>      __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
> -# endif
> -# ifdef __USE_XOPEN2K8
> +#  endif
> +#  ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -100,25 +103,26 @@ struct stat
>      struct timespec st_atim;		/* Time of last access.  */
>      struct timespec st_mtim;		/* Time of last modification.  */
>      struct timespec st_ctim;		/* Time of last status change.  */
> -#  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> -#  define st_mtime st_mtim.tv_sec
> -#  define st_ctime st_ctim.tv_sec
> -# else
> +#   define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> +#   define st_mtime st_mtim.tv_sec
> +#   define st_ctime st_ctim.tv_sec
> +#  else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -# endif
> -# ifndef __USE_FILE_OFFSET64
> +#  endif
> +#  ifndef __USE_FILE_OFFSET64
>      unsigned long int __glibc_reserved4;
>      unsigned long int __glibc_reserved5;
> -# else
> +#  else
>      __ino64_t st_ino;			/* File serial number.	*/
> +#  endif
>  # endif
>    };
> -#endif
> +# endif
>  
>  #ifdef __USE_LARGEFILE64
>  # if __WORDSIZE == 64
> @@ -162,6 +166,9 @@ struct stat64
>  # else
>  struct stat64
>    {
> +#  ifdef __USE_TIME_BITS64
> +#   include <bits/struct_stat_time64_helper.h>
> +#  else
>      __dev_t st_dev;			/* Device.  */
>      unsigned int __pad1;
>  
> @@ -176,7 +183,7 @@ struct stat64
>      __blksize_t st_blksize;		/* Optimal block size for I/O.  */
>  
>      __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
> -#  ifdef __USE_XOPEN2K8
> +#   ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -186,18 +193,19 @@ struct stat64
>      struct timespec st_atim;		/* Time of last access.  */
>      struct timespec st_mtim;		/* Time of last modification.  */
>      struct timespec st_ctim;		/* Time of last status change.  */
> -#   define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> -#   define st_mtime st_mtim.tv_sec
> -#   define st_ctime st_ctim.tv_sec
> -#  else
> +#    define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> +#    define st_mtime st_mtim.tv_sec
> +#    define st_ctime st_ctim.tv_sec
> +#   else
>      __time_t st_atime;			/* Time of last access.  */
>      unsigned long int st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
> -#  endif
> +#   endif
>      __ino64_t st_ino;			/* File serial number.		*/
> +#  endif
>    };
>  # endif
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/struct_stat_time64.h b/sysdeps/unix/sysv/linux/struct_stat_time64.h
> index f0a29d7fe5..260d1812be 100644
> --- a/sysdeps/unix/sysv/linux/struct_stat_time64.h
> +++ b/sysdeps/unix/sysv/linux/struct_stat_time64.h
> @@ -22,64 +22,13 @@
>  #if __TIMESIZE == 64
>  # define __stat64_t64 stat64
>  #else
> -# ifdef __USE_LARGEFILE64
> -#  include <endian.h>
> -
> -/* The definition should be equal to the 'struct __timespec64' internal
> -   layout.  */
> -#  if BYTE_ORDER == BIG_ENDIAN
> -#   define __fieldts64(name) 					\
> -     __time64_t name; __int32_t :32; __int32_t name ## nsec
> -#  else
> -#   define __fieldts64(name)					\
> -     __time64_t name; __int32_t name ## nsec; __int32_t :32
> -#  endif
> -
> -/* Workaround for the definition from struct_stat.h  */
> -#  undef st_atime
> -#  undef st_mtime
> -#  undef st_ctime
> +# include <struct___timespec64.h>
>  
>  struct __stat64_t64
>    {
> -    __dev_t st_dev;			/* Device.  */
> -    __ino64_t st_ino;			/* file serial number.	*/
> -    __mode_t st_mode;			/* File mode.  */
> -    __nlink_t st_nlink;			/* Link count.  */
> -    __uid_t st_uid;			/* User ID of the file's owner.	*/
> -    __gid_t st_gid;			/* Group ID of the file's group.*/
> -    __dev_t st_rdev;			/* Device number, if device.  */
> -    __off64_t st_size;			/* Size of file, in bytes.  */
> -    __blksize_t st_blksize;		/* Optimal block size for I/O.  */
> -    __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
> -#   ifdef __USE_XOPEN2K8
> -    /* Nanosecond resolution timestamps are stored in a format
> -       equivalent to 'struct timespec'.  This is the type used
> -       whenever possible but the Unix namespace rules do not allow the
> -       identifier 'timespec' to appear in the <sys/stat.h> header.
> -       Therefore we have to handle the use of this header in strictly
> -       standard-compliant sources special.  */
> -    struct __timespec64 st_atim;	/* Time of last access.  */
> -    struct __timespec64 st_mtim;	/* Time of last modification.  */
> -    struct __timespec64 st_ctim;	/* Time of last status change.  */
> -#    define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> -#    define st_mtime st_mtim.tv_sec
> -#    define st_ctime st_ctim.tv_sec
> -#   else
> -    __fieldts64 (st_atime);
> -    __fieldts64 (st_mtime);
> -    __fieldts64 (st_ctime);
> -#   endif /* __USE_XOPEN2K8  */
> +# define __struct_timespec struct __timespec64
> +# include <bits/struct_stat_time64_helper.h>
>    };
> -
> -#   define _STATBUF_ST_BLKSIZE
> -#   define _STATBUF_ST_RDEV
> -#   define _STATBUF_ST_NSEC
> -
> -#   undef __fieldts64
> -
> -#  endif /* __USE_LARGEFILE64  */
> -
> -# endif /* __TIMESIZE == 64  */
> +#endif /* __TIMESIZE == 64  */
>  
>  #endif /* _BITS_STRUCT_STAT_TIME64_H  */
> diff --git a/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h b/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h
> index 6ddd01db46..01ee7ff6b3 100644
> --- a/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h
> +++ b/sysdeps/unix/sysv/linux/x86/bits/struct_stat.h
> @@ -25,43 +25,46 @@
>  
>  struct stat
>    {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/struct_stat_time64_helper.h>
> +#else
>      __dev_t st_dev;		/* Device.  */
> -#ifndef __x86_64__
> +# ifndef __x86_64__
>      unsigned short int __pad1;
> -#endif
> -#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
> +# endif
> +# if defined __x86_64__ || !defined __USE_FILE_OFFSET64
>      __ino_t st_ino;		/* File serial number.	*/
> -#else
> +# else
>      __ino_t __st_ino;			/* 32bit file serial number.	*/
> -#endif
> -#ifndef __x86_64__
> +# endif
> +# ifndef __x86_64__
>      __mode_t st_mode;			/* File mode.  */
>      __nlink_t st_nlink;			/* Link count.  */
> -#else
> +# else
>      __nlink_t st_nlink;		/* Link count.  */
>      __mode_t st_mode;		/* File mode.  */
> -#endif
> +# endif
>      __uid_t st_uid;		/* User ID of the file's owner.	*/
>      __gid_t st_gid;		/* Group ID of the file's group.*/
> -#ifdef __x86_64__
> +# ifdef __x86_64__
>      int __pad0;
> -#endif
> +# endif
>      __dev_t st_rdev;		/* Device number, if device.  */
> -#ifndef __x86_64__
> +# ifndef __x86_64__
>      unsigned short int __pad2;
> -#endif
> -#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
> +# endif
> +# if defined __x86_64__ || !defined __USE_FILE_OFFSET64
>      __off_t st_size;			/* Size of file, in bytes.  */
> -#else
> +# else
>      __off64_t st_size;			/* Size of file, in bytes.  */
> -#endif
> +# endif
>      __blksize_t st_blksize;	/* Optimal block size for I/O.  */
> -#if defined __x86_64__  || !defined __USE_FILE_OFFSET64
> +# if defined __x86_64__  || !defined __USE_FILE_OFFSET64
>      __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
> -#else
> +# else
>      __blkcnt64_t st_blocks;		/* Number 512-byte blocks allocated. */
> -#endif
> -#ifdef __USE_XOPEN2K8
> +# endif
> +# ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -71,58 +74,62 @@ struct stat
>      struct timespec st_atim;		/* Time of last access.  */
>      struct timespec st_mtim;		/* Time of last modification.  */
>      struct timespec st_ctim;		/* Time of last status change.  */
> -# define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> -# define st_mtime st_mtim.tv_sec
> -# define st_ctime st_ctim.tv_sec
> -#else
> +#  define st_atime st_atim.tv_sec	/* Backward compatibility.  */
> +#  define st_mtime st_mtim.tv_sec
> +#  define st_ctime st_ctim.tv_sec
> +# else
>      __time_t st_atime;			/* Time of last access.  */
>      __syscall_ulong_t st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      __syscall_ulong_t st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      __syscall_ulong_t st_ctimensec;	/* Nsecs of last status change.  */
> -#endif
> -#ifdef __x86_64__
> +# endif
> +# ifdef __x86_64__
>      __syscall_slong_t __glibc_reserved[3];
> -#else
> -# ifndef __USE_FILE_OFFSET64
> +# else
> +#  ifndef __USE_FILE_OFFSET64
>      unsigned long int __glibc_reserved4;
>      unsigned long int __glibc_reserved5;
> -# else
> +#  else
>      __ino64_t st_ino;			/* File serial number.	*/
> +#  endif
>  # endif
> -#endif
> +#endif /* __USE_TIME_BITS64  */
>    };
>  
>  #ifdef __USE_LARGEFILE64
>  /* Note stat64 has the same shape as stat for x86-64.  */
>  struct stat64
>    {
> +# ifdef __USE_TIME_BITS64
> +#  include <bits/struct_stat_time64_helper.h>
> +# else
>      __dev_t st_dev;		/* Device.  */
> -# ifdef __x86_64__
> +#  ifdef __x86_64__
>      __ino64_t st_ino;		/* File serial number.  */
>      __nlink_t st_nlink;		/* Link count.  */
>      __mode_t st_mode;		/* File mode.  */
> -# else
> +#  else
>      unsigned int __pad1;
>      __ino_t __st_ino;			/* 32bit file serial number.	*/
>      __mode_t st_mode;			/* File mode.  */
>      __nlink_t st_nlink;			/* Link count.  */
> -# endif
> +#  endif
>      __uid_t st_uid;		/* User ID of the file's owner.	*/
>      __gid_t st_gid;		/* Group ID of the file's group.*/
> -# ifdef __x86_64__
> +#  ifdef __x86_64__
>      int __pad0;
>      __dev_t st_rdev;		/* Device number, if device.  */
>      __off_t st_size;		/* Size of file, in bytes.  */
> -# else
> +#  else
>      __dev_t st_rdev;			/* Device number, if device.  */
>      unsigned int __pad2;
>      __off64_t st_size;			/* Size of file, in bytes.  */
> -# endif
> +#  endif
>      __blksize_t st_blksize;	/* Optimal block size for I/O.  */
>      __blkcnt64_t st_blocks;	/* Nr. 512-byte blocks allocated.  */
> -# ifdef __USE_XOPEN2K8
> +#  ifdef __USE_XOPEN2K8
>      /* Nanosecond resolution timestamps are stored in a format
>         equivalent to 'struct timespec'.  This is the type used
>         whenever possible but the Unix namespace rules do not allow the
> @@ -132,19 +139,20 @@ struct stat64
>      struct timespec st_atim;		/* Time of last access.  */
>      struct timespec st_mtim;		/* Time of last modification.  */
>      struct timespec st_ctim;		/* Time of last status change.  */
> -# else
> +#  else
>      __time_t st_atime;			/* Time of last access.  */
>      __syscall_ulong_t st_atimensec;	/* Nscecs of last access.  */
>      __time_t st_mtime;			/* Time of last modification.  */
>      __syscall_ulong_t st_mtimensec;	/* Nsecs of last modification.  */
>      __time_t st_ctime;			/* Time of last status change.  */
>      __syscall_ulong_t st_ctimensec;	/* Nsecs of last status change.  */
> -# endif
> -# ifdef __x86_64__
> +#  endif
> +#  ifdef __x86_64__
>      __syscall_slong_t __glibc_reserved[3];
> -# else
> +#  else
>      __ino64_t st_ino;			/* File serial number.		*/
> -# endif
> +#  endif
> +# endif /* __USE_TIME_BITS64  */
>    };
>  #endif
>  
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 13/24] y2038: Use a common definition for msqid_ds
  2021-06-07 20:36 ` [PATCH v3 13/24] y2038: Use a common definition for msqid_ds Adhemerval Zanella
@ 2021-06-14 14:52   ` Carlos O'Donell
  0 siblings, 0 replies; 41+ messages in thread
From: Carlos O'Donell @ 2021-06-14 14:52 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 6/7/21 4:36 PM, Adhemerval Zanella wrote:
> From: Lukasz Majewski <lukma@denx.de>
> 
> Instead of replicate the same definitions from struct_msqid64_ds.h
> on the multiple struct_msqid_ds.h, use a common header which is included
> when required (struct_msqid64_ds_helper.h).
> 
> The __USE_TIME_BITS64 is not defined internally yet, although the
> internal header is used when building the 64-bit stat implementations.


No regressions on x86_64 and i686 and reviewed resulting ABI for correctness.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/unix/sysv/linux/Makefile              |  3 +-
>  .../sysv/linux/bits/types/struct_msqid64_ds.h | 10 +------
>  .../bits/types/struct_msqid64_ds_helper.h     | 30 +++++++++++++++++++
>  .../sysv/linux/bits/types/struct_msqid_ds.h   | 12 ++++++--
>  .../linux/hppa/bits/types/struct_msqid_ds.h   | 12 ++++++--
>  .../linux/mips/bits/types/struct_msqid_ds.h   | 18 +++++++----
>  .../powerpc/bits/types/struct_msqid_ds.h      | 12 ++++++--
>  .../linux/sparc/bits/types/struct_msqid_ds.h  | 12 ++++++--
>  8 files changed, 81 insertions(+), 28 deletions(-)
>  create mode 100644 sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds_helper.h
> 
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index c343d8c7d0..6715a4b623 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -101,7 +101,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
>  		  bits/types/struct_shmid_ds.h \
>  		  bits/ipc-perm.h \
>  		  bits/struct_stat.h \
> -		  bits/struct_stat_time64_helper.h
> +		  bits/struct_stat_time64_helper.h \
> +		  bits/types/struct_msqid64_ds_helper.h
>  
>  tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
>  	 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
> diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h
> index 43e8cd7cfc..992734914a 100644
> --- a/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h
> +++ b/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds.h
> @@ -25,14 +25,6 @@
>  #else
>  struct __msqid64_ds
>  {
> -  struct ipc_perm msg_perm;	/* structure describing operation permission */
> -  __time64_t msg_stime;		/* time of last msgsnd command */
> -  __time64_t msg_rtime;		/* time of last msgsnd command */
> -  __time64_t msg_ctime;		/* time of last change */
> -  __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
> -  msgqnum_t msg_qnum;		/* number of messages currently on queue */
> -  msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
> -  __pid_t msg_lspid;		/* pid of last msgsnd() */
> -  __pid_t msg_lrpid;		/* pid of last msgrcv() */
> +# include <bits/types/struct_msqid64_ds_helper.h>
>  };
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds_helper.h b/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds_helper.h
> new file mode 100644
> index 0000000000..58da9f223b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/bits/types/struct_msqid64_ds_helper.h
> @@ -0,0 +1,30 @@
> +/* Common definitions for struct msqid_ds with 64-bit time.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library.  If not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +  /* Content of internal __msqid64_ds.  */
> +  struct ipc_perm msg_perm;	/* structure describing operation permission */
> +  __time64_t msg_stime;		/* time of last msgsnd command */
> +  __time64_t msg_rtime;		/* time of last msgsnd command */
> +  __time64_t msg_ctime;		/* time of last change */
> +  __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
> +  msgqnum_t msg_qnum;		/* number of messages currently on queue */
> +  msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
> +  __pid_t msg_lspid;		/* pid of last msgsnd() */
> +  __pid_t msg_lrpid;		/* pid of last msgrcv() */
> +  unsigned long int __glibc_reserved4;
> +  unsigned long int __glibc_reserved5;

OK. Adds reserved entries. Matches kernel.

> diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_msqid_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_msqid_ds.h
> index 1ed041ae30..ae10a48452 100644
> --- a/sysdeps/unix/sysv/linux/bits/types/struct_msqid_ds.h
> +++ b/sysdeps/unix/sysv/linux/bits/types/struct_msqid_ds.h
> @@ -20,23 +20,28 @@
>  # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
>  #endif
>  
> +#include <bits/types/time_t.h>
> +
>  /* Structure of record for one message inside the kernel.
>     The type `struct msg' is opaque.  */
>  struct msqid_ds
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_msqid64_ds_helper.h>
> +#else
>    struct ipc_perm msg_perm;	/* structure describing operation permission */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>    __time_t msg_stime;		/* time of last msgsnd command */
>    unsigned long int __msg_stime_high;
>    __time_t msg_rtime;		/* time of last msgsnd command */
>    unsigned long int __msg_rtime_high;
>    __time_t msg_ctime;		/* time of last change */
>    unsigned long int __msg_ctime_high;
> -#else
> +# else
>    __time_t msg_stime;		/* time of last msgsnd command */
>    __time_t msg_rtime;		/* time of last msgsnd command */
>    __time_t msg_ctime;		/* time of last change */
> -#endif
> +# endif
>    __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
>    msgqnum_t msg_qnum;		/* number of messages currently on queue */
>    msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
> @@ -44,4 +49,5 @@ struct msqid_ds
>    __pid_t msg_lrpid;		/* pid of last msgrcv() */
>    __syscall_ulong_t __glibc_reserved4;
>    __syscall_ulong_t __glibc_reserved5;
> +#endif
>  };
> diff --git a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_msqid_ds.h b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_msqid_ds.h
> index d943edeb78..5b82dd7f5e 100644
> --- a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_msqid_ds.h
> +++ b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_msqid_ds.h
> @@ -20,23 +20,28 @@
>  # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
>  #endif
>  
> +#include <bits/types/time_t.h>
> +
>  /* Structure of record for one message inside the kernel.
>     The type `struct msg' is opaque.  */
>  struct msqid_ds
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_msqid64_ds_helper.h>
> +#else
>    struct ipc_perm msg_perm;	/* structure describing operation permission */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>    unsigned long int __msg_stime_high;
>    __time_t msg_stime;		/* time of last msgsnd command */
>    unsigned long int __msg_rtime_high;
>    __time_t msg_rtime;		/* time of last msgsnd command */
>    unsigned long int __msg_ctime_high;
>    __time_t msg_ctime;		/* time of last change */
> -#else
> +# else
>    __time_t msg_stime;		/* time of last msgsnd command */
>    __time_t msg_rtime;		/* time of last msgsnd command */
>    __time_t msg_ctime;		/* time of last change */
> -#endif
> +# endif
>    __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
>    msgqnum_t msg_qnum;		/* number of messages currently on queue */
>    msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
> @@ -44,4 +49,5 @@ struct msqid_ds
>    __pid_t msg_lrpid;		/* pid of last msgrcv() */
>    __syscall_ulong_t __glibc_reserved4;
>    __syscall_ulong_t __glibc_reserved5;
> +#endif
>  };
> diff --git a/sysdeps/unix/sysv/linux/mips/bits/types/struct_msqid_ds.h b/sysdeps/unix/sysv/linux/mips/bits/types/struct_msqid_ds.h
> index bdca5e5fe2..00c1804245 100644
> --- a/sysdeps/unix/sysv/linux/mips/bits/types/struct_msqid_ds.h
> +++ b/sysdeps/unix/sysv/linux/mips/bits/types/struct_msqid_ds.h
> @@ -20,32 +20,37 @@
>  # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
>  #endif
>  
> +#include <bits/types/time_t.h>
> +
>  /* Structure of record for one message inside the kernel.
>     The type `struct msg' is opaque.  */
>  struct msqid_ds
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_msqid64_ds_helper.h>
> +#else
>    struct ipc_perm msg_perm;	/* structure describing operation permission */
> -#if __TIMESIZE == 32
> -# ifdef __MIPSEL__
> +# if __TIMESIZE == 32
> +#  ifdef __MIPSEL__
>    __time_t msg_stime;		/* time of last msgsnd command */
>    unsigned long int __msg_stime_high;
>    __time_t msg_rtime;		/* time of last msgsnd command */
>    unsigned long int __msg_rtime_high;
>    __time_t msg_ctime;		/* time of last change */
>    unsigned long int __msg_ctime_high;
> -# else
> +#  else
>    unsigned long int __msg_stime_high;
>    __time_t msg_stime;		/* time of last msgsnd command */
>    unsigned long int __msg_rtime_high;
>    __time_t msg_rtime;		/* time of last msgsnd command */
>    unsigned long int __msg_ctime_high;
>    __time_t msg_ctime;		/* time of last change */
> -# endif
> -#else
> +#  endif
> +# else
>    __time_t msg_stime;		/* time of last msgsnd command */
>    __time_t msg_rtime;		/* time of last msgsnd command */
>    __time_t msg_ctime;		/* time of last change */
> -#endif
> +# endif
>    __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
>    msgqnum_t msg_qnum;		/* number of messages currently on queue */
>    msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
> @@ -53,4 +58,5 @@ struct msqid_ds
>    __pid_t msg_lrpid;		/* pid of last msgrcv() */
>    __syscall_ulong_t __glibc_reserved4;
>    __syscall_ulong_t __glibc_reserved5;
> +#endif
>  };
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_msqid_ds.h b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_msqid_ds.h
> index 72842ed747..8c296d2342 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_msqid_ds.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_msqid_ds.h
> @@ -20,23 +20,28 @@
>  # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
>  #endif
>  
> +#include <bits/types/time_t.h>
> +
>  /* Structure of record for one message inside the kernel.
>     The type `struct msg' is opaque.  */
>  struct msqid_ds
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_msqid64_ds_helper.h>
> +#else
>    struct ipc_perm msg_perm;	/* structure describing operation permission */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>    unsigned long int __msg_stime_high;
>    __time_t msg_stime;		/* time of last msgsnd command */
>    unsigned long int __msg_rtime_high;
>    __time_t msg_rtime;		/* time of last msgsnd command */
>    unsigned long int __msg_ctime_high;
>    __time_t msg_ctime;		/* time of last change */
> -#else
> +# else
>    __time_t msg_stime;		/* time of last msgsnd command */
>    __time_t msg_rtime;		/* time of last msgsnd command */
>    __time_t msg_ctime;		/* time of last change */
> -#endif
> +# endif
>    __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
>    msgqnum_t msg_qnum;		/* number of messages currently on queue */
>    msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
> @@ -44,4 +49,5 @@ struct msqid_ds
>    __pid_t msg_lrpid;		/* pid of last msgrcv() */
>    __syscall_ulong_t __glibc_reserved4;
>    __syscall_ulong_t __glibc_reserved5;
> +#endif
>  };
> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_msqid_ds.h b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_msqid_ds.h
> index 22e1839de1..3c1b68ccc0 100644
> --- a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_msqid_ds.h
> +++ b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_msqid_ds.h
> @@ -20,23 +20,28 @@
>  # error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
>  #endif
>  
> +#include <bits/types/time_t.h>
> +
>  /* Structure of record for one message inside the kernel.
>     The type `struct msg' is opaque.  */
>  struct msqid_ds
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_msqid64_ds_helper.h>
> +#else
>    struct ipc_perm msg_perm;	/* structure describing operation permission */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>    unsigned long int __msg_stime_high;
>    __time_t msg_stime;		/* time of last msgsnd command */
>    unsigned long int __msg_rtime_high;
>    __time_t msg_rtime;		/* time of last msgsnd command */
>    unsigned long int __msg_ctime_high;
>    __time_t msg_ctime;		/* time of last change */
> -#else
> +# else
>    __time_t msg_stime;		/* time of last msgsnd command */
>    __time_t msg_rtime;		/* time of last msgsnd command */
>    __time_t msg_ctime;		/* time of last change */
> -#endif
> +# endif
>    __syscall_ulong_t __msg_cbytes; /* current number of bytes on queue */
>    msgqnum_t msg_qnum;		/* number of messages currently on queue */
>    msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
> @@ -44,4 +49,5 @@ struct msqid_ds
>    __pid_t msg_lrpid;		/* pid of last msgrcv() */
>    __syscall_ulong_t __glibc_reserved4;
>    __syscall_ulong_t __glibc_reserved5;
> +#endif
>  };
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 04/24] linux: Add fallback for 64-bit time_t SO_{RCV,SND}TIMEO
  2021-06-07 20:35 ` [PATCH v3 04/24] linux: Add fallback for 64-bit time_t SO_{RCV, SND}TIMEO Adhemerval Zanella
@ 2021-06-14 14:52   ` Carlos O'Donell
  0 siblings, 0 replies; 41+ messages in thread
From: Carlos O'Donell @ 2021-06-14 14:52 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 6/7/21 4:35 PM, Adhemerval Zanella wrote:
> The constant values will be changed for __TIMESIZE=64, so binaries built
> with 64-bit time support might fail to work properly on old kernels.
> Both {get,set}sockopt will retry the syscall with the old constant
> values and the timeout value adjusted when kernel returns ENOTPROTOPT.
> 
> It also adds an internal only SO_{RCV,SND}TIMEO where
> COMPAT_SO_{RCV,SND}TIMEO_OLD indicates pre 32 bit time support and
> COMPAT_SO_{RCV,SND}TIMEO_NEW indicates time64 support.  It allows to
> refer to constant independently of the time_t ABI and kernel version
> used.

No regressions on x86_64 and i686 and reviewed resulting ABI for correctness.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: carlos O'Donell <carlos@redhat.com>
 
> Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
> kernel).
> ---
>  sysdeps/unix/sysv/linux/getsockopt.c          | 70 ++++++++++++++++--
>  .../sysv/linux/hppa/socket-constants-time64.h | 30 ++++++++
>  .../sysv/linux/mips/socket-constants-time64.h | 30 ++++++++
>  .../linux/powerpc/socket-constants-time64.h   | 30 ++++++++
>  sysdeps/unix/sysv/linux/setsockopt.c          | 71 ++++++++++++++++---
>  .../unix/sysv/linux/socket-constants-time64.h | 30 ++++++++
>  .../linux/sparc/socket-constants-time64.h     | 30 ++++++++
>  7 files changed, 276 insertions(+), 15 deletions(-)
>  create mode 100644 sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h
>  create mode 100644 sysdeps/unix/sysv/linux/mips/socket-constants-time64.h
>  create mode 100644 sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h
>  create mode 100644 sysdeps/unix/sysv/linux/socket-constants-time64.h
>  create mode 100644 sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h
> 
> diff --git a/sysdeps/unix/sysv/linux/getsockopt.c b/sysdeps/unix/sysv/linux/getsockopt.c
> index 76ee8a94d6..688a7de087 100644
> --- a/sysdeps/unix/sysv/linux/getsockopt.c
> +++ b/sysdeps/unix/sysv/linux/getsockopt.c
> @@ -15,16 +15,15 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <signal.h>
>  #include <sys/socket.h>
> -
> +#include <time.h>
> +#include <sysdep.h>
>  #include <socketcall.h>
> -#include <kernel-features.h>
> -#include <sys/syscall.h>
> +#include <socket-constants-time64.h>
>  
> -int
> -__getsockopt (int fd, int level, int optname, void *optval, socklen_t *len)
> +static int
> +getsockopt_syscall (int fd, int level, int optname, void *optval,
> +		    socklen_t *len)
>  {
>  #ifdef __ASSUME_GETSOCKOPT_SYSCALL
>    return INLINE_SYSCALL (getsockopt, 5, fd, level, optname, optval, len);
> @@ -32,4 +31,61 @@ __getsockopt (int fd, int level, int optname, void *optval, socklen_t *len)
>    return SOCKETCALL (getsockopt, fd, level, optname, optval, len);
>  #endif
>  }
> +
> +#ifndef __ASSUME_TIME64_SYSCALLS
> +static int
> +getsockopt32 (int fd, int level, int optname, void *optval,
> +	      socklen_t *len)
> +{
> +  int r = -1;
> +
> +  if (level != SOL_SOCKET)
> +    return r;
> +
> +  switch (optname)
> +    {
> +    case COMPAT_SO_RCVTIMEO_NEW:
> +    case COMPAT_SO_SNDTIMEO_NEW:
> +      {
> +	if (optname == COMPAT_SO_RCVTIMEO_NEW)
> +	  optname = COMPAT_SO_RCVTIMEO_OLD;
> +	if (optname == COMPAT_SO_SNDTIMEO_NEW)
> +	  optname = COMPAT_SO_SNDTIMEO_OLD;
> +
> +	struct __timeval32 tv32;
> +	r = getsockopt_syscall (fd, level, optname, &tv32,
> +				(socklen_t[]) { sizeof tv32 });
> +	if (r < 0)
> +	  break;
> +
> +	/* POSIX states that if the size of the option value is greater than
> +	   then option length, the option value argument shall be silently
> +	   truncated.  */

OK.

> +	if (*len >= sizeof (struct __timeval64))
> +	  {
> +	    struct __timeval64 *tv64 = (struct __timeval64 *) optval;
> +	    *tv64 = valid_timeval32_to_timeval64 (tv32);
> +	    *len = sizeof (*tv64);
> +	  }
> +	else
> +	  memcpy (optval, &tv32, sizeof tv32);

OK. Truncate.

> +      }
> +    }
> +
> +  return r;
> +}
> +#endif
> +
> +int
> +__getsockopt (int fd, int level, int optname, void *optval, socklen_t *len)
> +{
> +  int r = getsockopt_syscall (fd, level, optname, optval, len);
> +
> +#ifndef __ASSUME_TIME64_SYSCALLS
> +  if (r == -1 && errno == ENOPROTOOPT)
> +    r = getsockopt32 (fd, level, optname, optval, len);
> +#endif
> +
> + return r;
> +}
>  weak_alias (__getsockopt, getsockopt)
> diff --git a/sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h b/sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h
> new file mode 100644
> index 0000000000..9fe7576aaa
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/hppa/socket-constants-time64.h
> @@ -0,0 +1,30 @@
> +/* Compat socket constants used in 64-bit compat code.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _SOCKET_CONSTANTS_TIME64_H
> +#define _SOCKET_CONSTANTS_TIME64_H
> +
> +/* The compat code requires the SO_* constants used for both 32 and 64-bit
> +   time_t, however they were only added on v5.1 kernel.  */
> +
> +#define COMPAT_SO_RCVTIMEO_OLD 4102
> +#define COMPAT_SO_SNDTIMEO_OLD 4101
> +#define COMPAT_SO_RCVTIMEO_NEW 16448
> +#define COMPAT_SO_SNDTIMEO_NEW 16449
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/mips/socket-constants-time64.h b/sysdeps/unix/sysv/linux/mips/socket-constants-time64.h
> new file mode 100644
> index 0000000000..1252a8a23b
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/mips/socket-constants-time64.h
> @@ -0,0 +1,30 @@
> +/* Compat socket constants used in 64-bit compat code.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _SOCKET_CONSTANTS_TIME64_H
> +#define _SOCKET_CONSTANTS_TIME64_H
> +
> +/* The compat code requires the SO_* constants used for both 32 and 64-bit
> +   time_t, however they were only added on v5.1 kernel.  */
> +
> +#define COMPAT_SO_RCVTIMEO_OLD 4102
> +#define COMPAT_SO_SNDTIMEO_OLD 4101
> +#define COMPAT_SO_RCVTIMEO_NEW 66
> +#define COMPAT_SO_SNDTIMEO_NEW 67
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h b/sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h
> new file mode 100644
> index 0000000000..26e8b710ab
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/powerpc/socket-constants-time64.h
> @@ -0,0 +1,30 @@
> +/* Compat socket constants used in 64-bit compat code.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _SOCKET_CONSTANTS_TIME64_H
> +#define _SOCKET_CONSTANTS_TIME64_H
> +
> +/* The compat code requires the SO_* constants used for both 32 and 64-bit
> +   time_t, however they were only added on v5.1 kernel.  */
> +
> +#define COMPAT_SO_RCVTIMEO_OLD 18
> +#define COMPAT_SO_SNDTIMEO_OLD 19
> +#define COMPAT_SO_RCVTIMEO_NEW 66
> +#define COMPAT_SO_SNDTIMEO_NEW 67
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/setsockopt.c b/sysdeps/unix/sysv/linux/setsockopt.c
> index 12fd7bdcde..6505202265 100644
> --- a/sysdeps/unix/sysv/linux/setsockopt.c
> +++ b/sysdeps/unix/sysv/linux/setsockopt.c
> @@ -15,21 +15,76 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <errno.h>
> -#include <signal.h>
>  #include <sys/socket.h>
> -
> +#include <time.h>
> +#include <sysdep.h>
>  #include <socketcall.h>
> -#include <kernel-features.h>
> -#include <sys/syscall.h>
> +#include <socket-constants-time64.h>
>  
> -int
> -setsockopt (int fd, int level, int optname, const void *optval, socklen_t len)
> +static int
> +setsockopt_syscall (int fd, int level, int optname, const void *optval,
> +		    socklen_t len)
>  {
>  #ifdef __ASSUME_SETSOCKOPT_SYSCALL
> -  return INLINE_SYSCALL (setsockopt, 5, fd, level, optname, optval, len);
> +  return INLINE_SYSCALL_CALL (setsockopt, fd, level, optname, optval, len);
>  #else
>    return SOCKETCALL (setsockopt, fd, level, optname, optval, len);
>  #endif
>  }
> +
> +#ifndef __ASSUME_TIME64_SYSCALLS
> +static int
> +setsockopt32 (int fd, int level, int optname, const void *optval,
> +	      socklen_t len)
> +{
> +  int r = -1;
> +
> +  if (level != SOL_SOCKET)
> +    return r;
> +
> +  switch (optname)
> +    {
> +    case COMPAT_SO_RCVTIMEO_NEW:
> +    case COMPAT_SO_SNDTIMEO_NEW:
> +      {
> +        if (len < sizeof (struct __timeval64))
> +	  {
> +	    __set_errno (EINVAL);
> +	    break;
> +	  }
> +
> +	struct __timeval64 *tv64 = (struct __timeval64 *) optval;
> +	if (! in_time_t_range (tv64->tv_sec))
> +	  {
> +	    __set_errno (EOVERFLOW);
> +	    break;
> +	  }
> +
> +	if (optname == COMPAT_SO_RCVTIMEO_NEW)
> +	  optname = COMPAT_SO_RCVTIMEO_OLD;
> +	if (optname == COMPAT_SO_SNDTIMEO_NEW)
> +	  optname = COMPAT_SO_SNDTIMEO_OLD;
> +
> +	struct __timeval32 tv32 = valid_timeval64_to_timeval32 (*tv64);
> +
> +	r = setsockopt_syscall (fd, level, optname, &tv32, sizeof (tv32));
> +      }
> +    }
> +
> +  return r;
> +}
> +#endif
> +
> +int
> +setsockopt (int fd, int level, int optname, const void *optval, socklen_t len)
> +{
> +  int r = setsockopt_syscall (fd, level, optname, optval, len);
> +
> +#ifndef __ASSUME_TIME64_SYSCALLS
> +  if (r == -1 && errno == ENOPROTOOPT)
> +    r = setsockopt32 (fd, level, optname, optval, len);
> +#endif
> +
> +  return r;
> +}
>  weak_alias (setsockopt, __setsockopt)
> diff --git a/sysdeps/unix/sysv/linux/socket-constants-time64.h b/sysdeps/unix/sysv/linux/socket-constants-time64.h
> new file mode 100644
> index 0000000000..d09c39d6c2
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/socket-constants-time64.h
> @@ -0,0 +1,30 @@
> +/* Compat socket constants used in 64-bit compat code.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _SOCKET_CONSTANTS_TIME64_H
> +#define _SOCKET_CONSTANTS_TIME64_H
> +
> +/* The compat code requires the SO_* constants used for both 32 and 64-bit
> +   time_t, however they were only added on v5.1 kernel.  */
> +
> +#define COMPAT_SO_RCVTIMEO_OLD 20
> +#define COMPAT_SO_SNDTIMEO_OLD 21
> +#define COMPAT_SO_RCVTIMEO_NEW 66
> +#define COMPAT_SO_SNDTIMEO_NEW 67
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h b/sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h
> new file mode 100644
> index 0000000000..f4668db537
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/sparc/socket-constants-time64.h
> @@ -0,0 +1,30 @@
> +/* Compat socket constants used in 64-bit compat code.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _SOCKET_CONSTANTS_TIME64_H
> +#define _SOCKET_CONSTANTS_TIME64_H
> +
> +/* The compat code requires the SO_* constants used for both 32 and 64-bit
> +   time_t, however they were only added on v5.1 kernel.  */
> +
> +#define COMPAT_SO_RCVTIMEO_OLD 8192
> +#define COMPAT_SO_SNDTIMEO_OLD 16384
> +#define COMPAT_SO_RCVTIMEO_NEW 68
> +#define COMPAT_SO_SNDTIMEO_NEW 69
> +
> +#endif
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 14/24] y2038: Use a common definition for semid_ds
  2021-06-07 20:36 ` [PATCH v3 14/24] y2038: Use a common definition for semid_ds Adhemerval Zanella
@ 2021-06-14 14:52   ` Carlos O'Donell
  0 siblings, 0 replies; 41+ messages in thread
From: Carlos O'Donell @ 2021-06-14 14:52 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 6/7/21 4:36 PM, Adhemerval Zanella wrote:
> Instead of replicate the same definitions from struct_semid64_ds.h
> on the multiple struct_semid_ds.h, use a common header which is included
> when required (struct_semid64_ds_helper.h).
> 
> The __USE_TIME_BITS64 is not defined internally yet, although the
> internal header is used when building the 64-bit semctl implementation.

No regressions on x86_64 and i686 and reviewed resulting ABI for correctness.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/unix/sysv/linux/Makefile              |  3 ++-
>  .../sysv/linux/bits/types/struct_semid64_ds.h |  5 +---
>  .../bits/types/struct_semid64_ds_helper.h     | 25 +++++++++++++++++++
>  .../sysv/linux/bits/types/struct_semid_ds.h   | 10 +++++---
>  .../linux/hppa/bits/types/struct_semid_ds.h   |  4 +++
>  .../linux/mips/bits/types/struct_semid_ds.h   |  4 +++
>  .../powerpc/bits/types/struct_semid_ds.h      | 10 +++++---
>  .../linux/sparc/bits/types/struct_semid_ds.h  | 10 +++++---
>  .../linux/x86/bits/types/struct_semid_ds.h    |  4 +++
>  9 files changed, 61 insertions(+), 14 deletions(-)
>  create mode 100644 sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds_helper.h
> 
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index 6715a4b623..b6abcb1365 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -102,7 +102,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
>  		  bits/ipc-perm.h \
>  		  bits/struct_stat.h \
>  		  bits/struct_stat_time64_helper.h \
> -		  bits/types/struct_msqid64_ds_helper.h
> +		  bits/types/struct_msqid64_ds_helper.h \
> +		  bits/types/struct_semid64_ds_helper.h
>  
>  tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
>  	 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
> diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds.h
> index 7263e50bbf..adaee3eb9e 100644
> --- a/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds.h
> +++ b/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds.h
> @@ -25,9 +25,6 @@
>  #else
>  struct __semid64_ds
>  {
> -  struct ipc_perm sem_perm;		/* operation permission struct */
> -  __time64_t sem_otime;			/* last semop() time */
> -  __time64_t sem_ctime;			/* last time changed by semctl() */
> -  __syscall_ulong_t sem_nsems;		/* number of semaphores in set */
> +# include <bits/types/struct_semid64_ds_helper.h>
>  };
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds_helper.h b/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds_helper.h
> new file mode 100644
> index 0000000000..e6592e6c3f
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/bits/types/struct_semid64_ds_helper.h
> @@ -0,0 +1,25 @@
> +/* Common definitions for struct semid_ds with 64-bit time.
> +   Copyright (C) 2020-2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +  /* Content of internal __semid64_ds.  */
> +  struct ipc_perm sem_perm;		/* operation permission struct */
> +  __time64_t sem_otime;			/* last semop() time */
> +  __time64_t sem_ctime;			/* last time changed by semctl() */
> +  __syscall_ulong_t sem_nsems;		/* number of semaphores in set */
> +  unsigned long int __glibc_reserved3;
> +  unsigned long int __glibc_reserved4;

OK. Includes serverd entries for the kernel.

> diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_semid_ds.h
> index 2f32fa500e..a7b2c9022e 100644
> --- a/sysdeps/unix/sysv/linux/bits/types/struct_semid_ds.h
> +++ b/sysdeps/unix/sysv/linux/bits/types/struct_semid_ds.h
> @@ -23,17 +23,21 @@
>  /* Data structure describing a set of semaphores.  */
>  struct semid_ds
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_semid64_ds_helper.h>
> +#else
>    struct ipc_perm sem_perm;        /* operation permission struct */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>    __time_t sem_otime;              /* last semop() time */
>    __syscall_ulong_t __sem_otime_high;
>    __time_t sem_ctime;             /* last time changed by semctl() */
>    __syscall_ulong_t __sem_ctime_high;
> -#else
> +# else
>    __time_t sem_otime;
>    __time_t sem_ctime;
> -#endif
> +# endif
>    __syscall_ulong_t sem_nsems;    /* number of semaphores in set */
>    __syscall_ulong_t __glibc_reserved3;
>    __syscall_ulong_t __glibc_reserved4;
> +#endif
>  };
> diff --git a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_semid_ds.h
> index 16a9735e7b..5067fb1572 100644
> --- a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_semid_ds.h
> +++ b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_semid_ds.h
> @@ -23,6 +23,9 @@
>  /* Data structure describing a set of semaphores.  */
>  struct semid_ds
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_semid64_ds_helper.h>
> +#else
>    struct ipc_perm sem_perm;   /* operation permission struct */
>    __syscall_ulong_t __sem_otime_high;
>    __time_t sem_otime;         /* last semop() time */
> @@ -31,4 +34,5 @@ struct semid_ds
>    __syscall_ulong_t sem_nsems;    /* number of semaphores in set */
>    __syscall_ulong_t __glibc_reserved3;
>    __syscall_ulong_t __glibc_reserved4;
> +#endif
>  };
> diff --git a/sysdeps/unix/sysv/linux/mips/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/mips/bits/types/struct_semid_ds.h
> index 73587ea634..ee9a1e5e61 100644
> --- a/sysdeps/unix/sysv/linux/mips/bits/types/struct_semid_ds.h
> +++ b/sysdeps/unix/sysv/linux/mips/bits/types/struct_semid_ds.h
> @@ -23,10 +23,14 @@
>  /* Data structure describing a set of semaphores.  */
>  struct semid_ds
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_semid64_ds_helper.h>
> +#else
>    struct ipc_perm sem_perm;		/* operation permission struct */
>    __time_t sem_otime;	/* last semop() time */
>    __time_t sem_ctime;	/* last time changed by semctl() */
>    __syscall_ulong_t sem_nsems;		/* number of semaphores in set */
>    __syscall_ulong_t __sem_otime_high;
>    __syscall_ulong_t __sem_ctime_high;
> +#endif
>  };
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_semid_ds.h
> index 8fdbc5d776..0c080fed61 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_semid_ds.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_semid_ds.h
> @@ -23,17 +23,21 @@
>  /* Data structure describing a set of semaphores.  */
>  struct semid_ds
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_semid64_ds_helper.h>
> +#else
>    struct ipc_perm sem_perm;   /* operation permission struct */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>    __syscall_ulong_t __sem_otime_high;
>    __time_t sem_otime;         /* last semop() time */
>    __syscall_ulong_t __sem_ctime_high;
>    __time_t sem_ctime;        /* last time changed by semctl() */
> -#else
> +# else
>    __time_t sem_otime;         /* last semop() time */
>    __time_t sem_ctime;         /* last time changed by semctl() */
> -#endif
> +# endif
>    __syscall_ulong_t sem_nsems;    /* number of semaphores in set */
>    __syscall_ulong_t __glibc_reserved3;
>    __syscall_ulong_t __glibc_reserved4;
> +#endif
>  };
> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_semid_ds.h
> index 6b9b3639b2..76810427f6 100644
> --- a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_semid_ds.h
> +++ b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_semid_ds.h
> @@ -23,17 +23,21 @@
>  /* Data structure describing a set of semaphores.  */
>  struct semid_ds
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_semid64_ds_helper.h>
> +#else
>    struct ipc_perm sem_perm;   /* operation permission struct */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>    __syscall_ulong_t __sem_otime_high;
>    __time_t sem_otime;         /* last semop() time */
>    __syscall_ulong_t __sem_ctime_high;
>    __time_t sem_ctime;        /* last time changed by semctl() */
> -#else
> +# else
>    __time_t sem_otime;         /* last semop() time */
>    __time_t sem_ctime;         /* last time changed by semctl() */
> -#endif
> +# endif
>    __syscall_ulong_t sem_nsems;    /* number of semaphores in set */
>    __syscall_ulong_t __glibc_reserved3;
>    __syscall_ulong_t __glibc_reserved4;
> +#endif
>  };
> diff --git a/sysdeps/unix/sysv/linux/x86/bits/types/struct_semid_ds.h b/sysdeps/unix/sysv/linux/x86/bits/types/struct_semid_ds.h
> index 90f03b2407..affd38b6bd 100644
> --- a/sysdeps/unix/sysv/linux/x86/bits/types/struct_semid_ds.h
> +++ b/sysdeps/unix/sysv/linux/x86/bits/types/struct_semid_ds.h
> @@ -23,6 +23,9 @@
>  /* Data structure describing a set of semaphores.  */
>  struct semid_ds
>  {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_semid64_ds_helper.h>
> +#else
>    struct ipc_perm sem_perm;   /* operation permission struct */
>    __time_t sem_otime;  /* last semop() time */
>    __syscall_ulong_t __sem_otime_high;
> @@ -31,4 +34,5 @@ struct semid_ds
>    __syscall_ulong_t sem_nsems;    /* number of semaphores in set */
>    __syscall_ulong_t __glibc_reserved3;
>    __syscall_ulong_t __glibc_reserved4;
> +#endif
>  };
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 22/24] libsupport: Add 64-bit time_t support for time functions
  2021-06-07 20:36 ` [PATCH v3 22/24] libsupport: Add 64-bit time_t support for time functions Adhemerval Zanella
@ 2021-06-14 14:52   ` Carlos O'Donell
  0 siblings, 0 replies; 41+ messages in thread
From: Carlos O'Donell @ 2021-06-14 14:52 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 6/7/21 4:36 PM, Adhemerval Zanella wrote:
> The patch adds redirections for xclock_gettime, xclock_settime,
> timespec_add, timespec_sub, test_timespec_before_impl,
> test_timespec_equal_or_after_impl, support_timespec_ns,
> support_timespec_normalize, and support_timespec_check_in_range when
> _TIME_BITS=64 is defined.

No regressions on x86_64 and i686 and reviewed resulting ABI for correctness.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: carlos O'Donell <carlos@redhat.com>
 
OK. All occurrences of "64 bit" in v2 removed and fixed in v3.

> Co-authored-by: Lukasz Majewski <lukma@denx.de>
> Tested-by: Carlos O'Donell <carlos@redhat.com>
> ---
>  support/Makefile                |  6 ++++
>  support/timespec-add-time64.c   | 27 +++++++++++++++++
>  support/timespec-add.c          |  2 +-
>  support/timespec-sub-time64.c   | 27 +++++++++++++++++
>  support/timespec-sub.c          |  2 +-
>  support/timespec-time64.c       | 40 +++++++++++++++++++++++++
>  support/timespec.c              |  9 +++---
>  support/timespec.h              | 52 +++++++++++++++++++++++++--------
>  support/xclock_gettime_time64.c | 26 +++++++++++++++++
>  support/xclock_settime_time64.c | 26 +++++++++++++++++
>  support/xtime.h                 |  7 +++++
>  11 files changed, 205 insertions(+), 19 deletions(-)
>  create mode 100644 support/timespec-add-time64.c
>  create mode 100644 support/timespec-sub-time64.c
>  create mode 100644 support/timespec-time64.c
>  create mode 100644 support/xclock_gettime_time64.c
>  create mode 100644 support/xclock_settime_time64.c
> 
> diff --git a/support/Makefile b/support/Makefile
> index 0a4b057db5..e27b9b164e 100644
> --- a/support/Makefile
> +++ b/support/Makefile
> @@ -83,8 +83,11 @@ libsupport-routines = \
>    support_test_verify_impl \
>    temp_file \
>    timespec \
> +  timespec-time64 \
>    timespec-add \
> +  timespec-add-time64 \
>    timespec-sub \
> +  timespec-sub-time64 \
>    write_message \
>    xaccept \
>    xaccept4 \
> @@ -94,7 +97,9 @@ libsupport-routines = \
>    xchdir \
>    xchroot \
>    xclock_gettime \
> +  xclock_gettime_time64 \
>    xclock_settime \
> +  xclock_settime_time64 \
>    xclose \
>    xchmod \
>    xconnect \
> @@ -216,6 +221,7 @@ CFLAGS-support_paths.c = \
>  # in support_timespec_check_in_range and for that computation we use
>  # -fexcess-precision=standard.
>  CFLAGS-timespec.c += -fexcess-precision=standard
> +CFLAGS-timespec-time64.c += -fexcess-precision=standard
>  
>  ifeq (,$(CXX))
>  LINKS_DSO_PROGRAM = links-dso-program-c
> diff --git a/support/timespec-add-time64.c b/support/timespec-add-time64.c
> new file mode 100644
> index 0000000000..a25a3c8d34
> --- /dev/null
> +++ b/support/timespec-add-time64.c
> @@ -0,0 +1,27 @@
> +/* Add two struct __timespec64 values.  64-bit time support.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library and is also part of gnulib.
> +   Patches to this file should be submitted to both projects.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <time.h>
> +
> +#if __TIMESIZE != 64
> +# define timespec      __timespec64
> +# define time_t        __time64_t
> +# define timespec_add  timespec_add_time64
> +# include "timespec-add.c"
> +#endif
> diff --git a/support/timespec-add.c b/support/timespec-add.c
> index cf8bd91291..8ed3acef6d 100644
> --- a/support/timespec-add.c
> +++ b/support/timespec-add.c
> @@ -61,5 +61,5 @@ timespec_add (struct timespec a, struct timespec b)
>          }
>      }
>  
> -  return make_timespec (rs, rns);
> +  return (struct timespec) { .tv_sec = rs, .tv_nsec = rns };
>  }
> diff --git a/support/timespec-sub-time64.c b/support/timespec-sub-time64.c
> new file mode 100644
> index 0000000000..dcbb79211a
> --- /dev/null
> +++ b/support/timespec-sub-time64.c
> @@ -0,0 +1,27 @@
> +/* Subtract two struct __timespec64 values.  64-bit time support.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library and is also part of gnulib.
> +   Patches to this file should be submitted to both projects.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <time.h>
> +
> +#if __TIMESIZE != 64
> +# define timespec      __timespec64
> +# define time_t        __time64_t
> +# define timespec_sub  timespec_sub_time64
> +# include "timespec-sub.c"
> +#endif
> diff --git a/support/timespec-sub.c b/support/timespec-sub.c
> index 08cc233086..0b8fea042d 100644
> --- a/support/timespec-sub.c
> +++ b/support/timespec-sub.c
> @@ -61,5 +61,5 @@ timespec_sub (struct timespec a, struct timespec b)
>          }
>      }
>  
> -  return make_timespec (rs, rns);
> +  return (struct timespec) { .tv_sec = rs, .tv_nsec = rns };
>  }
> diff --git a/support/timespec-time64.c b/support/timespec-time64.c
> new file mode 100644
> index 0000000000..d780658ec3
> --- /dev/null
> +++ b/support/timespec-time64.c
> @@ -0,0 +1,40 @@
> +/* Support code for timespec checks.  64-bit time support.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <support/timespec.h>
> +#include <stdio.h>
> +#include <stdint.h>
> +#include <assert.h>
> +#include <intprops.h>
> +
> +#if __TIMESIZE != 64
> +struct __timespec64 timespec_sub_time64 (struct __timespec64,
> +					 struct __timespec64);
> +
> +#define test_timespec_before_impl          test_timespec_before_impl_time64
> +#define test_timespec_equal_or_after_impl  \
> +  test_timespec_equal_or_after_impl_time64
> +#define support_timespec_ns                support_timespec_ns_time64
> +#define support_timespec_normalize         support_timespec_normalize_time64
> +#define support_timespec_check_in_range    \
> +  support_timespec_check_in_range_time64
> +#define timespec                           __timespec64
> +#define timespec_sub                       timespec_sub_time64
> +
> +#include "timespec.c"
> +#endif
> diff --git a/support/timespec.c b/support/timespec.c
> index b02afad9d3..fcc54861b1 100644
> --- a/support/timespec.c
> +++ b/support/timespec.c
> @@ -23,9 +23,8 @@
>  #include <intprops.h>
>  
>  void
> -test_timespec_before_impl (const char *file, int line,
> -			   const struct timespec left,
> -			   const struct timespec right)
> +test_timespec_before_impl (const char *file, int line, struct timespec left,
> +			   struct timespec right)
>  {
>    if (left.tv_sec > right.tv_sec
>        || (left.tv_sec == right.tv_sec
> @@ -43,8 +42,8 @@ test_timespec_before_impl (const char *file, int line,
>  
>  void
>  test_timespec_equal_or_after_impl (const char *file, int line,
> -				   const struct timespec left,
> -				   const struct timespec right)
> +				   struct timespec left,
> +				   struct timespec right)
>  {
>    if (left.tv_sec < right.tv_sec
>        || (left.tv_sec == right.tv_sec
> diff --git a/support/timespec.h b/support/timespec.h
> index a3eb72aa01..0478aef51f 100644
> --- a/support/timespec.h
> +++ b/support/timespec.h
> @@ -24,11 +24,6 @@
>  #include <support/check.h>
>  #include <support/xtime.h>
>  
> -struct timespec timespec_add (struct timespec, struct timespec)
> -  __attribute__((const));
> -struct timespec timespec_sub (struct timespec, struct timespec)
> -  __attribute__((const));
> -
>  static inline struct timespec
>  make_timespec (time_t s, long int ns)
>  {
> @@ -40,21 +35,54 @@ make_timespec (time_t s, long int ns)
>  
>  enum { TIMESPEC_HZ = 1000000000 };
>  
> +#ifndef __USE_TIME_BITS64
> +struct timespec timespec_add (struct timespec, struct timespec)
> +  __attribute__((const));
> +struct timespec timespec_sub (struct timespec, struct timespec)
> +  __attribute__((const));
> +
>  void test_timespec_before_impl (const char *file, int line,
> -                                const struct timespec left,
> -                                const struct timespec right);
> +                                struct timespec left,
> +                                struct timespec right);
>  
>  void test_timespec_equal_or_after_impl (const char *file, int line,
> -                                        const struct timespec left,
> -                                        const struct timespec right);
> +                                        struct timespec left,
> +                                        struct timespec right);
>  
>  time_t support_timespec_ns (struct timespec time);
>  
>  struct timespec support_timespec_normalize (struct timespec time);
>  
> -int support_timespec_check_in_range (struct timespec expected, struct timespec observed,
> -				  double lower_bound, double upper_bound);
> -
> +int support_timespec_check_in_range (struct timespec expected,
> +				     struct timespec observed,
> +				     double lower_bound, double upper_bound);
> +
> +#else
> +struct timespec __REDIRECT (timespec_add, (struct timespec, struct timespec),
> +			    timespec_add_time64);
> +struct timespec __REDIRECT (timespec_sub, (struct timespec, struct timespec),
> +			    timespec_sub_time64);
> +void __REDIRECT (test_timespec_before_impl, (const char *file, int line,
> +					     struct timespec left,
> +					     struct timespec right),
> +		 test_timespec_before_impl_time64);
> +void __REDIRECT (test_timespec_equal_or_after_impl, (const char *f, int line,
> +						     struct timespec left,
> +						     struct timespec right),
> +		 test_timespec_equal_or_after_impl_time64);
> +
> +time_t __REDIRECT (support_timespec_ns, (struct timespec time),
> +		   support_timespec_ns_time64);
> +
> +struct timespec __REDIRECT (support_timespec_normalize, (struct timespec time),
> +			    support_timespec_normalize_time64);
> +
> +int __REDIRECT (support_timespec_check_in_range, (struct timespec expected,
> +						  struct timespec observed,
> +						  double lower_bound,
> +						  double upper_bound),
> +		support_timespec_check_in_range_time64);
> +#endif
>  
>  /* Check that the timespec on the left represents a time before the
>     time on the right. */
> diff --git a/support/xclock_gettime_time64.c b/support/xclock_gettime_time64.c
> new file mode 100644
> index 0000000000..d2ed0f026d
> --- /dev/null
> +++ b/support/xclock_gettime_time64.c
> @@ -0,0 +1,26 @@
> +/* clock_settime with error checking.  64-bit time_t support.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <support/xtime.h>
> +
> +#if __TIMESIZE != 64
> +# define xclock_gettime  xclock_gettime_time64
> +# define timespec        __timespec64
> +# define clock_gettime   __clock_gettime64
> +# include "xclock_gettime.c"
> +#endif
> diff --git a/support/xclock_settime_time64.c b/support/xclock_settime_time64.c
> new file mode 100644
> index 0000000000..7f7bead876
> --- /dev/null
> +++ b/support/xclock_settime_time64.c
> @@ -0,0 +1,26 @@
> +/* clock_settime helper with error checking - 64-bit time_t support.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <support/xtime.h>
> +
> +#if __TIMESIZE != 64
> +# define xclock_settime  xclock_settime_time64
> +# define timespec        __timespec64
> +# define clock_settime   __clock_settime64
> +# include "xclock_settime.c"
> +#endif
> diff --git a/support/xtime.h b/support/xtime.h
> index b4ac3b59e2..25a069d447 100644
> --- a/support/xtime.h
> +++ b/support/xtime.h
> @@ -30,8 +30,15 @@ __BEGIN_DECLS
>  /* The following functions call the corresponding libc functions and
>     terminate the process on error.  */
>  
> +#ifndef __USE_TIME_BITS64
>  void xclock_gettime (clockid_t clock, struct timespec *ts);
>  void xclock_settime (clockid_t clock, const struct timespec *ts);
> +#else
> +void __REDIRECT (xclock_gettime, (clockid_t clock, struct timespec *ts),
> +		 xclock_gettime_time64);
> +void __REDIRECT (xclock_settime, (clockid_t clock, const struct timespec *ts),
> +		 xclock_settime_time64);
> +#endif
>  
>  /* This helper can often simplify tests by avoiding an explicit
>     variable declaration or allowing that declaration to be const. */
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 19/24] posix: Add glob64 with 64-bit time_t support
  2021-06-07 20:36 ` [PATCH v3 19/24] posix: Add glob64 with 64-bit time_t support Adhemerval Zanella
@ 2021-06-14 14:52   ` Carlos O'Donell
  0 siblings, 0 replies; 41+ messages in thread
From: Carlos O'Donell @ 2021-06-14 14:52 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 6/7/21 4:36 PM, Adhemerval Zanella wrote:
> The glob might pass a different stat struct for gl_stat and gl_lstat
> when GLOB_ALTDIRFUNC is used.  This requires add a new 64-bit time
> version that also uses 64-bit time stat functions.
> 
> Checked on i686-linux-gnu and x86_64-linux-gnu.

No regressions on x86_64 and i686 and reviewed resulting ABI for correctness.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: carlos O'Donell <carlos@redhat.com>

> ---
>  include/glob.h                                | 28 +++++++++++
>  posix/Makefile                                |  4 +-
>  posix/glob.c                                  | 46 +++++++++--------
>  posix/glob.h                                  | 22 +++++++++
>  posix/glob64-lstat-compat.c                   |  3 +-
>  posix/glob64-time64.c                         | 49 +++++++++++++++++++
>  posix/globfree64-time64.c                     | 30 ++++++++++++
>  sysdeps/gnu/glob64-lstat-compat.c             |  3 +-
>  sysdeps/unix/sysv/linux/Versions              |  2 +
>  sysdeps/unix/sysv/linux/arm/be/libc.abilist   |  2 +
>  sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  2 +
>  sysdeps/unix/sysv/linux/csky/libc.abilist     |  2 +
>  sysdeps/unix/sysv/linux/glob-lstat-compat.c   |  6 ++-
>  sysdeps/unix/sysv/linux/glob.c                |  6 +++
>  sysdeps/unix/sysv/linux/glob64-lstat-compat.c | 12 ++---
>  sysdeps/unix/sysv/linux/glob64-time64.c       | 44 +++++++++++++++++
>  sysdeps/unix/sysv/linux/glob64.c              |  8 +--
>  sysdeps/unix/sysv/linux/globfree64-time64.c   | 35 +++++++++++++
>  sysdeps/unix/sysv/linux/hppa/libc.abilist     |  2 +
>  sysdeps/unix/sysv/linux/i386/libc.abilist     |  2 +
>  .../sysv/linux/m68k/coldfire/libc.abilist     |  2 +
>  .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  2 +
>  .../sysv/linux/microblaze/be/libc.abilist     |  2 +
>  .../sysv/linux/microblaze/le/libc.abilist     |  2 +
>  .../sysv/linux/mips/mips32/fpu/libc.abilist   |  2 +
>  .../sysv/linux/mips/mips32/nofpu/libc.abilist |  2 +
>  .../sysv/linux/mips/mips64/n32/libc.abilist   |  2 +
>  sysdeps/unix/sysv/linux/nios2/libc.abilist    |  2 +
>  sysdeps/unix/sysv/linux/oldglob.c             | 11 ++---
>  .../linux/powerpc/powerpc32/fpu/libc.abilist  |  2 +
>  .../powerpc/powerpc32/nofpu/libc.abilist      |  2 +
>  .../unix/sysv/linux/s390/s390-32/libc.abilist |  2 +
>  sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  2 +
>  sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  2 +
>  .../sysv/linux/sparc/sparc32/libc.abilist     |  2 +
>  35 files changed, 307 insertions(+), 40 deletions(-)
>  create mode 100644 posix/glob64-time64.c
>  create mode 100644 posix/globfree64-time64.c
>  create mode 100644 sysdeps/unix/sysv/linux/glob64-time64.c
>  create mode 100644 sysdeps/unix/sysv/linux/globfree64-time64.c
> 
> diff --git a/include/glob.h b/include/glob.h
> index 1d2f78793e..f48c71960d 100644
> --- a/include/glob.h
> +++ b/include/glob.h
> @@ -2,11 +2,39 @@
>  #include <posix/glob.h>
>  
>  #ifndef _ISOMAC
> +# include <sys/types.h>
> +
>  libc_hidden_proto (glob)
>  libc_hidden_proto (glob64)
>  libc_hidden_proto (globfree)
>  libc_hidden_proto (globfree64)
>  
> +# if __TIMESIZE == 64
> +#  define glob64_time64_t glob64_t
> +# else
> +# include <sys/stat.h>
> +
> +typedef struct
> +  {
> +    size_t gl_pathc;
> +    char **gl_pathv;
> +    size_t gl_offs;
> +    int gl_flags;
> +
> +    void (*gl_closedir) (void *);
> +    struct dirent64 *(*gl_readdir) (void *);
> +    void *(*gl_opendir) (const char *);
> +    int (*gl_lstat) (const char *__restrict, struct __stat64_t64 *__restrict);
> +    int (*gl_stat) (const char *__restrict, struct __stat64_t64 *__restrict);
> +  } glob64_time64_t;
> +
> +extern int __glob64_time64 (const char *pattern, int flags,
> +			    int (*errfunc) (const char *, int),
> +			    glob64_time64_t *pglob);
> +void __globfree64_time64 (glob64_time64_t *pglob);
> +libc_hidden_proto (__globfree64_time64)
> +# endif
> +
>  /* Now define the internal interfaces.  */
>  extern int __glob_pattern_p (const char *__pattern, int __quote);
>  extern int __glob64 (const char *__pattern, int __flags,
> diff --git a/posix/Makefile b/posix/Makefile
> index fa0dc0ea20..c8c538fcee 100644
> --- a/posix/Makefile
> +++ b/posix/Makefile
> @@ -67,7 +67,9 @@ routines :=								      \
>  	get_child_max sched_cpucount sched_cpualloc sched_cpufree \
>  	streams-compat \
>  	shm-directory                                                         \
> -	execveat
> +	execveat \
> +	glob64-time64 \
> +	globfree64-time64

OK. Fixed from v2.

>  
>  aux		:= init-posix environ
>  tests		:= test-errno tstgetopt testfnm runtests runptests \
> diff --git a/posix/glob.c b/posix/glob.c
> index 32c88e5d15..593a4c358f 100644
> --- a/posix/glob.c
> +++ b/posix/glob.c
> @@ -59,25 +59,37 @@
>  # define readdir(str) __readdir64 (str)
>  # define getpwnam_r(name, bufp, buf, len, res) \
>      __getpwnam_r (name, bufp, buf, len, res)
> -# define struct_stat64          struct stat64
>  # define FLEXIBLE_ARRAY_MEMBER
> +# ifndef struct_stat
> +#  define struct_stat           struct stat
> +# endif
> +# ifndef struct_stat64
> +#  define struct_stat64         struct stat64
> +# endif
> +# ifndef GLOB_LSTAT
> +#  define GLOB_LSTAT            gl_lstat
> +# endif
> +# ifndef GLOB_STAT64
> +#  define GLOB_STAT64           __stat64
> +# endif
> +# ifndef GLOB_LSTAT64
> +#  define GLOB_LSTAT64          __lstat64
> +# endif
>  # include <shlib-compat.h>
>  #else /* !_LIBC */
>  # define __glob                 glob
>  # define __getlogin_r(buf, len) getlogin_r (buf, len)
> -# define __lstat64(fname, buf)  lstat (fname, buf)
> -# if defined _WIN32 && !defined __CYGWIN__
> -   /* Avoid GCC or clang warning.  The original __stat64 macro is unused.  */
> -#  undef __stat64
> -# endif
> -# define __stat64(fname, buf)   stat (fname, buf)
>  # define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag)
> -# define struct_stat64          struct stat
>  # ifndef __MVS__
>  #  define __alloca              alloca
>  # endif
>  # define __readdir              readdir
>  # define COMPILE_GLOB64
> +# define struct_stat            struct stat
> +# define struct_stat64          struct stat
> +# define GLOB_LSTAT             gl_lstat
> +# define GLOB_STAT64            stat
> +# define GLOB_LSTAT64           lstat
>  #endif /* _LIBC */
>  
>  #include <fnmatch.h>
> @@ -196,22 +208,14 @@ glob_lstat (glob_t *pglob, int flags, const char *fullname)
>  {
>  /* Use on glob-lstat-compat.c to provide a compat symbol which does not
>     use lstat / gl_lstat.  */
> -#ifdef GLOB_NO_LSTAT
> -# define GL_LSTAT gl_stat
> -# define LSTAT64 __stat64
> -#else
> -# define GL_LSTAT gl_lstat
> -# define LSTAT64 __lstat64
> -#endif
> -
>    union
>    {
> -    struct stat st;
> +    struct_stat st;
>      struct_stat64 st64;
>    } ust;
>    return (__glibc_unlikely (flags & GLOB_ALTDIRFUNC)
> -          ? pglob->GL_LSTAT (fullname, &ust.st)
> -          : LSTAT64 (fullname, &ust.st64));
> +          ? pglob->GLOB_LSTAT (fullname, &ust.st)
> +          : GLOB_LSTAT64 (fullname, &ust.st64));
>  }
>  
>  /* Set *R = A + B.  Return true if the answer is mathematically
> @@ -249,11 +253,11 @@ static int collated_compare (const void *, const void *) __THROWNL;
>  static bool
>  is_dir (char const *filename, int flags, glob_t const *pglob)
>  {
> -  struct stat st;
> +  struct_stat st;
>    struct_stat64 st64;
>    return (__glibc_unlikely (flags & GLOB_ALTDIRFUNC)
>            ? pglob->gl_stat (filename, &st) == 0 && S_ISDIR (st.st_mode)
> -          : __stat64 (filename, &st64) == 0 && S_ISDIR (st64.st_mode));
> +          : GLOB_STAT64 (filename, &st64) == 0 && S_ISDIR (st64.st_mode));
>  }
>  
>  /* Find the end of the sub-pattern in a brace expression.  */
> diff --git a/posix/glob.h b/posix/glob.h
> index b5686600c7..700aeb2392 100644
> --- a/posix/glob.h
> +++ b/posix/glob.h
> @@ -150,20 +150,42 @@ extern int glob (const char *__restrict __pattern, int __flags,
>  /* Free storage allocated in PGLOB by a previous `glob' call.  */
>  extern void globfree (glob_t *__pglob) __THROW;
>  #else
> +# ifdef __USE_TIME_BITS64
> +extern int __REDIRECT_NTHNL (glob, (const char *__restrict __pattern,
> +				    int __flags,
> +				    int (*__errfunc) (const char *, int),
> +				    glob_t *__restrict __pglob),
> +			     __glob64_time64);
> +
> +extern void __REDIRECT_NTH (globfree, (glob_t *__pglob),
> +			    __globfree64_time64);
> +# else
>  extern int __REDIRECT_NTHNL (glob, (const char *__restrict __pattern,
>  				    int __flags,
>  				    int (*__errfunc) (const char *, int),
>  				    glob_t *__restrict __pglob), glob64);
>  
>  extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
> +# endif
>  #endif
>  
>  #ifdef __USE_LARGEFILE64
> +# ifdef __USE_TIME_BITS64
> +extern int __REDIRECT_NTHNL (glob64, (const char *__restrict __pattern,
> +				      int __flags,
> +				      int (*__errfunc) (const char *, int),
> +				      glob64_t *__restrict __pglob),
> +			     __glob64_time64);
> +
> +extern void __REDIRECT_NTH (globfree64, (glob64_t *__pglob),
> +			    __globfree64_time64);
> +# else
>  extern int glob64 (const char *__restrict __pattern, int __flags,
>  		   int (*__errfunc) (const char *, int),
>  		   glob64_t *__restrict __pglob) __THROWNL;
>  
>  extern void globfree64 (glob64_t *__pglob) __THROW;
> +# endif
>  #endif
>  
>  
> diff --git a/posix/glob64-lstat-compat.c b/posix/glob64-lstat-compat.c
> index bd81a1e390..e90d4ae93e 100644
> --- a/posix/glob64-lstat-compat.c
> +++ b/posix/glob64-lstat-compat.c
> @@ -28,7 +28,8 @@
>  # define GLOB_ATTRIBUTE attribute_compat_text_section
>  
>  /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
> -# define GLOB_NO_LSTAT
> +# define GLOB_LSTAT   gl_stat
> +# define GLOB_LSTAT64 __stat64
>  
>  # include <posix/glob64.c>
>  
> diff --git a/posix/glob64-time64.c b/posix/glob64-time64.c
> new file mode 100644
> index 0000000000..b0f8facd84
> --- /dev/null
> +++ b/posix/glob64-time64.c
> @@ -0,0 +1,49 @@
> +/* Long File Support glob with 64-bit time support.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <errno.h>
> +#include <glob.h>
> +#include <stddef.h>
> +
> +#if __TIMESIZE != 64
> +
> +/* Do glob searching for PATTERN, placing results in PGLOB.
> +   The bits defined above may be set in FLAGS.
> +   If a directory cannot be opened or read and ERRFUNC is not nil,
> +   it is called with the pathname that caused the error, and the
> +   `errno' value from the failing call; if it returns non-zero
> +   `glob' returns GLOB_ABORTED; if it returns zero, the error is ignored.
> +   If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
> +   Otherwise, `glob' returns zero.  */
> +int
> +__glob64_time64 (const char *pattern, int flags,
> +		 int (*errfunc) (const char *, int), glob64_time64_t *pglob)
> +{
> +  if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0)
> +    {
> +      __set_errno (EINVAL);
> +      return -1;
> +    }
> +
> +  __set_errno (ENOSYS);
> +  return GLOB_NOSYS;
> +}
> +
> +stub_warning (glob64)
> +
> +#endif
> diff --git a/posix/globfree64-time64.c b/posix/globfree64-time64.c
> new file mode 100644
> index 0000000000..1fc2085f3f
> --- /dev/null
> +++ b/posix/globfree64-time64.c
> @@ -0,0 +1,30 @@
> +/* Long File Support globfree with 64-bit time support.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <glob.h>
> +
> +#if __TIMESIZE != 64
> +
> +/* Free storage allocated in PGLOB by a previous `glob' call.  */
> +void
> +__globfree64_time64 (glob64_time64_t *pglob)
> +{
> +}
> +libc_hidden_def (__globfree64_time64)
> +
> +#endif
> diff --git a/sysdeps/gnu/glob64-lstat-compat.c b/sysdeps/gnu/glob64-lstat-compat.c
> index 6764f1d062..ade4ccac8a 100644
> --- a/sysdeps/gnu/glob64-lstat-compat.c
> +++ b/sysdeps/gnu/glob64-lstat-compat.c
> @@ -39,7 +39,8 @@
>  #define GLOB_ATTRIBUTE attribute_compat_text_section
>  
>  /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
> -#define GLOB_NO_LSTAT
> +#define GLOB_LSTAT   gl_stat
> +#define GLOB_LSTAT64 __stat64
>  
>  #include <posix/glob.c>
>  
> diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
> index 0aa2ef8559..f045604ad6 100644
> --- a/sysdeps/unix/sysv/linux/Versions
> +++ b/sysdeps/unix/sysv/linux/Versions
> @@ -209,6 +209,8 @@ libc {
>      __getitimer64;
>      __getrusage64;
>      __gettimeofday64;
> +    __glob64_time64;
> +    __globfree64_time64;
>      __gmtime64;
>      __gmtime64_r;
>      __localtime64;
> diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> index 1d32514579..8e3101b1c2 100644
> --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> @@ -209,6 +209,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> index 05d0878232..b29a0e324e 100644
> --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> @@ -206,6 +206,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
> index ac9f009f38..5f5427cb46 100644
> --- a/sysdeps/unix/sysv/linux/csky/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
> @@ -2296,6 +2296,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/glob-lstat-compat.c b/sysdeps/unix/sysv/linux/glob-lstat-compat.c
> index 1f502e3299..7729e0dc12 100644
> --- a/sysdeps/unix/sysv/linux/glob-lstat-compat.c
> +++ b/sysdeps/unix/sysv/linux/glob-lstat-compat.c
> @@ -30,7 +30,11 @@
>  #define GLOB_ATTRIBUTE attribute_compat_text_section
>  
>  /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
> -#define GLOB_NO_LSTAT
> +#define struct_stat    struct stat
> +#define struct_stat64  struct stat64
> +#define GLOB_LSTAT     gl_stat
> +#define GLOB_STAT64    __stat64
> +#define GLOB_LSTAT64   __stat64
>  
>  #include <posix/glob.c>
>  
> diff --git a/sysdeps/unix/sysv/linux/glob.c b/sysdeps/unix/sysv/linux/glob.c
> index 1be4885b96..89c287d01d 100644
> --- a/sysdeps/unix/sysv/linux/glob.c
> +++ b/sysdeps/unix/sysv/linux/glob.c
> @@ -19,6 +19,12 @@
>  #include <sys/stat.h>
>  #include <kernel_stat.h>
>  
> +#define struct_stat    struct stat
> +#define struct_stat64  struct stat64
> +#define GLOB_LSTAT     gl_lstat
> +#define GLOB_STAT64    __stat64
> +#define GLOB_LSTAT64   __lstat64
> +
>  #define glob64 __no_glob64_decl
>  #define __glob64 __no___glob64_decl
>  #include <posix/glob.c>
> diff --git a/sysdeps/unix/sysv/linux/glob64-lstat-compat.c b/sysdeps/unix/sysv/linux/glob64-lstat-compat.c
> index 40ad625f58..302a44d3a4 100644
> --- a/sysdeps/unix/sysv/linux/glob64-lstat-compat.c
> +++ b/sysdeps/unix/sysv/linux/glob64-lstat-compat.c
> @@ -33,15 +33,15 @@
>  # define __glob __glob64_lstat_compat
>  # define globfree globfree64
>  
> -# undef stat
> -# define stat stat64
> -
> -# define COMPILE_GLOB64	1
> -
>  # define GLOB_ATTRIBUTE attribute_compat_text_section
>  
>  /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
> -# define GLOB_NO_LSTAT
> +# define COMPILE_GLOB64	1
> +# define struct_stat    struct stat64
> +# define struct_stat64  struct stat64
> +# define GLOB_LSTAT     gl_stat
> +# define GLOB_STAT64    __stat64
> +# define GLOB_LSTAT64   __stat64
>  
>  # include <posix/glob.c>
>  
> diff --git a/sysdeps/unix/sysv/linux/glob64-time64.c b/sysdeps/unix/sysv/linux/glob64-time64.c
> new file mode 100644
> index 0000000000..260f067fa4
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/glob64-time64.c
> @@ -0,0 +1,44 @@
> +/* Find pathnames matching a pattern.  Linux version.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sys/stat.h>
> +
> +#if __TIMESIZE != 64
> +# include <glob.h>
> +# include <dirent.h>
> +# include <sys/stat.h>
> +
> +# define dirent dirent64
> +# define __readdir(dirp) __readdir64 (dirp)
> +
> +# define glob_t glob64_time64_t
> +# define __glob __glob64_time64
> +
> +# define globfree(pglob) __globfree64_time64 (pglob)
> +
> +# define COMPILE_GLOB64  1
> +# define struct_stat     struct __stat64_t64
> +# define struct_stat64   struct __stat64_t64
> +# define GLOB_LSTAT      gl_lstat
> +# define GLOB_STAT64     __stat64_time64
> +# define GLOB_LSTAT64    __lstat64_time64
> +
> +# define COMPILE_GLOB64	1
> +
> +# include <posix/glob.c>
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/glob64.c b/sysdeps/unix/sysv/linux/glob64.c
> index 3cbadf34fb..572ca215df 100644
> --- a/sysdeps/unix/sysv/linux/glob64.c
> +++ b/sysdeps/unix/sysv/linux/glob64.c
> @@ -31,10 +31,12 @@
>  # define __glob __glob64
>  # define globfree(pglob) globfree64 (pglob)
>  
> -# undef stat
> -# define stat stat64
> -
>  # define COMPILE_GLOB64	1
> +# define struct_stat    struct stat64
> +# define struct_stat64  struct stat64
> +# define GLOB_LSTAT     gl_lstat
> +# define GLOB_STAT64    __stat64
> +# define GLOB_LSTAT64   __lstat64
>  
>  # include <posix/glob.c>
>  
> diff --git a/sysdeps/unix/sysv/linux/globfree64-time64.c b/sysdeps/unix/sysv/linux/globfree64-time64.c
> new file mode 100644
> index 0000000000..d6b1e6ac49
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/globfree64-time64.c
> @@ -0,0 +1,35 @@
> +/* Frees the dynamically allocated storage from an earlier call to glob.
> +   Linux version.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sys/stat.h>
> +
> +#if __TIMESIZE != 64
> +# include <glob.h>
> +# include <dirent.h>
> +# include <sys/stat.h>
> +
> +# define glob_t glob64_time64_t
> +# define globfree(pglob) __globfree64_time64 (pglob)
> +
> +# undef stat
> +# define stat __stat64_t64
> +
> +# include <posix/globfree.c>
> +libc_hidden_def (__globfree64_time64)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> index d2770a4874..ca8f7c3dbb 100644
> --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> @@ -2250,6 +2250,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
> index eb20d66c28..d2b7b4d4b6 100644
> --- a/sysdeps/unix/sysv/linux/i386/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
> @@ -2433,6 +2433,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __isnanf128 F
> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> index 044cec51fc..515e383d50 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> @@ -210,6 +210,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> index 3a6463a3ef..6915fa115f 100644
> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> @@ -2377,6 +2377,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> index 612d7f1c58..9293872f80 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> @@ -2347,6 +2347,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> index 685cb974c3..cb671c56be 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> @@ -2344,6 +2344,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> index d17b5a02a5..f5effe36e1 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> @@ -2342,6 +2342,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> index aba6bd2e3c..2b66d26931 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> @@ -2340,6 +2340,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> index 88d8e2af38..bd76490d97 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> @@ -2348,6 +2348,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> index 3b64e2cf51..e62a2a5729 100644
> --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> @@ -2386,6 +2386,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/oldglob.c b/sysdeps/unix/sysv/linux/oldglob.c
> index 59bf89dc1d..a9a4439ddb 100644
> --- a/sysdeps/unix/sysv/linux/oldglob.c
> +++ b/sysdeps/unix/sysv/linux/oldglob.c
> @@ -28,13 +28,12 @@ libc_hidden_proto (__old_glob64);
>  #define convert_dirent __old_convert_dirent
>  #define glob_in_dir __old_glob_in_dir
>  
> -#undef stat
> -#define stat stat64
> -#undef __stat
> -#define __stat(file, buf) __stat64 (file, buf)
> -
>  /* Avoid calling gl_lstat with GLOB_ALTDIRFUNC.  */
> -#define GLOB_NO_LSTAT
> +#define struct_stat    struct stat64
> +#define struct_stat64  struct stat64
> +#define GLOB_LSTAT     gl_stat
> +#define GLOB_STAT64    __stat64
> +#define GLOB_LSTAT64   __stat64
>  
>  #define GLOB_ATTRIBUTE attribute_compat_text_section
>  
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> index 5404fdea4a..bc5b23c818 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> @@ -2404,6 +2404,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> index 506fa3619f..f9421c7777 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> @@ -2437,6 +2437,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> index 99b6d6d1ce..7581354bf4 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> @@ -2402,6 +2402,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> index 68a631b161..0e45f7fb0a 100644
> --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> @@ -2257,6 +2257,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> index 61a29e643a..ece6721841 100644
> --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> @@ -2254,6 +2254,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> index fa3ae954c1..6073443a3d 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> @@ -2395,6 +2395,8 @@ GLIBC_2.34 __futimesat64 F
>  GLIBC_2.34 __getitimer64 F
>  GLIBC_2.34 __getrusage64 F
>  GLIBC_2.34 __gettimeofday64 F
> +GLIBC_2.34 __glob64_time64 F
> +GLIBC_2.34 __globfree64_time64 F
>  GLIBC_2.34 __gmtime64 F
>  GLIBC_2.34 __gmtime64_r F
>  GLIBC_2.34 __libc_start_main F
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 15/24] y2038: Use a common definition for shmid_ds
  2021-06-07 20:36 ` [PATCH v3 15/24] y2038: Use a common definition for shmid_ds Adhemerval Zanella
@ 2021-06-14 14:59   ` Carlos O'Donell
  0 siblings, 0 replies; 41+ messages in thread
From: Carlos O'Donell @ 2021-06-14 14:59 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 6/7/21 4:36 PM, Adhemerval Zanella wrote:
> Instead of replicate the same definitions from struct_shmid64_ds.h
> on the multiple struct_shmid_ds.h, use a common header which is included
> when required (struct_shmid64_ds_helper.h).
> 
> The __USE_TIME_BITS64 is not defined internally yet, although the
> internal header is used when building the 64-bit semctl implementation.

No regressions on x86_64 and i686 and reviewed resulting ABI for correctness.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: carlos O'Donell <carlos@redhat.com>

> ---
>  sysdeps/unix/sysv/linux/Makefile              |  3 +-
>  .../sysv/linux/bits/types/struct_shmid64_ds.h |  9 +-----
>  .../bits/types/struct_shmid64_ds_helper.h     | 28 +++++++++++++++++++
>  .../sysv/linux/bits/types/struct_shmid_ds.h   | 10 +++++--
>  .../linux/hppa/bits/types/struct_shmid_ds.h   | 10 +++++--
>  .../linux/mips/bits/types/struct_shmid_ds.h   | 14 ++++++----
>  .../powerpc/bits/types/struct_shmid_ds.h      | 10 +++++--
>  .../linux/sparc/bits/types/struct_shmid_ds.h  | 10 +++++--
>  8 files changed, 68 insertions(+), 26 deletions(-)
>  create mode 100644 sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds_helper.h
> 
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index b6abcb1365..8b4d3a6a54 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -103,7 +103,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
>  		  bits/struct_stat.h \
>  		  bits/struct_stat_time64_helper.h \
>  		  bits/types/struct_msqid64_ds_helper.h \
> -		  bits/types/struct_semid64_ds_helper.h
> +		  bits/types/struct_semid64_ds_helper.h \
> +		  bits/types/struct_shmid64_ds_helper.h
>  
>  tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
>  	 tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
> diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds.h
> index 71100db1b5..a4af8cc5f4 100644
> --- a/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds.h
> +++ b/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds.h
> @@ -25,13 +25,6 @@
>  #else
>  struct __shmid64_ds
>  {
> -  struct ipc_perm shm_perm;	/* operation permission struct */
> -  size_t shm_segsz;		/* size of segment in bytes */
> -  __time64_t shm_atime;		/* time of last shmat() */
> -  __time64_t shm_dtime;		/* time of last shmdt() */
> -  __time64_t shm_ctime;		/* time of last change by shmctl() */
> -  __pid_t shm_cpid;		/* pid of creator */
> -  __pid_t shm_lpid;		/* pid of last shmop */
> -  shmatt_t shm_nattch;		/* number of current attaches */
> +# include <bits/types/struct_shmid64_ds_helper.h>

OK.

>  };
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds_helper.h b/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds_helper.h
> new file mode 100644
> index 0000000000..945e7ce63e
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/bits/types/struct_shmid64_ds_helper.h
> @@ -0,0 +1,28 @@
> +/* Common definitions for struct semid_ds with 64-bit time.
> +   Copyright (C) 2020-2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +  struct ipc_perm shm_perm;	/* operation permission struct */
> +  size_t shm_segsz;		/* size of segment in bytes */
> +  __time64_t shm_atime;		/* time of last shmat() */
> +  __time64_t shm_dtime;		/* time of last shmdt() */
> +  __time64_t shm_ctime;		/* time of last change by shmctl() */
> +  __pid_t shm_cpid;		/* pid of creator */
> +  __pid_t shm_lpid;		/* pid of last shmop */
> +  shmatt_t shm_nattch;		/* number of current attaches */
> +  unsigned long int __glibc_reserved5;
> +  unsigned long int __glibc_reserved6;

OK. Added reserved entries to match kernel entries.

> diff --git a/sysdeps/unix/sysv/linux/bits/types/struct_shmid_ds.h b/sysdeps/unix/sysv/linux/bits/types/struct_shmid_ds.h
> index 2bd587d2b0..5f8ac6257b 100644
> --- a/sysdeps/unix/sysv/linux/bits/types/struct_shmid_ds.h
> +++ b/sysdeps/unix/sysv/linux/bits/types/struct_shmid_ds.h
> @@ -23,23 +23,27 @@
>  /* Data structure describing a shared memory segment.  */
>  struct shmid_ds
>    {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_shmid64_ds_helper.h>
> +#else
>      struct ipc_perm shm_perm;		/* operation permission struct */
>      size_t shm_segsz;			/* size of segment in bytes */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>      __time_t shm_atime;			/* time of last shmat() */
>      unsigned long int __shm_atime_high;
>      __time_t shm_dtime;			/* time of last shmdt() */
>      unsigned long int __shm_dtime_high;
>      __time_t shm_ctime;			/* time of last change by shmctl() */
>      unsigned long int __shm_ctime_high;
> -#else
> +# else
>      __time_t shm_atime;			/* time of last shmat() */
>      __time_t shm_dtime;			/* time of last shmdt() */
>      __time_t shm_ctime;			/* time of last change by shmctl() */
> -#endif
> +# endif
>      __pid_t shm_cpid;			/* pid of creator */
>      __pid_t shm_lpid;			/* pid of last shmop */
>      shmatt_t shm_nattch;		/* number of current attaches */
>      __syscall_ulong_t __glibc_reserved5;
>      __syscall_ulong_t __glibc_reserved6;
> +#endif
>    };
> diff --git a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_shmid_ds.h b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_shmid_ds.h
> index 47ff80ebb0..7831fd7340 100644
> --- a/sysdeps/unix/sysv/linux/hppa/bits/types/struct_shmid_ds.h
> +++ b/sysdeps/unix/sysv/linux/hppa/bits/types/struct_shmid_ds.h
> @@ -23,8 +23,11 @@
>  /* Data structure describing a shared memory segment.  */
>  struct shmid_ds
>    {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_shmid64_ds_helper.h>
> +#else
>      struct ipc_perm shm_perm;		/* operation permission struct */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>      unsigned long int __shm_atime_high;
>      __time_t shm_atime;			/* time of last shmat() */
>      unsigned long int __shm_dtime_high;
> @@ -32,15 +35,16 @@ struct shmid_ds
>      unsigned long int __shm_ctime_high;
>      __time_t shm_ctime;			/* time of last change by shmctl() */
>      unsigned long int __glibc_reserved4;
> -#else
> +# else
>      __time_t shm_atime;			/* time of last shmat() */
>      __time_t shm_dtime;			/* time of last shmdt() */
>      __time_t shm_ctime;			/* time of last change by shmctl() */
> -#endif
> +# endif
>      size_t shm_segsz;			/* size of segment in bytes */
>      __pid_t shm_cpid;			/* pid of creator */
>      __pid_t shm_lpid;			/* pid of last shmop */
>      shmatt_t shm_nattch;		/* number of current attaches */
>      __syscall_ulong_t __glibc_reserved5;
>      __syscall_ulong_t __glibc_reserved6;
> +#endif
>    };
> diff --git a/sysdeps/unix/sysv/linux/mips/bits/types/struct_shmid_ds.h b/sysdeps/unix/sysv/linux/mips/bits/types/struct_shmid_ds.h
> index 7f8f3b9c51..0691a610ae 100644
> --- a/sysdeps/unix/sysv/linux/mips/bits/types/struct_shmid_ds.h
> +++ b/sysdeps/unix/sysv/linux/mips/bits/types/struct_shmid_ds.h
> @@ -23,27 +23,31 @@
>  /* Data structure describing a shared memory segment.  */
>  struct shmid_ds
>    {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_shmid64_ds_helper.h>
> +#else
>      struct ipc_perm shm_perm;		/* operation permission struct */
>      size_t shm_segsz;			/* size of segment in bytes */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>      __time_t shm_atime;			/* time of last shmat() */
>      __time_t shm_dtime;			/* time of last shmdt() */
>      __time_t shm_ctime;			/* time of last change by shmctl() */
> -#else
> +# else
>      __time_t shm_atime;			/* time of last shmat() */
>      __time_t shm_dtime;			/* time of last shmdt() */
>      __time_t shm_ctime;			/* time of last change by shmctl() */
> -#endif
> +# endif
>      __pid_t shm_cpid;			/* pid of creator */
>      __pid_t shm_lpid;			/* pid of last shmop */
>      shmatt_t shm_nattch;		/* number of current attaches */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>      unsigned short int __shm_atime_high;
>      unsigned short int __shm_dtime_high;
>      unsigned short int __shm_ctime_high;
>      unsigned short int __glibc_reserved4;
> -#else
> +# else
>      __syscall_ulong_t __glibc_reserved5;
>      __syscall_ulong_t __glibc_reserved6;
> +# endif
>  #endif
>    };
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_shmid_ds.h b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_shmid_ds.h
> index d71bdf1ecf..316d43ec99 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_shmid_ds.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/bits/types/struct_shmid_ds.h
> @@ -23,8 +23,11 @@
>  /* Data structure describing a shared memory segment.  */
>  struct shmid_ds
>    {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_shmid64_ds_helper.h>
> +#else
>      struct ipc_perm shm_perm;		/* operation permission struct */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>      unsigned long int __shm_atime_high;
>      __time_t shm_atime;			/* time of last shmat() */
>      unsigned long int __shm_dtime_high;
> @@ -32,15 +35,16 @@ struct shmid_ds
>      unsigned long int __shm_ctime_high;
>      __time_t shm_ctime;			/* time of last change by shmctl() */
>      unsigned long int __glibc_reserved4;
> -#else
> +# else
>      __time_t shm_atime;			/* time of last shmat() */
>      __time_t shm_dtime;			/* time of last shmdt() */
>      __time_t shm_ctime;			/* time of last change by shmctl() */
> -#endif
> +# endif
>      size_t shm_segsz;			/* size of segment in bytes */
>      __pid_t shm_cpid;			/* pid of creator */
>      __pid_t shm_lpid;			/* pid of last shmop */
>      shmatt_t shm_nattch;		/* number of current attaches */
>      __syscall_ulong_t __glibc_reserved5;
>      __syscall_ulong_t __glibc_reserved6;
> +#endif
>    };
> diff --git a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_shmid_ds.h b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_shmid_ds.h
> index 767099803f..86f0cedac3 100644
> --- a/sysdeps/unix/sysv/linux/sparc/bits/types/struct_shmid_ds.h
> +++ b/sysdeps/unix/sysv/linux/sparc/bits/types/struct_shmid_ds.h
> @@ -23,23 +23,27 @@
>  /* Data structure describing a shared memory segment.  */
>  struct shmid_ds
>    {
> +#ifdef __USE_TIME_BITS64
> +# include <bits/types/struct_shmid64_ds_helper.h>
> +#else
>      struct ipc_perm shm_perm;		/* operation permission struct */
> -#if __TIMESIZE == 32
> +# if __TIMESIZE == 32
>      unsigned long int __shm_atime_high;
>      __time_t shm_atime;			/* time of last shmat() */
>      unsigned long int __shm_dtime_high;
>      __time_t shm_dtime;			/* time of last shmdt() */
>      unsigned long int __shm_ctime_high;
>      __time_t shm_ctime;			/* time of last change by shmctl() */
> -#else
> +# else
>      __time_t shm_atime;			/* time of last shmat() */
>      __time_t shm_dtime;			/* time of last shmdt() */
>      __time_t shm_ctime;			/* time of last change by shmctl() */
> -#endif
> +# endif
>      size_t shm_segsz;			/* size of segment in bytes */
>      __pid_t shm_cpid;			/* pid of creator */
>      __pid_t shm_lpid;			/* pid of last shmop */
>      shmatt_t shm_nattch;		/* number of current attaches */
>      __syscall_ulong_t __glibc_reserved5;
>      __syscall_ulong_t __glibc_reserved6;
> +#endif
>    };
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 05/24] linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS}
  2021-06-07 20:35 ` [PATCH v3 05/24] linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS} Adhemerval Zanella
@ 2021-06-25 15:20   ` Florian Weimer
  2021-06-25 18:11     ` Adhemerval Zanella
  0 siblings, 1 reply; 41+ messages in thread
From: Florian Weimer @ 2021-06-25 15:20 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella via Libc-alpha:

> +/* It converts the first SO_TIMESTAMP or SO_TIMESTAMPNS with 32-bit time and
> +   appends it to the control buffer.  The 32-bit time field is kept as-is.
> +
> +   Calls with __TIMESIZE=32 will see the converted 64-bit time control
> +   messages as spurious control message of unknown type.
> +
> +   Calls with __TIMESIZE=64 running on pre-time64 kernels will see the
> +   original message as a spurious control ones of unknown typ while running
> +   on kernel with native 64-bit time support will only see the time64 version
> +   of the control message.  */
> +void
> +__convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize)
> +{
> +  if (msg->msg_control == NULL || msg->msg_controllen == 0)
> +    return;
> +
> +  /* The returned control message format for SO_TIMESTAMP_NEW is a
> +     'struct __kernel_sock_timeval' while for SO_TIMESTAMPNS_NEW is a
> +     'struct __kernel_timespec'.  In either case it is two uint64_t
> +     members.  */
> +  uint64_t tvts[2];
> +
> +  struct cmsghdr *cmsg, *last = NULL;
> +  int type = 0;
> +
> +  for (cmsg = CMSG_FIRSTHDR (msg);
> +       cmsg != NULL;
> +       cmsg = CMSG_NXTHDR (msg, cmsg))
> +    {
> +      if (cmsg->cmsg_level != SOL_SOCKET)
> +	continue;
> +
> +      switch (cmsg->cmsg_type)
> +	{
> +	case COMPAT_SO_TIMESTAMP_OLD:
> +	  if (type != 0)
> +	    break;
> +	  type = COMPAT_SO_TIMESTAMP_NEW;
> +	  goto common;
> +
> +	case COMPAT_SO_TIMESTAMPNS_OLD:
> +	  type = COMPAT_SO_TIMESTAMPNS_NEW;
> +
> +	/* fallthrough  */
> +	common:
> +	  memcpy (tvts, CMSG_DATA (cmsg), sizeof (tvts));
> +	  break;
> +	}
> +
> +      last = cmsg;
> +    }
> +
> +  if (last == NULL || type == 0)
> +    return;
> +
> +  if (CMSG_SPACE (sizeof tvts) > msgsize - msg->msg_controllen)
> +    {
> +      msg->msg_flags |= MSG_CTRUNC;
> +      return;
> +    }
> +
> +  msg->msg_controllen += CMSG_SPACE (sizeof tvts);
> +  cmsg = CMSG_NXTHDR(msg, last);
> +  cmsg->cmsg_level = SOL_SOCKET;
> +  cmsg->cmsg_type = type;
> +  cmsg->cmsg_len = CMSG_LEN (sizeof tvts);
> +  memcpy (CMSG_DATA (cmsg), tvts, sizeof tvts);
> +}
> +libc_hidden_def (__convert_scm_timestamps)
> +#endif

The Ruby test suite crashes on this line:

  cmsg->cmsg_level = SOL_SOCKET;

See:

  ruby: FTBFS with test suite failure (glibc 2.34 related)
  <https://bugzilla.redhat.com/show_bug.cgi?id=1975144>

The disassembly suggests that GCC has detected some undefined behavior.

This looks like a related bug:

  __cmsg_nxthdr in cmsg_nxthdr.c (CMSG_NXTHDR) has undefined behavior when setting up ancillary data
  <https://sourceware.org/bugzilla/show_bug.cgi?id=13500>

I believe you cannot use CMSG_NXTHDR to append data in this way.

The other question is why this code is running at all.  Doing this
complex conversion for a 32-bit applications doing a 32-bit function
call on a kernel which supports 32-bit system calls does not make much
sense to me.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 05/24] linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS}
  2021-06-25 15:20   ` Florian Weimer
@ 2021-06-25 18:11     ` Adhemerval Zanella
  2021-06-25 19:16       ` Florian Weimer
  0 siblings, 1 reply; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-25 18:11 UTC (permalink / raw)
  To: Florian Weimer, Adhemerval Zanella via Libc-alpha



On 25/06/2021 12:20, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> +/* It converts the first SO_TIMESTAMP or SO_TIMESTAMPNS with 32-bit time and
>> +   appends it to the control buffer.  The 32-bit time field is kept as-is.
>> +
>> +   Calls with __TIMESIZE=32 will see the converted 64-bit time control
>> +   messages as spurious control message of unknown type.
>> +
>> +   Calls with __TIMESIZE=64 running on pre-time64 kernels will see the
>> +   original message as a spurious control ones of unknown typ while running
>> +   on kernel with native 64-bit time support will only see the time64 version
>> +   of the control message.  */
>> +void
>> +__convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize)
>> +{
>> +  if (msg->msg_control == NULL || msg->msg_controllen == 0)
>> +    return;
>> +
>> +  /* The returned control message format for SO_TIMESTAMP_NEW is a
>> +     'struct __kernel_sock_timeval' while for SO_TIMESTAMPNS_NEW is a
>> +     'struct __kernel_timespec'.  In either case it is two uint64_t
>> +     members.  */
>> +  uint64_t tvts[2];
>> +
>> +  struct cmsghdr *cmsg, *last = NULL;
>> +  int type = 0;
>> +
>> +  for (cmsg = CMSG_FIRSTHDR (msg);
>> +       cmsg != NULL;
>> +       cmsg = CMSG_NXTHDR (msg, cmsg))
>> +    {
>> +      if (cmsg->cmsg_level != SOL_SOCKET)
>> +	continue;
>> +
>> +      switch (cmsg->cmsg_type)
>> +	{
>> +	case COMPAT_SO_TIMESTAMP_OLD:
>> +	  if (type != 0)
>> +	    break;
>> +	  type = COMPAT_SO_TIMESTAMP_NEW;
>> +	  goto common;
>> +
>> +	case COMPAT_SO_TIMESTAMPNS_OLD:
>> +	  type = COMPAT_SO_TIMESTAMPNS_NEW;
>> +
>> +	/* fallthrough  */
>> +	common:
>> +	  memcpy (tvts, CMSG_DATA (cmsg), sizeof (tvts));
>> +	  break;
>> +	}
>> +
>> +      last = cmsg;
>> +    }
>> +
>> +  if (last == NULL || type == 0)
>> +    return;
>> +
>> +  if (CMSG_SPACE (sizeof tvts) > msgsize - msg->msg_controllen)
>> +    {
>> +      msg->msg_flags |= MSG_CTRUNC;
>> +      return;
>> +    }
>> +
>> +  msg->msg_controllen += CMSG_SPACE (sizeof tvts);
>> +  cmsg = CMSG_NXTHDR(msg, last);
>> +  cmsg->cmsg_level = SOL_SOCKET;
>> +  cmsg->cmsg_type = type;
>> +  cmsg->cmsg_len = CMSG_LEN (sizeof tvts);
>> +  memcpy (CMSG_DATA (cmsg), tvts, sizeof tvts);
>> +}
>> +libc_hidden_def (__convert_scm_timestamps)
>> +#endif
> 
> The Ruby test suite crashes on this line:
> 
>   cmsg->cmsg_level = SOL_SOCKET;
> 
> See:
> 
>   ruby: FTBFS with test suite failure (glibc 2.34 related)
>   <https://bugzilla.redhat.com/show_bug.cgi?id=1975144>

Do we have a more contained testcase? I am trying to trigger using the ruby
example it is kind hard to no make it use the system libraries.

I am trying to create a testcase with different cmsghdr sizes, but at least 
on i686 I can't really reproduce the issue (I am also running on 5.11 kernel).

> 
> The disassembly suggests that GCC has detected some undefined behavior.
> 
> This looks like a related bug:
> 
>   __cmsg_nxthdr in cmsg_nxthdr.c (CMSG_NXTHDR) has undefined behavior when setting up ancillary data
>   <https://sourceware.org/bugzilla/show_bug.cgi?id=13500>
> 
> I believe you cannot use CMSG_NXTHDR to append data in this way.

I think I am getting luck here because the example provided does pass,
even when tested against valgrind, asan, and ubsan (using gcc 10).

> 
> The other question is why this code is running at all.  Doing this
> complex conversion for a 32-bit applications doing a 32-bit function
> call on a kernel which supports 32-bit system calls does not make much
> sense to me.

Mainly because kernel does not provide a 64-bit recvmsg, different than
recvmmg.  So for 64-bit time_t calls we need to do the conversion,
although it won't help much if the caller does not provide a buffer large
enough.

I don't think we can improve it much by adding a 64-bit symbol: the
underlying syscall will be the same we don't prior hand which
SO_TIMESTAMP value were used to setup the timer (32-bit or 64-bit
one).

Revising the code I found one issue with __convert_scm_timestamps,
where the memcpy might indeed being accessing invalid memory:

diff --git a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
index d75a4618dd..2c61267fec 100644
--- a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
+++ b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
@@ -44,7 +44,8 @@ __convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize)
      'struct __kernel_sock_timeval' while for SO_TIMESTAMPNS_NEW is a
      'struct __kernel_timespec'.  In either case it is two uint64_t
      members.  */
-  uint64_t tvts[2];
+  int64_t tvts[2];
+  int32_t tmp;
 
   struct cmsghdr *cmsg, *last = NULL;
   int type = 0;
@@ -69,7 +70,10 @@ __convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize)
 
        /* fallthrough  */
        common:
-         memcpy (tvts, CMSG_DATA (cmsg), sizeof (tvts));
+         memcpy (&tmp, CMSG_DATA (cmsg), sizeof (tmp));
+         tvts[0] = tmp;
+         memcpy (&tmp, CMSG_DATA (cmsg) + sizeof (tmp), sizeof (tmp));
+         tvts[1] = tmp;
          break;
        }
 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 05/24] linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS}
  2021-06-25 18:11     ` Adhemerval Zanella
@ 2021-06-25 19:16       ` Florian Weimer
  2021-06-28 13:36         ` Adhemerval Zanella
  0 siblings, 1 reply; 41+ messages in thread
From: Florian Weimer @ 2021-06-25 19:16 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Adhemerval Zanella via Libc-alpha

* Adhemerval Zanella:

>> See:
>> 
>>   ruby: FTBFS with test suite failure (glibc 2.34 related)
>>   <https://bugzilla.redhat.com/show_bug.cgi?id=1975144>
>
> Do we have a more contained testcase? I am trying to trigger using the ruby
> example it is kind hard to no make it use the system libraries.
>
> I am trying to create a testcase with different cmsghdr sizes, but at least 
> on i686 I can't really reproduce the issue (I am also running on 5.11
> kernel).

The ruby test case needs “set disable-randomization off” in GDB and even
then passes sporadically.  Without it, the test always succeeds for some
reason.

With the GCC 11 compiled binaries in Fedora, we fault in an isolated
error path (null pointer store followed by ud2 instruction).  I haven't
had time to look at the disassembly and GIMPLE dumps to see what is
going on.

>> The disassembly suggests that GCC has detected some undefined behavior.
>> 
>> This looks like a related bug:
>> 
>>   __cmsg_nxthdr in cmsg_nxthdr.c (CMSG_NXTHDR) has undefined behavior when setting up ancillary data
>>   <https://sourceware.org/bugzilla/show_bug.cgi?id=13500>
>> 
>> I believe you cannot use CMSG_NXTHDR to append data in this way.
>
> I think I am getting luck here because the example provided does pass,
> even when tested against valgrind, asan, and ubsan (using gcc 10).

Hmm.  I think it depends on previous buffer contents.

>> The other question is why this code is running at all.  Doing this
>> complex conversion for a 32-bit applications doing a 32-bit function
>> call on a kernel which supports 32-bit system calls does not make much
>> sense to me.
>
> Mainly because kernel does not provide a 64-bit recvmsg, different than
> recvmmg.  So for 64-bit time_t calls we need to do the conversion,
> although it won't help much if the caller does not provide a buffer large
> enough.

Yes, but the Fedora build does not use 64-bit time_t, so this conversion
is kind of pointless there.

I see that we didn't add a __recvmsg_time64 entrypoint (and similar
entrypoints for the other cases).  I think that's a mistake, we should
have those to future-proof things (similar for ioctl and fcntl—are there
any other multiplexers?).

> I don't think we can improve it much by adding a 64-bit symbol: the
> underlying syscall will be the same we don't prior hand which
> SO_TIMESTAMP value were used to setup the timer (32-bit or 64-bit
> one).

Yes, but old 32-bit binaries can avoid running the new code if we have
separate entrypoint.

> Revising the code I found one issue with __convert_scm_timestamps,
> where the memcpy might indeed being accessing invalid memory:
>
> diff --git a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
> index d75a4618dd..2c61267fec 100644
> --- a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
> +++ b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
> @@ -44,7 +44,8 @@ __convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize)
>       'struct __kernel_sock_timeval' while for SO_TIMESTAMPNS_NEW is a
>       'struct __kernel_timespec'.  In either case it is two uint64_t
>       members.  */
> -  uint64_t tvts[2];
> +  int64_t tvts[2];
> +  int32_t tmp;
>  
>    struct cmsghdr *cmsg, *last = NULL;
>    int type = 0;
> @@ -69,7 +70,10 @@ __convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize)
>  
>         /* fallthrough  */
>         common:
> -         memcpy (tvts, CMSG_DATA (cmsg), sizeof (tvts));
> +         memcpy (&tmp, CMSG_DATA (cmsg), sizeof (tmp));
> +         tvts[0] = tmp;
> +         memcpy (&tmp, CMSG_DATA (cmsg) + sizeof (tmp), sizeof (tmp));
> +         tvts[1] = tmp;
>           break;
>         }

Sorry, I can't quite wrap my head around this right now.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 05/24] linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS}
  2021-06-25 19:16       ` Florian Weimer
@ 2021-06-28 13:36         ` Adhemerval Zanella
  0 siblings, 0 replies; 41+ messages in thread
From: Adhemerval Zanella @ 2021-06-28 13:36 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Adhemerval Zanella via Libc-alpha



On 25/06/2021 16:16, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>>> See:
>>>
>>>   ruby: FTBFS with test suite failure (glibc 2.34 related)
>>>   <https://bugzilla.redhat.com/show_bug.cgi?id=1975144>
>>
>> Do we have a more contained testcase? I am trying to trigger using the ruby
>> example it is kind hard to no make it use the system libraries.
>>
>> I am trying to create a testcase with different cmsghdr sizes, but at least 
>> on i686 I can't really reproduce the issue (I am also running on 5.11
>> kernel).
> 
> The ruby test case needs “set disable-randomization off” in GDB and even
> then passes sporadically.  Without it, the test always succeeds for some
> reason.
> 
> With the GCC 11 compiled binaries in Fedora, we fault in an isolated
> error path (null pointer store followed by ud2 instruction).  I haven't
> had time to look at the disassembly and GIMPLE dumps to see what is
> going on.

I will create a testcase with a different struct msghdr sizes and alignment,
along with different timestamps configurations.

> 
>>> The disassembly suggests that GCC has detected some undefined behavior.
>>>
>>> This looks like a related bug:
>>>
>>>   __cmsg_nxthdr in cmsg_nxthdr.c (CMSG_NXTHDR) has undefined behavior when setting up ancillary data
>>>   <https://sourceware.org/bugzilla/show_bug.cgi?id=13500>
>>>
>>> I believe you cannot use CMSG_NXTHDR to append data in this way.
>>
>> I think I am getting luck here because the example provided does pass,
>> even when tested against valgrind, asan, and ubsan (using gcc 10).
> 
> Hmm.  I think it depends on previous buffer contents.

Ok, it might the case. But on my testing I also tried to add random 
initialization data on msghdr.

> 
>>> The other question is why this code is running at all.  Doing this
>>> complex conversion for a 32-bit applications doing a 32-bit function
>>> call on a kernel which supports 32-bit system calls does not make much
>>> sense to me.
>>
>> Mainly because kernel does not provide a 64-bit recvmsg, different than
>> recvmmg.  So for 64-bit time_t calls we need to do the conversion,
>> although it won't help much if the caller does not provide a buffer large
>> enough.
> 
> Yes, but the Fedora build does not use 64-bit time_t, so this conversion
> is kind of pointless there.> 
> I see that we didn't add a __recvmsg_time64 entrypoint (and similar
> entrypoints for the other cases).  I think that's a mistake, we should
> have those to future-proof things (similar for ioctl and fcntl—are there
> any other multiplexers?).
> 
>> I don't think we can improve it much by adding a 64-bit symbol: the
>> underlying syscall will be the same we don't prior hand which
>> SO_TIMESTAMP value were used to setup the timer (32-bit or 64-bit
>> one).
> 
> Yes, but old 32-bit binaries can avoid running the new code if we have
> separate entrypoint.

There are two fold problems here:

  1. With __ASSUME_TIME64_SYSCALLS, the SO_* timestamp constants being used
     will always 64-bit.  It means we will need translation for programs
     built *without* _TIME_BITS=64.

  2. Without __ASSUME_TIME64_SYSCALLS, we can't know what kind of timestamp
     is being configured on the socket.  The setsockopt() will still maps
     to old 32-bit timestamps for ENOPROTOOPT.

A new 64-bit entrypoint does not help much in my opinion: we can't know
for sure if the socket has being configured with an old library or either
pass with 32-bit timestamps with SCM_RIGHTS.

> 
>> Revising the code I found one issue with __convert_scm_timestamps,
>> where the memcpy might indeed being accessing invalid memory:
>>
>> diff --git a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
>> index d75a4618dd..2c61267fec 100644
>> --- a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
>> +++ b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
>> @@ -44,7 +44,8 @@ __convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize)
>>       'struct __kernel_sock_timeval' while for SO_TIMESTAMPNS_NEW is a
>>       'struct __kernel_timespec'.  In either case it is two uint64_t
>>       members.  */
>> -  uint64_t tvts[2];
>> +  int64_t tvts[2];
>> +  int32_t tmp;
>>  
>>    struct cmsghdr *cmsg, *last = NULL;
>>    int type = 0;
>> @@ -69,7 +70,10 @@ __convert_scm_timestamps (struct msghdr *msg, socklen_t msgsize)
>>  
>>         /* fallthrough  */
>>         common:
>> -         memcpy (tvts, CMSG_DATA (cmsg), sizeof (tvts));
>> +         memcpy (&tmp, CMSG_DATA (cmsg), sizeof (tmp));
>> +         tvts[0] = tmp;
>> +         memcpy (&tmp, CMSG_DATA (cmsg) + sizeof (tmp), sizeof (tmp));
>> +         tvts[1] = tmp;
>>           break;
>>         }
> 
> Sorry, I can't quite wrap my head around this right now.
> 
> Thanks,
> Florian
> 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 18/24] y2038: Add support for 64-bit time on legacy ABIs
  2021-06-07 20:36 ` [PATCH v3 18/24] y2038: Add support for 64-bit time on legacy ABIs Adhemerval Zanella
@ 2021-10-13 11:44   ` Stafford Horne
  2021-10-13 16:45     ` Paul Eggert
  2021-10-13 20:47     ` Joseph Myers
  0 siblings, 2 replies; 41+ messages in thread
From: Stafford Horne @ 2021-10-13 11:44 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GLIBC patches

Hello,

Sorry, for bringing up this old patch I have recently rebased my OpenRISC
port onto the latest glibc master and this seems to be causing issues.

Without doing any changes to my build (i.e. not touching _TIME_BITS) I am
able to build everything find but getting the following test failures:

  FAIL: misc/tst-ntp_gettime
  FAIL: misc/tst-ntp_gettimex

This is traced back to glibc using 32 bit words in the timex structure in
sysdeps/unix/sysv/linux/bits/timex.h.  I was able to hack around it by
changing
the #ifdef __USE_TIME_BITS64, to #if 1 and then the tests pass.

See some comments below...

On Tue, Jun 8, 2021 at 5:54 AM Adhemerval Zanella via Libc-alpha <
libc-alpha@sourceware.org> wrote:
>
> A new build flag, _TIME_BITS, enables the usage of the newer 64-bit
> time symbols for legacy ABI (where 32 bit time_t is default).  The 64
> bit time support is only enabled if LFS (_FILE_OFFSET_BITS=64) is
> also used.
>
> Different than LFS support, the y2038 symbols are added only for the
> required ABIs (armhf, csky, hppa, i386, m68k, microblaze, mips32,
> mips64-n32, nios2, powerpc32, sparc32, s390-32, and sh).  The ABIs with
> 64-bit time support are unchanged, both for symbol and types
> redirection.
>
> On Linux the full 64-bit time support requires a minimum of kernel
> version v5.1.  Otherwise, the 32 bit fallbacks are used and might
> results in error with overflow return code (EOVERFLOW).
>
> The i686-gnu does not yet support 64-bit time.
[...]
> --- a/NEWS
> +++ b/NEWS
> @@ -31,6 +31,11 @@ Major new features:
>    __STDC_WANT_IEC_60559_BFP_EXT__, as specified in TS 18661-1, is
>    defined, and when _GNU_SOURCE is defined.
>
> +* Add support for 64-bit time_t for ABIs with defaults to 32 bit time_t.
> +  This is enabled with the _TIME_BITS preprocessor set to 64 and only
> +  supported when LFS (_FILE_OFFSET_BITS=64) is also enabled.  It is only
> +  enabled for Linux and the full support requires a minimum version of
5.1.
> +

Now, I am trying to build with
CFLAGS="-g -Og -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64",
but this is causing build failures.

    iofgetpos.c:84:40: error: conflicting types for 'fgetpos'; have
'int(FILE *, __fpos_t *)' {aka 'int(struct _IO_FILE *, struct _G
    _fpos_t *)'}
       84 | versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
          |                                        ^~~~~~~
    ./../include/libc-symbols.h:155:26: note: in definition of macro
'_weak_alias'
      155 |   extern __typeof (name) aliasname __attribute__ ((weak, alias
(#name))) \
          |                          ^~~~~~~~~
    ../include/shlib-compat.h:117:3: note: in expansion of macro
'weak_alias'
      117 |   weak_alias (local, symbol)
          |   ^~~~~~~~~~
    iofgetpos.c:84:1: note: in expansion of macro 'versioned_symbol'
       84 | versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
          | ^~~~~~~~~~~~~~~~
    In file included from ../include/sys/cdefs.h:10,
                 from ../include/features.h:488,
                 from ../stdlib/errno.h:25,
                 from ../include/errno.h:2,
                 from libioP.h:40,
                 from iofgetpos.c:34:
    ../libio/stdio.h:762:24: note: previous declaration of 'fgetpos' with
type 'int(FILE * restrict,  fpos_t * restrict)' {aka 'int(
    struct _IO_FILE * restrict,  struct _G_fpos64_t * restrict)'}
      762 | extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
          |                        ^~~~~~~
    ../misc/sys/cdefs.h:198:41: note: in definition of macro '__REDIRECT'
      198 | # define __REDIRECT(name, proto, alias) name proto __asm__
(__ASMNAME (#alias))

Trying to fix this I get further build failures

    ../sysdeps/unix/sysv/linux/globfree.c:28:23: error: 'globfree64'
aliased to undefined symbol 'globfree'
     28 | weak_alias (globfree, globfree64)
        |                       ^~~~~~~~~~
   ./../include/libc-symbols.h:155:26: note: in definition of macro
'_weak_alias'
    155 |   extern __typeof (name) aliasname __attribute__ ((weak, alias
(#name))) \
        |                          ^~~~~~~~~
   ../sysdeps/unix/sysv/linux/globfree.c:28:1: note: in expansion of macro
'weak_alias'
     28 | weak_alias (globfree, globfree64)
        | ^~~~~~~~~~

[...]
> index 705a949089..9fa658e9a7 100644
> --- a/manual/creature.texi
> +++ b/manual/creature.texi
> @@ -165,6 +165,50 @@ This macro was introduced as part of the Large File
Support extension
>  (LFS).
>  @end defvr
>
> +@defvr Macro _TIME_BITS
> +This macro determines the bit size of @code{time_t} (and therefore the
> +bit size of all @code{time_t} derived types and the prototypes of all
> +related functions).  If @code{_TIME_BITS} is undefined, the bit size of
> +@code{time_t} is architecture dependent.
> +
> +Possible values of @code{_TIME_BITS}:
> +@enumerate
> +@item
> +@code{_TIME_BITS=64} and port from the outset uses 64-bit
> +@code{time_t} and word size equals to @w{64 bits} (e.g. x86_64) - no
> +action
> +
> +@item
> +@code{_TIME_BITS=32} and port from the outset uses 32-bit
> +@code{time_t} and word size equals to @w{64 bits} (e.g. ARM) - no
> +action
> +
> +@item
> +@code{_TIME_BITS=64} and port from the outset uses 64-bit
> +@code{time_t} and word size equals to @w{32 bits} (e.g. ARC, RV32)
> +- no action

OpenRISC falls into this category.  We have 64-bit support but word size is
32 bits.

What does "no action" mean here? Does it mean as long as I set _TIME_BITS=64
no extra porting effort is needed?

> +@item
> +@code{_TIME_BITS=64} and port from the outset uses 32-bit
> +@code{time_t} and word size equals to @w{32 bits} (e.g. ARM)
> +- the @code{time_t} is modified to be able to hold 64-bit time.
> +
> +@item
> +For any other use case the compile-time error is emitted.
> +@end enumerate
> +
> +The @code{_TIME_BITS} can be only used when @code{_FILE_OFFSET_BITS=64}
> +is also defined.
> +
> +For the point @b{4} above, calls to proper syscalls depend on the
> +Linux kernel version on which the system is running. For Linux kernel
> +version above @b{5.1} syscalls supporting 64-bit time are used.
Otherwise,
> +a fallback code is used with legacy (i.e. 32-bit) syscalls.
> +
> +By using this macro certain ports gain support for 64-bit time and as
> +a result become immune to Y2038 problem.
> +@end defvr
> +

[...]

> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/features-time64.h
> @@ -0,0 +1,37 @@
> +/* Features part to handle 64-bit time_t support.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +/* We need to know the word size in order to check the time size.  */
> +#include <bits/wordsize.h>
> +#include <bits/timesize.h>
> +
> +#if defined _TIME_BITS
> +# if _TIME_BITS == 64
> +#  if ! defined (_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64
> +#   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
> +#  elif __TIMESIZE == 32
> +#   define __USE_TIME_BITS64   1

Is this correct? We only use __USE_TIME_BITS64 on machines where
__TIMESIZE==32?

On OpenRISC we have __TIMESIZE == 64, so __USE_TIME_BITS64 does not get
defined.  Hence the timex issue I mentioned earlier.

Sorry, it's hard for me to understand what is the intent of some of these
flags so I
can't be sure where it's going wrong.

> +#  endif
> +# elif _TIME_BITS == 32
> +#  if __TIMESIZE > 32
> +#   error "_TIME_BITS=32 is not compatible with __TIMESIZE > 32"
> +#  endif
> +# else
> +#  error Invalid _TIME_BITS value (can only be 32 or 64-bit)
> +# endif
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/hppa/libanl.abilist
b/sysdeps/unix/sysv/linux/hppa/libanl.abilist
> index d9a5ed015d..ff719e7605 100644


-Stafford

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 18/24] y2038: Add support for 64-bit time on legacy ABIs
  2021-10-13 11:44   ` Stafford Horne
@ 2021-10-13 16:45     ` Paul Eggert
  2021-10-13 21:51       ` Stafford Horne
  2021-10-13 20:47     ` Joseph Myers
  1 sibling, 1 reply; 41+ messages in thread
From: Paul Eggert @ 2021-10-13 16:45 UTC (permalink / raw)
  To: Stafford Horne, Adhemerval Zanella; +Cc: GLIBC patches

On 10/13/21 4:44 AM, Stafford Horne via Libc-alpha wrote:

>> +@item
>> +@code{_TIME_BITS=64} and port from the outset uses 64-bit
>> +@code{time_t} and word size equals to @w{32 bits} (e.g. ARC, RV32)
>> +- no action
> 
> OpenRISC falls into this category.  We have 64-bit support but word size is
> 32 bits.

If OpenRISC has always had 64-bit time_t, the -D_TIME_BITS=64 option 
should have no effect on compilation. I.e., time_t used to be 64 bits, 
and it'll still be 64 bits regardless of whether you use that option.

> On OpenRISC we have __TIMESIZE == 64, so __USE_TIME_BITS64 does not get
> defined.

That sounds OK. If time_t has always been 64 bits, there's no need for 
the 32- vs 64-bit time_t complexity.

The diagnostics you gave don't seem to have anything to do with time_t. 
However, if you're getting them with -D_TIME_BITS=64 but not getting 
them without that option, that suggests there's a glitch somewhere that 
needs to be tracked down more carefully.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 18/24] y2038: Add support for 64-bit time on legacy ABIs
  2021-10-13 11:44   ` Stafford Horne
  2021-10-13 16:45     ` Paul Eggert
@ 2021-10-13 20:47     ` Joseph Myers
  2021-10-13 21:50       ` Stafford Horne
  1 sibling, 1 reply; 41+ messages in thread
From: Joseph Myers @ 2021-10-13 20:47 UTC (permalink / raw)
  To: Stafford Horne; +Cc: Adhemerval Zanella, GLIBC patches

On Wed, 13 Oct 2021, Stafford Horne via Libc-alpha wrote:

> Now, I am trying to build with
> CFLAGS="-g -Og -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64",
> but this is causing build failures.

glibc can't be built with those options.  All the setup for building 
functions with the correct names and aliases assumes that those macros are 
not defined when building glibc itself; defining them will cause function 
redirections that are only appropriate for user applications, not for 
building glibc itself.

> > +@item
> > +@code{_TIME_BITS=64} and port from the outset uses 64-bit
> > +@code{time_t} and word size equals to @w{32 bits} (e.g. ARC, RV32)
> > +- no action
> 
> OpenRISC falls into this category.  We have 64-bit support but word size is
> 32 bits.
> 
> What does "no action" mean here? Does it mean as long as I set _TIME_BITS=64
> no extra porting effort is needed?

"no action" means _TIME_BITS does nothing and the user gets 64-bit time 
regardless.

As with any port, the architecture-specific files need to be set up 
appropriately for the choices made by the port, and new ports may 
sometimes encounter issues in architecture-independent files for ports not 
needing various kinds of compatibility.

> Is this correct? We only use __USE_TIME_BITS64 on machines where
> __TIMESIZE==32?

The purpose of __USE_TIME_BITS64 is to enable header redirections to 
different function names on systems that support both 32-bit and 64-bit 
time_t.

For an architecture that only supports 64-bit time_t, no such redirections 
should ever be in effect and no separate function names for 64-bit time_t 
should exist, so __USE_TIME_BITS64 should not be defined.  OpenRISC should 
be just like x86_64 in this regard.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 18/24] y2038: Add support for 64-bit time on legacy ABIs
  2021-10-13 20:47     ` Joseph Myers
@ 2021-10-13 21:50       ` Stafford Horne
  0 siblings, 0 replies; 41+ messages in thread
From: Stafford Horne @ 2021-10-13 21:50 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Adhemerval Zanella, GLIBC patches

On Wed, Oct 13, 2021 at 08:47:39PM +0000, Joseph Myers wrote:
> On Wed, 13 Oct 2021, Stafford Horne via Libc-alpha wrote:
> 
> > Now, I am trying to build with
> > CFLAGS="-g -Og -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64",
> > but this is causing build failures.
> 
> glibc can't be built with those options.  All the setup for building 
> functions with the correct names and aliases assumes that those macros are 
> not defined when building glibc itself; defining them will cause function 
> redirections that are only appropriate for user applications, not for 
> building glibc itself.

OK, thank's for the clarification I missed that part of the documentation.

But that explains all of the build failures.

> > > +@item
> > > +@code{_TIME_BITS=64} and port from the outset uses 64-bit
> > > +@code{time_t} and word size equals to @w{32 bits} (e.g. ARC, RV32)
> > > +- no action
> > 
> > OpenRISC falls into this category.  We have 64-bit support but word size is
> > 32 bits.
> > 
> > What does "no action" mean here? Does it mean as long as I set _TIME_BITS=64
> > no extra porting effort is needed?
> 
> "no action" means _TIME_BITS does nothing and the user gets 64-bit time 
> regardless.
> 
> As with any port, the architecture-specific files need to be set up 
> appropriately for the choices made by the port, and new ports may 
> sometimes encounter issues in architecture-independent files for ports not 
> needing various kinds of compatibility.

OK, this makes sense now.  Its a bit confusing saying _TIME_BITS=64, because
_TIME_BITS does not have to be defined at all.  Let me read the docs again maybe
there is a patch in there to help clarify for the next reader too.

> > Is this correct? We only use __USE_TIME_BITS64 on machines where
> > __TIMESIZE==32?
> 
> The purpose of __USE_TIME_BITS64 is to enable header redirections to 
> different function names on systems that support both 32-bit and 64-bit 
> time_t.

I see, thats a much more clear explaination.

> For an architecture that only supports 64-bit time_t, no such redirections 
> should ever be in effect and no separate function names for 64-bit time_t 
> should exist, so __USE_TIME_BITS64 should not be defined.  OpenRISC should 
> be just like x86_64 in this regard.

OK, makes sense.

Thanks for clarifying, I am still having the issue with struct timex using
__USE_TIME_BITS64 and choosing a 32-bit implementation.

I think I can go over all of the code again and add some clarifications via
comments and doc's, then I will probably understand enough to know the right
approach to fix the timex issue.

Just for reference/brain dump, sysdeps/unix/sysv/linux/bits/timex.h defines:

    struct timex {
    # ifdef __USE_TIME_BITS64
    ...
       long long offset;
    ...
    # else
    ...
       __syscall_slong_t offset;
    ...
    # endif

For the above on openrisc I need offset (and other fields) to be 64-bit.

But there are 2 problems:
  1. __syscall_slong_t is 32-bit
  2. __USE_TIME_BITS64 is not defined for openrisc (as per above)

So options:
  1. Use a different type other __syscall_slong_t, i.e. time_t
  2. Use a different macro other than __USE_TIME_BITS64

Timex is defined 3 times:
  - 2 times          (external) sysdeps/unix/sysv/linux/bits/timex.h
  - 1 time __timex64 (internal) sysdeps/unix/sysv/linux/include/sys/timex.h

-Stafford

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 18/24] y2038: Add support for 64-bit time on legacy ABIs
  2021-10-13 16:45     ` Paul Eggert
@ 2021-10-13 21:51       ` Stafford Horne
  0 siblings, 0 replies; 41+ messages in thread
From: Stafford Horne @ 2021-10-13 21:51 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Adhemerval Zanella, GLIBC patches

On Wed, Oct 13, 2021 at 09:45:22AM -0700, Paul Eggert wrote:
> On 10/13/21 4:44 AM, Stafford Horne via Libc-alpha wrote:
> 
> > > +@item
> > > +@code{_TIME_BITS=64} and port from the outset uses 64-bit
> > > +@code{time_t} and word size equals to @w{32 bits} (e.g. ARC, RV32)
> > > +- no action
> > 
> > OpenRISC falls into this category.  We have 64-bit support but word size is
> > 32 bits.
> 
> If OpenRISC has always had 64-bit time_t, the -D_TIME_BITS=64 option should
> have no effect on compilation. I.e., time_t used to be 64 bits, and it'll
> still be 64 bits regardless of whether you use that option.
> 
> > On OpenRISC we have __TIMESIZE == 64, so __USE_TIME_BITS64 does not get
> > defined.
> 
> That sounds OK. If time_t has always been 64 bits, there's no need for the
> 32- vs 64-bit time_t complexity.
> 
> The diagnostics you gave don't seem to have anything to do with time_t.
> However, if you're getting them with -D_TIME_BITS=64 but not getting them
> without that option, that suggests there's a glitch somewhere that needs to
> be tracked down more carefully.

Thanks, between this and Joseph's mail it makes sense where I was going wrong.

-Stafford

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2021-10-13 21:51 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07 20:35 [PATCH v3 00/24] Add 64 bit time support on legacy ABIs Adhemerval Zanella
2021-06-07 20:35 ` [PATCH v3 01/24] linux: mips: Split librt.abilist in n32 and n64 Adhemerval Zanella
2021-06-07 20:35 ` [PATCH v3 02/24] linux: mips: Split libanl.abilist " Adhemerval Zanella
2021-06-07 20:35 ` [PATCH v3 03/24] linux: s390: Add libanl.abilist in s390 and s390x Adhemerval Zanella
2021-06-07 20:35 ` [PATCH v3 04/24] linux: Add fallback for 64-bit time_t SO_{RCV, SND}TIMEO Adhemerval Zanella
2021-06-14 14:52   ` [PATCH v3 04/24] linux: Add fallback for 64-bit time_t SO_{RCV,SND}TIMEO Carlos O'Donell
2021-06-07 20:35 ` [PATCH v3 05/24] linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS} Adhemerval Zanella
2021-06-25 15:20   ` Florian Weimer
2021-06-25 18:11     ` Adhemerval Zanella
2021-06-25 19:16       ` Florian Weimer
2021-06-28 13:36         ` Adhemerval Zanella
2021-06-07 20:35 ` [PATCH v3 06/24] linux: Add recvvmsg " Adhemerval Zanella
2021-06-07 20:35 ` [PATCH v3 07/24] y2038: Add __USE_TIME_BITS64 support for time_t Adhemerval Zanella
2021-06-07 20:35 ` [PATCH v3 08/24] y2038: Add __USE_TIME_BITS64 support for struct timeval Adhemerval Zanella
2021-06-07 20:35 ` [PATCH v3 09/24] y2038: Add __USE_TIME_BITS64 support for struct timespec Adhemerval Zanella
2021-06-07 20:35 ` [PATCH v3 10/24] y2038: Add __USE_TIME_BITS64 support for struct utimbuf Adhemerval Zanella
2021-06-07 20:36 ` [PATCH v3 11/24] y2038: linux: Add __USE_TIME_BITS64 support for struct timex Adhemerval Zanella
2021-06-07 20:36 ` [PATCH v3 12/24] y2038: Use a common definition for stat Adhemerval Zanella
2021-06-14 14:52   ` Carlos O'Donell
2021-06-07 20:36 ` [PATCH v3 13/24] y2038: Use a common definition for msqid_ds Adhemerval Zanella
2021-06-14 14:52   ` Carlos O'Donell
2021-06-07 20:36 ` [PATCH v3 14/24] y2038: Use a common definition for semid_ds Adhemerval Zanella
2021-06-14 14:52   ` Carlos O'Donell
2021-06-07 20:36 ` [PATCH v3 15/24] y2038: Use a common definition for shmid_ds Adhemerval Zanella
2021-06-14 14:59   ` Carlos O'Donell
2021-06-07 20:36 ` [PATCH v3 16/24] y2038: Add __USE_TIME_BITS64 support for socket-constants.h Adhemerval Zanella
2021-06-07 20:36 ` [PATCH v3 17/24] time: Add 64-bit time support for getdate Adhemerval Zanella
2021-06-07 20:36 ` [PATCH v3 18/24] y2038: Add support for 64-bit time on legacy ABIs Adhemerval Zanella
2021-10-13 11:44   ` Stafford Horne
2021-10-13 16:45     ` Paul Eggert
2021-10-13 21:51       ` Stafford Horne
2021-10-13 20:47     ` Joseph Myers
2021-10-13 21:50       ` Stafford Horne
2021-06-07 20:36 ` [PATCH v3 19/24] posix: Add glob64 with 64-bit time_t support Adhemerval Zanella
2021-06-14 14:52   ` Carlos O'Donell
2021-06-07 20:36 ` [PATCH v3 20/24] io: Add fts64 " Adhemerval Zanella
2021-06-07 20:36 ` [PATCH v3 21/24] io: Add ftw64 " Adhemerval Zanella
2021-06-07 20:36 ` [PATCH v3 22/24] libsupport: Add 64-bit time_t support for time functions Adhemerval Zanella
2021-06-14 14:52   ` Carlos O'Donell
2021-06-07 20:36 ` [PATCH v3 23/24] libsupport: Add 64-bit time_t support for stat functions Adhemerval Zanella
2021-06-07 20:36 ` [PATCH v3 24/24] y2038: Add test coverage Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).