[v2,20/25] posix: Add glob64 with 64 bit time_t support

Message ID 20210518205613.1487824-21-adhemerval.zanella@linaro.org
State Superseded
Headers
Series Add 64 bit time support on legacy ABIs |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Adhemerval Zanella May 18, 2021, 8:56 p.m. UTC
  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 time
version that also uses 64 time stat functions.

Checked on i686-linux-gnu and x86_64-linux-gnu.
---
 include/glob.h                                | 28 +++++++++++
 posix/Makefile                                |  5 +-
 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, 308 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
  

Comments

Lukasz Majewski May 19, 2021, 10:44 a.m. UTC | #1
On Tue, 18 May 2021 17:56:08 -0300
Adhemerval Zanella <adhemerval.zanella@linaro.org> 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 time
> version that also uses 64 time stat functions.
> 
> Checked on i686-linux-gnu and x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>

> ---
>  include/glob.h                                | 28 +++++++++++
>  posix/Makefile                                |  5 +-
>  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, 308 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..84204b1270 100644
> --- a/posix/Makefile
> +++ b/posix/Makefile
> @@ -67,7 +67,10 @@ routines :=
> 			      \ get_child_max sched_cpucount
> sched_cpualloc sched_cpufree \ streams-compat \
>  	shm-directory
>          \
> -	execveat
> +	execveat \
> +	shm-directory \
> +	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..04db45f93a
> --- /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..d815bc6df1
> --- /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 52fedc61f0..27a464483b 100644
> --- a/sysdeps/unix/sysv/linux/Versions
> +++ b/sysdeps/unix/sysv/linux/Versions
> @@ -192,6 +192,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
> 694033a42b..397c97cc16 100644 ---
> a/sysdeps/unix/sysv/linux/arm/be/libc.abilist +++
> b/sysdeps/unix/sysv/linux/arm/be/libc.abilist @@ -208,6 +208,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
> 1ead45904f..9bc948703c 100644 ---
> a/sysdeps/unix/sysv/linux/arm/le/libc.abilist +++
> b/sysdeps/unix/sysv/linux/arm/le/libc.abilist @@ -205,6 +205,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
> e8fce124fd..0f84021d9f 100644 ---
> a/sysdeps/unix/sysv/linux/csky/libc.abilist +++
> b/sysdeps/unix/sysv/linux/csky/libc.abilist @@ -2285,6 +2285,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
> f196d94139..31caf8ebc3 100644 ---
> a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++
> b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -2238,6 +2238,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
> 0687af280c..75b71b8a5b 100644 ---
> a/sysdeps/unix/sysv/linux/i386/libc.abilist +++
> b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -2420,6 +2420,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
> bfd2b7c135..2f93afc071 100644 ---
> a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++
> b/sysdeps/unix/sysv/linux/m68k/coldfire/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/m68k/m680x0/libc.abilist
> b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index
> 2bd9f7ab64..dc074cf576 100644 ---
> a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++
> b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -2364,6 +2364,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
> 2436c57b2e..a8b8366c48 100644 ---
> a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++
> b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -2336,6
> +2336,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
> 1262d01845..63e3b096e3 100644 ---
> a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist +++
> b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist @@ -2333,6
> +2333,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
> 2812b458c8..3d17b78b42 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++
> b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -2329,6
> +2329,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
> 782c5470a6..ba96f15040 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++
> b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -2327,6
> +2327,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
> 3487d0f4c3..04cc170344 100644 ---
> a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -2335,6
> +2335,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
> 056254475b..ce21e19622 100644 ---
> a/sysdeps/unix/sysv/linux/nios2/libc.abilist +++
> b/sysdeps/unix/sysv/linux/nios2/libc.abilist @@ -2375,6 +2375,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
> 98e1da179b..4cfae3b735 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@
> -2391,6 +2391,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
> 6dc0ecf108..3e03f313b1 100644 ---
> a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@
> -2424,6 +2424,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
> 230031f2be..4dfdc61761 100644 ---
> a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -2389,6
> +2389,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
> 72073ecc27..2c00100dd6 100644 ---
> a/sysdeps/unix/sysv/linux/sh/be/libc.abilist +++
> b/sysdeps/unix/sysv/linux/sh/be/libc.abilist @@ -2245,6 +2245,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
> e07c4657f9..2bcf38af9b 100644 ---
> a/sysdeps/unix/sysv/linux/sh/le/libc.abilist +++
> b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -2242,6 +2242,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
> 7467677c1b..dad08de21f 100644 ---
> a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++
> b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -2382,6
> +2382,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



Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
  
