-lldap_r can now be implemented...
/* These are defined in ldap_features.h */
/*
+ LDAP_API_FEATURE_X_OPENLDAP_REENTRANT
+ LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
*/
clean-common: FORCE
$(RM) $(LIBRARY) ../$(LIBRARY) $(XLIBRARY) \
- $(PROGRAMS) $(XPROGRAMS) $(XSRCS) \
+ $(PROGRAMS) $(XPROGRAMS) $(XSRCS) $(XXSRCS) \
*.o *.lo a.out core version.c .libs/*
depend-common: FORCE
- $(MKDEP) $(DEFS) $(DEFINES) $(SRCS)
+ $(MKDEP) $(DEFS) $(DEFINES) $(SRCS) $(XXSRCS)
lint-local: FORCE
lint5-local: FORCE
for ac_func in \
bcopy \
- ctime_r \
flock \
getdtablesize \
gethostname \
- gethostbyaddr_r gethostbyname_r \
getpwuid \
gettimeofday \
lockf \
strsep \
strstr \
strtok \
- strtok_r \
strtol \
strtoul \
sysconf \
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7816: checking for $ac_func" >&5
+echo "configure:7813: 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 7821 "configure"
+#line 7818 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:7844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7841: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
done
+# these functions are required to build a thread_safe -lldap
+for ac_func in \
+ strtok_r \
+ ctime_r \
+ gethostbyaddr_r \
+ gethostbyname_r \
+
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:7875: 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 7880 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:7903: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+if test $ac_cv_func_strtok_r = yes \
+ -a $ac_cv_func_ctime_r = yes \
+ -a $ac_cv_func_gethostbyaddr_r = yes \
+ -a $ac_cv_func_gethostbyname_r = yes \
+ ; then
+
+ cat >> confdefs.h <<\EOF
+#define LDAP_API_FEATURE_X_OPENLDAP_REENTRANT 1
+EOF
+
+fi
+
+if test $ol_link_threads != no ; then
+ cat >> confdefs.h <<\EOF
+#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1
+EOF
+
+fi
+
for ac_func in getopt strdup tempnam
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7872: checking for $ac_func" >&5
+echo "configure:7950: 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 7877 "configure"
+#line 7955 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:7900: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7978: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
# Check Configuration
echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6
-echo "configure:7930: checking declaration of sys_errlist" >&5
+echo "configure:8008: 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 7936 "configure"
+#line 8014 "configure"
#include "confdefs.h"
#include <stdio.h>
char *c = (char *) *sys_errlist
; return 0; }
EOF
-if { (eval echo configure:7946: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8024: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ol_cv_dcl_sys_errlist=yes
else
EOF
echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6
-echo "configure:7967: checking existence of sys_errlist" >&5
+echo "configure:8045: 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 7973 "configure"
+#line 8051 "configure"
#include "confdefs.h"
#include <errno.h>
int main() {
char *c = (char *) *sys_errlist
; return 0; }
EOF
-if { (eval echo configure:7980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:8058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ol_cv_have_sys_errlist=yes
else
dnl || defined( HAVE_FUNC_R )
dnl func_r(...);
dnl #else
-dnl func(...);
+dnl # if defined( HAVE_THREADS )
+dnl /* lock */
+dnl # endif
+dnl func(...);
+dnl # if defined( HAVE_THREADS )
+dnl /* unlock */
+dnl # endif
dnl #endif
dnl
dnl HAVE_REENTRANT_FUNCTIONS is derived from:
dnl _POSIX_REENTRANT_FUNCTIONS
dnl _POSIX_THREAD_SAFE_FUNCTIONS
dnl _POSIX_THREADSAFE_FUNCTIONS
+dnl
+dnl and is currently defined in lthread.h
+dnl
+dnl HAVE_THREADS is defined by lthread.h iff -UNO_THREADS
+dnl
+dnl libldap/*.c should only include <lthread.h> iff
+dnl LDAP_R_COMPILE is defined. ie:
+dnl #ifdef LDAP_R_COMPILE
+dnl # include LDAP_R_COMPILE
+dnl #endif
+dnl
+dnl LDAP_R_COMIPLE is defined by libldap_r/Makefile.in
+dnl specifically for compiling the threadsafe version of
+dnl the ldap library (-lldap_r).
dnl
dnl dnl check for reentrant/threadsafe functions
dnl dnl
AC_CHECK_FUNCS( \
bcopy \
- ctime_r \
flock \
getdtablesize \
gethostname \
- gethostbyaddr_r gethostbyname_r \
getpwuid \
gettimeofday \
lockf \
strsep \
strstr \
strtok \
- strtok_r \
strtol \
strtoul \
sysconf \
waitpid \
)
+# these functions are required to build a thread_safe -lldap
+AC_CHECK_FUNCS( \
+ strtok_r \
+ ctime_r \
+ gethostbyaddr_r \
+ gethostbyname_r \
+)
+
+if test $ac_cv_func_strtok_r = yes \
+ -a $ac_cv_func_ctime_r = yes \
+ -a $ac_cv_func_gethostbyaddr_r = yes \
+ -a $ac_cv_func_gethostbyname_r = yes \
+ ; then
+
+ AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_REENTRANT, 1)
+fi
+
+if test $ol_link_threads != no ; then
+ AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE, 1)
+fi
+
dnl We actually may need to replace more than this.
AC_REPLACE_FUNCS(getopt strdup tempnam)
/* include LDAP_API_FEATURE defines */
#include <ldap_features.h>
+#if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT ) || \
+ ( defined( LDAP_THREAD_SAFE ) && \
+ defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) )
+ /* -lldap may or may not be thread safe */
+ /* -lldap_r, if available, is always thread safe */
+# define LDAP_API_FEATURE_THREAD_SAFE 1
+#endif
+#if defined( LDAP_THREAD_SAFE ) && \
+ defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE )
+/* #define LDAP_API_FEATURE_SESSION_SAFE 1 */
+/* #define LDAP_API_OPERATION_SESSION_SAFE 1 */
+#endif
+
#define LDAP_COMPAT20
#define LDAP_COMPAT30
#if defined(LDAP_COMPAT20) || defined(LDAP_COMPAT30)
#ifndef _LDAP_FEATURES_H
#define _LDAP_FEATURES_H 1
+/*
+** OpenLDAP reentrancy/thread-safeness should be dynamically
+** checked using ldap_get_option().
+**
+** The -lldap implementation may or may not be:
+** LDAP_API_FEATURE_THREAD_SAFE
+**
+** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_REENTRANT can
+** be used to determine if -lldap is LDAP_API_FEATURE_THREAD_SAFE at
+** compile time.
+**
+** The -lldap_r implementation is always THREAD_SAFE but
+** may also be:
+** LDAP_API_FEATURE_SESSION_THREAD_SAFE
+** LDAP_API_FEATURE_OPERATION_THREAD_SAFE
+**
+** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
+** can be used to determine if -lldap_r is availalbe at compile
+** time. You must define LDAP_THREAD_SAFE if and only if you
+** link with -lldap_r.
+**
+** If you fail to define LDAP_THREAD_SAFE when linking with
+** -lldap_r or define LDAP_THREAD_SAFE when linking with -lldap,
+** provided header definations and declarations may be incorrect.
+**
+*/
+
+/* is -lldap reentrant or not */
+#undef LDAP_API_FEATURE_X_OPENLDAP_REENTRANT
+
+/* is threadsafe version of -lldap (ie: -lldap_r) *available* or not */
+#undef LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
+
/* LDAP v2 DNS */
#undef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
LDAP_BEGIN_DECL
+#if defined( _POSIX_REENTRANT_FUNCTIONS ) || \
+ defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \
+ defined( _POSIX_THREAD_SAFE_FUNCTIONS )
+#define HAVE_REENTRANT_FUNCTIONS 1
+#endif
+
#if !defined( HAVE_PTHREAD_ATTR_INIT ) && \
defined( HAVE_PTHREAD_ATTR_CREATE )
#define pthread_attr_init( a ) pthread_attr_create( a )
LDAP_BEGIN_DECL
+#define HAVE_REENTRANT_FUNCTIONS 1
+
typedef void *(*VFP)();
/* default attr states */
LDAP_BEGIN_DECL
+#define HAVE_REENTRANT_FUNCTIONS 1
+
stkalign_t *get_stack( int *stacknop );
void free_stack( int *stackno );
LDAP_END_DECL
#endif /* no threads support */
+
+#ifndef NO_THREADS
+# define HAVE_THREADS 1
+#endif
+
#endif /* _LTHREAD_H */
/* These are defined in ldap_features.h */
/*
+ LDAP_API_FEATURE_X_OPENLDAP_REENTRANT
+ LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
*/
#ifndef _LDAP_INT_H
#define _LDAP_INT_H 1
+#ifdef LDAP_COMPILING_R
+#define LDAP_THREAD_SAFE 1
+#endif
+
#include "../liblber/lber-int.h"
#include "ldap_log.h"
#include "ldap.h"
-#include <time.h>
-#include <netdb.h>
LDAP_BEGIN_DECL
*
*/
+struct hostent; /* avoid pulling in <netdb.h> */
+
extern char *ldap_int_strtok( char *str, const char *delim, char **pos );
extern char *ldap_int_ctime( const time_t *tp, char *buf );
extern int ldap_int_gethostbyname_a(
#include "ldap-int.h"
static const char* features[] = {
+#ifdef LDAP_API_FEATURE_THREAD_SAFE
+ "THREAD_SAFE",
+#endif
+#ifdef LDAP_API_FEATURE_SESSION_THREAD_SAFE
+ "SESSION_THREAD_SAFE",
+#endif
+#ifdef LDAP_API_FEATURE_OPERATION_THREAD_SAFE
+ "OPERATION_THREAD_SAFE",
+#endif
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_REEENTRANT
+ "X_OPENLDAP_REENTRANT",
+#endif
+#if defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) && \
+ defined( LDAP_THREAD_SAFE )
+ "X_OPENLDAP_THREAD_SAFE",
+#endif
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
"X_OPENLDAP_V2_DNS",
#endif
LIBRARY = libldap_r.la
XLIBRARY = ../libldap_r.a
-XDIR = ../libldap
-XDEFS = -DLDAP_THREAD_SAFE -I$(XDIR)
-
PROGRAMS = apitest ltest ttest
-XSRCS = apitest.c test.c tmpltest.c \
+XXDIR = ../libldap
+XXSRCS = apitest.c test.c tmpltest.c \
bind.c open.c result.c error.c compare.c search.c \
modify.c add.c modrdn.c delete.c abandon.c ufn.c cache.c \
getfilter.c sbind.c kbind.c unbind.c friendly.c cldap.c \
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries
+XDEFS = -DLDAP_R_COMPILE -I$(XXDIR)
LIBS = $(LDAP_LIBPATH) $(LDAP_LIBLDAP) $(LDAP_LIBLBER) $(AC_LIBS)
-.links :
- @for i in $(XSRCS); do \
+.links : FORCE
+ @for i in $(XXSRCS); do \
$(RM) $$i ; \
- $(LN_S) $(XDIR)/$$i . ; \
+ $(LN_S) $(XXDIR)/$$i . ; \
done
touch .links
-$(XSRCS) : .links
+$(XXSRCS) : .links
clean-local: FORCE
- $(RM) .links
+ @$(RM) .links
+
+depend-common: .links
apitest: $(LIBRARY) apitest.o $(LDAP_LIBLBER_DEPEND)
$(LTLINK) $(LDFLAGS) -o $@ apitest.o $(LIBS)