From cbfe325c2f790051674feab896d6c543fc3b2120 Mon Sep 17 00:00:00 2001 From: brendan Date: Thu, 6 Mar 2003 01:55:20 +0000 Subject: [PATCH] Use gnu archive ACX_PTHREAD macro to figure out how to compile thread support. Also make it possible to build libshout without threads, albeit without locking in the resolver or avl trees. New option --disable-pthread too. svn path=/trunk/avl/; revision=4411 --- src/avl/avl.h | 16 +++++++++++++--- src/httpp/httpp.c | 1 - src/net/resolver.c | 10 ++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/avl/avl.h b/src/avl/avl.h index af224a7e..fbb29670 100644 --- a/src/avl/avl.h +++ b/src/avl/avl.h @@ -2,7 +2,7 @@ * Copyright (C) 1995 by Sam Rushing */ -/* $Id: avl.h,v 1.2 2002/02/11 09:11:18 msmith Exp $ */ +/* $Id: avl.h,v 1.3 2003/03/06 01:55:20 brendan Exp $ */ #ifndef __AVL_H #define __AVL_H @@ -11,7 +11,15 @@ extern "C" { #endif +#ifdef USE_THREAD #include "thread.h" +#else +#define thread_rwlock_create(x) +#define thread_rwlock_destroy(x) +#define thread_rwlock_rlock(x) +#define thread_rwlock_wlock(x) +#define thread_rwlock_unlock(x) +#endif typedef struct avl_node_tag { void * key; @@ -24,8 +32,9 @@ typedef struct avl_node_tag { * The rest of the bits are used for */ unsigned long rank_and_balance; - +#ifdef USE_THREAD rwlock_t rwlock; +#endif } avl_node; #define AVL_GET_BALANCE(n) ((int)(((n)->rank_and_balance & 3) - 1)) @@ -59,8 +68,9 @@ typedef struct _avl_tree { unsigned long length; avl_key_compare_fun_type compare_fun; void * compare_arg; - +#ifdef USE_THREAD rwlock_t rwlock; +#endif } avl_tree; avl_tree * avl_tree_new (avl_key_compare_fun_type compare_fun, void * compare_arg); diff --git a/src/httpp/httpp.c b/src/httpp/httpp.c index fa6bbcab..14f94c21 100644 --- a/src/httpp/httpp.c +++ b/src/httpp/httpp.c @@ -9,7 +9,6 @@ #include #include -#include "thread.h" #include "avl.h" #include "httpp.h" diff --git a/src/net/resolver.c b/src/net/resolver.c index 2f5a0128..5cd05fda 100644 --- a/src/net/resolver.c +++ b/src/net/resolver.c @@ -19,7 +19,15 @@ #include #endif +#ifdef USE_THREAD #include "../thread/thread.h" +#else +#define thread_mutex_create(x) +#define thread_mutex_destroy(x) +#define thread_mutex_lock(x) +#define thread_mutex_unlock(x) +#endif + #include "resolver.h" #include "sock.h" @@ -29,7 +37,9 @@ static int _isip(const char *what); /* internal data */ +#ifdef USE_THREAD static mutex_t _resolver_mutex; +#endif static int _initialized = 0; #ifdef HAVE_INET_PTON