]> Dogcows Code - chaz/tar/commitdiff
Merge changes from gnulib for file system sub-second time stamps.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 16 Sep 2005 07:03:44 +0000 (07:03 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 16 Sep 2005 07:03:44 +0000 (07:03 +0000)
* configure.ac: Remove checks for struct stat.st_spare1, struct
stat.st_atim.tv_nsec, struct stat.st_atimespec.tv_nsec, struct
stat.st_atimensec, as gnulib now does this for us.
Similarly for LIB_CLOCK_GETTIME.
* gnulib.modules: Add stat-time.
* lib/.cvsignore: Add stat-time.h.
* src/common.h: Include stat-time.h.
(timespec_lt): Remove.  All callers changed to use timespec_cmp.
(get_stat_atime, get_stat_ctime, get_stat_mtime):
(set_stat_atime, set_stat_ctime, set_stat_mtime):
Remove; now defined by stat-time.h.

ChangeLog
configure.ac
gnulib.modules
lib/.cvsignore
src/common.h
src/extract.c

index e10b9fe43e9eb9a6f916bf4fdbf548031504fb54..dcc627a53c9b9214d4b2611375a0dd549c9a433d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2005-09-16  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Merge changes from gnulib for file system sub-second time stamps.
+       * configure.ac: Remove checks for struct stat.st_spare1, struct
+       stat.st_atim.tv_nsec, struct stat.st_atimespec.tv_nsec, struct
+       stat.st_atimensec, as gnulib now does this for us.
+       Similarly for LIB_CLOCK_GETTIME.
+       * gnulib.modules: Add stat-time.
+       * lib/.cvsignore: Add stat-time.h.
+       * src/common.h: Include stat-time.h.
+       (timespec_lt): Remove.  All callers changed to use timespec_cmp.
+       (get_stat_atime, get_stat_ctime, get_stat_mtime):
+       (set_stat_atime, set_stat_ctime, set_stat_mtime):
+       Remove; now defined by stat-time.h.
+
 2005-09-14  Sergey Poznyakoff  <gray@gnu.org.ua>
 
        * src/incremen.c (list_dumpdir): New function. Used to dump
index 0985f74c01143310c0c99dea5641269c6d70c462..d6849fce12d69b6d67019fd6362bb61af57d6108 100644 (file)
@@ -88,27 +88,6 @@ tar_GNULIB
 # paxutils modules
 tar_PAXUTILS
 
-AC_CHECK_MEMBERS([struct stat.st_spare1, struct stat.st_atim.tv_nsec, struct stat.st_atimespec.tv_nsec, struct stat.st_atimensec], , ,
-                 [
-#include <sys/types.h>
-#include <sys/stat.h>])
-
-# Save and restore LIBS so e.g., -lrt, isn't added to it.  Otherwise, *all*
-# programs in the package would end up linked with that potentially-shared
-# library, inducing unnecessary run-time overhead.
-
-# Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
-# Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
-tar_save_LIBS=$LIBS
-  LIB_CLOCK_GETTIME=
-  AC_SEARCH_LIBS(clock_gettime, [rt posix4])
-  case "$ac_cv_search_clock_gettime" in
-    -l*) LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime;;
-  esac
-  AC_SUBST(LIB_CLOCK_GETTIME)
-  AC_CHECK_FUNCS(clock_gettime)
-LIBS=$tar_save_LIBS
-
 AC_CHECK_FUNCS(fsync lstat mkfifo readlink strerror symlink setlocale utimes)
 AC_CHECK_DECLS([getgrgid],,, [#include <grp.h>])
 AC_CHECK_DECLS([getpwuid],,, [#include <pwd.h>])
index 0d8eaff4febbfb910360fe908b585dc8269f41bd..7e3b1ef6d0f738c257609db75d31f69b7b82af3b 100644 (file)
@@ -32,6 +32,7 @@ safe-read
 save-cwd
 savedir
 setenv
+stat-time
 stdbool
 stpcpy
 strdup
index ceb861c9d4614c5159b1e619623cf42755151b01..21c24ea5da81471d1b783e2ea7c306ffa091d025 100644 (file)
@@ -132,6 +132,7 @@ setenv.c
 setenv.h
 size_max.h
 stat-macros.h
+stat-time.h
 stdbool.h
 stdbool_.h
 stpcpy.c
index 0cd9c3bdae9d8a96a9b40efb21b5dadafbe4c4c2..be7f35d15dbfa7f52c584c2eae362a1f7855fc20 100644 (file)
@@ -55,6 +55,7 @@
 #include <modechange.h>
 #include <quote.h>
 #include <safe-read.h>
+#include <stat-time.h>
 #include <timespec.h>
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free free
@@ -188,15 +189,7 @@ GLOBAL struct timespec newer_mtime_option;
 /* Return true if the struct stat ST's M time is less than
    newer_mtime_option.  */
 #define OLDER_STAT_TIME(st, m) \
-  timespec_lt (get_stat_##m##time (&st), newer_mtime_option)
-
-/* Return true if A < B.  */
-static inline bool
-timespec_lt (struct timespec a, struct timespec b)
-{
-  return (a.tv_sec < b.tv_sec
-         || (a.tv_sec == b.tv_sec && a.tv_nsec < b.tv_nsec));
-}
+  (timespec_cmp (get_stat_##m##time (&st), newer_mtime_option) < 0)
 
 /* Zero if there is no recursion, otherwise FNM_LEADING_DIR.  */
 GLOBAL int recursion_option;
@@ -646,120 +639,3 @@ bool sparse_diff_file (int, struct tar_stat_info *);
 /* Module utf8.c */
 bool string_ascii_p (const char *str);
 bool utf8_convert (bool to_utf, char const *input, char **output);
-
-
-/* FIXME: The following should get moved into gnulib.  */
-
-static inline struct timespec
-get_stat_atime (struct stat const *st)
-{
-#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
-  return st->st_atim;
-#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
-  return st->st_atimespec;
-#else
-  struct timespec t;
-  t.tv_sec = st->st_atime;
-# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC
-  t.tv_nsec = st->stat.st_atimensec;
-# elif defined HAVE_STRUCT_STAT_ST_SPARE1
-  t.tv_nsec = st->stat.st_spare1 * 1000;
-# else
-  t.tv_nsec = 0;
-# endif
-  return t;
-#endif
-}
-
-static inline struct timespec
-get_stat_ctime (struct stat const *st)
-{
-#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
-  return st->st_ctim;
-#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
-  return st->st_ctimespec;
-#else
-  struct timespec t;
-  t.tv_sec = st->st_ctime;
-# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC
-  t.tv_nsec = st->stat.st_ctimensec;
-# elif defined HAVE_STRUCT_STAT_ST_SPARE1
-  t.tv_nsec = st->stat.st_spare1 * 1000;
-# else
-  t.tv_nsec = 0;
-# endif
-  return t;
-#endif
-}
-
-static inline struct timespec
-get_stat_mtime (struct stat const *st)
-{
-#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
-  return st->st_mtim;
-#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
-  return st->st_mtimespec;
-#else
-  struct timespec t;
-  t.tv_sec = st->st_mtime;
-# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC
-  t.tv_nsec = st->stat.st_mtimensec;
-# elif defined HAVE_STRUCT_STAT_ST_SPARE1
-  t.tv_nsec = st->stat.st_spare1 * 1000;
-# else
-  t.tv_nsec = 0;
-# endif
-  return t;
-#endif
-}
-
-static inline void
-set_stat_atime (struct stat *st, struct timespec t)
-{
-#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
-  st->st_atim = t;
-#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
-  st->st_atimespec = t;
-#else
-  st->st_atime = t.tv_sec;
-# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC
-  st->stat.st_atimensec = t.tv_nsec;
-# elif defined HAVE_STRUCT_STAT_ST_SPARE1
-  st->stat.st_spare1 = t.tv_nsec / 1000;
-# endif
-#endif
-}
-
-static inline void
-set_stat_ctime (struct stat *st, struct timespec t)
-{
-#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
-  st->st_ctim = t;
-#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
-  st->st_ctimespec = t;
-#else
-  st->st_ctime = t.tv_sec;
-# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC
-  st->stat.st_ctimensec = t.tv_nsec;
-# elif defined HAVE_STRUCT_STAT_ST_SPARE1
-  st->stat.st_spare1 = t.tv_nsec / 1000;
-# endif
-#endif
-}
-
-static inline void
-set_stat_mtime (struct stat *st, struct timespec t)
-{
-#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
-  st->st_mtim = t;
-#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
-  st->st_mtimespec = t;
-#else
-  st->st_mtime = t.tv_sec;
-# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC
-  st->stat.st_mtimensec = t.tv_nsec;
-# elif defined HAVE_STRUCT_STAT_ST_SPARE1
-  st->stat.st_spare1 = t.tv_nsec / 1000;
-# endif
-#endif
-}
index d835813424f524ac4aac58de27834efa687eec4e..80f2f9ceec68d1616d311680c6537e30cb83b348 100644 (file)
@@ -200,11 +200,11 @@ check_time (char const *file_name, struct timespec t)
   if (t.tv_sec <= 0)
     WARN ((0, 0, _("%s: implausibly old time stamp %s"),
           file_name, tartime (t, true)));
-  else if (timespec_lt (start_time, t))
+  else if (timespec_cmp (start_time, t) < 0)
     {
       struct timespec now;
       gettime (&now);
-      if (timespec_lt (now, t))
+      if (timespec_cmp (now, t) < 0)
        {
          unsigned long int ds = t.tv_sec - now.tv_sec;
          int dns = t.tv_nsec - now.tv_nsec;
This page took 0.038846 seconds and 4 git commands to generate.