[PATCH 16/30] Added Thread Local Storage


Michael Schonberg <mschonberg@...>
 

In preparation for windows support macros for pthread style thread local
storage added to linux/port.h

wthread_key_create
wthread_key_delete
wthread_getspecific
wthread_setspecific
These map directly to the same pthread_xxx methods for linux, but they
are implemented with TlsAlloc(), etc for windows.

Signed-off-by: Mike Schonberg <mschonberg@nyx.com>
---
common/c_cpp/src/c/linux/port.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index 86d2e50..e289006 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -100,6 +100,13 @@ typedef long long int w_i64_t;

#define PATHSEP "/"

+/* Thread local storage */
+typedef pthread_key_t wthread_key_t;
+#define wthread_key_create(x, val) pthread_key_create((x), (val))
+#define wthread_key_delete(x) pthread_key_delete((x))
+#define wthread_setspecific(x, val) pthread_setspecific((x),(void*)((val)))
+#define wthread_getspecific(x) pthread_getspecific((x))
+
/* Use Posix semaphores for Linux */
#define wsem_t sem_t
#define wsem_init sem_init
--
1.7.7.6

Join Openmama-dev@lists.openmama.org to automatically receive all group messages.