]> git.kaiwu.me - njs.git/commitdiff
Moved njs_time() out of the core as it is not a part of the spec.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 15 Feb 2024 05:33:56 +0000 (21:33 -0800)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 15 Feb 2024 05:33:56 +0000 (21:33 -0800)
auto/sources
external/njs_shell.c
src/njs_date.c
src/njs_main.h
src/njs_time.c [deleted file]
src/njs_time.h [deleted file]
src/test/njs_benchmark.c

index d675b73909f89849331192ac4834d40868a1734a..d97021c98f31c64f20581bcf08de2fea7e891d9e 100644 (file)
@@ -16,7 +16,6 @@ NJS_LIB_SRCS=" \
    src/njs_md5.c \
    src/njs_sha1.c \
    src/njs_sha2.c \
-   src/njs_time.c \
    src/njs_malloc.c \
    src/njs_mp.c \
    src/njs_sprintf.c \
index 9af73b7384453df769515dd35748302ffde1e545..65c4c264d2e526a9c73c0af301d10343b459e3ac 100644 (file)
@@ -7,7 +7,6 @@
 
 #include <njs.h>
 #include <njs_unix.h>
-#include <njs_time.h>
 #include <njs_arr.h>
 #include <njs_queue.h>
 #include <njs_rbtree.h>
@@ -169,6 +168,7 @@ static void njs_console_logger(njs_log_level_t level, const u_char *start,
 
 static intptr_t njs_event_rbtree_compare(njs_rbtree_node_t *node1,
     njs_rbtree_node_t *node2);
+static uint64_t njs_time(void);
 
 njs_int_t njs_array_buffer_detach(njs_vm_t *vm, njs_value_t *args,
     njs_uint_t nargs, njs_index_t unused, njs_value_t *retval);
@@ -2122,3 +2122,22 @@ njs_event_rbtree_compare(njs_rbtree_node_t *node1, njs_rbtree_node_t *node2)
 
     return 0;
 }
+
+
+static uint64_t
+njs_time(void)
+{
+#if (NJS_HAVE_CLOCK_MONOTONIC)
+    struct timespec ts;
+
+    clock_gettime(CLOCK_MONOTONIC, &ts);
+
+    return (uint64_t) ts.tv_sec * 1000000000 + ts.tv_nsec;
+#else
+    struct timeval tv;
+
+    gettimeofday(&tv, NULL);
+
+    return (uint64_t) tv.tv_sec * 1000000000 + tv.tv_usec * 1000;
+#endif
+}
index 8f0850abe3db038e5c12d684bd0b34b063488cbe..49ac3fc0959df45a4260c1846893f664c2c72a84 100644 (file)
 #define NJS_DATE_MSEC                   7
 
 
+#if (NJS_HAVE_TM_GMTOFF)
+
+#define njs_timezone(tm)                                                      \
+    ((tm)->tm_gmtoff)
+
+#elif (NJS_HAVE_ALTZONE)
+
+#define njs_timezone(tm)                                                      \
+    (-(((tm)->tm_isdst > 0) ? altzone : timezone))
+
+#endif
+
+
 #define njs_date_magic(field, local)                                          \
     ((local << 6) + field)
 
index afb024e1ce35033b2db797fca4f9e729b456865b..f52ee9a46e61e0bf57c9e13d9b3b3a1fdbb760c6 100644 (file)
@@ -27,7 +27,6 @@
 #include <njs_queue.h>
 #include <njs_flathsh.h>
 #include <njs_random.h>
-#include <njs_time.h>
 #include <njs_malloc.h>
 #include <njs_rbtree.h>
 #include <njs_mp.h>
diff --git a/src/njs_time.c b/src/njs_time.c
deleted file mode 100644 (file)
index 68733c7..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-
-/*
- * Copyright (C) Igor Sysoev
- * Copyright (C) NGINX, Inc.
- */
-
-
-#include <njs_main.h>
-
-
-uint64_t
-njs_time(void)
-{
-#if (NJS_HAVE_CLOCK_MONOTONIC)
-    struct timespec ts;
-
-    clock_gettime(CLOCK_MONOTONIC, &ts);
-
-    return (uint64_t) ts.tv_sec * 1000000000 + ts.tv_nsec;
-#else
-    struct timeval tv;
-
-    gettimeofday(&tv, NULL);
-
-    return (uint64_t) tv.tv_sec * 1000000000 + tv.tv_usec * 1000;
-#endif
-}
diff --git a/src/njs_time.h b/src/njs_time.h
deleted file mode 100644 (file)
index d375120..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-
-/*
- * Copyright (C) Igor Sysoev
- * Copyright (C) NGINX, Inc.
- */
-
-#ifndef _NJS_TIME_H_INCLUDED_
-#define _NJS_TIME_H_INCLUDED_
-
-
-#if (NJS_HAVE_TM_GMTOFF)
-
-#define njs_timezone(tm)                                                      \
-    ((tm)->tm_gmtoff)
-
-#elif (NJS_HAVE_ALTZONE)
-
-#define njs_timezone(tm)                                                      \
-    (-(((tm)->tm_isdst > 0) ? altzone : timezone))
-
-#endif
-
-
-uint64_t njs_time(void);
-
-
-#endif /* _NJS_TIME_H_INCLUDED_ */
index 8ae38e458f2a336e03eb598b988fbf4ca9277c1e..a99e7506cb1bca52ffd5231f978c6bd5bfe6fe15 100644 (file)
@@ -35,6 +35,25 @@ njs_module_t *njs_benchmark_addon_external_modules[] = {
 };
 
 
+static uint64_t
+njs_time(void)
+{
+#if (NJS_HAVE_CLOCK_MONOTONIC)
+    struct timespec ts;
+
+    clock_gettime(CLOCK_MONOTONIC, &ts);
+
+    return (uint64_t) ts.tv_sec * 1000000000 + ts.tv_nsec;
+#else
+    struct timeval tv;
+
+    gettimeofday(&tv, NULL);
+
+    return (uint64_t) tv.tv_sec * 1000000000 + tv.tv_usec * 1000;
+#endif
+}
+
+
 static njs_int_t
 njs_benchmark_test(njs_vm_t *parent, njs_opts_t *opts, njs_value_t *report,
     njs_benchmark_test_t *test)