Author: rfm Date: Wed Jun 22 09:54:16 2016 New Revision: 39901 URL: http://svn.gna.org/viewcvs/gnustep?rev=39901&view=rev Log: s390x portability fixes
Modified: libs/base/trunk/ChangeLog libs/base/trunk/Source/NSObject.m libs/base/trunk/Source/NSOperation.m libs/base/trunk/Tests/base/NSOperation/concurrent.m libs/base/trunk/Tests/base/NSOperation/threads.m Modified: libs/base/trunk/ChangeLog URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=39901&r1=39900&r2=39901&view=diff ============================================================================== --- libs/base/trunk/ChangeLog (original) +++ libs/base/trunk/ChangeLog Wed Jun 22 09:54:16 2016 @@ -1,3 +1,12 @@ +2016-06-22 Richard Frith-Macdonald <r...@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 <r...@gnu.org> * Source/cifframe.m: Use sizeof(NSInteger) as the buffer size for Modified: libs/base/trunk/Source/NSObject.m URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSObject.m?rev=39901&r1=39900&r2=39901&view=diff ============================================================================== --- libs/base/trunk/Source/NSObject.m (original) +++ libs/base/trunk/Source/NSObject.m Wed Jun 22 09:54:16 2016 @@ -202,8 +202,8 @@ #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 @@ #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 @@ 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 @@ #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 @@ 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 @@ #define GSATOMICREAD(X) (*(X)) -static __inline__ int +static __inline__ int32_t GSAtomicIncrement(gsatomic_t X) { __asm__ __volatile__ ( @@ -303,7 +303,7 @@ return *X; } -static __inline__ int +static __inline__ int32_t GSAtomicDecrement(gsatomic_t X) { __asm__ __volatile__ ( @@ -318,10 +318,10 @@ #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 @@ 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 @@ * (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 @@ * 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 @@ 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 @@ 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 @@ } 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"]; Modified: libs/base/trunk/Source/NSOperation.m URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSOperation.m?rev=39901&r1=39900&r2=39901&view=diff ============================================================================== --- libs/base/trunk/Source/NSOperation.m (original) +++ libs/base/trunk/Source/NSOperation.m Wed Jun 22 09:54:16 2016 @@ -413,6 +413,7 @@ NSAutoreleasePool *pool = [NSAutoreleasePool new]; double prio = [NSThread threadPriority]; + AUTORELEASE(RETAIN(self)); // Make sure we exist while running. [internal->lock lock]; NS_DURING { Modified: libs/base/trunk/Tests/base/NSOperation/concurrent.m URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Tests/base/NSOperation/concurrent.m?rev=39901&r1=39900&r2=39901&view=diff ============================================================================== --- libs/base/trunk/Tests/base/NSOperation/concurrent.m (original) +++ libs/base/trunk/Tests/base/NSOperation/concurrent.m Wed Jun 22 09:54:16 2016 @@ -131,6 +131,7 @@ { obj = [[MyOperation alloc] initWithValue: i]; [a addObject: obj]; + [obj release]; } [q addOperations: a waitUntilFinished: YES]; PASS(([obj isFinished] == YES), "operation ran"); Modified: libs/base/trunk/Tests/base/NSOperation/threads.m URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Tests/base/NSOperation/threads.m?rev=39901&r1=39900&r2=39901&view=diff ============================================================================== --- libs/base/trunk/Tests/base/NSOperation/threads.m (original) +++ libs/base/trunk/Tests/base/NSOperation/threads.m Wed Jun 22 09:54:16 2016 @@ -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 _______________________________________________ Gnustep-cvs mailing list Gnustep-cvs@gna.org https://mail.gna.org/listinfo/gnustep-cvs