Simplify the pthreads detection macros.

This commit is contained in:
Bill Currie 2013-03-18 13:31:35 +09:00
parent 1c20a49dba
commit ffb6d628bd
2 changed files with 17 additions and 5 deletions

View file

@ -34,10 +34,22 @@
#endif
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
#define USE_PTHREADS
#endif
#ifdef USE_PTHREADS
#include <pthread.h>
extern pthread_mutex_t *my_mutex;
#define LOCK do {if (options.threads > 1) pthread_mutex_lock (my_mutex); } while (0)
#define UNLOCK do {if (options.threads > 1) pthread_mutex_unlock (my_mutex); } while (0)
#define LOCK \
do { \
if (options.threads > 1) \
pthread_mutex_lock (my_mutex); \
} while (0)
#define UNLOCK \
do { \
if (options.threads > 1) \
pthread_mutex_unlock (my_mutex); \
} while (0)
#else
#define LOCK
#define UNLOCK

View file

@ -62,7 +62,7 @@
#define MAX_THREADS 4
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
#ifdef USE_PTHREADS
pthread_mutex_t *my_mutex;
#endif
@ -390,7 +390,7 @@ LeafThread (void *_thread)
return NULL;
}
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
#ifdef USE_PTHREADS
static void *
WatchThread (void *_thread)
{
@ -536,7 +536,7 @@ CalcPortalVis (void)
return;
}
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
#ifdef USE_PTHREADS
{
pthread_t work_threads[MAX_THREADS + 1];
void *status;