added localtime_r check.

added SA_SIGINFO check
This commit is contained in:
hyung-hwan 2018-10-14 10:28:28 +00:00
parent 9e72cb1ca3
commit 7001dfa037
7 changed files with 70 additions and 15 deletions

12
configure vendored
View File

@ -18318,6 +18318,18 @@ _ACEOF
fi fi
done 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 for ac_func in snprintf _vsnprintf _vsnwprintf
do : do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`

View File

@ -144,6 +144,7 @@ AC_CHECK_FUNCS([gettimeofday settimeofday clock_gettime clock_settime getitimer
AC_CHECK_FUNCS([backtrace backtrace_symbols]) AC_CHECK_FUNCS([backtrace backtrace_symbols])
AC_CHECK_FUNCS([makecontext swapcontext getcontext setcontext]) AC_CHECK_FUNCS([makecontext swapcontext getcontext setcontext])
AC_CHECK_FUNCS([clock_nanosleep nanosleep usleep]) AC_CHECK_FUNCS([clock_nanosleep nanosleep usleep])
AC_CHECK_FUNCS([localtime_r gmtime_r])
AC_CHECK_FUNCS([snprintf _vsnprintf _vsnwprintf]) AC_CHECK_FUNCS([snprintf _vsnprintf _vsnwprintf])
AC_CHECK_FUNCS([isatty mmap munmap readv writev]) AC_CHECK_FUNCS([isatty mmap munmap readv writev])

View File

@ -75,6 +75,9 @@
/* Define to 1 if you have the `gettimeofday' function. */ /* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY #undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the `gmtime_r' function. */
#undef HAVE_GMTIME_R
/* Define to 1 if you have the <inttypes.h> header file. */ /* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H #undef HAVE_INTTYPES_H
@ -84,6 +87,9 @@
/* Define to 1 if you have the <libunwind.h> header file. */ /* Define to 1 if you have the <libunwind.h> header file. */
#undef HAVE_LIBUNWIND_H #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. */ /* Define to 1 if you have the `log10q' function. */
#undef HAVE_LOG10Q #undef HAVE_LOG10Q

View File

@ -236,12 +236,19 @@ static void log_write (hcl_client_t* client, hcl_bitmask_t mask, const hcl_ooch_
now = time(NULL); now = time(NULL);
tmp = localtime_r (&now, &tm); #if defined(__OS2__)
#if defined(HAVE_STRFTIME_SMALL_Z) 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); 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); tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
#endif #endif
if (tslen == 0) if (tslen == 0)
{ {
strcpy (ts, "0000-00-00 00:00:00 +0000"); strcpy (ts, "0000-00-00 00:00:00 +0000");

View File

@ -187,12 +187,18 @@ static void log_write (hcl_json_t* json, hcl_bitmask_t mask, const hcl_ooch_t* m
now = time(NULL); now = time(NULL);
tmp = localtime_r (&now, &tm); #if defined(__OS2__)
#if defined(HAVE_STRFTIME_SMALL_Z) 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); 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); tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
#endif #endif
if (tslen == 0) if (tslen == 0)
{ {
strcpy (ts, "0000-00-00 00:00:00 +0000"); strcpy (ts, "0000-00-00 00:00:00 +0000");

View File

@ -230,12 +230,18 @@ static void log_write (hcl_server_t* server, hcl_oow_t wid, hcl_bitmask_t mask,
now = time(NULL); now = time(NULL);
tmp = localtime_r (&now, &tm); #if defined(__OS2__)
#if defined(HAVE_STRFTIME_SMALL_Z) 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); 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); tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
#endif #endif
if (tslen == 0) if (tslen == 0)
{ {
strcpy (ts, "0000-00-00 00:00:00 +0000"); strcpy (ts, "0000-00-00 00:00:00 +0000");

View File

@ -698,7 +698,13 @@ static void log_write (hcl_t* hcl, hcl_bitmask_t mask, const hcl_ooch_t* msg, hc
tslen = 20; tslen = 20;
} }
#else #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) #if defined(HAVE_STRFTIME_SMALL_Z)
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp); tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
#else #else
@ -1662,8 +1668,10 @@ static void cancel_tick (void)
typedef void(*signal_handler_t)(int); typedef void(*signal_handler_t)(int);
#elif defined(macintosh) #elif defined(macintosh)
typedef void(*signal_handler_t)(int); /* TODO: */ typedef void(*signal_handler_t)(int); /* TODO: */
#else #elif defined(SA_SIGINFO)
typedef void(*signal_handler_t)(int, siginfo_t*, void*); typedef void(*signal_handler_t)(int, siginfo_t*, void*);
#else
typedef void(*signal_handler_t)(int);
#endif #endif
@ -1674,11 +1682,16 @@ static void handle_sigint (int sig)
} }
#elif defined(macintosh) #elif defined(macintosh)
/* TODO */ /* TODO */
#else #elif defined(SA_SIGINFO)
static void handle_sigint (int sig, siginfo_t* siginfo, void* ctx) static void handle_sigint (int sig, siginfo_t* siginfo, void* ctx)
{ {
if (g_hcl) hcl_abort (g_hcl); if (g_hcl) hcl_abort (g_hcl);
} }
#else
static void handle_sigint (int sig)
{
if (g_hcl) hcl_abort (g_hcl);
}
#endif #endif
static void set_signal (int sig, signal_handler_t handler) 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)); memset (&sa, 0, sizeof(sa));
/*sa.sa_handler = handler;*/ /*sa.sa_handler = handler;*/
#if defined(SA_SIGINFO)
sa.sa_flags = SA_SIGINFO; sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = handler; sa.sa_sigaction = handler;
#else
sa.sa_handler = handler;
#endif
sigemptyset (&sa.sa_mask); sigemptyset (&sa.sa_mask);
sigaction (sig, &sa, NULL); sigaction (sig, &sa, NULL);