Commit 457b1ddd authored by brendan's avatar brendan

Require NO_THREAD to be defined to turn off locking in avl and net

According to Karl, defining nops with do{}while(0) is a la mode.

svn path=/trunk/avl/; revision=4412
parent 34ea78ad
......@@ -111,7 +111,6 @@ have_thread="no"
if test "$enable_pthread" != "no"
then
ACX_PTHREAD([
AC_DEFINE([USE_THREAD], 1, [Define if you want to use the thread library])
LIBS="$LIBS $PTHREAD_LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
......@@ -119,6 +118,10 @@ then
])
fi
AM_CONDITIONAL([HAVE_THREAD], [test "$have_thread" == "yes"])
if test "$have_thread" != "yes"
then
AC_DEFINE([NO_THREAD], 1, [Define if you don't want to use the thread library])
fi
XIPH_PATH_OGG
XIPH_PATH_VORBIS
......
......@@ -2,7 +2,7 @@
* Copyright (C) 1995 by Sam Rushing <rushing@nightmare.com>
*/
/* $Id: avl.h,v 1.3 2003/03/06 01:55:20 brendan Exp $ */
/* $Id: avl.h,v 1.4 2003/03/06 02:35:12 brendan Exp $ */
#ifndef __AVL_H
#define __AVL_H
......@@ -11,14 +11,14 @@
extern "C" {
#endif
#ifdef USE_THREAD
#ifndef NO_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)
#define thread_rwlock_create(x) do{}while(0)
#define thread_rwlock_destroy(x) do{}while(0)
#define thread_rwlock_rlock(x) do{}while(0)
#define thread_rwlock_wlock(x) do{}while(0)
#define thread_rwlock_unlock(x) do{}while(0)
#endif
typedef struct avl_node_tag {
......@@ -32,7 +32,7 @@ typedef struct avl_node_tag {
* The rest of the bits are used for <rank>
*/
unsigned long rank_and_balance;
#ifdef USE_THREAD
#ifndef NO_THREAD
rwlock_t rwlock;
#endif
} avl_node;
......@@ -68,7 +68,7 @@ typedef struct _avl_tree {
unsigned long length;
avl_key_compare_fun_type compare_fun;
void * compare_arg;
#ifdef USE_THREAD
#ifndef NO_THREAD
rwlock_t rwlock;
#endif
} avl_tree;
......
......@@ -19,13 +19,13 @@
#include <winsock2.h>
#endif
#ifdef USE_THREAD
#include "../thread/thread.h"
#ifndef NO_THREAD
#include "thread.h"
#else
#define thread_mutex_create(x)
#define thread_mutex_destroy(x)
#define thread_mutex_lock(x)
#define thread_mutex_unlock(x)
#define thread_mutex_create(x) do{}while(0)
#define thread_mutex_destroy(x) do{}while(0)
#define thread_mutex_lock(x) do{}while(0)
#define thread_mutex_unlock(x) do{}while(0)
#endif
#include "resolver.h"
......@@ -37,7 +37,7 @@ static int _isip(const char *what);
/* internal data */
#ifdef USE_THREAD
#ifndef NO_THREAD
static mutex_t _resolver_mutex;
#endif
static int _initialized = 0;
......
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