diff options
author | Alan Modra <amodra@gmail.com> | 2021-04-15 00:36:42 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-04-15 17:51:17 +0930 |
commit | 985e026451640c880e13827454aa31b7a636d1bc (patch) | |
tree | 2a034beb448ef79b8b57e9d207f2e0722e38cda5 /binutils/configure.ac | |
parent | d0ecdcddc363ad7f05fc50cf1eee4028fa7f8964 (diff) | |
download | fsf-binutils-gdb-985e026451640c880e13827454aa31b7a636d1bc.zip fsf-binutils-gdb-985e026451640c880e13827454aa31b7a636d1bc.tar.gz fsf-binutils-gdb-985e026451640c880e13827454aa31b7a636d1bc.tar.bz2 |
PR27725, better objcopy -p times
Nanosecond rather than second resolution.
PR 27725
* configure.ac: Check for sys/time.h and utimensat. Use standard
checks for mkstemp and mkdtemp. Whitespace. Check for nanosecond
members of struct stat.
* rename.c: Prefer sys/time.h for utimes over utime.h for utime.
(STAT_TIMESPEC, STAT_TIMESPEC_NS): Define
(get_stat_atime_ns, get_stat_mtime_ns): New inline functions.
(get_stat_atime, get_stat_mtime): Likewise.
(set_times): Choose first available of utimensat, utimes, utime.
Use above inline functions to set timespec and timeval values.
* configure: Regenerate.
* config.in: Regenerate.
* testsuite/binutils-all/objcopy.exp (objcopy_test): Add test of
file timestamp when --preserve-dates is used.
Diffstat (limited to 'binutils/configure.ac')
-rw-r--r-- | binutils/configure.ac | 65 |
1 files changed, 49 insertions, 16 deletions
diff --git a/binutils/configure.ac b/binutils/configure.ac index 3c5a8e1..b8ab642 100644 --- a/binutils/configure.ac +++ b/binutils/configure.ac @@ -182,24 +182,57 @@ AC_CHECK_SIZEOF([long long]) # plugin-api.h tests HAVE_STDINT_H and HAVE_INTTYPES_H # Besides those, we need to check anything used in binutils/ not in C99. AC_CHECK_HEADERS(fcntl.h inttypes.h stdint.h sys/file.h \ - sys/stat.h sys/types.h unistd.h) + sys/stat.h sys/time.h sys/types.h unistd.h) AC_HEADER_SYS_WAIT AC_FUNC_MMAP -AC_CHECK_FUNCS(getc_unlocked sbrk utimes) -AC_CHECK_FUNC([mkstemp], - AC_DEFINE([HAVE_MKSTEMP], 1, - [Define to 1 if you have the `mkstemp' function.])) -AC_CHECK_FUNC([mkdtemp], - AC_DEFINE([HAVE_MKDTEMP], 1, - [Define to 1 if you have the `mkdtemp' function.])) - AC_MSG_CHECKING([for mbstate_t]) - AC_TRY_COMPILE([#include <wchar.h>], - [mbstate_t teststate;], - have_mbstate_t=yes, have_mbstate_t=no) - AC_MSG_RESULT($have_mbstate_t) - if test x"$have_mbstate_t" = xyes; then - AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.]) - fi +AC_CHECK_FUNCS(getc_unlocked mkdtemp mkstemp sbrk utimensat utimes) + +AC_MSG_CHECKING([for mbstate_t]) +AC_TRY_COMPILE([#include <wchar.h>], +[mbstate_t teststate;], +have_mbstate_t=yes, have_mbstate_t=no) +AC_MSG_RESULT($have_mbstate_t) +if test x"$have_mbstate_t" = xyes; then + AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.]) +fi + +# Copied from gnulib stat-time.m4. +# We should just switch over to using gnulib. +AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec], + [AC_CACHE_CHECK([whether struct stat.st_atim is of type struct timespec], + [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ + #include <sys/types.h> + #include <sys/stat.h> + #if HAVE_SYS_TIME_H + # include <sys/time.h> + #endif + #include <time.h> + struct timespec ts; + struct stat st; + ]], + [[ + st.st_atim = ts; + ]])], + [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=yes], + [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no])]) + if test $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec = yes; then + AC_DEFINE([TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC], [1], + [Define to 1 if the type of the st_atim member of a struct stat is + struct timespec.]) + fi], + [AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec], [], + [AC_CHECK_MEMBERS([struct stat.st_atimensec], [], + [AC_CHECK_MEMBERS([struct stat.st_atim.st__tim.tv_nsec], [], [], + [#include <sys/types.h> + #include <sys/stat.h>])], + [#include <sys/types.h> + #include <sys/stat.h>])], + [#include <sys/types.h> + #include <sys/stat.h>])], + [#include <sys/types.h> + #include <sys/stat.h>]) # Some systems have frexp only in -lm, not in -lc. AC_SEARCH_LIBS(frexp, m) |