mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
s390x portability fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39901 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
78097d25b0
commit
0c7237ec08
5 changed files with 47 additions and 23 deletions
|
@ -1,3 +1,12 @@
|
|||
2016-06-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSObject.m: Make sure we treat the reference count as a
|
||||
32bit integer everywhere, so that atomic operations operate on the
|
||||
correct value on big endian CPUs with different word sizes.
|
||||
* Source/NSOperation.m: When starting an operation, have it retain
|
||||
itself in case it'ss removed from the queue and released while
|
||||
running.
|
||||
|
||||
2016-06-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/cifframe.m: Use sizeof(NSInteger) as the buffer size for
|
||||
|
|
|
@ -202,8 +202,8 @@ typedef int32_t volatile *gsatomic_t;
|
|||
|
||||
#define GSATOMICREAD(X) (*(X))
|
||||
|
||||
#define GSAtomicIncrement(X) InterlockedIncrement((LONG volatile*)X)
|
||||
#define GSAtomicDecrement(X) InterlockedDecrement((LONG volatile*)X)
|
||||
#define GSAtomicIncrement(X) InterlockedIncrement(X)
|
||||
#define GSAtomicDecrement(X) InterlockedDecrement(X)
|
||||
|
||||
|
||||
#elif defined(__llvm__) || (defined(USE_ATOMIC_BUILTINS) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)))
|
||||
|
@ -223,10 +223,10 @@ typedef int32_t volatile *gsatomic_t;
|
|||
|
||||
#define GSATOMICREAD(X) (*(X))
|
||||
|
||||
static __inline__ int
|
||||
static __inline__ int32_t
|
||||
GSAtomicIncrement(gsatomic_t X)
|
||||
{
|
||||
register int tmp;
|
||||
register int32_t tmp;
|
||||
__asm__ __volatile__ (
|
||||
"movl $1, %0\n"
|
||||
"lock xaddl %0, %1"
|
||||
|
@ -236,10 +236,10 @@ GSAtomicIncrement(gsatomic_t X)
|
|||
return tmp + 1;
|
||||
}
|
||||
|
||||
static __inline__ int
|
||||
static __inline__ int32_t
|
||||
GSAtomicDecrement(gsatomic_t X)
|
||||
{
|
||||
register int tmp;
|
||||
register int32_t tmp;
|
||||
__asm__ __volatile__ (
|
||||
"movl $1, %0\n"
|
||||
"negl %0\n"
|
||||
|
@ -256,10 +256,10 @@ typedef int32_t volatile *gsatomic_t;
|
|||
|
||||
#define GSATOMICREAD(X) (*(X))
|
||||
|
||||
static __inline__ int
|
||||
static __inline__ int32_t
|
||||
GSAtomicIncrement(gsatomic_t X)
|
||||
{
|
||||
int tmp;
|
||||
int32_t tmp;
|
||||
__asm__ __volatile__ (
|
||||
"0:"
|
||||
"lwarx %0,0,%1 \n"
|
||||
|
@ -272,10 +272,10 @@ GSAtomicIncrement(gsatomic_t X)
|
|||
return tmp;
|
||||
}
|
||||
|
||||
static __inline__ int
|
||||
static __inline__ int32_t
|
||||
GSAtomicDecrement(gsatomic_t X)
|
||||
{
|
||||
int tmp;
|
||||
int32_t tmp;
|
||||
__asm__ __volatile__ (
|
||||
"0:"
|
||||
"lwarx %0,0,%1 \n"
|
||||
|
@ -294,7 +294,7 @@ typedef int32_t volatile *gsatomic_t;
|
|||
|
||||
#define GSATOMICREAD(X) (*(X))
|
||||
|
||||
static __inline__ int
|
||||
static __inline__ int32_t
|
||||
GSAtomicIncrement(gsatomic_t X)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
@ -303,7 +303,7 @@ GSAtomicIncrement(gsatomic_t X)
|
|||
return *X;
|
||||
}
|
||||
|
||||
static __inline__ int
|
||||
static __inline__ int32_t
|
||||
GSAtomicDecrement(gsatomic_t X)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
@ -318,10 +318,10 @@ typedef int32_t volatile *gsatomic_t;
|
|||
|
||||
#define GSATOMICREAD(X) (*(X))
|
||||
|
||||
static __inline__ int
|
||||
static __inline__ int32_t
|
||||
GSAtomicIncrement(gsatomic_t X)
|
||||
{
|
||||
int tmp;
|
||||
int32_t tmp;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
#if !defined(__mips64)
|
||||
|
@ -335,10 +335,10 @@ GSAtomicIncrement(gsatomic_t X)
|
|||
return tmp;
|
||||
}
|
||||
|
||||
static __inline__ int
|
||||
static __inline__ int32_t
|
||||
GSAtomicDecrement(gsatomic_t X)
|
||||
{
|
||||
int tmp;
|
||||
int32_t tmp;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
#if !defined(__mips64)
|
||||
|
@ -391,7 +391,7 @@ static inline NSLock *GSAllocationLockForObject(id p)
|
|||
* (before the start) in each object.
|
||||
*/
|
||||
typedef struct obj_layout_unpadded {
|
||||
NSUInteger retained;
|
||||
int32_t retained;
|
||||
} unp;
|
||||
#define UNP sizeof(unp)
|
||||
|
||||
|
@ -409,9 +409,9 @@ typedef struct obj_layout_unpadded {
|
|||
* structure correct.
|
||||
*/
|
||||
struct obj_layout {
|
||||
char padding[__BIGGEST_ALIGNMENT__ - ((UNP % __BIGGEST_ALIGNMENT__)
|
||||
? (UNP % __BIGGEST_ALIGNMENT__) : __BIGGEST_ALIGNMENT__)];
|
||||
NSUInteger retained;
|
||||
char padding[__BIGGEST_ALIGNMENT__ - ((UNP % __BIGGEST_ALIGNMENT__)
|
||||
? (UNP % __BIGGEST_ALIGNMENT__) : __BIGGEST_ALIGNMENT__)];
|
||||
int32_t retained;
|
||||
};
|
||||
typedef struct obj_layout *obj;
|
||||
|
||||
|
@ -437,7 +437,7 @@ NSDecrementExtraRefCountWasZero(id anObject)
|
|||
if (allocationLock != 0)
|
||||
{
|
||||
#if defined(GSATOMICREAD)
|
||||
int result;
|
||||
int32_t result;
|
||||
|
||||
result = GSAtomicDecrement((gsatomic_t)&(((obj)anObject)[-1].retained));
|
||||
if (result < 0)
|
||||
|
@ -526,7 +526,7 @@ NSIncrementExtraRefCount(id anObject)
|
|||
NSLock *theLock = GSAllocationLockForObject(anObject);
|
||||
|
||||
[theLock lock];
|
||||
if (((obj)anObject)[-1].retained == UINT_MAX - 1)
|
||||
if (((obj)anObject)[-1].retained > 0xfffffe)
|
||||
{
|
||||
[theLock unlock];
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
|
@ -538,7 +538,7 @@ NSIncrementExtraRefCount(id anObject)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (((obj)anObject)[-1].retained == UINT_MAX - 1)
|
||||
if (((obj)anObject)[-1].retained > 0xfffffe)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"NSIncrementExtraRefCount() asked to increment too far"];
|
||||
|
|
|
@ -413,6 +413,7 @@ static NSArray *empty = nil;
|
|||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
double prio = [NSThread threadPriority];
|
||||
|
||||
AUTORELEASE(RETAIN(self)); // Make sure we exist while running.
|
||||
[internal->lock lock];
|
||||
NS_DURING
|
||||
{
|
||||
|
|
|
@ -131,6 +131,7 @@ int main()
|
|||
{
|
||||
obj = [[MyOperation alloc] initWithValue: i];
|
||||
[a addObject: obj];
|
||||
[obj release];
|
||||
}
|
||||
[q addOperations: a waitUntilFinished: YES];
|
||||
PASS(([obj isFinished] == YES), "operation ran");
|
||||
|
|
|
@ -80,6 +80,19 @@
|
|||
{
|
||||
return thread;
|
||||
}
|
||||
|
||||
- (void) release
|
||||
{
|
||||
NSLog(@"Will release %@ at %@", self, [NSThread callStackSymbols]);
|
||||
[super release];
|
||||
}
|
||||
|
||||
- (id) retain
|
||||
{
|
||||
NSLog(@"Will retain %@ at %@", self, [NSThread callStackSymbols]);
|
||||
return [super retain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface OpExit : OpFlag
|
||||
|
|
Loading…
Reference in a new issue