|
@@ -633,15 +633,12 @@ int get_total_system_memory(size_t *mem_out);
|
|
int spawn_func(void (*func)(void *), void *data);
|
|
int spawn_func(void (*func)(void *), void *data);
|
|
void spawn_exit(void) ATTR_NORETURN;
|
|
void spawn_exit(void) ATTR_NORETURN;
|
|
|
|
|
|
-#if defined(ENABLE_THREADS) && defined(_WIN32)
|
|
+#if defined(_WIN32)
|
|
#define USE_WIN32_THREADS
|
|
#define USE_WIN32_THREADS
|
|
-#define TOR_IS_MULTITHREADED 1
|
|
+#elif defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_CREATE)
|
|
-#elif (defined(ENABLE_THREADS) && defined(HAVE_PTHREAD_H) && \
|
|
|
|
- defined(HAVE_PTHREAD_CREATE))
|
|
|
|
#define USE_PTHREADS
|
|
#define USE_PTHREADS
|
|
-#define TOR_IS_MULTITHREADED 1
|
|
|
|
#else
|
|
#else
|
|
-#undef TOR_IS_MULTITHREADED
|
|
+#error "No threading system was found"
|
|
#endif
|
|
#endif
|
|
|
|
|
|
int compute_num_cpus(void);
|
|
int compute_num_cpus(void);
|
|
@@ -667,7 +664,6 @@ typedef struct tor_mutex_t {
|
|
|
|
|
|
int tor_mlockall(void);
|
|
int tor_mlockall(void);
|
|
|
|
|
|
-#ifdef TOR_IS_MULTITHREADED
|
|
|
|
tor_mutex_t *tor_mutex_new(void);
|
|
tor_mutex_t *tor_mutex_new(void);
|
|
void tor_mutex_init(tor_mutex_t *m);
|
|
void tor_mutex_init(tor_mutex_t *m);
|
|
void tor_mutex_acquire(tor_mutex_t *m);
|
|
void tor_mutex_acquire(tor_mutex_t *m);
|
|
@@ -676,21 +672,10 @@ void tor_mutex_free(tor_mutex_t *m);
|
|
void tor_mutex_uninit(tor_mutex_t *m);
|
|
void tor_mutex_uninit(tor_mutex_t *m);
|
|
unsigned long tor_get_thread_id(void);
|
|
unsigned long tor_get_thread_id(void);
|
|
void tor_threads_init(void);
|
|
void tor_threads_init(void);
|
|
-#else
|
|
|
|
-#define tor_mutex_new() ((tor_mutex_t*)tor_malloc(sizeof(int)))
|
|
|
|
-#define tor_mutex_init(m) STMT_NIL
|
|
|
|
-#define tor_mutex_acquire(m) STMT_VOID(m)
|
|
|
|
-#define tor_mutex_release(m) STMT_NIL
|
|
|
|
-#define tor_mutex_free(m) STMT_BEGIN tor_free(m); STMT_END
|
|
|
|
-#define tor_mutex_uninit(m) STMT_NIL
|
|
|
|
-#define tor_get_thread_id() (1UL)
|
|
|
|
-#define tor_threads_init() STMT_NIL
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
void set_main_thread(void);
|
|
void set_main_thread(void);
|
|
int in_main_thread(void);
|
|
int in_main_thread(void);
|
|
|
|
|
|
-#ifdef TOR_IS_MULTITHREADED
|
|
|
|
#if 0
|
|
#if 0
|
|
typedef struct tor_cond_t tor_cond_t;
|
|
typedef struct tor_cond_t tor_cond_t;
|
|
tor_cond_t *tor_cond_new(void);
|
|
tor_cond_t *tor_cond_new(void);
|
|
@@ -699,7 +684,6 @@ int tor_cond_wait(tor_cond_t *cond, tor_mutex_t *mutex);
|
|
void tor_cond_signal_one(tor_cond_t *cond);
|
|
void tor_cond_signal_one(tor_cond_t *cond);
|
|
void tor_cond_signal_all(tor_cond_t *cond);
|
|
void tor_cond_signal_all(tor_cond_t *cond);
|
|
#endif
|
|
#endif
|
|
-#endif
|
|
|
|
|
|
|
|
/** Macros for MIN/MAX. Never use these when the arguments could have
|
|
/** Macros for MIN/MAX. Never use these when the arguments could have
|
|
* side-effects.
|
|
* side-effects.
|