From: Bart Hartgers Date: Sat, 2 Jan 1999 00:56:45 +0000 (+0000) Subject: Teached autoconf to figure out how may arguments ctime_r expects. X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~821 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f9d26dacd4e3a41ed1de9564d57caec909a20869;p=openldap Teached autoconf to figure out how may arguments ctime_r expects. Updated util-int.c to use this information. --- diff --git a/aclocal.m4 b/aclocal.m4 index 73203f1438..bdb05477ee 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -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_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_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 +]) + + + diff --git a/configure.in b/configure.in index 349b82b08a..955271f7be 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/include/portable.h.in b/include/portable.h.in index 93e1f80819..a4a67bd71a 100644 --- a/include/portable.h.in +++ b/include/portable.h.in @@ -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 diff --git a/libraries/libldap/util-int.c b/libraries/libldap/util-int.c index 375747bfe0..3ace0c799b 100644 --- a/libraries/libldap/util-int.c +++ b/libraries/libldap/util-int.c @@ -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