kopia lustrzana https://github.com/Hamlib/Hamlib
Move MUTEX macros to mutex.h to allow inclusion in other code
rodzic
e09d1611b2
commit
5f0fe34dad
|
@ -0,0 +1,18 @@
|
|||
#include "hamlib/config.h"
|
||||
|
||||
#if defined(HAVE_PTHREAD)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
#define MUTEX(var) static pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER
|
||||
#define MUTEX_LOCK(var) pthread_mutex_lock(&var)
|
||||
#define MUTEX_UNLOCK(var) pthread_mutex_unlock(&var)
|
||||
#else
|
||||
#warning NOT PTHREAD
|
||||
#define MUTEX(var)
|
||||
#define MUTEX_LOCK(var)
|
||||
#define MUTEX_UNLOCK(var)
|
||||
#endif
|
||||
|
||||
extern int MUTEX_CHECK(pthread_mutex_t *m);
|
16
src/rig.c
16
src/rig.c
|
@ -61,10 +61,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#if defined(HAVE_PTHREAD)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#include "mutex.h"
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include "serial.h"
|
||||
|
@ -174,17 +171,6 @@ const char hamlib_copyright[231] = /* hamlib 1.2 ABI specifies 231 bytes */
|
|||
|
||||
#define LOCK(n) if (rig->state.depth == 1) { rig_debug(RIG_DEBUG_CACHE, "%s: %s\n", n?"lock":"unlock", __func__); rig_lock(rig,n); }
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
#define MUTEX(var) static pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER
|
||||
#define MUTEX_LOCK(var) pthread_mutex_lock(&var)
|
||||
#define MUTEX_UNLOCK(var) pthread_mutex_unlock(&var)
|
||||
#else
|
||||
#warning NOT PTHREAD
|
||||
#define MUTEX(var)
|
||||
#define MUTEX_LOCK(var)
|
||||
#define MUTEX_UNLOCK(var)
|
||||
#endif
|
||||
|
||||
MUTEX(morse_mutex);
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
|
|
Ładowanie…
Reference in New Issue