mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
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:
parent
f30057c85f
commit
2663321b83
1 changed files with 53 additions and 17 deletions
|
@ -1,12 +1,47 @@
|
||||||
#include "runtime.h"
|
#import "Foundation/NSObject.h"
|
||||||
|
|
||||||
// Subset of NSObject interface needed for properties.
|
#if !defined(_NATIVE_OBJC_EXCEPTIONS)
|
||||||
@interface NSObject {}
|
/* If we don't have support for native exceptions then we can't use
|
||||||
- (id)retain;
|
* @synchronized, so we use NSException and NSLock.
|
||||||
- (id)copy;
|
* This is a horribly inefficient, but you probably shouldn't be using
|
||||||
- (id)autorelease;
|
* the property functions anyway :-)
|
||||||
- (void)release;
|
*/
|
||||||
@end
|
#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
|
id
|
||||||
objc_getProperty(id obj, SEL _cmd, ptrdiff_t offset, BOOL isAtomic)
|
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)
|
if (isAtomic)
|
||||||
{
|
{
|
||||||
@synchronized(obj)
|
id result;
|
||||||
{
|
|
||||||
return objc_getProperty(obj, _cmd, offset, NO);
|
SYNCBEG(obj)
|
||||||
}
|
result = objc_getProperty(obj, _cmd, offset, NO);
|
||||||
|
SYNCEND();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
addr = (char*)obj;
|
addr = (char*)obj;
|
||||||
addr += offset;
|
addr += offset;
|
||||||
|
@ -36,11 +73,10 @@ objc_setProperty(id obj, SEL _cmd, ptrdiff_t offset, id arg, BOOL isAtomic,
|
||||||
|
|
||||||
if (isAtomic)
|
if (isAtomic)
|
||||||
{
|
{
|
||||||
@synchronized(obj)
|
SYNCBEG(obj)
|
||||||
{
|
objc_setProperty(obj, _cmd, offset, arg, NO, isCopy);
|
||||||
objc_setProperty(obj, _cmd, offset, arg, NO, isCopy);
|
SYNCEND();
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isCopy)
|
if (isCopy)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue