diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-11-01 13:14:43 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-11-05 09:22:02 -0500 |
commit | b8c50eabfee1bd9f5ed03f8ec569cc53b980f1d1 (patch) | |
tree | 25cbee463c1409c43085db90faa2a0205a64aecd /src/lib/thread | |
parent | 178c1821b2115972ce3c3f194d1fcbd0d75ca364 (diff) | |
download | tor-b8c50eabfee1bd9f5ed03f8ec569cc53b980f1d1.tar.gz tor-b8c50eabfee1bd9f5ed03f8ec569cc53b980f1d1.zip |
Add a subsystem for our threading support
Diffstat (limited to 'src/lib/thread')
-rw-r--r-- | src/lib/thread/.may_include | 1 | ||||
-rw-r--r-- | src/lib/thread/compat_threads.c | 16 | ||||
-rw-r--r-- | src/lib/thread/include.am | 5 | ||||
-rw-r--r-- | src/lib/thread/thread_sys.h | 14 |
4 files changed, 34 insertions, 2 deletions
diff --git a/src/lib/thread/.may_include b/src/lib/thread/.may_include index 93ad0cd734..c26a426923 100644 --- a/src/lib/thread/.may_include +++ b/src/lib/thread/.may_include @@ -2,5 +2,6 @@ orconfig.h lib/cc/*.h lib/lock/*.h lib/log/*.h +lib/subsys/*.h lib/testsupport/*.h lib/thread/*.h diff --git a/src/lib/thread/compat_threads.c b/src/lib/thread/compat_threads.c index 7f1970af45..3d41faa8ce 100644 --- a/src/lib/thread/compat_threads.c +++ b/src/lib/thread/compat_threads.c @@ -14,9 +14,11 @@ #include "orconfig.h" #include <stdlib.h> #include "lib/thread/threads.h" +#include "lib/thread/thread_sys.h" #include "lib/log/log.h" #include "lib/log/util_bug.h" +#include "lib/subsys/subsys.h" #include <string.h> @@ -109,3 +111,17 @@ atomic_counter_exchange(atomic_counter_t *counter, size_t newval) return oldval; } #endif /* !defined(HAVE_WORKING_STDATOMIC) */ + +static int +sys_threads_initialize(void) +{ + tor_threads_init(); + return 0; +} + +const subsys_fns_t sys_threads = { + .name = "threads", + .supported = true, + .level = -95, + .initialize = sys_threads_initialize, +}; diff --git a/src/lib/thread/include.am b/src/lib/thread/include.am index 9ec23d166e..695795a2c8 100644 --- a/src/lib/thread/include.am +++ b/src/lib/thread/include.am @@ -23,5 +23,6 @@ src_lib_libtor_thread_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS) src_lib_libtor_thread_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS) noinst_HEADERS += \ - src/lib/thread/threads.h \ - src/lib/thread/numcpus.h + src/lib/thread/numcpus.h \ + src/lib/thread/thread_sys.h \ + src/lib/thread/threads.h diff --git a/src/lib/thread/thread_sys.h b/src/lib/thread/thread_sys.h new file mode 100644 index 0000000000..984abe88e8 --- /dev/null +++ b/src/lib/thread/thread_sys.h @@ -0,0 +1,14 @@ +/* Copyright (c) 2018, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file threads_sys.h + * \brief Declare subsystem object for threads library + **/ + +#ifndef TOR_THREADS_SYS_H +#define TOR_THREADS_SYS_H + +extern const struct subsys_fns_t sys_threads; + +#endif /* !defined(TOR_THREADS_SYS_H) */ |