aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/ngx_linux_config.h1
-rw-r--r--src/os/unix/ngx_solaris_config.h1
-rw-r--r--src/os/unix/ngx_time.c18
-rw-r--r--src/os/unix/ngx_time.h12
4 files changed, 19 insertions, 13 deletions
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h
index 11dbfac34..ca53a2306 100644
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -35,6 +35,7 @@
#define SIZE_FMT "%d"
#define SIZEX_FMT "%x"
#define PID_FMT "%d"
+#define TIME_FMT "%lu"
diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h
index f94936dca..21724f80b 100644
--- a/src/os/unix/ngx_solaris_config.h
+++ b/src/os/unix/ngx_solaris_config.h
@@ -33,6 +33,7 @@ typedef uint32_t u_int32_t;
#define SIZE_FMT "%d"
#define SIZEX_FMT "%x"
#define PID_FMT "%ld"
+#define TIME_FMT "%lu"
#ifndef HAVE_SELECT
diff --git a/src/os/unix/ngx_time.c b/src/os/unix/ngx_time.c
index bf3432ba7..37039918e 100644
--- a/src/os/unix/ngx_time.c
+++ b/src/os/unix/ngx_time.c
@@ -5,22 +5,24 @@
void ngx_localtime(ngx_tm_t *tm)
{
+#if (HAVE_LOCALTIME_R)
+
localtime_r(&ngx_cached_time, tm);
- tm->ngx_tm_mon++;
- tm->ngx_tm_year += 1900;
-}
+#else
+ ngx_tm_t *t;
-u_int ngx_msec(void)
-{
- struct timeval tv;
+ t = localtime(&ngx_cached_time);
+ *tm = *t;
- gettimeofday(&tv, NULL);
+#endif
- return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+ tm->ngx_tm_mon++;
+ tm->ngx_tm_year += 1900;
}
+
#if 0
typedef struct {
diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h
index cdec417e2..9dc4aea40 100644
--- a/src/os/unix/ngx_time.h
+++ b/src/os/unix/ngx_time.h
@@ -3,9 +3,13 @@
#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+typedef uint64_t ngx_epoch_msec_t;
typedef u_int ngx_msec_t;
-#define NGX_MAX_MSEC (u_int) -1
+#define NGX_MAX_MSEC (ngx_msec_t) -1
typedef struct tm ngx_tm_t;
@@ -17,16 +21,14 @@ typedef struct tm ngx_tm_t;
#define ngx_tm_year tm_year
#define ngx_tm_wday tm_wday
-#define ngx_msleep(ms) usleep(ms * 1000)
void ngx_localtime(ngx_tm_t *tm);
-ngx_msec_t ngx_msec(void);
+#define ngx_gettimeofday(tp) gettimeofday(tp, NULL);
+#define ngx_msleep(ms) usleep(ms * 1000)
-time_t ngx_time();
extern time_t ngx_cached_time;
-
#endif /* _NGX_TIME_H_INCLUDED_ */