diff --git a/configure b/configure index 2a3031c..2e4e13f 100755 --- a/configure +++ b/configure @@ -18318,6 +18318,18 @@ _ACEOF fi done +for ac_func in localtime_r gmtime_r +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + for ac_func in snprintf _vsnprintf _vsnwprintf do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/configure.ac b/configure.ac index 9d7f256..d96ec61 100644 --- a/configure.ac +++ b/configure.ac @@ -144,6 +144,7 @@ AC_CHECK_FUNCS([gettimeofday settimeofday clock_gettime clock_settime getitimer AC_CHECK_FUNCS([backtrace backtrace_symbols]) AC_CHECK_FUNCS([makecontext swapcontext getcontext setcontext]) AC_CHECK_FUNCS([clock_nanosleep nanosleep usleep]) +AC_CHECK_FUNCS([localtime_r gmtime_r]) AC_CHECK_FUNCS([snprintf _vsnprintf _vsnwprintf]) AC_CHECK_FUNCS([isatty mmap munmap readv writev]) diff --git a/lib/hcl-cfg.h.in b/lib/hcl-cfg.h.in index 7cbac63..105047d 100644 --- a/lib/hcl-cfg.h.in +++ b/lib/hcl-cfg.h.in @@ -75,6 +75,9 @@ /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY +/* Define to 1 if you have the `gmtime_r' function. */ +#undef HAVE_GMTIME_R + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -84,6 +87,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LIBUNWIND_H +/* Define to 1 if you have the `localtime_r' function. */ +#undef HAVE_LOCALTIME_R + /* Define to 1 if you have the `log10q' function. */ #undef HAVE_LOG10Q diff --git a/lib/main-c.c b/lib/main-c.c index 302523e..0038e7e 100644 --- a/lib/main-c.c +++ b/lib/main-c.c @@ -236,12 +236,19 @@ static void log_write (hcl_client_t* client, hcl_bitmask_t mask, const hcl_ooch_ now = time(NULL); - tmp = localtime_r (&now, &tm); - #if defined(HAVE_STRFTIME_SMALL_Z) + #if defined(__OS2__) + tmp = _localtime(&now, &tm); + #elif defined(HAVE_LOCALTIME_R) + tmp = localtime_r(&now, &tm); + #else + tmp = localtime(&now); + #endif + + #if defined(HAVE_STRFTIME_SMALL_Z) tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp); - #else + #else tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp); - #endif + #endif if (tslen == 0) { strcpy (ts, "0000-00-00 00:00:00 +0000"); diff --git a/lib/main-j.c b/lib/main-j.c index bc052b8..2969639 100644 --- a/lib/main-j.c +++ b/lib/main-j.c @@ -187,12 +187,18 @@ static void log_write (hcl_json_t* json, hcl_bitmask_t mask, const hcl_ooch_t* m now = time(NULL); - tmp = localtime_r (&now, &tm); - #if defined(HAVE_STRFTIME_SMALL_Z) + #if defined(__OS2__) + tmp = _localtime(&now, &tm); + #elif defined(HAVE_LOCALTIME_R) + tmp = localtime_r(&now, &tm); + #else + tmp = localtime(&now); + #endif + #if defined(HAVE_STRFTIME_SMALL_Z) tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp); - #else + #else tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp); - #endif + #endif if (tslen == 0) { strcpy (ts, "0000-00-00 00:00:00 +0000"); diff --git a/lib/main-s.c b/lib/main-s.c index 2efca53..4c78c77 100644 --- a/lib/main-s.c +++ b/lib/main-s.c @@ -230,12 +230,18 @@ static void log_write (hcl_server_t* server, hcl_oow_t wid, hcl_bitmask_t mask, now = time(NULL); - tmp = localtime_r (&now, &tm); - #if defined(HAVE_STRFTIME_SMALL_Z) + #if defined(__OS2__) + tmp = _localtime(&now, &tm); + #elif defined(HAVE_LOCALTIME_R) + tmp = localtime_r(&now, &tm); + #else + tmp = localtime(&now); + #endif + #if defined(HAVE_STRFTIME_SMALL_Z) tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp); - #else + #else tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp); - #endif + #endif if (tslen == 0) { strcpy (ts, "0000-00-00 00:00:00 +0000"); diff --git a/lib/main.c b/lib/main.c index 6702f20..4e4825a 100644 --- a/lib/main.c +++ b/lib/main.c @@ -698,7 +698,13 @@ static void log_write (hcl_t* hcl, hcl_bitmask_t mask, const hcl_ooch_t* msg, hc tslen = 20; } #else - tmp = localtime_r (&now, &tm); + #if defined(__OS2__) + tmp = _localtime(&now, &tm); + #elif defined(HAVE_LOCALTIME_R) + tmp = localtime_r(&now, &tm); + #else + tmp = localtime(&now); + #endif #if defined(HAVE_STRFTIME_SMALL_Z) tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp); #else @@ -1662,8 +1668,10 @@ static void cancel_tick (void) typedef void(*signal_handler_t)(int); #elif defined(macintosh) typedef void(*signal_handler_t)(int); /* TODO: */ -#else +#elif defined(SA_SIGINFO) typedef void(*signal_handler_t)(int, siginfo_t*, void*); +#else +typedef void(*signal_handler_t)(int); #endif @@ -1674,11 +1682,16 @@ static void handle_sigint (int sig) } #elif defined(macintosh) /* TODO */ -#else +#elif defined(SA_SIGINFO) static void handle_sigint (int sig, siginfo_t* siginfo, void* ctx) { if (g_hcl) hcl_abort (g_hcl); } +#else +static void handle_sigint (int sig) +{ + if (g_hcl) hcl_abort (g_hcl); +} #endif static void set_signal (int sig, signal_handler_t handler) @@ -1692,8 +1705,12 @@ static void set_signal (int sig, signal_handler_t handler) memset (&sa, 0, sizeof(sa)); /*sa.sa_handler = handler;*/ +#if defined(SA_SIGINFO) sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = handler; +#else + sa.sa_handler = handler; +#endif sigemptyset (&sa.sa_mask); sigaction (sig, &sa, NULL);