Skip to content
Snippets Groups Projects
Commit f9d26dac authored by Bart Hartgers's avatar Bart Hartgers
Browse files

Teached autoconf to figure out how may arguments ctime_r expects.
Updated util-int.c to use this information.
parent 4219a94c
No related branches found
No related tags found
No related merge requests found
......@@ -506,3 +506,28 @@ AC_DEFUN(AM_TYPE_PTRDIFF_T,
fi
])
dnl check arguments for ctime_r - Bart Hartgers
# serial 1
AC_DEFUN(OL_NARGS_CTIME_R,
[AC_MSG_CHECKING([number of args for ctime_r])
AC_TRY_COMPILE([#include <time.h>],
[time_t ti; char *buffer;
ctime_r(&ti,buffer,32);],ol_nargs_ctime_r=3,
ol_nargs_ctime_r=0)
if test $ol_nargs_ctime_r = 0 ; then
AC_TRY_COMPILE([#include <time.h>],
[time_t ti; char *buffer;
ctime_r(&ti,buffer);],ol_nargs_ctime_r=2 )
fi
AC_MSG_RESULT($ol_nargs_ctime_r)
if test $ol_nargs_ctime_r = 2 ; then
AC_DEFINE( ARGS_CTIME_R_2 )
fi
if test $ol_nargs_ctime_r = 3 ; then
AC_DEFINE( ARGS_CTIME_R_3 )
fi
])
......@@ -1232,6 +1232,8 @@ if test $ac_cv_func_strtok_r = yes \
AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_REENTRANT, 1)
fi
OL_NARGS_CTIME_R
if test $ol_link_threads != no ; then
AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE, 1)
fi
......
......@@ -274,6 +274,12 @@
/* Define if you have the ctime_r function. */
#undef HAVE_CTIME_R
/* Define if ctime_r takes two arguments */
#undef ARGS_CTIME_R_2
/* Define if ctime_r takes three arguments */
#undef ARGS_CTIME_R_3
/* Define if you have the flock function. */
#undef HAVE_FLOCK
......
......@@ -42,7 +42,13 @@ char *ldap_int_strtok( char *str, const char *delim, char **pos )
char *ldap_int_ctime( const time_t *tp, char *buf )
{
#ifdef HAVE_CTIME_R
# if defined( ARGS_CTIME_R_2 )
return ctime_r(tp,buf);
# elif defined( ARGS_CTIME_R_3 )
return ctime_r(tp,buf,26);
# else
Do not know how many arguments ctime_r takes, so generating error
# endif
#else
return ctime(tp);
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment