[Groonga-commit] groonga/groonga at f4619bf [master] windows: never use clock_gettime()

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Jun 21 12:54:55 JST 2018


Kouhei Sutou	2018-06-21 12:54:55 +0900 (Thu, 21 Jun 2018)

  New Revision: f4619bf7dfcbec991cff2c4e511e2cd7dcdaf0a8
  https://github.com/groonga/groonga/commit/f4619bf7dfcbec991cff2c4e511e2cd7dcdaf0a8

  Message:
    windows: never use clock_gettime()

  Modified files:
    lib/time.c

  Modified: lib/time.c (+13 -13)
===================================================================
--- lib/time.c    2018-06-21 12:01:48 +0900 (38fa5086e)
+++ lib/time.c    2018-06-21 12:54:55 +0900 (0c5a071a0)
@@ -36,7 +36,16 @@
 grn_rc
 grn_timeval_now(grn_ctx *ctx, grn_timeval *tv)
 {
-#ifdef HAVE_CLOCK_GETTIME
+#ifdef WIN32
+  time_t t;
+  struct _timeb tb;
+  time(&t);
+  _ftime(&tb);
+  tv->tv_sec = t;
+  tv->tv_nsec = tb.millitm * (GRN_TIME_NSEC_PER_SEC / 1000);
+  return GRN_SUCCESS;
+#else /* WIN32 */
+# ifdef HAVE_CLOCK_GETTIME
   struct timespec t;
   if (clock_gettime(CLOCK_REALTIME, &t)) {
     SERR("clock_gettime");
@@ -45,16 +54,7 @@ grn_timeval_now(grn_ctx *ctx, grn_timeval *tv)
     tv->tv_nsec = t.tv_nsec;
   }
   return ctx->rc;
-#else /* HAVE_CLOCK_GETTIME */
-# ifdef WIN32
-  time_t t;
-  struct _timeb tb;
-  time(&t);
-  _ftime(&tb);
-  tv->tv_sec = t;
-  tv->tv_nsec = tb.millitm * (GRN_TIME_NSEC_PER_SEC / 1000);
-  return GRN_SUCCESS;
-# else /* WIN32 */
+# else /* HAVE_CLOCK_GETTIME */
   struct timeval t;
   if (gettimeofday(&t, NULL)) {
     SERR("gettimeofday");
@@ -63,8 +63,8 @@ grn_timeval_now(grn_ctx *ctx, grn_timeval *tv)
     tv->tv_nsec = GRN_TIME_USEC_TO_NSEC(t.tv_usec);
   }
   return ctx->rc;
-# endif /* WIN32 */
-#endif /* HAVE_CLOCK_GETTIME */
+# endif /* HAVE_CLOCK_GETTIME */
+#endif /* WIN32 */
 }
 
 void
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180621/c76c0cc9/attachment-0001.htm 



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