summaryrefslogtreecommitdiff
path: root/src/libstrongswan/threading
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/threading')
-rw-r--r--src/libstrongswan/threading/semaphore.h5
-rw-r--r--src/libstrongswan/threading/thread.c15
2 files changed, 19 insertions, 1 deletions
diff --git a/src/libstrongswan/threading/semaphore.h b/src/libstrongswan/threading/semaphore.h
index cdb0a6f19..34d814971 100644
--- a/src/libstrongswan/threading/semaphore.h
+++ b/src/libstrongswan/threading/semaphore.h
@@ -21,6 +21,11 @@
#ifndef THREADING_SEMAPHORE_H_
#define THREADING_SEMAPHORE_H_
+#ifdef __APPLE__
+/* Mach uses a semaphore_create() call, use a different name for ours */
+#define semaphore_create(x) strongswan_semaphore_create(x)
+#endif /* __APPLE__ */
+
typedef struct semaphore_t semaphore_t;
/**
diff --git a/src/libstrongswan/threading/thread.c b/src/libstrongswan/threading/thread.c
index d6d98d1ef..eb167d6a4 100644
--- a/src/libstrongswan/threading/thread.c
+++ b/src/libstrongswan/threading/thread.c
@@ -341,7 +341,20 @@ thread_t *thread_create(thread_main_t main, void *arg)
*/
thread_t *thread_current()
{
- return current_thread->get(current_thread);
+ private_thread_t *this;
+
+ this = (private_thread_t*)current_thread->get(current_thread);
+ if (!this)
+ {
+ this = thread_create_internal();
+
+ id_mutex->lock(id_mutex);
+ this->id = next_id++;
+ id_mutex->unlock(id_mutex);
+
+ current_thread->set(current_thread, (void*)this);
+ }
+ return &this->public;
}
/**