- return ((flags & GLOB_ALTDIRFUNC)
- ? (*pglob->gl_stat) (fullname, &st) == 0 && S_ISDIR (st.st_mode)
- : __stat64 (fullname, &st64) == 0 && S_ISDIR (st64.st_mode));
+# if !defined _LIBC && !HAVE_FSTATAT
+ if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) == 0, 1))
+ {
+ struct_stat64 st64;
+ return __stat64 (fullname, &st64) == 0;
+ }
+# endif
+ return (*pglob->gl_stat) (fullname, &st) == 0;
+}
+
+/* Return true if DIR/FNAME exists. */
+static int
+link_exists_p (int dfd, const char *dir, size_t dirlen, const char *fname,
+ glob_t *pglob, int flags)
+{
+# if defined _LIBC || HAVE_FSTATAT
+ if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
+ return link_exists2_p (dir, dirlen, fname, pglob);
+ else
+ {
+ struct_stat64 st64;
+ return __fxstatat64 (_STAT_VER, dfd, fname, &st64, 0) == 0;
+ }
+# else
+ return link_exists2_p (dir, dirlen, fname, pglob, flags);
+# endif