Moved strdup/tempnam to liblutil

This commit is contained in:
Kurt Zeilenga 1998-10-22 01:45:30 +00:00
parent c4b1286fa9
commit 71b34373b7
9 changed files with 456 additions and 501 deletions

360
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -338,7 +338,7 @@ if test $ol_with_threads = auto -o $ol_with_threads = posix ; then
AC_DEFINE(HAVE_DCE)
ol_link_threads=posix
LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc"],,
if test $with_preemptive = auto ; then
if test $ol_with_preemptive = auto ; then
ol_with_preemptive=yes
fi
[-lmach -lexc -lc])
@ -462,6 +462,10 @@ if test $ol_with_threads = auto -o $ol_with_threads = lwp ; then
AC_DEFINE(HAVE_LWP)
AC_DEFINE(HAVE_LWP_THR)
LTHREAD_LIBS="$LTHREAD_LIBS -llwp"
if test $ol_with_preemptive = auto ; then
ol_with_preemptive=yes
fi
fi
fi
@ -474,8 +478,8 @@ if test $ol_with_threads = auto -o $ol_with_threads = lwp ; then
AC_DEFINE(HAVE_LWP)
LTHREAD_LIBS="$LTHREAD_LIBS -llwp"
if test $with_preemptive = auto ; then
with_preemptive=yes
if test $ol_with_preemptive = auto ; then
ol_with_preemptive=no
fi
fi
fi
@ -756,10 +760,11 @@ AC_CHECK_FUNCS( \
strtol \
strtoul \
sysconf \
tempnam \
waitpid \
)
AC_REPLACE_FUNCS(getopt strdup)
AC_REPLACE_FUNCS(getopt strdup tempnam)
dnl ----------------------------------------------------------------
# Check Configuration

View file

@ -5,14 +5,50 @@
#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 ( THREAD_NEXT_CTHREADS )
#if defined( HAVE_DCE )
/* dce threads are preemptive */
#define _THREAD
#define pthread_attr_init( a ) pthread_attr_create( a )
#define pthread_attr_destroy( a ) pthread_attr_delete( a )
#define pthread_attr_setdetachstate( a, b ) \
pthread_attr_setdetach_np( a, b )
#elif !defined(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;
@ -40,18 +76,65 @@ typedef struct mutex pthread_mutex_t;
typedef int pthread_condattr_t;
typedef struct condition pthread_cond_t;
#elif defined( THREAD_SUNOS4_LWP )
/***********************************
* *
* thread definitions for sunos4 *
* *
***********************************/
LDAP_END_DECL
#define _THREAD
#elif defined( HAVE_LWP_THR )
/**************************************
* *
* thread definitions for Solaris LWP *
* *
**************************************/
#include <thread.h>
#include <synch.h>
LDAP_BEGIN_DECL
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
#if !defined(__SunOS_5_6)
/* 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;
#endif /* ! sunos56 */
LDAP_END_DECL
#elif defined( HAVE_LWP )
/*************************************
* *
* thread definitions for SunOS LWP *
* *
*************************************/
#include <lwp/lwp.h>
#include <lwp/stackdep.h>
LDAP_BEGIN_DECL
typedef void *(*VFP)();
/* thread attributes and thread type */
@ -84,110 +167,9 @@ typedef struct lwpcv {
cv_t lcv_cv;
} pthread_cond_t;
#else /* end sunos4 */
LDAP_END_DECL
#if defined( THREAD_SUNOS5_LWP )
/***********************************
* *
* thread definitions for sunos5 *
* *
***********************************/
#define _THREAD
#include <thread.h>
#include <synch.h>
typedef void *(*VFP)();
/* sunos5 threads are preemptive */
#define PTHREAD_PREEMPTIVE 1
#if !defined(__SunOS_5_6)
/* thread attributes and thread type */
typedef int pthread_attr_t;
typedef thread_t pthread_t;
#endif /* ! sunos56 */
/* 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
#if !defined(__SunOS_5_6)
/* mutex attributes and mutex type */
typedef int pthread_mutexattr_t;
typedef mutex_t pthread_mutex_t;
#endif /* ! sunos56 */
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE USYNC_THREAD
#define PTHREAD_SHARE_PROCESS USYNC_PROCESS
#if !defined(__SunOS_5_6)
/* condition variable attributes and condition variable type */
typedef int pthread_condattr_t;
typedef cond_t pthread_cond_t;
#endif /* ! sunos56 */
#else /* end sunos5 */
#if defined( THREAD_MIT_PTHREADS )
/***********************************
* *
* definitions for mit pthreads *
* *
***********************************/
#define _THREAD
#include <pthread.h>
#else /* end mit pthreads */
#if defined( THREAD_DCE_PTHREADS )
/***********************************
* *
* definitions for mit pthreads *
* *
***********************************/
#define _THREAD
#include <pthread.h>
/* dce threads are preemptive */
#define PTHREAD_PREEMPTIVE 1
#define pthread_attr_init( a ) pthread_attr_create( a )
#define pthread_attr_destroy( a ) pthread_attr_delete( a )
#define pthread_attr_setdetachstate( a, b ) \
pthread_attr_setdetach_np( a, b )
#else /* end dce pthreads */
#if defined( POSIX_THREADS )
#define _THREAD
#include <pthread.h>
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
#endif /* posix threads */
#endif /* dce pthreads */
#endif /* mit pthreads */
#endif /* sunos5 */
#endif /* sunos4 */
#ifndef _THREAD
#else
/***********************************
* *
@ -196,6 +178,8 @@ typedef cond_t pthread_cond_t;
* *
***********************************/
LDAP_BEGIN_DECL
typedef void *(*VFP)();
/* thread attributes and thread type */
@ -225,8 +209,7 @@ typedef int pthread_mutex_t;
typedef int pthread_condattr_t;
typedef int pthread_cond_t;
#endif /* no threads support */
LDAP_END_DECL
#endif /* no threads support */
#endif /* _LTHREAD_H */

