mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-02-17 14:00:30 +08:00
Update ctime_r() argument macro to cache results and to produce
one preprocessor macro instead of two. Ran aclocal, autoconf, autoheader to update derived files. Modify util-int.c to use CTIME_R_NARGS define and fallback to ctime() if not set. Made LDAP_API_FEATURE_X_OPENLDAP_REENTRANT dependent upon result.
This commit is contained in:
parent
60b6d7185c
commit
114a0cd339
@ -25,6 +25,9 @@
|
||||
/* define this if toupper() requires tolower() check */
|
||||
#undef C_UPPER_LOWER
|
||||
|
||||
/* define this to the number of arguments ctime_r() expects
|
||||
#undef CTIME_R_NARGS
|
||||
|
||||
/* define this if sys_errlist is not defined in stdio.h or errno.h */
|
||||
#undef DECL_SYS_ERRLIST
|
||||
|
||||
|
27
aclocal.m4
vendored
27
aclocal.m4
vendored
@ -10,6 +10,8 @@ dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
dnl PARTICULAR PURPOSE.
|
||||
|
||||
dnl Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
|
||||
dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file
|
||||
dnl
|
||||
dnl OpenLDAP Autoconf Macros
|
||||
dnl
|
||||
@ -506,28 +508,3 @@ 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
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
@ -427,23 +427,20 @@ AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
|
||||
|
||||
dnl ====================================================================
|
||||
dnl check no of arguments for ctime_r
|
||||
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 )
|
||||
AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
|
||||
[AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
|
||||
[AC_TRY_COMPILE([#include <time.h>],
|
||||
[time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
|
||||
ol_cv_func_ctime_r_nargs=3, ol_cv_func_ctime_r_nargs=0)
|
||||
if test $ol_cv_func_ctime_r_nargs = 0 ; then
|
||||
AC_TRY_COMPILE([#include <time.h>],
|
||||
[time_t ti; char *buffer;
|
||||
ctime_r(&ti,buffer);],
|
||||
ol_cv_func_ctime_r_nargs=2, ol_cv_func_ctime_r_nargs=0)
|
||||
fi
|
||||
])
|
||||
if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
|
||||
AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs)
|
||||
fi
|
||||
])dnl
|
||||
|
||||
|
75
configure
vendored
75
configure
vendored
@ -8191,8 +8191,65 @@ fi
|
||||
done
|
||||
|
||||
|
||||
echo $ac_n "checking number of arguments of ctime_r""... $ac_c" 1>&6
|
||||
echo "configure:8196: checking number of arguments of ctime_r" >&5
|
||||
if eval "test \"`echo '$''{'ol_cv_func_ctime_r_nargs'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 8201 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <time.h>
|
||||
int main() {
|
||||
time_t ti; char *buffer; ctime_r(&ti,buffer,32);
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:8208: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ol_cv_func_ctime_r_nargs=3
|
||||
else
|
||||
echo "configure: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
rm -rf conftest*
|
||||
ol_cv_func_ctime_r_nargs=0
|
||||
fi
|
||||
rm -f conftest*
|
||||
if test $ol_cv_func_ctime_r_nargs = 0 ; then
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 8220 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <time.h>
|
||||
int main() {
|
||||
time_t ti; char *buffer;
|
||||
ctime_r(&ti,buffer);
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:8228: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ol_cv_func_ctime_r_nargs=2
|
||||
else
|
||||
echo "configure: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
rm -rf conftest*
|
||||
ol_cv_func_ctime_r_nargs=0
|
||||
fi
|
||||
rm -f conftest*
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ol_cv_func_ctime_r_nargs" 1>&6
|
||||
if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
|
||||
cat >> confdefs.h <<EOF
|
||||
#define CTIME_R_NARGS $ol_cv_func_ctime_r_nargs
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if test $ac_cv_func_strtok_r = yes \
|
||||
-a $ac_cv_func_ctime_r = yes \
|
||||
-a $ol_cv_func_ctime_r_nargs -ge 2 -a $ol_cv_func_ctime_r_nargs -le 3 \
|
||||
-a $ac_cv_func_gethostbyaddr_r = yes \
|
||||
-a $ac_cv_func_gethostbyname_r = yes \
|
||||
; then
|
||||
@ -8213,12 +8270,12 @@ fi
|
||||
for ac_func in getopt strdup tempnam
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:8217: checking for $ac_func" >&5
|
||||
echo "configure:8274: checking for $ac_func" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 8222 "configure"
|
||||
#line 8279 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@ -8241,7 +8298,7 @@ $ac_func();
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:8245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
if { (eval echo configure:8302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
@ -8271,13 +8328,13 @@ done
|
||||
# Check Configuration
|
||||
|
||||
echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6
|
||||
echo "configure:8275: checking declaration of sys_errlist" >&5
|
||||
echo "configure:8332: checking declaration of sys_errlist" >&5
|
||||
if eval "test \"`echo '$''{'ol_cv_dcl_sys_errlist'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 8281 "configure"
|
||||
#line 8338 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@ -8287,7 +8344,7 @@ int main() {
|
||||
char *c = (char *) *sys_errlist
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:8291: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:8348: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ol_cv_dcl_sys_errlist=yes
|
||||
else
|
||||
@ -8308,20 +8365,20 @@ if test $ol_cv_dcl_sys_errlist = no ; then
|
||||
EOF
|
||||
|
||||
echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6
|
||||
echo "configure:8312: checking existence of sys_errlist" >&5
|
||||
echo "configure:8369: checking existence of sys_errlist" >&5
|
||||
if eval "test \"`echo '$''{'ol_cv_have_sys_errlist'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 8318 "configure"
|
||||
#line 8375 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <errno.h>
|
||||
int main() {
|
||||
char *c = (char *) *sys_errlist
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:8325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
if { (eval echo configure:8382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
rm -rf conftest*
|
||||
ol_cv_have_sys_errlist=yes
|
||||
else
|
||||
|
@ -1223,8 +1223,11 @@ AC_CHECK_FUNCS( \
|
||||
gethostbyname_r \
|
||||
)
|
||||
|
||||
OL_FUNC_CTIME_R_NARGS
|
||||
|
||||
if test $ac_cv_func_strtok_r = yes \
|
||||
-a $ac_cv_func_ctime_r = yes \
|
||||
-a $ol_cv_func_ctime_r_nargs -ge 2 -a $ol_cv_func_ctime_r_nargs -le 3 \
|
||||
-a $ac_cv_func_gethostbyaddr_r = yes \
|
||||
-a $ac_cv_func_gethostbyname_r = yes \
|
||||
; then
|
||||
@ -1232,8 +1235,6 @@ 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
|
||||
|
@ -107,6 +107,9 @@
|
||||
/* define this if toupper() requires tolower() check */
|
||||
#undef C_UPPER_LOWER
|
||||
|
||||
/* define this to the number of arguments ctime_r() expects
|
||||
#undef CTIME_R_NARGS
|
||||
|
||||
/* define this if sys_errlist is not defined in stdio.h or errno.h */
|
||||
#undef DECL_SYS_ERRLIST
|
||||
|
||||
@ -274,12 +277,6 @@
|
||||
/* 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
|
||||
|
||||
|
@ -41,13 +41,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 )
|
||||
#if defined( HAVE_CTIME_R ) && defined( CTIME_R_NARGS )
|
||||
# if (CTIME_R_NARGS > 3) || (CTIME_R_NARGS < 2)
|
||||
choke me! nargs should have 2 or 3
|
||||
# elif CTIME_R_NARGS > 2
|
||||
return ctime_r(tp,buf,26);
|
||||
# else
|
||||
Do not know how many arguments ctime_r takes, so generating error
|
||||
return ctime_r(tp,buf);
|
||||
# endif
|
||||
#else
|
||||
return ctime(tp);
|
||||
|
Loading…
Reference in New Issue
Block a user