Skip to content

Commit

Permalink
Add localtime_r() declaration in case it isn't available
Browse files Browse the repository at this point in the history
  • Loading branch information
rockdaboot committed Feb 11, 2024
1 parent 941f402 commit c98f305
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ AC_SUBST(PSL_TESTFILE)

AC_CHECK_FUNCS([strdup strndup clock_gettime fmemopen nl_langinfo])
AC_CHECK_DECLS([strdup])
AC_CHECK_DECLS([localtime_r])

# check for dirent.h
AC_HEADER_DIRENT
Expand Down
8 changes: 6 additions & 2 deletions tools/psl.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@

// Windows does not have localtime_r but has localtime_s, which is more or less
// the same except that the arguments are reversed
# define LOCALTIME_R_SUCCESSFUL(t_sec,t_now) \
# define LOCALTIME_R_SUCCESSFUL(t_sec, t_now) \
(localtime_s(t_now, t_sec) == 0)
#else
# include <time.h>
# define LOCALTIME_R_SUCCESSFUL(t_sec,t_now) \
# if ! HAVE_DECL_LOCALTIME_R
struct tm *localtime_r(const time_t *, struct tm *);
#endif

# define LOCALTIME_R_SUCCESSFUL(t_sec, t_now) \
(localtime_r(t_sec, t_now) != NULL)
#endif

Expand Down

0 comments on commit c98f305

Please sign in to comment.