Ticket #189: nginx-gettimeofday.patch

File nginx-gettimeofday.patch, 1.6 KB (added by Kristof Provost, 14 years ago)
  • auto/make

    diff -ru nginx-1.0.5-orig/auto/make nginx-1.0.5-fixed/auto/make
    a b  
    188188cat << END                                                    >> $NGX_MAKEFILE
    189189
    190190$NGX_OBJS${ngx_dirsep}nginx${ngx_binext}:  $ngx_deps$ngx_spacer
    191    \$(LINK) ${ngx_long_start}${ngx_binout}$NGX_OBJS${ngx_dirsep}nginx$ngx_long_cont$ngx_objs$ngx_libs$ngx_link
     191   \$(LINK) ${ngx_long_start}${ngx_binout}$NGX_OBJS${ngx_dirsep}nginx$ngx_long_cont$ngx_objs$ngx_libs$ngx_link -lrt
    192192   $ngx_rcc
    193193${ngx_long_end}
    194194END
  • src/os/unix/ngx_time.c

    diff -ru nginx-1.0.5-orig/src/os/unix/ngx_time.c nginx-1.0.5/src/os/unix/ngx_time.c
    a b  
    10199
    102100#endif
    103101}
     102
     103void
     104ngx_gettimeofday(struct timeval *tv)
     105{
     106    struct timespec ts;
     107
     108    (void) clock_gettime(CLOCK_MONOTONIC, &ts);
     109
     110    tv->tv_sec = ts.tv_sec;
     111    tv->tv_usec = ts.tv_nsec / 1000;
     112}
     113
  • src/os/unix/ngx_time.h

    diff -ru nginx-1.0.5-orig/src/os/unix/ngx_time.h nginx-1.0.5/src/os/unix/ngx_time.h
    a b  
    5655void ngx_localtime(time_t s, ngx_tm_t *tm);
    5756void ngx_libc_localtime(time_t s, struct tm *tm);
    5857void ngx_libc_gmtime(time_t s, struct tm *tm);
     58void ngx_gettimeofday(struct timeval *tv);
    5959
    60 #define ngx_gettimeofday(tp)  (void) gettimeofday(tp, NULL);
    6160#define ngx_msleep(ms)        (void) usleep(ms * 1000)
    6261#define ngx_sleep(s)          (void) sleep(s)
    6362