replace with autoconf versions

This commit is contained in:
Kurt Zeilenga 1998-10-25 02:08:13 +00:00
parent a57b7a5bb0
commit eb16d5d88f
3 changed files with 211 additions and 214 deletions

View file

@ -1,8 +1,28 @@
/* 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,13 +172,150 @@ pthread_cond_broadcast( pthread_cond_t *cv )
return( 0 );
}
#elif defined( THREAD_SUNOS4_LWP )
#elif defined( HAVE_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();
@ -318,196 +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 )
#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 *

View file

@ -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;

View file

@ -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);