Carlos O'Donell June 4, 2021, 7:39 p.m. UTC | #2
On 5/18/21 4:56 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 time
> version that also uses 64 time stat functions.

Needs a v3 please. See below. Minor mistake in the test list?

No regressions on x86_64, i686, ppc64le, aarch64, s390x.

Tested-by: Carlos O'Donell <carlos@redhat.com>
 
> Checked on i686-linux-gnu and x86_64-linux-gnu.
> ---
>  include/glob.h                                | 28 +++++++++++
>  posix/Makefile                                |  5 +-
>  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, 308 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>

OK.

> +
>  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

OK.

> +# else
> +# include <sys/stat.h>
> +
> +typedef struct
> +  {
> +    size_t gl_pathc;

OK. vs. __size_t

> +    char **gl_pathv;

OK. vs. char**

> +    size_t gl_offs;

OK. vs. __size_t

> +    int gl_flags;

OK. vs. int.

> +
> +    void (*gl_closedir) (void *);

OK. func ptr.

> +    struct dirent64 *(*gl_readdir) (void *);

OK. func ptr, but this one returns struct direent64 vs. struct direent.

> +    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);

OK. struct __stat64_t64 vs. struct stat for 64-bit time_t.

> +  } glob64_time64_t;

OK. New ABI looks good to me. Should be the same size as the previous ABI.

> +
> +extern int __glob64_time64 (const char *pattern, int flags,
> +			    int (*errfunc) (const char *, int),
> +			    glob64_time64_t *pglob);

OK, use new glob64_time64_t type for 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..84204b1270 100644
> --- a/posix/Makefile
> +++ b/posix/Makefile
> @@ -67,7 +67,10 @@ routines :=								      \
>  	get_child_max sched_cpucount sched_cpualloc sched_cpufree \
>  	streams-compat \
>  	shm-directory                                                         \
> -	execveat
> +	execveat \
> +	shm-directory \

This is not correct since it duplicates shm-directory. I expect you intended
to fix the silly "\" way on the end.

We should make all of those routines clearly into one entry per line to make
merging easier.

> +	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;

OK.

>      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));

OK.

