Avoid failure with older complilers

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29672 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2010-02-19 15:15:24 +00:00
parent f30057c85f
commit 2663321b83

View file

@ -1,12 +1,47 @@
#include "runtime.h"
#import "Foundation/NSObject.h"
// Subset of NSObject interface needed for properties.
@interface NSObject {}
- (id)retain;
- (id)copy;
- (id)autorelease;
- (void)release;
@end
#if !defined(_NATIVE_OBJC_EXCEPTIONS)
/* If we don't have support for native exceptions then we can't use
* @synchronized, so we use NSException and NSLock.
* This is a horribly inefficient, but you probably shouldn't be using
* the property functions anyway :-)
*/
#import "Foundation/NSException.h"
#import "Foundation/NSLock.h"
static NSRecursiveLock *propertyLock = nil;
static inline NSRecursiveLock*
pLock()
{
if (propertyLock == nil)
{
[gnustep_global_lock lock];
if (propertyLock == nil)
{
propertyLock = [NSRecursiveLock new];
}
[gnustep_global_lock unlock];
}
return propertyLock;
}
#define SYNCBEG(X) \
[pLock() lock]; \
NS_DURING
#define SYNCEND() \
NS_HANDLER \
[pLock() unlock]; \
[localException raise]; \
NS_ENDHANDLER \
[pLock() unlock]
#else
#define SYNCBEG(X) @synchronized(X) {
#define SYNCEND() }
#endif
id
objc_getProperty(id obj, SEL _cmd, ptrdiff_t offset, BOOL isAtomic)
@ -16,10 +51,12 @@ objc_getProperty(id obj, SEL _cmd, ptrdiff_t offset, BOOL isAtomic)
if (isAtomic)
{
@synchronized(obj)
{
return objc_getProperty(obj, _cmd, offset, NO);
}
id result;
SYNCBEG(obj)
result = objc_getProperty(obj, _cmd, offset, NO);
SYNCEND();
return result;
}
addr = (char*)obj;
addr += offset;
@ -36,11 +73,10 @@ objc_setProperty(id obj, SEL _cmd, ptrdiff_t offset, id arg, BOOL isAtomic,
if (isAtomic)
{
@synchronized(obj)
{
objc_setProperty(obj, _cmd, offset, arg, NO, isCopy);
return;
}
SYNCBEG(obj)
objc_setProperty(obj, _cmd, offset, arg, NO, isCopy);
SYNCEND();
return;
}
if (isCopy)
{