Navigation Menu

Skip to content

Commit

Permalink
windows: check "64" version
Browse files Browse the repository at this point in the history
Because localtime_s() and gmtime_s() are inline functions. So we need to
include time.h to use them. But we don't have a way to check function
with including header file.
  • Loading branch information
kou committed Jan 30, 2015
1 parent a3d2669 commit a29eee1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions build/ac_macros/check_functions.m4
Expand Up @@ -4,9 +4,9 @@ AC_CHECK_FUNCS(_stricmp)
AC_CHECK_FUNCS(_strnicmp)
AC_CHECK_FUNCS(_strtoui64)
AC_CHECK_FUNCS(close)
AC_CHECK_FUNCS(gmtime_s)
AC_CHECK_FUNCS(gmtime64_s)
AC_CHECK_FUNCS(gmtime_r)
AC_CHECK_FUNCS(localtime_s)
AC_CHECK_FUNCS(localtime64_s)
AC_CHECK_FUNCS(localtime_r)
AC_CHECK_FUNCS(mkostemp)
AC_CHECK_FUNCS(open)
Expand Down
4 changes: 2 additions & 2 deletions config.h.cmake
Expand Up @@ -141,9 +141,9 @@
#cmakedefine HAVE_CLOCK_GETTIME
#cmakedefine HAVE_CLOSE
#cmakedefine HAVE_FPCLASSIFY
#cmakedefine HAVE_GMTIME_S
#cmakedefine HAVE_GMTIME64_S
#cmakedefine HAVE_GMTIME_R
#cmakedefine HAVE_LOCALTIME_S
#cmakedefine HAVE_LOCALTIME64_S
#cmakedefine HAVE_LOCALTIME_R
#cmakedefine HAVE_MKOSTEMP
#cmakedefine HAVE_OPEN
Expand Down
6 changes: 3 additions & 3 deletions lib/ctx.c
Expand Up @@ -134,12 +134,12 @@ grn_timeval2str(grn_ctx *ctx, grn_timeval *tv, char *buf)
{
struct tm *ltm;
const char *function_name;
#ifdef HAVE_LOCALTIME_S
#ifdef HAVE_LOCALTIME64_S
struct tm tm;
time_t t = tv->tv_sec;
function_name = "localtime_s";
ltm = (localtime_s(&tm, &t) == 0) ? &tm : NULL;
#else /* HAVE_LOCALTIME_S */
#else /* HAVE_LOCALTIME64_S */
# ifdef HAVE_LOCALTIME_R
struct tm tm;
time_t t = tv->tv_sec;
Expand All @@ -150,7 +150,7 @@ grn_timeval2str(grn_ctx *ctx, grn_timeval *tv, char *buf)
function_name = "localtime";
ltm = localtime(&tvsec);
# endif /* HAVE_LOCALTIME_R */
#endif /* HAVE_LOCALTIME_S */
#endif /* HAVE_LOCALTIME64_S */
if (!ltm) { SERR(function_name); }
snprintf(buf, GRN_TIMEVAL_STR_SIZE - 1, GRN_TIMEVAL_STR_FORMAT,
ltm->tm_year + 1900, ltm->tm_mon + 1, ltm->tm_mday,
Expand Down
2 changes: 1 addition & 1 deletion lib/str.c
Expand Up @@ -2441,7 +2441,7 @@ grn_text_time2rfc1123(grn_ctx *ctx, grn_obj *bulk, int sec)
{
time_t tsec;
struct tm *t;
#ifdef HAVE_GMTIME_S
#ifdef HAVE_GMTIME64_S
struct tm tm;
tsec = (time_t)sec;
t = (gmtime_s(&tm, &tsec) == 0) ? &tm : NULL;
Expand Down

0 comments on commit a29eee1

Please sign in to comment.