>  }
>  
>  /* 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));

OK.

>  }
>  
>  /* 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);

OK. New ABI redirect.

> +# 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);

OK.

> +# 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

OK.

>  
>  # include <posix/glob64.c>
>  
> diff --git a/posix/glob64-time64.c b/posix/glob64-time64.c
> new file mode 100644
> index 0000000000..04db45f93a
> --- /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

OK. Stub.

> diff --git a/posix/globfree64-time64.c b/posix/globfree64-time64.c
> new file mode 100644
> index 0000000000..d815bc6df1
> --- /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

OK. Stub.

> 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

OK.

>  
>  #include <posix/glob.c>
>  
> diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
> index 52fedc61f0..27a464483b 100644
> --- a/sysdeps/unix/sysv/linux/Versions
> +++ b/sysdeps/unix/sysv/linux/Versions
> @@ -192,6 +192,8 @@ libc {
>      __getitimer64;
>      __getrusage64;
>      __gettimeofday64;
> +    __glob64_time64;
> +    __globfree64_time64;

OK. New ABI.

>      __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 694033a42b..397c97cc16 100644
> --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> @@ -208,6 +208,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 1ead45904f..9bc948703c 100644
> --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> @@ -205,6 +205,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 e8fce124fd..0f84021d9f 100644
> --- a/sysdeps/unix/sysv/linux/csky/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
> @@ -2285,6 +2285,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

OK.

> +
>  #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>

OK. Include posix/glob.c with different types.

> +#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)

OK.

> +#endif
> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> index f196d94139..31caf8ebc3 100644
> --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> @@ -2238,6 +2238,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 0687af280c..75b71b8a5b 100644
> --- a/sysdeps/unix/sysv/linux/i386/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
> @@ -2420,6 +2420,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 bfd2b7c135..2f93afc071 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/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/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> index 2bd9f7ab64..dc074cf576 100644
> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> @@ -2364,6 +2364,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 2436c57b2e..a8b8366c48 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> @@ -2336,6 +2336,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 1262d01845..63e3b096e3 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> @@ -2333,6 +2333,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 2812b458c8..3d17b78b42 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> @@ -2329,6 +2329,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 782c5470a6..ba96f15040 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> @@ -2327,6 +2327,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 3487d0f4c3..04cc170344 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> @@ -2335,6 +2335,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 056254475b..ce21e19622 100644
> --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> @@ -2375,6 +2375,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 98e1da179b..4cfae3b735 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> @@ -2391,6 +2391,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 6dc0ecf108..3e03f313b1 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> @@ -2424,6 +2424,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 230031f2be..4dfdc61761 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> @@ -2389,6 +2389,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 72073ecc27..2c00100dd6 100644
> --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> @@ -2245,6 +2245,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 e07c4657f9..2bcf38af9b 100644
> --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> @@ -2242,6 +2242,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 7467677c1b..dad08de21f 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> @@ -2382,6 +2382,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
>
  
Adhemerval Zanella June 7, 2021, 6:52 p.m. UTC | #3
On 04/06/2021 16:39, Carlos O'Donell wrote:
> On 5/18/21 4:56 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 time
>> version that also uses 64 time stat functions.
> 
> Needs a v3 please. See below. Minor mistake in the test list?

Ok, although the mistake is pretty obvious (the extra shm-directory
entry in routines).  Do you think it would be worth to resend
the v3 upstream?

> 
> No regressions on x86_64, i686, ppc64le, aarch64, s390x.
> 
> Tested-by: Carlos O'Donell <carlos@redhat.com>
>  

>> diff --git a/posix/Makefile b/posix/Makefile
>> index fa0dc0ea20..84204b1270 100644
>> --- a/posix/Makefile
>> +++ b/posix/Makefile
>> @@ -67,7 +67,10 @@ routines :=								      \
>>  	get_child_max sched_cpucount sched_cpualloc sched_cpufree \
>>  	streams-compat \
>>  	shm-directory                                                         \
>> -	execveat
>> +	execveat \
>> +	shm-directory \
> 
> This is not correct since it duplicates shm-directory. I expect you intended
> to fix the silly "\" way on the end.
> 
> We should make all of those routines clearly into one entry per line to make
> merging easier.
> 
>> +	glob64-time64 \
>> +	globfree64-time64
>>  
>>  aux		:= init-posix environ
>>  tests		:= test-errno tstgetopt testfnm runtests runptests \

Indeed the duplicated 'shm-directory' is wrong, I removed it.
  

Patch

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..84204b1270 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -67,7 +67,10 @@  routines :=								      \
 	get_child_max sched_cpucount sched_cpualloc sched_cpufree \
 	streams-compat \
 	shm-directory                                                         \
-	execveat
+	execveat \
+	shm-directory \
+	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..04db45f93a
--- /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..d815bc6df1
--- /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 52fedc61f0..27a464483b 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -192,6 +192,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 694033a42b..397c97cc16 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -208,6 +208,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 1ead45904f..9bc948703c 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -205,6 +205,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 e8fce124fd..0f84021d9f 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2285,6 +2285,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 f196d94139..31caf8ebc3 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2238,6 +2238,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 0687af280c..75b71b8a5b 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2420,6 +2420,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 bfd2b7c135..2f93afc071 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/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/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 2bd9f7ab64..dc074cf576 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2364,6 +2364,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 2436c57b2e..a8b8366c48 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2336,6 +2336,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 1262d01845..63e3b096e3 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2333,6 +2333,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 2812b458c8..3d17b78b42 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2329,6 +2329,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 782c5470a6..ba96f15040 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2327,6 +2327,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 3487d0f4c3..04cc170344 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2335,6 +2335,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 056254475b..ce21e19622 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2375,6 +2375,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 98e1da179b..4cfae3b735 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2391,6 +2391,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 6dc0ecf108..3e03f313b1 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2424,6 +2424,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 230031f2be..4dfdc61761 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2389,6 +2389,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 72073ecc27..2c00100dd6 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2245,6 +2245,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 e07c4657f9..2bcf38af9b 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2242,6 +2242,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 7467677c1b..dad08de21f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2382,6 +2382,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