summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-13 23:50:26 -0700
committerPixel <pixel@nobis-crew.org>2011-10-13 23:50:26 -0700
commit9704c57c47dc31f592ecf3a38e303ee3bcbbae74 (patch)
treeb2d54dd6609aeba929864e0dc1f851d48f55a0fe /src
parent4974182b6aabca78940976984fca02a9b2e69795 (diff)
Implementing a pthread TLSManager.
Diffstat (limited to 'src')
-rw-r--r--src/Local.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Local.cc b/src/Local.cc
index 1619557..8418fb1 100644
--- a/src/Local.cc
+++ b/src/Local.cc
@@ -29,3 +29,32 @@ void Balau::Local::doStart() {
m_globals = reinterpret_cast<void **>(realloc(m_globals, s_size * sizeof(void *)));
m_globals[m_idx] = 0;
}
+
+class PThreadsTLSManager : public Balau::TLSManager, public Balau::AtStart {
+ public:
+ PThreadsTLSManager() : AtStart(0) { }
+ virtual void * getTLS();
+ virtual void * setTLS(void * val);
+ virtual void doStart();
+ private:
+ pthread_key_t m_key;
+};
+
+PThreadsTLSManager pthreadsTLSManager;
+
+void PThreadsTLSManager::doStart() {
+ int r;
+
+ r = pthread_key_create(&m_key, NULL);
+ Assert(r == 0);
+}
+
+void * PThreadsTLSManager::getTLS() {
+ return pthread_getspecific(m_key);
+}
+
+void * PThreadsTLSManager::setTLS(void * val) {
+ void * r = pthread_getspecific(m_key);
+ pthread_setspecific(m_key, val);
+ return r;
+}