View file

@ -1,11 +1,28 @@
/* thread.c - glue routines to provide a consistent thread interface */
#define DISABLE_BRIDGE
#include "portable.h"
#include <lthread.h>
#if defined( THREAD_NEXT_CTHREADS )
#if defined( HAVE_PTHREADS )
#ifdef HAVE_DCE
/***********************************************************************
* *
* pthreads package with DCE - no mapping to do (except to create a *
* pthread_kill() routine) *
* *
***********************************************************************/
/* ARGSUSED */
void
pthread_kill( pthread_t tid, int sig )
{
kill( getpid(), sig );
}
#endif /* DCE */
#elif defined( HAVE_MACH_CTHREADS )
/***********************************************************************
* *
@ -155,13 +172,150 @@ pthread_cond_broadcast( pthread_cond_t *cv )
return( 0 );
}
#elif defined( THREAD_SUNOS4_LWP )
#elif defined( HAVE_LWP_THR )
/***********************************************************************
* *
* under sunos 4 - use the built in non-preemptive lwp threads package *
* *
***********************************************************************/
/*******************
* *
* Solaris Threads *
* *
*******************/
#if !defined(__SunOS_5_6)
int
pthread_attr_init( pthread_attr_t *attr )
{
*attr = 0;
return( 0 );
}
int
pthread_attr_destroy( pthread_attr_t *attr )
{
*attr = 0;
return( 0 );
}
int
pthread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate )
{
*detachstate = *attr;
return( 0 );
}
int
pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate )
{
*attr = detachstate;
return( 0 );
}
/* ARGSUSED */
int
pthread_create(
pthread_t *tid,
pthread_attr_t *attr,
VFP func,
void *arg
)
{
return( thr_create( NULL, 0, func, arg, *attr, tid ) );
}
#endif /* ! sunos56 */
void
pthread_yield()
{
thr_yield();
}
#if !defined(__SunOS_5_6)
void
pthread_exit()
{
thr_exit( NULL );
}
void
pthread_join( pthread_t tid, int *status )
{
thr_join( tid, NULL, (void **) status );
}
void
pthread_kill( pthread_t tid, int sig )
{
thr_kill( tid, sig );
}
/* ARGSUSED */
int
pthread_mutex_init( pthread_mutex_t *mp, pthread_mutexattr_t *attr )
{
return( mutex_init( mp, attr ? *attr : USYNC_THREAD, NULL ) );
}
int
pthread_mutex_destroy( pthread_mutex_t *mp )
{
return( mutex_destroy( mp ) );
}
int
pthread_mutex_lock( pthread_mutex_t *mp )
{
return( mutex_lock( mp ) );
}
int
pthread_mutex_unlock( pthread_mutex_t *mp )
{
return( mutex_unlock( mp ) );
}
int
pthread_mutex_trylock( pthread_mutex_t *mp )
{
return( mutex_trylock( mp ) );
}
int
pthread_cond_init( pthread_cond_t *cv, pthread_condattr_t *attr )
{
return( cond_init( cv, attr ? *attr : USYNC_THREAD, NULL ) );
}
int
pthread_cond_destroy( pthread_cond_t *cv )
{
return( cond_destroy( cv ) );
}
int
pthread_cond_wait( pthread_cond_t *cv, pthread_mutex_t *mp )
{
return( cond_wait( cv, mp ) );
}
int
pthread_cond_signal( pthread_cond_t *cv )
{
return( cond_signal( cv ) );
}
int
pthread_cond_broadcast( pthread_cond_t *cv )
{
return( cond_broadcast( cv ) );
}
#endif /* ! sunos56 */
#elif defined( HAVE_LWP )
/*************
* *
* SunOS LWP *
* *
*************/
extern stkalign_t *get_stack();
static void lwp_create_stack();
@ -321,200 +475,9 @@ pthread_cond_broadcast( pthread_cond_t *cv )
return( cv->lcv_created ? cv_broadcast( cv->lcv_cv ) : 0 );
}
#else /* end sunos4 */
# if defined( THREAD_SUNOS5_LWP )
/***********************************************************************
* *
* under sunos 5 - use the built in preemptive solaris threads package *
* *
***********************************************************************/
#if !defined(__SunOS_5_6)
int
pthread_attr_init( pthread_attr_t *attr )
{
*attr = 0;
return( 0 );
}
int
pthread_attr_destroy( pthread_attr_t *attr )
{
*attr = 0;
return( 0 );
}
int
pthread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate )
{
*detachstate = *attr;
return( 0 );
}
int
pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate )
{
*attr = detachstate;
return( 0 );
}
/* ARGSUSED */
int
pthread_create(
pthread_t *tid,
pthread_attr_t *attr,
VFP func,
void *arg
)
{
return( thr_create( NULL, 0, func, arg, *attr, tid ) );
}
#endif /* ! sunos56 */
void
pthread_yield()
{
thr_yield();
}
#if !defined(__SunOS_5_6)
void
pthread_exit()
{
thr_exit( NULL );
}
void
pthread_join( pthread_t tid, int *status )
{
thr_join( tid, NULL, (void **) status );
}
void
pthread_kill( pthread_t tid, int sig )
{
thr_kill( tid, sig );
}
/* ARGSUSED */
int
pthread_mutex_init( pthread_mutex_t *mp, pthread_mutexattr_t *attr )
{
return( mutex_init( mp, attr ? *attr : USYNC_THREAD, NULL ) );
}
int
pthread_mutex_destroy( pthread_mutex_t *mp )
{
return( mutex_destroy( mp ) );
}
int
pthread_mutex_lock( pthread_mutex_t *mp )
{
return( mutex_lock( mp ) );
}
int
pthread_mutex_unlock( pthread_mutex_t *mp )
{
return( mutex_unlock( mp ) );
}
int
pthread_mutex_trylock( pthread_mutex_t *mp )
{
return( mutex_trylock( mp ) );
}
int
pthread_cond_init( pthread_cond_t *cv, pthread_condattr_t *attr )
{
return( cond_init( cv, attr ? *attr : USYNC_THREAD, NULL ) );
}
int
pthread_cond_destroy( pthread_cond_t *cv )
{
return( cond_destroy( cv ) );
}
int
pthread_cond_wait( pthread_cond_t *cv, pthread_mutex_t *mp )
{
return( cond_wait( cv, mp ) );
}
int
pthread_cond_signal( pthread_cond_t *cv )
{
return( cond_signal( cv ) );
}
int
pthread_cond_broadcast( pthread_cond_t *cv )
{
return( cond_broadcast( cv ) );
}
#endif /* ! sunos56 */
#else /* end sunos5 threads */
#if defined( THREAD_MIT_PTHREADS )
/***********************************************************************
* *
* pthreads package by Chris Provenzano of MIT - provides all the *
* pthreads calls already, so no mapping to do *
* *
***********************************************************************/
#else /* end mit pthreads */
#if defined( THREAD_DCE_PTHREADS )
/***********************************************************************
* *
* pthreads package with DCE - no mapping to do (except to create a *
* pthread_kill() routine) *
* *
***********************************************************************/
/* ARGSUSED */
void
pthread_kill( pthread_t tid, int sig )
{
kill( getpid(), sig );
}
#else
#if defined ( POSIX_THREADS )
#ifdef HAVE_SCHED_YIELD
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif /* HAVE_SCHED_H */
/* POSIX Threads (final) does have a pthread_yield function */
void pthread_yield( void )
{
sched_yield();
}
#endif /* HAVE_SCHED_YIELD */
#endif /* posix threads */
#endif /* dce pthreads */
#endif /* mit pthreads */
#endif /* sunos5 lwp */
#endif /* sunos4 lwp */
#ifndef _THREAD
/***********************************************************************
* *
* no threads package defined for this system - fake ok returns from *

View file

@ -4,7 +4,7 @@
LIBRARY = liblutil.a
SRCS = base64.c md5.c sha1.c
OBJS = base64.o md5.o sha1.o
OBJS = base64.o md5.o sha1.o @LIBOBJS@
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries

View file

@ -4,7 +4,7 @@
#include <ac/string.h>
char *strdup( char *s )
char *strdup( const char *s )
{
char *p;

View file

@ -8,14 +8,14 @@ SRCS = main.c daemon.c connection.c search.c filter.c add.c charray.c \
dn.c compare.c modify.c delete.c modrdn.c ch_malloc.c \
value.c ava.c bind.c unbind.c abandon.c filterentry.c \
phonetic.c acl.c str2filter.c aclparse.c init.c \
detach.c strdup.c tempnam.c repl.c lock.c \
detach.c repl.c lock.c \
schema.c schemaparse.c monitor.c configinfo.c
OBJS = main.o daemon.o connection.o search.o filter.o add.o charray.o \
attr.o entry.o config.o backend.o result.o operation.o \
dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
value.o ava.o bind.o unbind.o abandon.o filterentry.o \
phonetic.o acl.o str2filter.o aclparse.o init.o \
detach.o strdup.o tempnam.o repl.o lock.o \
detach.o repl.o lock.o \
schema.o schemaparse.o monitor.o configinfo.o
LDAP_INCDIR= ../../include

View file

@ -25,13 +25,13 @@ SRCS = centipede.c ldbmcat.c ldbmtest.c sizecount.c \
ldif.c ldif2id2children.c ldif2id2entry.c ldif2index.c ldif2ldbm.c
EDB2LDIFSRCS = edb2ldif.c ldapsyntax.c
EDB2LDIFOBJS = edb2ldif.o ldapsyntax.o ../strdup.o
EDB2LDIFOBJS = edb2ldif.o ldapsyntax.o
OBJS2 = ../config.o ../ch_malloc.o ../backend.o ../charray.o \
../aclparse.o ../schema.o ../result.o ../filterentry.o \
../acl.o ../phonetic.o ../attr.o ../value.o ../entry.o \
../dn.o ../filter.o ../str2filter.o ../ava.o ../init.o \
../schemaparse.o ../strdup.o
../schemaparse.o
all-local: build-ldbm build-edb2ldif build-chlog2replog