Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
71b34373
Commit
71b34373
authored
Oct 22, 1998
by
Kurt Zeilenga
Browse files
Moved strdup/tempnam to liblutil
parent
c4b1286f
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
configure
View file @
71b34373
This diff is collapsed.
Click to expand it.
configure.in
View file @
71b34373
...
...
@@ -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
...
...
include/lthread.h
View file @
71b34373
...
...
@@ -5,58 +5,53 @@
#include
"portable.h"
LDAP_BEGIN_DECL
#if defined( HAVE_PTHREADS )
/**********************************
* *
* definitions for POSIX Threads *
* *
**********************************/
#if defined ( THREAD_NEXT_CTHREADS )
#include
<pthread.h>
#ifdef HAVE_SCHED_H
#include
<sched.h>
#endif
#define _THREAD
LDAP_BEGIN_DECL
#include
<mach/cthreads.h>
#if defined( HAVE_DCE )
/* dce threads are preemptive */
typedef
cthread_fn_t
VFP
;
typedef
int
pthread_attr_t
;
typedef
cthread_t
pthread_t
;
#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 )
/* default attr states */
#elif !defined(HAVE_PTHREADS_D4)
#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
#ifdef HAVE_SCHED_YIELD
#define pthread_yield sched_yield
#endif
#endif
/* condition variable attributes and condition variable type */
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_MACH_CTHREADS )
/**********************************
* *
* definitions for Mach CThreads *
* *
**********************************/
#include
<lwp/lwp.h>
#include
<lwp/stackdep.h>
#include
<mach/cthreads.h>
typedef
void
*
(
*
VFP
)();
LDAP_BEGIN_DECL
/* thread attributes and thread type */
typedef
cthread_fn_t
VFP
;
typedef
int
pthread_attr_t
;
typedef
thread_t
pthread_t
;
typedef
c
thread_t
pthread_t
;
/* default attr states */
#define pthread_mutexattr_default NULL
...
...
@@ -71,7 +66,7 @@ typedef thread_t pthread_t;
/* mutex attributes and mutex type */
typedef
int
pthread_mutexattr_t
;
typedef
mon_t
pthread_mutex_t
;
typedef
struct
mutex
pthread_mutex_t
;
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE 0
...
...
@@ -79,35 +74,23 @@ typedef mon_t pthread_mutex_t;
/* condition variable attributes and condition variable type */
typedef
int
pthread_condattr_t
;
typedef
struct
lwpcv
{
int
lcv_created
;
cv_t
lcv_cv
;
}
pthread_cond_t
;
#else
/* end sunos4 */
typedef
struct
condition
pthread_cond_t
;
#if defined( THREAD_SUNOS5_LWP )
/***********************************
* *
* thread definitions for sunos5 *
* *
***********************************/
LDAP_END_DECL
#define _THREAD
#elif defined( HAVE_LWP_THR )
/**************************************
* *
* thread definitions for Solaris LWP *
* *
**************************************/
#include
<thread.h>
#include
<synch.h>
typedef
void
*
(
*
VFP
)();
/* sunos5 threads are preemptive */
#define PTHREAD_PREEMPTIVE 1
LDAP_BEGIN_DECL
#if !defined(__SunOS_5_6)
/* thread attributes and thread type */
typedef
int
pthread_attr_t
;
typedef
thread_t
pthread_t
;
#endif
/* ! sunos56 */
typedef
void
*
(
*
VFP
)();
/* default attr states */
#define pthread_mutexattr_default NULL
...
...
@@ -119,75 +102,74 @@ typedef thread_t pthread_t;
/* 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
;
#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>
LDAP_END_DECL
#else
/* end mit pthreads */
#elif defined( HAVE_LWP )
/*************************************
* *
* thread definitions for SunOS LWP *
* *
*************************************/
#if defined( THREAD_DCE_PTHREADS )
/***********************************
* *
* definitions for mit pthreads *
* *
***********************************/
#define _THREAD
#include
<lwp/lwp.h>
#include
<lwp/stackdep.h>
#include
<pthread.h>
LDAP_BEGIN_DECL
/* dce threads are preemptive */
#define PTHREAD_PREEMPTIVE 1
typedef
void
*
(
*
VFP
)();
#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 )
/* thread attributes and thread type */
typedef
int
pthread_attr_t
;
typedef
thread_t
pthread_t
;
#else
/* end dce pthreads */
/* default attr states */
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
#if defined( POSIX_THREADS )
/* 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
#define _THREAD
/* mutex attributes and mutex type */
typedef
int
pthread_mutexattr_t
;
typedef
mon_t
pthread_mutex_t
;
#include
<pthread.h>
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE 0
#define PTHREAD_SHARE_PROCESS 1
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
/* condition variable attributes and condition variable type */
typedef
int
pthread_condattr_t
;
typedef
struct
lwpcv
{
int
lcv_created
;
cv_t
lcv_cv
;
}
pthread_cond_t
;
#endif
/* posix threads */
#endif
/* dce pthreads */
#endif
/* mit pthreads */
#endif
/* sunos5 */
#endif
/* sunos4 */
LDAP_END_DECL
#
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 */
libraries/liblthread/thread.c
View file @
71b34373
/* 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,17 +172,15 @@ pthread_cond_broadcast( pthread_cond_t *cv )
return
(
0
);
}
#elif defined( THREAD_SUNOS4_LWP )
/***********************************************************************
* *
* under sunos 4 - use the built in non-preemptive lwp threads package *
* *
***********************************************************************/
#elif defined( HAVE_LWP_THR )
extern
stkalign_t
*
get_stack
();
static
void
lwp_create_stack
();
/*******************
* *
* Solaris Threads *
* *
*******************/
#if !defined(__SunOS_5_6)
int
pthread_attr_init
(
pthread_attr_t
*
attr
)
{
...
...
@@ -176,6 +191,7 @@ pthread_attr_init( pthread_attr_t *attr )
int
pthread_attr_destroy
(
pthread_attr_t
*
attr
)
{
*
attr
=
0
;
return
(
0
);
}
...
...
@@ -202,136 +218,108 @@ pthread_create(
void
*
arg
)
{
stkalign_t
*
stack
;
int
stackno
;
if
(
(
stack
=
get_stack
(
&
stackno
))
==
NULL
)
{
return
(
-
1
);
}
return
(
lwp_create
(
tid
,
lwp_create_stack
,
MINPRIO
,
0
,
stack
,
3
,
func
,
arg
,
stackno
)
);
}
static
void
lwp_create_stack
(
VFP
func
,
void
*
arg
,
int
stackno
)
{
(
*
func
)(
arg
);
free_stack
(
stackno
);
return
(
thr_create
(
NULL
,
0
,
func
,
arg
,
*
attr
,
tid
)
);
}
#endif
/* ! sunos56 */
void
pthread_yield
()
{
lwp
_yield
(
SELF
);
thr
_yield
();
}
#if !defined(__SunOS_5_6)
void
pthread_exit
()
{
lwp_destroy
(
SELF
);
thr_exit
(
NULL
);
}
void
pthread_join
(
pthread_t
tid
,
int
*
status
)
{
lwp
_join
(
tid
);
thr
_join
(
tid
,
NULL
,
(
void
**
)
status
);
}
/* ARGSUSED */
void
pthread_kill
(
pthread_t
tid
,
int
sig
)
{
return
;
thr_kill
(
tid
,
sig
)
;
}
/* ARGSUSED */
int
pthread_mutex_init
(
pthread_mutex_t
*
mp
,
pthread_mutexattr_t
*
attr
)
{
return
(
m
on_create
(
mp
)
);
return
(
m
utex_init
(
mp
,
attr
?
*
attr
:
USYNC_THREAD
,
NULL
)
);
}
int
pthread_mutex_destroy
(
pthread_mutex_t
*
mp
)
{
return
(
m
on
_destroy
(
*
mp
)
);
return
(
m
utex
_destroy
(
mp
)
);
}
int
pthread_mutex_lock
(
pthread_mutex_t
*
mp
)
{
return
(
m
on_enter
(
*
mp
)
);
return
(
m
utex_lock
(
mp
)
);
}
int
pthread_mutex_unlock
(
pthread_mutex_t
*
mp
)
{
return
(
m
on_exit
(
*
mp
)
);
return
(
m
utex_unlock
(
mp
)
);
}
int
pthread_mutex_trylock
(
pthread_mutex_t
*
mp
)
{
return
(
m
on_cond_enter
(
*
mp
)
);
return
(
m
utex_trylock
(
mp
)
);
}
int
pthread_cond_init
(
pthread_cond_t
*
cv
,
pthread_condattr_t
*
attr
)
{
/*
* lwp cv_create requires the monitor id be passed in
* when the cv is created, pthreads passes it when the
* condition is waited for. so, we fake the creation
* here and actually do it when the cv is waited for
* later.
*/
cv
->
lcv_created
=
0
;
return
(
0
);
return
(
cond_init
(
cv
,
attr
?
*
attr
:
USYNC_THREAD
,
NULL
)
);
}
int
pthread_cond_destroy
(
pthread_cond_t
*
cv
)
{
return
(
c
v
->
lcv_created
?
cv_destroy
(
cv
->
lcv_cv
)
:
0
);
return
(
c
ond_destroy
(
cv
)
);
}
int
pthread_cond_wait
(
pthread_cond_t
*
cv
,
pthread_mutex_t
*
mp
)
{
if
(
!
cv
->
lcv_created
)
{
cv_create
(
&
cv
->
lcv_cv
,
*
mp
);
cv
->
lcv_created
=
1
;
}
return
(
cv_wait
(
cv
->
lcv_cv
)
);
return
(
cond_wait
(
cv
,
mp
)
);
}
int
pthread_cond_signal
(
pthread_cond_t
*
cv
)
{
return
(
c
v
->
lcv_created
?
cv_notify
(
cv
->
lcv_cv
)
:
0
);
return
(
c
ond_signal
(
cv
)
);
}
int
pthread_cond_broadcast
(
pthread_cond_t
*
cv
)
{
return
(
c
v
->
lcv_created
?
cv_broadcast
(
cv
->
lcv_cv
)
:
0
);
return
(
c
ond_broadcast
(
cv
)
);
}
#endif
/* ! sunos56 */
#el
se
/* end sunos4 */
#el
if defined( HAVE_LWP )
# if defined( THREAD_SUNOS5_LWP )
/*************
* *
* SunOS LWP *
* *
*************/
/***********************************************************************
* *
* under sunos 5 - use the built in preemptive solaris threads package *
* *
***********************************************************************/
extern
stkalign_t
*
get_stack
();
static
void
lwp_create_stack
();
#if !defined(__SunOS_5_6)
int
pthread_attr_init
(
pthread_attr_t
*
attr
)
{
...
...
@@ -342,7 +330,6 @@ pthread_attr_init( pthread_attr_t *attr )
int
pthread_attr_destroy
(
pthread_attr_t
*
attr
)
{
*
attr
=
0
;
return
(
0
);
}
...
...
@@ -369,152 +356,128 @@ pthread_create(
void
*
arg
)
{
return
(
thr_create
(
NULL
,
0
,
func
,
arg
,
*
attr
,
tid
)
);
stkalign_t
*
stack
;
int
stackno
;
if
(
(
stack
=
get_stack
(
&
stackno
))
==
NULL
)
{
return
(
-
1
);
}
return
(
lwp_create
(
tid
,
lwp_create_stack
,
MINPRIO
,
0
,
stack
,
3
,
func
,
arg
,
stackno
)
);
}
static
void
lwp_create_stack
(
VFP
func
,
void
*
arg
,
int
stackno
)
{
(
*
func
)(
arg
);
free_stack
(
stackno
);
}
#endif
/* ! sunos56 */
void
pthread_yield
()
{
thr
_yield
();
lwp
_yield
(
SELF
);
}
#if !defined(__SunOS_5_6)
void
pthread_exit
()
{
thr_exit
(
NULL
);
lwp_destroy
(
SELF
);
}
void
pthread_join
(
pthread_t
tid
,
int
*
status
)
{
thr
_join
(
tid
,
NULL
,
(
void
**
)
status
);
lwp
_join
(
tid
);
}
/* ARGSUSED */
void
pthread_kill
(
pthread_t
tid
,
int
sig
)
{
thr_kill
(
tid
,
sig
)
;
return
;
}
/* ARGSUSED */
int
pthread_mutex_init
(
pthread_mutex_t
*
mp
,
pthread_mutexattr_t
*
attr
)
{
return
(
m
utex_init
(
mp
,
attr
?
*
attr
:
USYNC_THREAD
,
NULL
)
);
return
(
m
on_create
(
mp
)
);
}
int
pthread_mutex_destroy
(
pthread_mutex_t
*
mp
)
{
return
(
m
utex
_destroy
(
mp
)
);
return
(
m
on
_destroy
(
*
mp
)
);
}
int
pthread_mutex_lock
(
pthread_mutex_t
*
mp
)
{
return
(
m
utex_lock
(
mp
)
);
return
(
m
on_enter
(
*
mp
)
);
}
int
pthread_mutex_unlock
(
pthread_mutex_t
*
mp
)
{