* utimecmp.c: Include stat-time.h.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 16 Sep 2005 07:16:21 +0000 (07:16 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 16 Sep 2005 07:16:21 +0000 (07:16 +0000)
(SYSCALL_RESOLUTION): Depend on whether various struct stat
members exist, not on the obsolescent ST_MTIM_NSEC.
(utimecmp): Use the new stat-time functions rater than TIMESPEC_NS.

lib/ChangeLog
lib/utimecmp.c

index 3304fa06c19ecd9d2195468c19fe4d48a25bbe51..1786690b9f5a7e78b177b2f7bb371da913c03a65 100644 (file)
@@ -1,10 +1,14 @@
-2005-09-15  Paul Eggert  <eggert@cs.ucla.edu>
+2005-09-16  Paul Eggert  <eggert@cs.ucla.edu>
 
        * stat-time.h: New file.
        * timespec.h (ST_TIME_CMP_NS, ST_TIME_CMP, ATIME_CMP, CTIME_CMP):
        (MTIME_CMP, TIMESPEC_NS): Remove.  Now done by stat-time.h,
        in a different way.
        (timespec_cmp): New function.
+       * utimecmp.c: Include stat-time.h.
+       (SYSCALL_RESOLUTION): Depend on whether various struct stat
+       members exist, not on the obsolescent ST_MTIM_NSEC.
+       (utimecmp): Use the new stat-time functions rater than TIMESPEC_NS.
 
 2005-09-15  Derek Price  <derek@ximbiot.com>
            Paul Eggert  <eggert@cs.ucla.edu>
index de18944121d21c37115db7bb10e93855e06169d7..4c8e6c9caff3708c913023cd1cbbf02e1ed1c226 100644 (file)
@@ -36,6 +36,7 @@
 #include <stdlib.h>
 #include "hash.h"
 #include "intprops.h"
+#include "stat-time.h"
 #include "timespec.h"
 #include "utimens.h"
 #include "xalloc.h"
@@ -56,7 +57,12 @@ enum { BILLION = 1000 * 1000 * 1000 };
 /* Best possible resolution that utimens can set and stat can return,
    due to system-call limitations.  It must be a power of 10 that is
    no greater than 1 billion.  */
-#if HAVE_WORKING_UTIMES && defined ST_MTIM_NSEC
+#if (HAVE_WORKING_UTIMES                                       \
+     && (defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC              \
+        || defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC       \
+        || defined HAVE_STRUCT_STAT_ST_ATIMENSEC               \
+        || defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC    \
+        || defined HAVE_STRUCT_STAT_ST_SPARE1))
 enum { SYSCALL_RESOLUTION = 1000 };
 #else
 enum { SYSCALL_RESOLUTION = BILLION };
@@ -139,8 +145,8 @@ utimecmp (char const *dst_name,
   /* Destination and source time stamps.  */
   time_t dst_s = dst_stat->st_mtime;
   time_t src_s = src_stat->st_mtime;
-  int dst_ns = TIMESPEC_NS (dst_stat->st_mtim);
-  int src_ns = TIMESPEC_NS (src_stat->st_mtim);
+  int dst_ns = get_stat_mtime_ns (dst_stat);
+  int src_ns = get_stat_mtime_ns (src_stat);
 
   if (options & UTIMECMP_TRUNCATE_SOURCE)
     {
@@ -186,8 +192,8 @@ utimecmp (char const *dst_name,
          time_t dst_a_s = dst_stat->st_atime;
          time_t dst_c_s = dst_stat->st_ctime;
          time_t dst_m_s = dst_s;
-         int dst_a_ns = TIMESPEC_NS (dst_stat->st_atim);
-         int dst_c_ns = TIMESPEC_NS (dst_stat->st_ctim);
+         int dst_a_ns = get_stat_atime_ns (dst_stat);
+         int dst_c_ns = get_stat_ctime_ns (dst_stat);
          int dst_m_ns = dst_ns;
 
          /* Set RES to an upper bound on the file system resolution
@@ -280,7 +286,7 @@ utimecmp (char const *dst_name,
 
                if (stat_result
                    | (dst_status.st_mtime ^ dst_m_s)
-                   | (TIMESPEC_NS (dst_status.st_mtim) ^ dst_m_ns))
+                   | (get_stat_mtime_ns (&dst_status) ^ dst_m_ns))
                  {
                    /* The modification time changed, or we can't tell whether
                       it changed.  Change it back as best we can.  */
@@ -298,7 +304,7 @@ utimecmp (char const *dst_name,
              {
                int old_res = res;
                int a = (BILLION * (dst_status.st_mtime & 1)
-                        + TIMESPEC_NS (dst_status.st_mtim));
+                        + get_stat_mtime_ns (&dst_status));
 
                res = SYSCALL_RESOLUTION;