mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
port latest gc canges to windows
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28090 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1549f5b5e7
commit
b0c507570a
8 changed files with 90 additions and 80 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2009-03-18 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source\win32\GSFileHandle.m:
|
||||||
|
* Source\win32\NSMessagePort.m:
|
||||||
|
* Source\win32\NSMessagePortNameServer.m:
|
||||||
|
* Source\NSConcreteMapTable.m:
|
||||||
|
* Source\Additions\GSCompatibility.m:
|
||||||
|
* Source\Additions\GSCategories.m:
|
||||||
|
* Source\NSData.m:
|
||||||
|
Fixes for windows and changes to GC code, plus changes for old
|
||||||
|
compilers which don't support anonymous unions, plus improvement
|
||||||
|
to error reporting on windows, plus fix to correctly rename
|
||||||
|
protected files if possible.
|
||||||
|
|
||||||
2009-03-16 Richard Frith-Macdonald <rfm@gnu.org>
|
2009-03-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSConcretePointerFunctions.h: Minor GC tweaks
|
* Source/NSConcretePointerFunctions.h: Minor GC tweaks
|
||||||
|
|
|
@ -963,13 +963,15 @@ strerror_r(int eno, char *buf, int len)
|
||||||
*/
|
*/
|
||||||
+ (NSError*) _last
|
+ (NSError*) _last
|
||||||
{
|
{
|
||||||
#if defined(__MINGW32__)
|
|
||||||
return [self _systemError: GetLastError()];
|
|
||||||
#else
|
|
||||||
extern int errno;
|
extern int errno;
|
||||||
|
int eno;
|
||||||
return [self _systemError: errno];
|
#if defined(__MINGW32__)
|
||||||
|
eno = GetLastError();
|
||||||
|
if (eno == 0) eno = errno;
|
||||||
|
#else
|
||||||
|
eno = errno;
|
||||||
#endif
|
#endif
|
||||||
|
return [self _systemError: eno];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSError*) _systemError: (long)code
|
+ (NSError*) _systemError: (long)code
|
||||||
|
|
|
@ -485,22 +485,3 @@ BOOL GSDebugSet(NSString *level)
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSLock (GSCompatibility)
|
|
||||||
/*
|
|
||||||
* Dummy implementation of garbage collection cleanup method called by
|
|
||||||
* GSLazyLock on deallocation.
|
|
||||||
*/
|
|
||||||
- (void) gcFinalize
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation NSRecursiveLock (GSCompatibility)
|
|
||||||
/*
|
|
||||||
* Dummy implementation of garbage collection cleanup method called by
|
|
||||||
* GSLazyRecursiveLock on deallocation.
|
|
||||||
*/
|
|
||||||
- (void) gcFinalize
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
|
@ -72,30 +72,30 @@ typedef GSIMapNode_t *GSIMapNode;
|
||||||
NSMapTableKeyCallBacks k;
|
NSMapTableKeyCallBacks k;
|
||||||
NSMapTableValueCallBacks v;
|
NSMapTableValueCallBacks v;
|
||||||
} old;
|
} old;
|
||||||
};
|
}cb;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#define GSI_MAP_TABLE_T NSConcreteMapTable
|
#define GSI_MAP_TABLE_T NSConcreteMapTable
|
||||||
|
|
||||||
#define GSI_MAP_HASH(M, X)\
|
#define GSI_MAP_HASH(M, X)\
|
||||||
(M->legacy ? M->old.k.hash(M, X.ptr) \
|
(M->legacy ? M->cb.old.k.hash(M, X.ptr) \
|
||||||
: pointerFunctionsHash(&M->pf.k, X.ptr))
|
: pointerFunctionsHash(&M->cb.pf.k, X.ptr))
|
||||||
#define GSI_MAP_EQUAL(M, X, Y)\
|
#define GSI_MAP_EQUAL(M, X, Y)\
|
||||||
(M->legacy ? M->old.k.isEqual(M, X.ptr, Y.ptr) \
|
(M->legacy ? M->cb.old.k.isEqual(M, X.ptr, Y.ptr) \
|
||||||
: pointerFunctionsEqual(&M->pf.k, X.ptr, Y.ptr))
|
: pointerFunctionsEqual(&M->cb.pf.k, X.ptr, Y.ptr))
|
||||||
#define GSI_MAP_RELEASE_KEY(M, X)\
|
#define GSI_MAP_RELEASE_KEY(M, X)\
|
||||||
(M->legacy ? M->old.k.release(M, X.ptr) \
|
(M->legacy ? M->cb.old.k.release(M, X.ptr) \
|
||||||
: pointerFunctionsRelinquish(&M->pf.k, &X.ptr))
|
: pointerFunctionsRelinquish(&M->cb.pf.k, &X.ptr))
|
||||||
#define GSI_MAP_RETAIN_KEY(M, X)\
|
#define GSI_MAP_RETAIN_KEY(M, X)\
|
||||||
(M->legacy ? M->old.k.retain(M, X.ptr) \
|
(M->legacy ? M->cb.old.k.retain(M, X.ptr) \
|
||||||
: pointerFunctionsAcquire(&M->pf.k, &X.ptr, X.ptr))
|
: pointerFunctionsAcquire(&M->cb.pf.k, &X.ptr, X.ptr))
|
||||||
#define GSI_MAP_RELEASE_VAL(M, X)\
|
#define GSI_MAP_RELEASE_VAL(M, X)\
|
||||||
(M->legacy ? M->old.v.release(M, X.ptr) \
|
(M->legacy ? M->cb.old.v.release(M, X.ptr) \
|
||||||
: pointerFunctionsRelinquish(&M->pf.v, &X.ptr))
|
: pointerFunctionsRelinquish(&M->cb.pf.v, &X.ptr))
|
||||||
#define GSI_MAP_RETAIN_VAL(M, X)\
|
#define GSI_MAP_RETAIN_VAL(M, X)\
|
||||||
(M->legacy ? M->old.v.retain(M, X.ptr) \
|
(M->legacy ? M->cb.old.v.retain(M, X.ptr) \
|
||||||
: pointerFunctionsAcquire(&M->pf.v, &X.ptr, X.ptr))
|
: pointerFunctionsAcquire(&M->cb.pf.v, &X.ptr, X.ptr))
|
||||||
|
|
||||||
#define GSI_MAP_ENUMERATOR NSMapEnumerator
|
#define GSI_MAP_ENUMERATOR NSMapEnumerator
|
||||||
|
|
||||||
|
@ -253,13 +253,13 @@ NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone)
|
||||||
t->legacy = o->legacy;
|
t->legacy = o->legacy;
|
||||||
if (t->legacy == YES)
|
if (t->legacy == YES)
|
||||||
{
|
{
|
||||||
t->old.k = o->old.k;
|
t->cb.old.k = o->cb.old.k;
|
||||||
t->old.v = o->old.v;
|
t->cb.old.v = o->cb.old.v;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t->pf.k = o->pf.k;
|
t->cb.pf.k = o->cb.pf.k;
|
||||||
t->pf.v = o->pf.v;
|
t->cb.pf.v = o->cb.pf.v;
|
||||||
}
|
}
|
||||||
#if GS_WITH_GC
|
#if GS_WITH_GC
|
||||||
zone = ((GSIMapTable)table)->zone;
|
zone = ((GSIMapTable)table)->zone;
|
||||||
|
@ -350,8 +350,8 @@ NSCreateMapTableWithZone(
|
||||||
v.describe = NSNonOwnedPointerMapValueCallBacks.describe;
|
v.describe = NSNonOwnedPointerMapValueCallBacks.describe;
|
||||||
|
|
||||||
table->legacy = YES;
|
table->legacy = YES;
|
||||||
table->old.k = k;
|
table->cb.old.k = k;
|
||||||
table->old.v = v;
|
table->cb.old.v = v;
|
||||||
|
|
||||||
#if GS_WITH_GC
|
#if GS_WITH_GC
|
||||||
GSIMapInitWithZoneAndCapacity(table, (NSZone*)nodeSS, capacity);
|
GSIMapInitWithZoneAndCapacity(table, (NSZone*)nodeSS, capacity);
|
||||||
|
@ -456,7 +456,7 @@ NSMapInsert(NSMapTable *table, const void *key, const void *value)
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"Attempt to place key-value in null table"];
|
format: @"Attempt to place key-value in null table"];
|
||||||
}
|
}
|
||||||
if (key == t->old.k.notAKeyMarker)
|
if (key == t->cb.old.k.notAKeyMarker)
|
||||||
{
|
{
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"Attempt to place notAKeyMarker in map table"];
|
format: @"Attempt to place notAKeyMarker in map table"];
|
||||||
|
@ -494,7 +494,7 @@ NSMapInsertIfAbsent(NSMapTable *table, const void *key, const void *value)
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"Attempt to place key-value in null table"];
|
format: @"Attempt to place key-value in null table"];
|
||||||
}
|
}
|
||||||
if (key == t->old.k.notAKeyMarker)
|
if (key == t->cb.old.k.notAKeyMarker)
|
||||||
{
|
{
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"Attempt to place notAKeyMarker in map table"];
|
format: @"Attempt to place notAKeyMarker in map table"];
|
||||||
|
@ -528,7 +528,7 @@ NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value)
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"Attempt to place key-value in null table"];
|
format: @"Attempt to place key-value in null table"];
|
||||||
}
|
}
|
||||||
if (key == t->old.k.notAKeyMarker)
|
if (key == t->cb.old.k.notAKeyMarker)
|
||||||
{
|
{
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"Attempt to place notAKeyMarker in map table"];
|
format: @"Attempt to place notAKeyMarker in map table"];
|
||||||
|
@ -693,8 +693,8 @@ NSStringFromMapTable(NSMapTable *table)
|
||||||
while (NSNextMapEnumeratorPair(&enumerator, &key, &value) == YES)
|
while (NSNextMapEnumeratorPair(&enumerator, &key, &value) == YES)
|
||||||
{
|
{
|
||||||
[string appendFormat: @"%@ = %@;\n",
|
[string appendFormat: @"%@ = %@;\n",
|
||||||
(t->old.k.describe)(table, key),
|
(t->cb.old.k.describe)(table, key),
|
||||||
(t->old.v.describe)(table, value)];
|
(t->cb.old.v.describe)(table, value)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -702,8 +702,8 @@ NSStringFromMapTable(NSMapTable *table)
|
||||||
while (NSNextMapEnumeratorPair(&enumerator, &key, &value) == YES)
|
while (NSNextMapEnumeratorPair(&enumerator, &key, &value) == YES)
|
||||||
{
|
{
|
||||||
[string appendFormat: @"%@ = %@;\n",
|
[string appendFormat: @"%@ = %@;\n",
|
||||||
(t->pf.k.descriptionFunction)(key),
|
(t->cb.pf.k.descriptionFunction)(key),
|
||||||
(t->pf.v.descriptionFunction)(value)];
|
(t->cb.pf.v.descriptionFunction)(value)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NSEndMapTableEnumeration(&enumerator);
|
NSEndMapTableEnumeration(&enumerator);
|
||||||
|
@ -926,45 +926,45 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
||||||
legacy = NO;
|
legacy = NO;
|
||||||
if ([keyFunctions class] == [NSConcretePointerFunctions class])
|
if ([keyFunctions class] == [NSConcretePointerFunctions class])
|
||||||
{
|
{
|
||||||
memcpy(&self->pf.k, &((NSConcretePointerFunctions*)keyFunctions)->_x,
|
memcpy(&self->cb.pf.k, &((NSConcretePointerFunctions*)keyFunctions)->_x,
|
||||||
sizeof(self->pf.k));
|
sizeof(self->cb.pf.k));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self->pf.k.acquireFunction = [keyFunctions acquireFunction];
|
self->cb.pf.k.acquireFunction = [keyFunctions acquireFunction];
|
||||||
self->pf.k.descriptionFunction = [keyFunctions descriptionFunction];
|
self->cb.pf.k.descriptionFunction = [keyFunctions descriptionFunction];
|
||||||
self->pf.k.hashFunction = [keyFunctions hashFunction];
|
self->cb.pf.k.hashFunction = [keyFunctions hashFunction];
|
||||||
self->pf.k.isEqualFunction = [keyFunctions isEqualFunction];
|
self->cb.pf.k.isEqualFunction = [keyFunctions isEqualFunction];
|
||||||
self->pf.k.relinquishFunction = [keyFunctions relinquishFunction];
|
self->cb.pf.k.relinquishFunction = [keyFunctions relinquishFunction];
|
||||||
self->pf.k.sizeFunction = [keyFunctions sizeFunction];
|
self->cb.pf.k.sizeFunction = [keyFunctions sizeFunction];
|
||||||
self->pf.k.usesStrongWriteBarrier
|
self->cb.pf.k.usesStrongWriteBarrier
|
||||||
= [keyFunctions usesStrongWriteBarrier];
|
= [keyFunctions usesStrongWriteBarrier];
|
||||||
self->pf.k.usesWeakReadAndWriteBarriers
|
self->cb.pf.k.usesWeakReadAndWriteBarriers
|
||||||
= [keyFunctions usesWeakReadAndWriteBarriers];
|
= [keyFunctions usesWeakReadAndWriteBarriers];
|
||||||
}
|
}
|
||||||
if ([valueFunctions class] == [NSConcretePointerFunctions class])
|
if ([valueFunctions class] == [NSConcretePointerFunctions class])
|
||||||
{
|
{
|
||||||
memcpy(&self->pf.v, &((NSConcretePointerFunctions*)valueFunctions)->_x,
|
memcpy(&self->cb.pf.v, &((NSConcretePointerFunctions*)valueFunctions)->_x,
|
||||||
sizeof(self->pf.v));
|
sizeof(self->cb.pf.v));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self->pf.v.acquireFunction = [valueFunctions acquireFunction];
|
self->cb.pf.v.acquireFunction = [valueFunctions acquireFunction];
|
||||||
self->pf.v.descriptionFunction = [valueFunctions descriptionFunction];
|
self->cb.pf.v.descriptionFunction = [valueFunctions descriptionFunction];
|
||||||
self->pf.v.hashFunction = [valueFunctions hashFunction];
|
self->cb.pf.v.hashFunction = [valueFunctions hashFunction];
|
||||||
self->pf.v.isEqualFunction = [valueFunctions isEqualFunction];
|
self->cb.pf.v.isEqualFunction = [valueFunctions isEqualFunction];
|
||||||
self->pf.v.relinquishFunction = [valueFunctions relinquishFunction];
|
self->cb.pf.v.relinquishFunction = [valueFunctions relinquishFunction];
|
||||||
self->pf.v.sizeFunction = [valueFunctions sizeFunction];
|
self->cb.pf.v.sizeFunction = [valueFunctions sizeFunction];
|
||||||
self->pf.v.usesStrongWriteBarrier
|
self->cb.pf.v.usesStrongWriteBarrier
|
||||||
= [valueFunctions usesStrongWriteBarrier];
|
= [valueFunctions usesStrongWriteBarrier];
|
||||||
self->pf.v.usesWeakReadAndWriteBarriers
|
self->cb.pf.v.usesWeakReadAndWriteBarriers
|
||||||
= [valueFunctions usesWeakReadAndWriteBarriers];
|
= [valueFunctions usesWeakReadAndWriteBarriers];
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GC_WITH_GC
|
#if GC_WITH_GC
|
||||||
if (self->pf.k.usesWeakReadAndWriteBarriers)
|
if (self->cb.pf.k.usesWeakReadAndWriteBarriers)
|
||||||
{
|
{
|
||||||
if (self->pf.v.usesWeakReadAndWriteBarriers)
|
if (self->cb.pf.v.usesWeakReadAndWriteBarriers)
|
||||||
{
|
{
|
||||||
zone = (NSZone*)nodeWW;
|
zone = (NSZone*)nodeWW;
|
||||||
}
|
}
|
||||||
|
@ -975,7 +975,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (self->pf.v.usesWeakReadAndWriteBarriers)
|
if (self->cb.pf.v.usesWeakReadAndWriteBarriers)
|
||||||
{
|
{
|
||||||
zone = (NSZone*)nodeSW;
|
zone = (NSZone*)nodeSW;
|
||||||
}
|
}
|
||||||
|
@ -1003,7 +1003,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
||||||
{
|
{
|
||||||
NSConcretePointerFunctions *p = [NSConcretePointerFunctions new];
|
NSConcretePointerFunctions *p = [NSConcretePointerFunctions new];
|
||||||
|
|
||||||
p->_x = self->pf.k;
|
p->_x = self->cb.pf.k;
|
||||||
return [p autorelease];
|
return [p autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1074,7 +1074,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
||||||
{
|
{
|
||||||
NSConcretePointerFunctions *p = [NSConcretePointerFunctions new];
|
NSConcretePointerFunctions *p = [NSConcretePointerFunctions new];
|
||||||
|
|
||||||
p->_x = self->pf.v;
|
p->_x = self->cb.pf.v;
|
||||||
return [p autorelease];
|
return [p autorelease];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -79,6 +79,7 @@
|
||||||
#include "Foundation/NSPathUtilities.h"
|
#include "Foundation/NSPathUtilities.h"
|
||||||
#include "Foundation/NSRange.h"
|
#include "Foundation/NSRange.h"
|
||||||
#include "Foundation/NSURL.h"
|
#include "Foundation/NSURL.h"
|
||||||
|
#include "Foundation/NSValue.h"
|
||||||
#include "Foundation/NSZone.h"
|
#include "Foundation/NSZone.h"
|
||||||
#include "GSPrivate.h"
|
#include "GSPrivate.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -987,6 +988,9 @@ failure:
|
||||||
{
|
{
|
||||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||||
NSMutableDictionary *att = nil;
|
NSMutableDictionary *att = nil;
|
||||||
|
#if defined(__MINGW32__)
|
||||||
|
NSUInteger perm;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ([mgr fileExistsAtPath: path])
|
if ([mgr fileExistsAtPath: path])
|
||||||
{
|
{
|
||||||
|
@ -996,6 +1000,15 @@ failure:
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__MINGW32__)
|
#if defined(__MINGW32__)
|
||||||
|
/* To replace the existing file on windows, it must be writable.
|
||||||
|
*/
|
||||||
|
perm = [att filePosixPermissions];
|
||||||
|
if (perm != NSNotFound && (perm & 0200) == 0)
|
||||||
|
{
|
||||||
|
[mgr changeFileAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
[NSNumber numberWithUnsignedInt: 0777], NSFilePosixPermissions,
|
||||||
|
nil] atPath: path];
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* The windoze implementation of the POSIX rename() function is buggy
|
* The windoze implementation of the POSIX rename() function is buggy
|
||||||
* and doesn't work if the destination file already exists ... so we
|
* and doesn't work if the destination file already exists ... so we
|
||||||
|
|
|
@ -248,14 +248,14 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||||
RELEASE(service);
|
RELEASE(service);
|
||||||
RELEASE(protocol);
|
RELEASE(protocol);
|
||||||
|
|
||||||
[self gcFinalize];
|
[self finalize];
|
||||||
|
|
||||||
RELEASE(readInfo);
|
RELEASE(readInfo);
|
||||||
RELEASE(writeInfo);
|
RELEASE(writeInfo);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) gcFinalize
|
- (void) finalize
|
||||||
{
|
{
|
||||||
if (self == fh_stdin)
|
if (self == fh_stdin)
|
||||||
fh_stdin = nil;
|
fh_stdin = nil;
|
||||||
|
|
|
@ -233,7 +233,7 @@ static Class messagePortClass = 0;
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[self gcFinalize];
|
[self finalize];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ static Class messagePortClass = 0;
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) gcFinalize
|
- (void) finalize
|
||||||
{
|
{
|
||||||
internal *this;
|
internal *this;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ extern __declspec(dllimport) int errno;
|
||||||
|
|
||||||
static NSRecursiveLock *serverLock = nil;
|
static NSRecursiveLock *serverLock = nil;
|
||||||
static NSMessagePortNameServer *defaultServer = nil;
|
static NSMessagePortNameServer *defaultServer = nil;
|
||||||
static NSMapTable portToNamesMap;
|
static NSMapTable *portToNamesMap;
|
||||||
static NSString *registry;
|
static NSString *registry;
|
||||||
static HKEY key;
|
static HKEY key;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue