diff options
author | obrien <obrien@FreeBSD.org> | 2002-05-09 22:50:04 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2002-05-09 22:50:04 +0000 |
commit | 9202658d3cd1b82b9c9b96c52fde1774d313ab2c (patch) | |
tree | ba6f9907191b31996edc00ff6dae7cf7978d19e9 /contrib/libobjc/thr.c | |
parent | eb81e01d5162436a00b210305c91bbba234a0238 (diff) | |
download | FreeBSD-src-9202658d3cd1b82b9c9b96c52fde1774d313ab2c.zip FreeBSD-src-9202658d3cd1b82b9c9b96c52fde1774d313ab2c.tar.gz |
Gcc 3.1.0 pre-release's Objective C support bits from the FSF anoncvs repo
on 9-May-2002 15:57:15 EDT.
Diffstat (limited to 'contrib/libobjc/thr.c')
-rw-r--r-- | contrib/libobjc/thr.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/contrib/libobjc/thr.c b/contrib/libobjc/thr.c index f1c957a..13a22a5 100644 --- a/contrib/libobjc/thr.c +++ b/contrib/libobjc/thr.c @@ -318,7 +318,7 @@ objc_mutex_lock(objc_mutex_t mutex) return -1; /* If we already own the lock then increment depth */ - thread_id = objc_thread_id(); + thread_id = __objc_thread_id(); if (mutex->owner == thread_id) return ++mutex->depth; @@ -350,7 +350,7 @@ objc_mutex_trylock(objc_mutex_t mutex) return -1; /* If we already own the lock then increment depth */ - thread_id = objc_thread_id(); + thread_id = __objc_thread_id(); if (mutex->owner == thread_id) return ++mutex->depth; @@ -385,7 +385,7 @@ objc_mutex_unlock(objc_mutex_t mutex) return -1; /* If another thread owns the lock then abort */ - thread_id = objc_thread_id(); + thread_id = __objc_thread_id(); if (mutex->owner != thread_id) return -1; @@ -477,7 +477,7 @@ objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex) return -1; /* Make sure we are owner of mutex */ - thread_id = objc_thread_id(); + thread_id = __objc_thread_id(); if (mutex->owner != thread_id) return -1; @@ -531,4 +531,33 @@ objc_condition_signal(objc_condition_t condition) return __objc_condition_signal(condition); } +/* Make the objc thread system aware that a thread which is managed + (started, stopped) by external code could access objc facilities + from now on. This is used when you are interfacing with some + external non-objc-based environment/system - you must call + objc_thread_add() before an alien thread makes any calls to + Objective-C. Do not cause the _objc_became_multi_threaded hook to + be executed. */ +void +objc_thread_add(void) +{ + objc_mutex_lock(__objc_runtime_mutex); + __objc_is_multi_threaded = 1; + __objc_runtime_threads_alive++; + objc_mutex_unlock(__objc_runtime_mutex); +} + +/* Make the objc thread system aware that a thread managed (started, + stopped) by some external code will no longer access objc and thus + can be forgotten by the objc thread system. Call + objc_thread_remove() when your alien thread is done with making + calls to Objective-C. */ +void +objc_thread_remove(void) +{ + objc_mutex_lock(__objc_runtime_mutex); + __objc_runtime_threads_alive--; + objc_mutex_unlock(__objc_runtime_mutex); +} + /* End of File */ |