From efd90a1b8a9d3bbb1bdd8e6ae41b3462e7193fb2 Mon Sep 17 00:00:00 2001 From: jdybnis Date: Wed, 12 Nov 2008 06:22:02 +0000 Subject: [PATCH] rename util/ to runtime/ --- makefile | 8 ++++---- {util => runtime}/CuTest.c | 0 {util => runtime}/lwt.c | 0 {util => runtime}/mem.c | 0 {util => runtime}/rcu.c | 0 util/nbd.c => runtime/runtime.c | 0 runtime/tls.h | 34 +++++++++++++++++++++++++++++++++ 7 files changed, 38 insertions(+), 4 deletions(-) rename {util => runtime}/CuTest.c (100%) rename {util => runtime}/lwt.c (100%) rename {util => runtime}/mem.c (100%) rename {util => runtime}/rcu.c (100%) rename util/nbd.c => runtime/runtime.c (100%) create mode 100644 runtime/tls.h diff --git a/makefile b/makefile index a59466f..1e4c1ec 100644 --- a/makefile +++ b/makefile @@ -11,10 +11,10 @@ INCS := $(addprefix -I, include) TESTS := output/rcu_test output/list_test output/ht_test EXES := $(TESTS) -UTIL_SRCS := util/nbd.c util/rcu.c util/lwt.c util/CuTest.c util/mem.c -rcu_test_SRCS := $(UTIL_SRCS) -list_test_SRCS := $(UTIL_SRCS) struct/list.c -ht_test_SRCS := $(UTIL_SRCS) struct/ht.c struct/ht_test.c +RUNTIME_SRCS := runtime/runtime.c runtime/rcu.c runtime/lwt.c runtime/mem.c runtime/CuTest.c +rcu_test_SRCS := $(RUNTIME_SRCS) +list_test_SRCS := $(RUNTIME_SRCS) struct/list.c +ht_test_SRCS := $(RUNTIME_SRCS) struct/ht.c struct/ht_test.c tests: $(TESTS) diff --git a/util/CuTest.c b/runtime/CuTest.c similarity index 100% rename from util/CuTest.c rename to runtime/CuTest.c diff --git a/util/lwt.c b/runtime/lwt.c similarity index 100% rename from util/lwt.c rename to runtime/lwt.c diff --git a/util/mem.c b/runtime/mem.c similarity index 100% rename from util/mem.c rename to runtime/mem.c diff --git a/util/rcu.c b/runtime/rcu.c similarity index 100% rename from util/rcu.c rename to runtime/rcu.c diff --git a/util/nbd.c b/runtime/runtime.c similarity index 100% rename from util/nbd.c rename to runtime/runtime.c diff --git a/runtime/tls.h b/runtime/tls.h new file mode 100644 index 0000000..def2bec --- /dev/null +++ b/runtime/tls.h @@ -0,0 +1,34 @@ +/* + * Written by Josh Dybnis and released to the public domain, as explained at + * http://creativecommons.org/licenses/publicdomain + * + * A platform independant wrapper around thread-local storage. On platforms that don't support + * __thread variables (e.g. Mac OS X), we have to use the pthreads library for thread-local storage + */ +#ifndef TLS_H +#define TLS_H + +#ifdef __ELF__ // use gcc thread-local storage (i.e. __thread variables) +#define DECLARE_THREAD_LOCAL (name, type) type name +#define INIT_THREAD_LOCAL (name, value) name = value +#define SET_THREAD_LOCAL (name, value) name = value +#define LOCALIZE_THREAD_LOCAL(name, type) extern __thread type name + +#else//!__ELF__ + +#include + +#define DECLARE_THREAD_LOCAL(name, type) pthread_key_t name##_KEY + +#define INIT_THREAD_LOCAL(name, value) \ + do { \ + if (pthread_key_create(&name##_KEY, (void *)(size_t)value) != 0) { assert(FALSE); } \ + } while (0) + +#define SET_THREAD_LOCAL(name, value) pthread_setspecific(name##_KEY, (void *)(size_t)value); + +#define LOCALIZE_THREAD_LOCAL(name, type) \ + extern pthread_key_t name##_KEY; type name = (type)(size_t)pthread_getspecific(name##_KEY) + +#endif//__ELF__ +#endif//TLS_H -- 2.40.0