Commit eb16d5d8 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

replace with autoconf versions

parent a57b7a5b
/* thread.c - glue routines to provide a consistent thread interface */
#include <stdio.h>
#include "lthread.h"
#if defined( THREAD_NEXT_CTHREADS )
#include "portable.h"
#include <lthread.h>
#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 )
/***********************************************************************
* *
......@@ -152,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_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 )
{
......@@ -173,6 +191,7 @@ pthread_attr_init( pthread_attr_t *attr )
int
pthread_attr_destroy( pthread_attr_t *attr )
{
*attr = 0;
return( 0 );
}
......@@ -199,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( mon_create( mp ) );
return( mutex_init( mp, attr ? *attr : USYNC_THREAD, NULL ) );
}
int
pthread_mutex_destroy( pthread_mutex_t *mp )
{
return( mon_destroy( *mp ) );
return( mutex_destroy( mp ) );
}
int
pthread_mutex_lock( pthread_mutex_t *mp )
{
return( mon_enter( *mp ) );
return( mutex_lock( mp ) );
}
int
pthread_mutex_unlock( pthread_mutex_t *mp )
{
return( mon_exit( *mp ) );
return( mutex_unlock( mp ) );
}
int
pthread_mutex_trylock( pthread_mutex_t *mp )
{
return( mon_cond_enter( *mp ) );
return( mutex_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( cv->lcv_created ? cv_destroy( cv->lcv_cv ) : 0 );
return( cond_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( cv->lcv_created ? cv_notify( cv->lcv_cv ) : 0 );
return( cond_signal( cv ) );
}
int
pthread_cond_broadcast( pthread_cond_t *cv )
{
return( cv->lcv_created ? cv_broadcast( cv->lcv_cv ) : 0 );
return( cond_broadcast( cv ) );
}
#endif /* ! sunos56 */
#else /* end sunos4 */
#elif 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 )
{
......@@ -339,7 +330,6 @@ pthread_attr_init( pthread_attr_t *attr )
int
pthread_attr_destroy( pthread_attr_t *attr )
{
*attr = 0;
return( 0 );
}
......@@ -366,148 +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( mutex_init( mp, attr ? *attr : USYNC_THREAD, NULL ) );
return( mon_create( mp ) );
}
int
pthread_mutex_destroy( pthread_mutex_t *mp )
{
return( mutex_destroy( mp ) );
return( mon_destroy( *mp ) );
}
int
pthread_mutex_lock( pthread_mutex_t *mp )
{
return( mutex_lock( mp ) );
return( mon_enter( *mp ) );
}
int
pthread_mutex_unlock( pthread_mutex_t *mp )
{
return( mutex_unlock( mp ) );
return( mon_exit( *mp ) );
}
int
pthread_mutex_trylock( pthread_mutex_t *mp )
{
return( mutex_trylock( mp ) );
return( mon_cond_enter( *mp ) );
}
int
pthread_cond_init( pthread_cond_t *cv, pthread_condattr_t *attr )
{
return( cond_init( cv, attr ? *attr : USYNC_THREAD, NULL ) );
/*
* 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 );
}
int
pthread_cond_destroy( pthread_cond_t *cv )
{
return( cond_destroy( cv ) );
return( cv->lcv_created ? cv_destroy( cv->lcv_cv ) : 0 );
}
int
pthread_cond_wait( pthread_cond_t *cv, pthread_mutex_t *mp )
{
return( cond_wait( cv, mp ) );
if ( ! cv->lcv_created ) {
cv_create( &cv->lcv_cv, *mp );
cv->lcv_created = 1;
}
return( cv_wait( cv->lcv_cv ) );
}
int
pthread_cond_signal( pthread_cond_t *cv )
{
return( cond_signal( cv ) );
return( cv->lcv_created ? cv_notify( cv->lcv_cv ) : 0 );
}
int
pthread_cond_broadcast( pthread_cond_t *cv )
{
return( cond_broadcast( cv ) );
return( cv->lcv_created ? cv_broadcast( cv->lcv_cv ) : 0 );
}
#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 )
#ifndef SCHED_YIELD_MISSING
#include <sched.h>
void pthread_yield( void )
{
sched_yield();
}
#endif
#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 *
......
......@@ -29,9 +29,14 @@
copyright in any changes I have made; this code remains in the
public domain. */
#include <string.h>
#include "portable.h"
#include "lutil_md5.h"
#include <ac/string.h>
/* include socket.h to get sys/types.h and/or winsock2.h */
#include <ac/socket.h>
#include <lutil_md5.h>
/* Little-endian byte-swapping routines. Note that these do not
depend on the size of datatypes such as uint32, nor do they require
......@@ -64,7 +69,7 @@ putu32 (data, addr)
*/
void
ldap_MD5Init(ctx)
struct MD5Context *ctx;
struct ldap_MD5Context *ctx;
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
......@@ -81,7 +86,7 @@ ldap_MD5Init(ctx)
*/
void
ldap_MD5Update(ctx, buf, len)
struct MD5Context *ctx;
struct ldap_MD5Context *ctx;
unsigned char const *buf;
unsigned len;
{
......@@ -133,7 +138,7 @@ ldap_MD5Update(ctx, buf, len)
void
ldap_MD5Final(digest, ctx)
unsigned char digest[16];
struct MD5Context *ctx;
struct ldap_MD5Context *ctx;
{
unsigned count;
unsigned char *p;
......@@ -293,7 +298,7 @@ ldap_MD5Transform(buf, inraw)
int
main (int argc, char **argv)
{
struct MD5Context context;
struct ldap_MD5Context context;
unsigned char checksum[16];
int i;
int j;
......
......@@ -15,12 +15,20 @@
* 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
#define SHA1HANDSOFF /* Copies data before messing with it. */
#include "portable.h"
#include <ac/string.h>
/* include socket.h to get sys/types.h and/or winsock2.h */
#include <ac/socket.h>
#if defined(HAVE_SYS_PARAM_H)
#include <sys/param.h>
#include <string.h>
#endif
#include "lutil_sha1.h"
#define SHA1HANDSOFF /* Copies data before messing with it. */
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
/*
......@@ -113,7 +121,7 @@ void ldap_SHA1Transform(state, buffer)
* ldap_SHA1Init - Initialize new context
*/
void ldap_SHA1Init(context)
SHA1_CTX *context;
ldap_SHA1_CTX *context;
{
/* SHA1 initialization constants */
......@@ -130,7 +138,7 @@ void ldap_SHA1Init(context)
* Run your data through this.
*/
void ldap_SHA1Update(context, data, len)
SHA1_CTX *context;
ldap_SHA1_CTX *context;
const unsigned char *data;
u_int len;
{
......@@ -158,7 +166,7 @@ void ldap_SHA1Update(context, data, len)
*/
void ldap_SHA1Final(digest, context)
unsigned char digest[20];
SHA1_CTX* context;
ldap_SHA1_CTX* context;
{
u_int i;
unsigned char finalcount[8];
......@@ -193,18 +201,32 @@ void ldap_SHA1Final(digest, context)
static char rcsid[] = "$OpenBSD: sha1hl.c,v 1.1 1997/07/12 20:06:03 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <ac/errno.h>
#include <ac/unistd.h>
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#include <unistd.h>
#endif
#ifdef HAVE_IO_H
#include <io.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
/* ARGSUSED */
char *
ldap_SHA1End(ctx, buf)
SHA1_CTX *ctx;
ldap_SHA1_CTX *ctx;
char *buf;
{
int i;
......@@ -230,7 +252,7 @@ ldap_SHA1File (filename, buf)
char *buf;
{
unsigned char buffer[BUFSIZ];
SHA1_CTX ctx;
ldap_SHA1_CTX ctx;
int fd, num, oerrno;
ldap_SHA1Init(&ctx);
......@@ -253,7 +275,7 @@ ldap_SHA1Data (data, len, buf)
size_t len;
char *buf;
{
SHA1_CTX ctx;
ldap_SHA1_CTX ctx;
ldap_SHA1Init(&ctx);
ldap_SHA1Update(&ctx, data, len);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment