mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-28 07:45:00 +00:00
8654f9d7d6
On my host, this speeds up directory-files-and-attributes by a factor of 3, when applied to Emacs's src directory. These functions are standardized by POSIX and are common these days; fall back on a (slower) gnulib implementation if the host is too old to supply them. * .bzrignore: Add lib/dirent.h. * lib/Makefile.am (libgnu_a_SOURCES): Add openat-die.c, save-cwd.c. * lib/careadlinkat.c, lib/careadlinkat.h: Merge from gnulib, incorporating: 2013-01-29 careadlinkat: do not provide careadlinkatcwd. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * lib/dirent.in.h, lib/fdopendir.c, lib/fstatat.c, lib/openat-priv.h: * lib/openat-proc.c, lib/openat.h, m4/dirent_h.m4, m4/fdopendir.m4: * m4/fstatat.m4: New files, from gnulib. * lib/openat-die.c, lib/save-cwd.c, lib/save-cwd.h: New files. These last three are specific to Emacs and are not copied from gnulib. They are simpler than the gnulib versions and are tuned for Emacs. * admin/merge-gnulib (GNULIB_MODULES): Add fdopendir, fstatat, readlinkat. (GNULIB_TOOL_FLAGS): Do not avoid at-internal, openat-h. Avoid dup, open, opendir. * nt/inc/sys/stat.h (fstatat): * nt/inc/unistd.h (readlinkat): New decls. * src/conf_post.h (GNULIB_SUPPORT_ONLY_AT_FDCWD): Remove. * src/dired.c: Include <fcntl.h>. (open_directory): New function, which uses open and fdopendir rather than opendir. DOS_NT platforms still use opendir, though. (directory_files_internal, file_name_completion): Use it. (file_attributes): New function, with most of the old Ffile_attributes. (directory_files_internal, Ffile_attributes): Use it. (file_attributes, file_name_completion_stat): First arg is now fd, not dir name. All uses changed. Use fstatat rather than lstat + stat. (file_attributes): Use emacs_readlinkat rather than Ffile_symlink_p. * src/fileio.c: Include <allocator.h>, <careadlinkat.h>. (emacs_readlinkat): New function, with much of the old Ffile_symlink_p, but with an fd argument for speed. It uses readlinkat rather than careadlinkatcwd, so that it need not assume the working directory. (Ffile_symlink_p): Use it. * src/filelock.c (current_lock_owner): Use emacs_readlinkat rather than emacs_readlink. * src/lisp.h (emacs_readlinkat): New decl. (READLINK_BUFSIZE, emacs_readlink): Remove. * src/sysdep.c: Do not include <allocator.h>, <careadlinkat.h>. (emacs_norealloc_allocator, emacs_readlink): Remove. This stuff is moved to fileio.c. * src/w32.c (fstatat, readlinkat): New functions. (careadlinkat): Don't check that fd == AT_FDCWD. (careadlinkatcwd): Remove; no longer needed. Fixes: debbugs:13539
61 lines
1.9 KiB
Plaintext
61 lines
1.9 KiB
Plaintext
# fstatat.m4 serial 3
|
|
dnl Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
|
dnl This file is free software; the Free Software Foundation
|
|
dnl gives unlimited permission to copy and/or distribute it,
|
|
dnl with or without modifications, as long as this notice is preserved.
|
|
|
|
# Written by Jim Meyering.
|
|
|
|
# If we have the fstatat function, and it has the bug (in AIX 7.1)
|
|
# that it does not fill in st_size correctly, use the replacement function.
|
|
AC_DEFUN([gl_FUNC_FSTATAT],
|
|
[
|
|
AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
|
|
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
|
AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
|
|
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
AC_CHECK_FUNCS_ONCE([fstatat])
|
|
|
|
if test $ac_cv_func_fstatat = no; then
|
|
HAVE_FSTATAT=0
|
|
else
|
|
dnl Test for an AIX 7.1 bug; see
|
|
dnl <http://lists.gnu.org/archive/html/bug-tar/2011-09/msg00015.html>.
|
|
AC_CACHE_CHECK([whether fstatat (..., 0) works],
|
|
[gl_cv_func_fstatat_zero_flag],
|
|
[AC_RUN_IFELSE(
|
|
[AC_LANG_SOURCE(
|
|
[[
|
|
#include <fcntl.h>
|
|
#include <sys/stat.h>
|
|
int
|
|
main (void)
|
|
{
|
|
struct stat a;
|
|
return fstatat (AT_FDCWD, ".", &a, 0) != 0;
|
|
}
|
|
]])],
|
|
[gl_cv_func_fstatat_zero_flag=yes],
|
|
[gl_cv_func_fstatat_zero_flag=no],
|
|
[case "$host_os" in
|
|
aix*) gl_cv_func_fstatat_zero_flag="guessing no";;
|
|
*) gl_cv_func_fstatat_zero_flag="guessing yes";;
|
|
esac
|
|
])
|
|
])
|
|
|
|
case $gl_cv_func_fstatat_zero_flag+$gl_cv_func_lstat_dereferences_slashed_symlink in
|
|
*yes+*yes) ;;
|
|
*) REPLACE_FSTATAT=1
|
|
case $gl_cv_func_fstatat_zero_flag in
|
|
*yes)
|
|
AC_DEFINE([HAVE_WORKING_FSTATAT_ZERO_FLAG], [1],
|
|
[Define to 1 if fstatat (..., 0) works.
|
|
For example, it does not work in AIX 7.1.])
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
fi
|
|
])
|