Author: rfm
Date: Wed Feb 10 10:15:10 2016
New Revision: 39350
URL: http://svn.gna.org/viewcvs/gnustep?rev=39350&view=rev
Log:
Tweaks to avoid compiler warnings, and consistently use ref counting macros.
Modified:
libs/base/trunk/Source/NSThread.m
Modified: libs/base/trunk/Source/NSThread.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSThread.m?rev=39350&r1=39349&r2=39350&view=diff
==============================================================================
--- libs/base/trunk/Source/NSThread.m (original)
+++ libs/base/trunk/Source/NSThread.m Wed Feb 10 10:15:10 2016
@@ -411,11 +411,14 @@
* Conversely, we need to be able to retrieve the pthread_t
* from an NSValue.
*/
-static inline void _getPthreadFromNSValue(NSValue* value, pthread_t
*thread_ptr)
-{
+static inline void
+_getPthreadFromNSValue(NSValue* value, pthread_t *thread_ptr)
+{
+ const char *enc;
+
NSCAssert(thread_ptr, @"No storage for thread reference");
# ifndef NS_BLOCK_ASSERTIONS
- const char* enc = [value objCType];
+ enc = [value objCType];
NSCAssert(enc != NULL && (0 == strcmp(@encode(pthread_t),enc)),
@"Invalid NSValue container for thread reference");
# endif
@@ -433,6 +436,7 @@
{
pthread_t thread;
pthread_t otherThread;
+
_getPthreadFromNSValue(boxed, &thread);
_getPthreadFromNSValue(boxedOther, &otherThread);
return pthread_equal(thread, otherThread);
@@ -463,7 +467,7 @@
*/
static void _boxedPthreadRetain(NSMapTable* t, const void* value)
{
- [(NSValue*)value retain];
+ RETAIN((NSValue*)value);
}
/**
@@ -471,7 +475,7 @@
*/
static void _boxedPthreadRelease(NSMapTable* t, void* value)
{
- [(NSValue*)value release];
+ RELEASE((NSValue*)value);
}
/**
@@ -567,25 +571,24 @@
*/
static void exitedThread(void *thread)
{
-
if (thread != defaultThread)
{
- [(NSThread*)thread retain];
- NSValue *ref = NSValueCreateFromPthread(pthread_self());
+ CREATE_AUTORELEASE_POOL(arp);
+ NSValue *ref;
+
+ RETAIN((NSThread*)thread);
+ ref = NSValueCreateFromPthread(pthread_self());
_willLateUnregisterThread(ref, (NSThread*)thread);
- /* We create a pool for all objects used during cleanup to go into.
- */
- NSAutoreleasePool *arp = [NSAutoreleasePool new];
NS_DURING
{
- unregisterActiveThread((NSThread*)thread);
+ unregisterActiveThread((NSThread*)thread);
}
NS_HANDLER
{
DESTROY(arp);
_didLateUnregisterCurrentThread(ref);
DESTROY(ref);
- [(NSThread*)thread release];
+ RELEASE((NSThread*)thread);
}
NS_ENDHANDLER
DESTROY(arp);
@@ -595,7 +598,7 @@
*/
_didLateUnregisterCurrentThread(ref);
DESTROY(ref);
- [(NSThread*)thread release];
+ RELEASE((NSThread*)thread);
}
}
@@ -631,7 +634,7 @@
thr = pthread_getspecific(thread_object_key);
if ((nil == defaultThread) && IS_MAIN_PTHREAD)
{
- defaultThread = [thr retain];
+ defaultThread = RETAIN(thr);
}
}
assert(nil != thr && "No main thread");
@@ -759,7 +762,7 @@
userInfo: nil];
[(GSRunLoopThreadInfo*)thread->_runLoopInfo invalidate];
- [thread release];
+ RELEASE(thread);
[[NSGarbageCollector defaultCollector] enableCollectorForPointer:
thread];
pthread_setspecific(thread_object_key, nil);
@@ -1197,7 +1200,7 @@
/* The thread must persist until it finishes executing.
*/
- [self retain];
+ RETAIN(self);
/* Mark the thread as active whiul it's running.
*/
@@ -1363,7 +1366,7 @@
NSArray *p;
[lock lock];
- p = [performers autorelease];
+ p = AUTORELEASE(performers);
performers = nil;
#ifdef __MINGW__
if (event != INVALID_HANDLE_VALUE)
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs