[Groonga-commit] groonga/groonga at 6f6f1ad [master] io: futimens() uses timespec not timeval

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jul 30 14:57:22 JST 2018


Kouhei Sutou	2018-07-30 14:57:22 +0900 (Mon, 30 Jul 2018)

  New Revision: 6f6f1ade6f9b7168efdd42bfe9c97b6e72e0c921
  https://github.com/groonga/groonga/commit/6f6f1ade6f9b7168efdd42bfe9c97b6e72e0c921

  Message:
    io: futimens() uses timespec not timeval

  Modified files:
    lib/io.c

  Modified: lib/io.c (+10 -6)
===================================================================
--- lib/io.c    2018-07-27 16:39:02 +0900 (40ea2fb25)
+++ lib/io.c    2018-07-30 14:57:22 +0900 (6e0d0604d)
@@ -51,10 +51,10 @@
 
 #ifndef WIN32
 # ifdef HAVE_FUTIMENS
-#  define grn_futimens(fd, times) futimens((fd), (times))
+#  define grn_futimens(fd, time_values, time_specs) futimens((fd), (time_specs))
 #  define grn_futimens_name "futimens"
 # elif defined(HAVE_FUTIMES) /* HAVE_FUTIMENS */
-#  define grn_futimens(fd, times) futimes((fd), (times))
+#  define grn_futimens(fd, time_values, time_specs) futimes((fd), (time_values))
 #  define grn_futimens_name "futimes"
 # else /* HAVE_FUTIMENS */
 #  error Support for either the futimens() or futimens() function is required
@@ -2150,10 +2150,14 @@ grn_msync(grn_ctx *ctx, fileinfo *fi, void *start, size_t length)
   }
 
   if (fi->fd > 0) {
-    struct timeval times[2];
-    gettimeofday(&(times[0]), NULL);
-    times[1] = times[0];
-    r = grn_futimens(fi->fd, times);
+    struct timeval time_values[2];
+    struct timespec time_specs[2];
+    gettimeofday(&(time_values[0]), NULL);
+    time_values[1] = time_values[0];
+    time_specs[0].tv_sec = time_values[0].tv_sec;
+    time_specs[0].tv_nsec = time_values[0].tv_usec * 1000;
+    time_specs[1] = time_specs[0];
+    r = grn_futimens(fi->fd, time_values, time_specs);
     if (r == -1) {
       SERR("%s failed: <%d>", grn_futimens_name, fi->fd);
     }
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180730/76faf3f7/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index