From 3274bc38d460be0469d1708a098f8a5c603bd234 Mon Sep 17 00:00:00 2001 From: brendan Date: Thu, 6 Mar 2003 02:35:12 +0000 Subject: [PATCH] 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 --- src/avl/avl.h | 18 +++++++++--------- src/net/resolver.c | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/avl/avl.h b/src/avl/avl.h index fbb29670..fc1ab5d7 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.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 */ 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; diff --git a/src/net/resolver.c b/src/net/resolver.c index 5cd05fda..95d2c943 100644 --- a/src/net/resolver.c +++ b/src/net/resolver.c @@ -19,13 +19,13 @@ #include #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;