Commit 72ba4cfb authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Use -lldap_r instead of -lldap -lthread.

	Likely broke things for non-posix threadings....

Update -lldap_r implementation to:
	remove attribute support
	hide thread detachment
	provide concurrency accessors
	provide initialization function
	fix gethostby{addr,name}_r codes (not coverred by HAVE_REENTRANT_FUNCTIONS)
Update servers/libraries to use ldap_pvt_thread_ calls.
Cleanup server codes (no #ifdef HAVE_PTHREAD_THIS or _THATs)!
Removed -llthread
parent ae0df6f8
This diff is collapsed.
......@@ -618,30 +618,28 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
if test $ac_cv_func_sched_yield = no -a \
$ac_cv_func_pthread_yield = no ; then
dnl Solaris has sched_yield() in -lposix4
AC_CHECK_LIB(posix4, sched_yield,
[LTHREAD_LIBS="$LTHREAD_LIBS -lposix4"
AC_DEFINE(HAVE_SCHED_YIELD,1)
ac_cv_func_sched_yield=yes],
[ac_cv_func_sched_yield=no])
dnl but we'll use thr_yield instead.
AC_CHECK_FUNCS(thr_yield)
fi
if test $ac_cv_func_sched_yield = no -a \
$ac_cv_func_pthread_yield = no ; then
$ac_cv_func_pthread_yield = no -a \
"$ac_cv_func_thr_yield" = no ; then
AC_MSG_WARN([could not locate sched_yield() or pthread_yield()])
fi
dnl Check functions for compatibility
AC_CHECK_FUNCS(pthread_kill pthread_detach)
AC_CHECK_FUNCS( \
pthread_attr_create pthread_attr_init \
pthread_attr_destroy pthread_attr_delete \
pthread_attr_setdetachstate pthread_attr_setdetach_np \
)
if test $ac_cv_func_pthread_detach = no ; then
AC_MSG_ERROR([could not locate pthread_detach()])
fi
dnl Check for setconcurreny functions
AC_CHECK_FUNCS( \
pthread_setconcurrency \
pthread_getconcurrency \
thr_setconcurrency \
thr_getconcurrency \
)
AC_MSG_CHECKING([if pthread_create() works])
......@@ -834,21 +832,11 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
ol_with_yielding_select=yes
fi
AC_CACHE_CHECK([for misplaced posix thread in headers],
[ol_cv_header_misplaced_pthreads], [
AC_TRY_COMPILE([
#include <sys/types.h>
typedef double pthread_t;
], [
pthread_t thread = 0.0;
],
[ol_cv_header_misplaced_pthreads=no],
[ol_cv_header_misplaced_pthreads=yes])
])
if test "$ol_cv_header_misplaced_pthreads" = yes ; then
AC_MSG_ERROR([pthread types are misplaced, use --with-threads=posix]);
fi
dnl Check for setconcurreny functions
AC_CHECK_FUNCS( \
thr_setconcurrency \
thr_getconcurrency \
)
fi
fi
......@@ -983,22 +971,6 @@ if test $ol_link_threads = no ; then
ol_with_threads=no
fi
AC_CACHE_CHECK([for misplaced posix thread in headers],
[ol_cv_header_misplaced_pthreads], [
AC_TRY_COMPILE([
#include <sys/types.h>
typedef double pthread_t;
], [
pthread_t thread = 0.0;
],
[ol_cv_header_misplaced_pthreads=no],
[ol_cv_header_misplaced_pthreads=yes])
])
if test "$ol_cv_header_misplaced_pthreads" = yes ; then
AC_MSG_ERROR([pthread types are misplaced, use --with-threads=posix]);
fi
AC_DEFINE(NO_THREADS,1)
LTHREAD_LIBS=""
fi
......@@ -1479,7 +1451,6 @@ libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib.
libraries/libldap_r/Makefile:build/top.mk:libraries/libldap_r/Makefile.in:build/lib.mk:build/lib-shared.mk \
libraries/libldbm/Makefile:build/top.mk:libraries/libldbm/Makefile.in:build/lib.mk:build/lib-static.mk \
libraries/libldif/Makefile:build/top.mk:libraries/libldif/Makefile.in:build/lib.mk:build/lib-static.mk \
libraries/liblthread/Makefile:build/top.mk:libraries/liblthread/Makefile.in:build/lib.mk:build/lib-static.mk \
libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk:build/lib-static.mk \
servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \
servers/ldapd/Makefile:build/top.mk:servers/ldapd/Makefile.in:build/srv.mk \
......
......@@ -15,9 +15,13 @@
#include <ldap_cdefs.h>
LDAP_BEGIN_DECL
extern char *optarg;
extern int optind, opterr, optopt;
LDAP_F int getopt LDAP_P((int, char * const [], const char *));
LDAP_END_DECL
#endif /* _GETOPT_COMPAT_H */
......@@ -21,22 +21,22 @@ LDAP_BEGIN_DECL
struct hostent; /* avoid pulling in <netdb.h> */
extern char *ldap_pvt_ctime( const time_t *tp, char *buf );
extern int ldap_pvt_gethostbyname_a(
LDAP_F char *ldap_pvt_ctime LDAP_P(( const time_t *tp, char *buf ));
LDAP_F int ldap_pvt_gethostbyname_a LDAP_P((
const char *name,
struct hostent *resbuf,
char **buf,
struct hostent **result,
int *herrno_ptr );
extern int ldap_pvt_gethostbyaddr_a(
int *herrno_ptr ));
LDAP_F int ldap_pvt_gethostbyaddr_a LDAP_P((
const char *addr,
int len,
int type,
struct hostent *resbuf,
char **buf,
struct hostent **result,
int *herrno_ptr );
extern void ldap_pvt_init_utils( void );
int *herrno_ptr ));
LDAP_F void ldap_pvt_init_utils LDAP_P(( void ));
LDAP_END_DECL
......
......@@ -29,14 +29,8 @@
LDAP_BEGIN_DECL
typedef pthread_t ldap_pvt_thread_t;
typedef pthread_attr_t ldap_pvt_thread_attr_t;
typedef pthread_mutex_t ldap_pvt_thread_mutex_t;
typedef pthread_mutexattr_t ldap_pvt_thread_mutexattr_t;
typedef pthread_cond_t ldap_pvt_thread_cond_t;
typedef pthread_condattr_t ldap_pvt_thread_condattr_t;
#define LDAP_PVT_THREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
#define LDAP_PVT_THREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
#if defined( _POSIX_REENTRANT_FUNCTIONS ) || \
defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \
......@@ -44,6 +38,16 @@ typedef pthread_condattr_t ldap_pvt_thread_condattr_t;
#define HAVE_REENTRANT_FUNCTIONS 1
#endif
#if defined( HAVE_PTHREAD_GETCONCURRENCY ) || \
defined( HAVE_THR_GETCONCURRENCY )
#define HAVE_GETCONCURRENCY 1
#endif
#if defined( HAVE_PTHREAD_SETCONCURRENCY ) || \
defined( HAVE_THR_SETCONCURRENCY )
#define HAVE_SETCONCURRENCY 1
#endif
LDAP_END_DECL
#elif defined ( HAVE_MACH_CTHREADS )
......@@ -58,23 +62,17 @@ LDAP_END_DECL
LDAP_BEGIN_DECL
typedef cthread_t ldap_pvt_thread_t;
typedef int ldap_pvt_thread_attr_t;
typedef struct mutex ldap_pvt_thread_mutex_t;
typedef int ldap_pvt_thread_mutexattr_t;
typedef struct condition ldap_pvt_thread_cond_t;
typedef int ldap_pvt_thread_condattr_t;
#define LDAP_PVT_THREAD_CREATE_DETACHED 1
#define LDAP_PVT_THREAD_CREATE_JOINABLE 0
LDAP_END_DECL
#elif defined( HAVE_THR )
/**************************************
* *
* thread definitions for Solaris LWP *
* *
**************************************/
/********************************************
* *
* thread definitions for Solaris LWP (THR) *
* *
********************************************/
#include <thread.h>
#include <synch.h>
......@@ -82,17 +80,18 @@ LDAP_END_DECL
LDAP_BEGIN_DECL
typedef thread_t ldap_pvt_thread_t;
typedef int ldap_pvt_thread_attr_t;
typedef mutex_t ldap_pvt_thread_mutex_t;
typedef int ldap_pvt_thread_mutexattr_t;
typedef cond_t ldap_pvt_thread_cond_t;
typedef int ldap_pvt_thread_condattr_t;
#define LDAP_PVT_THREAD_CREATE_DETACHED THR_DETACHED
#define LDAP_PVT_THREAD_CREATE_JOINABLE 0
#define HAVE_REENTRANT_FUNCTIONS 1
#ifdef HAVE_THR_GETCONCURRENCY
#define HAVE_GETCONCURRENCY 1
#endif
#ifdef HAVE_THR_SETCONCURRENCY
#define HAVE_SETCONCURRENCY 1
#endif
LDAP_END_DECL
#elif defined( HAVE_LWP )
......@@ -108,24 +107,15 @@ LDAP_END_DECL
LDAP_BEGIN_DECL
typedef thread_t ldap_pvt_thread_t;
typedef int ldap_pvt_thread_attr_t;
typedef mon_t ldap_pvt_thread_mutex_t;
typedef int ldap_pvt_thread_mutexattr_t;
struct lwpcv {
int lcv_created;
cv_t lcv_cv;
};
typedef struct lwpcv ldap_pvt_thread_cond_t;
typedef int ldap_pvt_thread_condattr_t;
#define LDAP_PVT_THREAD_CREATE_DETACHED 1
#define LDAP_PVT_THREAD_CREATE_JOINABLE 0
#define HAVE_REENTRANT_FUNCTIONS 1
stkalign_t *ldap_pvt_thread_get_stack( int *stacknop );
void ldap_pvt_thread_free_stack( int *stackno );
LDAP_END_DECL
#elif HAVE_NT_THREADS
......@@ -136,14 +126,8 @@ LDAP_END_DECL
LDAP_BEGIN_DECL
typedef HANDLE ldap_pvt_thread_t;
typedef int ldap_pvt_thread_attr_t;
typedef HANDLE ldap_pvt_thread_mutex_t;
typedef int ldap_pvt_thread_mutexattr_t;
typedef HANDLE ldap_pvt_thread_cond_t;
typedef int ldap_pvt_thread_condattr_t;
#define LDAP_PVT_THREAD_CREATE_DETACHED 0
#define LDAP_PVT_THREAD_CREATE_JOINABLE 0
LDAP_END_DECL
......@@ -163,14 +147,8 @@ LDAP_BEGIN_DECL
#endif
typedef int ldap_pvt_thread_t;
typedef int ldap_pvt_thread_attr_t;
typedef int ldap_pvt_thread_mutex_t;
typedef int ldap_pvt_thread_mutexattr_t;
typedef int ldap_pvt_thread_cond_t;
typedef int ldap_pvt_thread_condattr_t;
#define LDAP_PVT_THREAD_CREATE_DETACHED 0
#define LDAP_PVT_THREAD_CREATE_JOINABLE 0
LDAP_END_DECL
......@@ -178,22 +156,42 @@ LDAP_END_DECL
#ifndef NO_THREADS
# define HAVE_THREADS 1
#endif
LDAP_BEGIN_DECL
LDAP_F int
ldap_pvt_thread_initialize LDAP_P(( void ));
LDAP_F unsigned int
ldap_pvt_thread_sleep LDAP_P(( unsigned int s ));
#ifdef HAVE_GETCONCURRENCY
LDAP_F int
ldap_pvt_thread_getconcurrency LDAP_P(( void ));
#endif
#ifdef HAVE_SETCONCURRENCY
# ifndef LDAP_THREAD_CONCURRENCY
/* three concurrent threads should be enough */
# define LDAP_THREAD_CONCURRENCY 3
# endif
LDAP_F int
ldap_pvt_thread_setconcurrency LDAP_P(( int ));
#endif
LDAP_F int
ldap_pvt_thread_create LDAP_P(( ldap_pvt_thread_t * thread,
ldap_pvt_thread_attr_t *attr,
void *(*start_routine)( void *),
void *arg));
ldap_pvt_thread_create LDAP_P((
ldap_pvt_thread_t * thread,
int detach,
void *(*start_routine)( void * ),
void *arg));
LDAP_F void
ldap_pvt_thread_exit LDAP_P(( void *retval ));
LDAP_F int
ldap_pvt_thread_join LDAP_P(( ldap_pvt_thread_t thread,
void **thread_return ));
ldap_pvt_thread_join LDAP_P(( ldap_pvt_thread_t thread, void **status ));
LDAP_F int
ldap_pvt_thread_kill LDAP_P(( ldap_pvt_thread_t thread, int signo ));
......@@ -202,18 +200,7 @@ LDAP_F int
ldap_pvt_thread_yield LDAP_P(( void ));
LDAP_F int
ldap_pvt_thread_attr_init LDAP_P(( ldap_pvt_thread_attr_t *attr ));
LDAP_F int
ldap_pvt_thread_attr_destroy LDAP_P(( ldap_pvt_thread_attr_t *attr ));
LDAP_F int
ldap_pvt_thread_attr_setdetachstate LDAP_P(( ldap_pvt_thread_attr_t *attr,
int dstate ));
LDAP_F int
ldap_pvt_thread_cond_init LDAP_P(( ldap_pvt_thread_cond_t *cond,
ldap_pvt_thread_condattr_t *attr ));
ldap_pvt_thread_cond_init LDAP_P(( ldap_pvt_thread_cond_t *cond ));
LDAP_F int
ldap_pvt_thread_cond_signal LDAP_P(( ldap_pvt_thread_cond_t *cond ));
......@@ -222,12 +209,12 @@ LDAP_F int
ldap_pvt_thread_cond_broadcast LDAP_P(( ldap_pvt_thread_cond_t *cond ));
LDAP_F int
ldap_pvt_thread_cond_wait LDAP_P(( ldap_pvt_thread_cond_t *cond,
ldap_pvt_thread_mutex_t *mutex ));
ldap_pvt_thread_cond_wait LDAP_P((
ldap_pvt_thread_cond_t *cond,
ldap_pvt_thread_mutex_t *mutex ));
LDAP_F int
ldap_pvt_thread_mutex_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex,
ldap_pvt_thread_mutexattr_t *attr ));
ldap_pvt_thread_mutex_init LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
LDAP_F int
ldap_pvt_thread_mutex_destroy LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
......@@ -235,21 +222,24 @@ ldap_pvt_thread_mutex_destroy LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
LDAP_F int
ldap_pvt_thread_mutex_lock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
LDAP_F int
ldap_pvt_thread_mutex_trylock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
LDAP_F int
ldap_pvt_thread_mutex_unlock LDAP_P(( ldap_pvt_thread_mutex_t *mutex ));
typedef struct ldap_pvt_thread_rdwr_var {
int readers_reading;
int writer_writing;
ldap_pvt_thread_mutex_t mutex;
ldap_pvt_thread_cond_t lock_free;
int lt_readers_reading;
int lt_writer_writing;
ldap_pvt_thread_mutex_t lt_mutex;
ldap_pvt_thread_cond_t lt_lock_free;
} ldap_pvt_thread_rdwr_t;
typedef void * ldap_pvt_thread_rdwrattr_t;
#define LDAP_PVT_THREAD_CREATE_DETACHED 1
#define LDAP_PVT_THREAD_CREATE_JOINABLE 0
LDAP_F int
ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp,
ldap_pvt_thread_rdwrattr_t *attrp));
ldap_pvt_thread_rdwr_init LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F int
ldap_pvt_thread_rdwr_rlock LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
LDAP_F int
......
......@@ -37,12 +37,16 @@
#endif
LDAP_BEGIN_DECL
typedef DBT Datum;
#define dsize size
#define dptr data
typedef DB *LDBM;
LDAP_END_DECL
#define DB_TYPE DB_BTREE
/* for ldbm_open */
......@@ -90,12 +94,16 @@ typedef DB *LDBM;
# endif
#endif
LDAP_BEGIN_DECL
typedef DBT Datum;
#define dsize size
#define dptr data
typedef DB *LDBM;
LDAP_END_DECL
#define DB_TYPE DB_HASH
/* for ldbm_open */
......@@ -129,12 +137,16 @@ typedef DB *LDBM;
#include <gdbm.h>
LDAP_BEGIN_DECL
typedef datum Datum;
typedef GDBM_FILE LDBM;
extern gdbm_error gdbm_errno;
LDAP_END_DECL
/* for ldbm_open */
#define LDBM_READER GDBM_READER
#define LDBM_WRITER GDBM_WRITER
......@@ -164,10 +176,14 @@ extern gdbm_error gdbm_errno;
#include <fcntl.h>
#endif
LDAP_BEGIN_DECL
typedef datum Datum;
typedef DBM *LDBM;
LDAP_END_DECL
/* for ldbm_open */
#define LDBM_READER O_RDONLY
#define LDBM_WRITER O_WRONLY
......
......@@ -47,10 +47,17 @@ extern int ldif_debug;
((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
+ ((LDIF_BASE64_LEN(vlen) + (tlen) + 3) / LINE_WIDTH * 2 ))
int ldif_parse_line LDAP_P(( char *line, char **type, char **value, int *vlen));
char * ldif_getline LDAP_P(( char **next ));
void ldif_put_type_and_value LDAP_P(( char **out, char *t, char *val, int vlen ));
char *ldif_type_and_value LDAP_P(( char *type, char *val, int vlen ));
LDAP_F int
ldif_parse_line LDAP_P(( char *line, char **type, char **value, int *vlen));
LDAP_F char *
ldif_getline LDAP_P(( char **next ));
LDAP_F void
ldif_put_type_and_value LDAP_P(( char **out, char *t, char *val, int vlen ));
LDAP_F char
*ldif_type_and_value LDAP_P(( char *type, char *val, int vlen ));
LDAP_END_DECL
......
/*
* Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted only
* as authorized by the OpenLDAP Public License. A copy of this
* license is available at http://www.OpenLDAP.org/license.html or
* in file LICENSE in the top-level directory of the distribution.
*/
/* lthread.h - ldap threads header file */
#ifndef _LTHREAD_H
#define _LTHREAD_H
#include "portable.h"
#if defined( HAVE_PTHREADS )
/**********************************
* *
* definitions for POSIX Threads *
* *
**********************************/
#include <pthread.h>
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif
LDAP_BEGIN_DECL
#if defined( _POSIX_REENTRANT_FUNCTIONS ) || \
defined( _POSIX_THREAD_SAFE_FUNCTIONS ) || \
defined( _POSIX_THREADSAFE_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 )
#endif
#if !defined( HAVE_PTHREAD_ATTR_DESTROY ) && \
defined( HAVE_PTHREAD_ATTR_DELETE )
#define pthread_attr_destroy( a ) pthread_attr_delete( a )
#endif
#if !defined( HAVE_PTHREAD_ATTR_SETDETACHSTATE ) && \
defined( HAVE_PTHREAD_ATTR_SETDETACH_NP )
#define pthread_attr_setdetachstate( a, b ) \
pthread_attr_setdetach_np( a, b )
#endif
#ifndef HAVE_PTHREAD_KILL
/* missing pthread_kill(), define prototype */
LDAP_F void pthread_kill LDAP_P(( pthread_t tid, int sig ));
#endif
#ifndef HAVE_PTHREADS_D4
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
#ifdef HAVE_SCHED_YIELD
#define pthread_yield sched_yield
#endif
#endif
LDAP_END_DECL
#elif defined ( HAVE_MACH_CTHREADS )
/**********************************
* *
* definitions for Mach CThreads *
* *
**********************************/
#include <mach/cthreads.h>
LDAP_BEGIN_DECL
typedef cthread_fn_t VFP;
typedef int pthread_attr_t;
typedef cthread_t pthread_t;
/* default attr states */
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
/* thread state - joinable or not */
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED 1
/* thread scope - who is in scheduling pool */
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM 1
/* mutex attributes and mutex type */
typedef int pthread_mutexattr_t;
typedef struct mutex pthread_mutex_t;
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE 0
#define PTHREAD_SHARE_PROCESS 1
/* condition variable attributes and condition variable type */
typedef int pthread_condattr_t;
typedef struct condition pthread_cond_t;
LDAP_END_DECL
#elif defined( HAVE_THR )
/**************************************
* *
* thread definitions for Solaris LWP *
* *
**************************************/
#include <thread.h>
#include <synch.h>
LDAP_BEGIN_DECL
#define HAVE_REENTRANT_FUNCTIONS 1
typedef void *(*VFP)();
/* default attr states */
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
/* thread state - joinable or not */
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED THR_DETACHED
/* thread scope - who is in scheduling pool */
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM THR_BOUND
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE USYNC_THREAD
#define PTHREAD_SHARE_PROCESS USYNC_PROCESS
/* thread attributes and thread type */
typedef int pthread_attr_t;
typedef thread_t pthread_t;
/* mutex attributes and mutex type */
typedef int pthread_mutexattr_t;
typedef mutex_t pthread_mutex_t;
/* condition variable attributes and condition variable type */
typedef int pthread_condattr_t;
typedef cond_t pthread_cond_t;
LDAP_END_DECL
#elif defined( HAVE_LWP )
/*************************************
* *
* thread definitions for SunOS LWP *
* *
*************************************/
#include <lwp/lwp.h>