#ifndef TOR_COMPAT_MUTEX_H
#define TOR_COMPAT_MUTEX_H
#include "orconfig.h"
#include "lib/cc/torint.h"
#include "lib/malloc/malloc.h"
#if defined(HAVE_PTHREAD_H) && !defined(_WIN32)
#include <pthread.h>
#endif
#if defined(_WIN32)
#include <windows.h>
#endif
#if defined(_WIN32)
#define USE_WIN32_THREADS
#elif defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_CREATE)
#define USE_PTHREADS
#else
#error "No threading system was found"
#endif
typedef struct tor_mutex_t {
#if defined(USE_WIN32_THREADS)
CRITICAL_SECTION mutex;
#elif defined(USE_PTHREADS)
pthread_mutex_t mutex;
#else
int _unused;
#endif
} tor_mutex_t;
tor_mutex_t *tor_mutex_new(void);
tor_mutex_t *tor_mutex_new_nonrecursive(void);
void tor_mutex_init(tor_mutex_t *m);
void tor_mutex_init_nonrecursive(tor_mutex_t *m);
void tor_mutex_acquire(tor_mutex_t *m);
void tor_mutex_release(tor_mutex_t *m);
void tor_mutex_free_(tor_mutex_t *m);
#define tor_mutex_free(m) FREE_AND_NULL(tor_mutex_t, tor_mutex_free_, (m))
void tor_mutex_uninit(tor_mutex_t *m);
void tor_locking_init(void);
#endif