removal of garbage collection

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39608 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2016-03-25 11:15:28 +00:00
parent 030f54a9cf
commit d40d219015
72 changed files with 122 additions and 1787 deletions

View file

@ -1,3 +1,78 @@
2016-03-25 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Foundation/NSObject.h:
* Headers/GNUstepBase/GNUstep.h:
* Headers/GNUstepBase/GSConfig.h.in:
* Headers/GNUstepBase/GSIArray.h:
* Headers/GNUstepBase/GSIMap.h:
* Source/Additions/GCDictionary.m:
* Source/Additions/GSLock.m:
* Source/Additions/GSMime.m:
* Source/Additions/GSObjCRuntime.m:
* Source/Additions/Unicode.m:
* Source/GSArray.m:
* Source/GSAttributedString.m:
* Source/GSConcreteValueTemplate.m:
* Source/GSCountedSet.m:
* Source/GSDictionary.m:
* Source/GSHTTPAuthentication.m:
* Source/GSRunLoopCtxt.h:
* Source/GSSet.m:
* Source/GSString.m:
* Source/NSArchiver.m:
* Source/NSArray.m:
* Source/NSAutoreleasePool.m:
* Source/NSCalendar.m:
* Source/NSConcreteHashTable.m:
* Source/NSConcreteMapTable.m:
* Source/NSConcretePointerFunctions.h:
* Source/NSConcretePointerFunctions.m:
* Source/NSConnection.m:
* Source/NSCountedSet.m:
* Source/NSData.m:
* Source/NSDebug.m:
* Source/NSDictionary.m:
* Source/NSDistributedNotificationCenter.m:
* Source/NSFileManager.m:
* Source/NSGarbageCollector.m:
* Source/NSHashTable.m:
* Source/NSIndexSet.m:
* Source/NSKeyValueObserving.m:
* Source/NSKeyedArchiver.m:
* Source/NSKeyedUnarchiver.m:
* Source/NSMapTable.m:
* Source/NSMessagePort.m:
* Source/NSNotificationCenter.m:
* Source/NSNotificationQueue.m:
* Source/NSObject.m:
* Source/NSPointerArray.m:
* Source/NSPortCoder.m:
* Source/NSProxy.m:
* Source/NSRunLoop.m:
* Source/NSSerializer.m:
* Source/NSSet.m:
* Source/NSSocketPort.m:
* Source/NSString.m:
* Source/NSThread.m:
* Source/NSTimeZone.m:
* Source/NSURL.m:
* Source/NSURLConnection.m:
* Source/NSURLProtocol.m:
* Source/NSUnarchiver.m:
* Source/NSZone.m:
* Source/callframe.m:
* Source/unix/GSRunLoopCtxt.m:
* Source/win32/GSRunLoopCtxt.m:
* Tools/AGSHtml.m:
* Tools/AGSOutput.m:
* Tools/AGSParser.m:
* Tools/autogsdoc.m:
* Tools/gdnc.m:
* Tools/make_strings/make_strings.m:
* configure.ac:
* macosx/config.h:
Removal of garbage collection support.
2016-03-25 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSNumber.m: Attempt to fix endianness archiving issue.

View file

@ -31,9 +31,10 @@
#import <objc/objc.h>
#import <Foundation/NSZone.h>
#ifndef GS_WITH_GC
#define GS_WITH_GC 0
#ifdef GS_WITH_GC
#undef GS_WITH_GC
#endif
#define GS_WITH_GC 0
#import <GNUstepBase/GNUstep.h>

View file

@ -44,7 +44,7 @@
# define __has_extension(x) __has_feature(x)
#endif
#if GS_WITH_GC || __has_feature(objc_arc)
#if __has_feature(objc_arc)
#ifndef RETAIN
#define RETAIN(object) (object)

View file

@ -218,22 +218,10 @@ typedef gsuaddr gsaddr;
//#define USE_GMP @USE_GMP@
#define USE_GMP 0
/*
* Macros to deal with hiding an object from the garbage collector
* This macro employs the procesor-dependent knowledge that a pointer to an
* object will always be on an even address boundary. If we ever port to a
* system where this is not the case, we will have to find another mechanism.
*/
#ifndef GS_WITH_GC
#ifdef GS_WITH_GC
#undef GS_WITH_GC
#endif
#define GS_WITH_GC 0
#endif
#if GS_WITH_GC
#define GS_GC_HIDE(obj) ((id)(((uintptr_t)obj) | 1))
#define GS_GC_UNHIDE(obj) ((id)(((uintptr_t)obj) & ~1))
#else
#define GS_GC_HIDE(obj) ((id)obj)
#define GS_GC_UNHIDE(obj) ((id)obj)
#endif
/*
* Define to say if we use NXConstantString or NSConstantString

View file

@ -208,23 +208,14 @@ GSIArrayGrow(GSIArray array)
}
next = array->cap + array->old;
size = next*sizeof(GSIArrayItem);
#if GS_WITH_GC
tmp = NSAllocateCollectable(size, array->zone ? NSScannedOption : 0);
#else
tmp = NSZoneMalloc(array->zone, size);
#endif
memcpy(tmp, array->ptr, array->count * sizeof(GSIArrayItem));
}
else
{
next = array->cap + array->old;
size = next*sizeof(GSIArrayItem);
#if GS_WITH_GC
tmp = NSReallocateCollectable(array->ptr, size,
array->zone ? NSScannedOption : 0);
#else
tmp = NSZoneRealloc(array->zone, array->ptr, size);
#endif
}
if (tmp == 0)
@ -254,21 +245,12 @@ GSIArrayGrowTo(GSIArray array, unsigned next)
/*
* Statically initialised buffer ... copy into new heap buffer.
*/
#if GS_WITH_GC
tmp = NSAllocateCollectable(size, array->zone ? NSScannedOption : 0);
#else
tmp = NSZoneMalloc(array->zone, size);
#endif
memcpy(tmp, array->ptr, array->count * sizeof(GSIArrayItem));
}
else
{
#if GS_WITH_GC
tmp = NSReallocateCollectable(array->ptr, size,
array->zone ? NSScannedOption : 0);
#else
tmp = NSZoneRealloc(array->zone, array->ptr, size);
#endif
}
if (tmp == 0)
@ -464,9 +446,6 @@ GSIArrayRemoveItemAtIndex(GSIArray array, unsigned index)
while (++index < array->count)
array->ptr[index-1] = array->ptr[index];
array->count--;
# if GS_WITH_GC
array->ptr[array->count] = (GSIArrayItem)(NSUInteger)0;
# endif
#else
GSIArrayItem tmp;
# ifdef GSI_ARRAY_CHECKS
@ -476,9 +455,6 @@ GSIArrayRemoveItemAtIndex(GSIArray array, unsigned index)
while (++index < array->count)
array->ptr[index-1] = array->ptr[index];
array->count--;
# if GS_WITH_GC
array->ptr[array->count] = (GSIArrayItem)(NSUInteger)0;
# endif
GSI_ARRAY_RELEASE(array, tmp);
#endif
}
@ -492,9 +468,6 @@ GSIArrayRemoveLastItem(GSIArray array)
array->count--;
#if !defined(GSI_ARRAY_NO_RELEASE)
GSI_ARRAY_RELEASE(array, array->ptr[array->count]);
#if GS_WITH_GC
array->ptr[array->count] = (GSIArrayItem)(NSUInteger)0;
#endif
#endif
}
@ -507,9 +480,6 @@ GSIArrayRemoveItemAtIndexNoRelease(GSIArray array, unsigned index)
while (++index < array->count)
array->ptr[index-1] = array->ptr[index];
array->count--;
#if GS_WITH_GC && !defined(GSI_ARRAY_NO_RELEASE)
array->ptr[array->count] = (GSIArrayItem)(NSUInteger)0;
#endif
}
GS_STATIC_INLINE void
@ -566,7 +536,6 @@ GSIArrayClear(GSIArray array)
{
if (array->ptr)
{
#if !GS_WITH_GC
/*
* Only free memory if it was dynamically initialised (old > 0)
*/
@ -574,7 +543,6 @@ GSIArrayClear(GSIArray array)
{
NSZoneFree(array->zone, (void*)array->ptr);
}
#endif
array->ptr = 0;
array->cap = 0;
}
@ -589,9 +557,6 @@ GSIArrayRemoveItemsFromIndex(GSIArray array, unsigned index)
while (array->count-- > index)
{
GSI_ARRAY_RELEASE(array, array->ptr[array->count]);
#if GS_WITH_GC
array->ptr[array->count] = (GSIArrayItem)(NSUInteger)0;
#endif
}
#endif
array->count = index;
@ -605,9 +570,6 @@ GSIArrayRemoveAllItems(GSIArray array)
while (array->count--)
{
GSI_ARRAY_RELEASE(array, array->ptr[array->count]);
#if GS_WITH_GC
array->ptr[array->count] = (GSIArrayItem)(NSUInteger)0;
#endif
}
#endif
array->count = 0;
@ -632,12 +594,7 @@ GSIArrayInitWithZoneAndCapacity(GSIArray array, NSZone *zone, size_t capacity)
array->cap = capacity;
array->old = capacity/2;
size = capacity*sizeof(GSIArrayItem);
#if GS_WITH_GC
array->ptr = (GSIArrayItem*)NSAllocateCollectable(size,
array->zone ? NSScannedOption : 0);
#else
array->ptr = (GSIArrayItem*)NSZoneMalloc(zone, size);
#endif
return array;
}
@ -659,12 +616,7 @@ GSIArrayCopyWithZone(GSIArray array, NSZone *zone)
unsigned int i;
GSIArray new;
#if GS_WITH_GC
new = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
#else
new = NSZoneMalloc(zone, sizeof(GSIArray_t));
#endif
GSIArrayInitWithZoneAndCapacity(new, zone, array->count);
for (i = 0; i < array->count; i++)
{

View file

@ -571,15 +571,8 @@ GSIMapMoreNodes(GSIMapTable map, unsigned required)
{
GSIMapNode *newArray;
#if GS_WITH_GC
uintptr_t arraySize = (map->chunkCount+1)*sizeof(GSIMapNode);
/* We don't want our nodes collected before we have finished with them,
* so we must keep the array of pointers to memory chunks in scanned memory.
*/
newArray = (GSIMapNode*)NSAllocateCollectable(arraySize, NSScannedOption);
#else
newArray = (GSIMapNode*)NSZoneCalloc(map->zone, (map->chunkCount+1), sizeof(GSIMapNode));
#endif
newArray = (GSIMapNode*)NSZoneCalloc(map->zone,
(map->chunkCount+1), sizeof(GSIMapNode));
if (newArray)
{
GSIMapNode newNodes;
@ -589,9 +582,7 @@ GSIMapMoreNodes(GSIMapTable map, unsigned required)
{
memcpy(newArray, map->nodeChunks,
(map->chunkCount)*sizeof(GSIMapNode));
#if !GS_WITH_GC
NSZoneFree(map->zone, map->nodeChunks);
#endif
}
map->nodeChunks = newArray;
@ -610,12 +601,8 @@ GSIMapMoreNodes(GSIMapTable map, unsigned required)
{
chunkCount = required;
}
#if GS_WITH_GC
newNodes = GSI_MAP_NODES(map, chunkCount);
#else
newNodes
= (GSIMapNode)NSZoneCalloc(map->zone, chunkCount, sizeof(GSIMapNode_t));
#endif
if (newNodes)
{
map->nodeChunks[map->chunkCount++] = newNodes;
@ -792,30 +779,19 @@ GSIMapResize(GSIMapTable map, uintptr_t new_capacity)
size++;
}
#if GS_WITH_GC
/* We don't need to use scanned memory because the nodes are not 'owned'
* by the bucket they are in, but rather are in chunks pointed to by
* the nodeChunks array.
*/
new_buckets = (GSIMapBucket)NSAllocateCollectable
(size * sizeof(GSIMapBucket_t), 0);
#else
/* Use the zone specified for this map.
*/
new_buckets = (GSIMapBucket)NSZoneCalloc(map->zone, size,
sizeof(GSIMapBucket_t));
#endif
if (new_buckets != 0)
{
GSIMapRemangleBuckets(map, map->buckets, map->bucketCount, new_buckets,
size);
#if !GS_WITH_GC
if (map->buckets != 0)
{
NSZoneFree(map->zone, map->buckets);
}
#endif
map->buckets = new_buckets;
map->bucketCount = size;
}
@ -1225,15 +1201,12 @@ GSIMapEmptyMap(GSIMapTable map)
#endif
if (map->buckets != 0)
{
#if !GS_WITH_GC
NSZoneFree(map->zone, map->buckets);
#endif
map->buckets = 0;
map->bucketCount = 0;
}
if (map->nodeChunks != 0)
{
#if !GS_WITH_GC
unsigned int i;
for (i = 0; i < map->chunkCount; i++)
@ -1241,7 +1214,6 @@ GSIMapEmptyMap(GSIMapTable map)
NSZoneFree(map->zone, map->nodeChunks[i]);
}
NSZoneFree(map->zone, map->nodeChunks);
#endif
map->chunkCount = 0;
map->nodeChunks = 0;
}

View file

@ -99,11 +99,9 @@ _GCCompareObjects(NSMapTable *table, const GCInfo *o1, const GCInfo *o2)
static void
_GCRetainObjects(NSMapTable *table, const void *ptr)
{
#if !GS_WITH_GC
GCInfo *objectStruct = (GCInfo*)ptr;
[objectStruct->object retain];
#endif
}
static void

View file

@ -72,19 +72,11 @@
locked = -1;
}
#ifdef __GS_WITH_GC__
- (void) finalize
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
[super finalize];
}
#else
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
[super dealloc];
}
#endif
- (id) init
{
@ -222,22 +214,11 @@
counter = -1;
}
#ifdef __GS_WITH_GC__
- (void) finalize
{
if (counter >= 0)
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
}
[super finalize];
}
#else
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
[super dealloc];
}
#endif
- (id) init
{

View file

@ -1781,11 +1781,7 @@ wordData(NSString *word, BOOL *encoded)
NSUInteger l = [tmp length];
unsigned char *b;
#if GS_WITH_GC
b = NSAllocateCollectable(l + 3, 0);
#else
b = NSZoneMalloc(NSDefaultMallocZone(), l + 3);
#endif
b[0] = '-';
b[1] = '-';
[tmp getCString: (char*)&b[2]
@ -4702,11 +4698,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
src = (const unsigned char*)[source bytes];
end = &src[length];
#if GS_WITH_GC
result = (unsigned char*)NSAllocateCollectable(declen, 0);
#else
result = (unsigned char*)NSZoneMalloc(NSDefaultMallocZone(), declen);
#endif
dst = result;
while ((src != end) && *src != '\0')
@ -4845,11 +4837,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
}
destlen = 4 * ((length + 2) / 3);
sBuf = (unsigned char*)[source bytes];
#if GS_WITH_GC
dBuf = NSAllocateCollectable(destlen, 0);
#else
dBuf = NSZoneMalloc(NSDefaultMallocZone(), destlen);
#endif
GSPrivateEncodeBase64(sBuf, length, dBuf);

View file

@ -1975,9 +1975,6 @@ NSArray *GSObjCDirectSubclassesOfClass(Class cls)
void *
GSAutoreleasedBuffer(unsigned size)
{
#if GS_WITH_GC || __OBJC_GC__
return NSAllocateCollectable(size, NSScannedOption);
#else
#ifdef ALIGN
#undef ALIGN
#endif
@ -2004,7 +2001,6 @@ GSAutoreleasedBuffer(unsigned size)
size + offset, NSDefaultMallocZone());
(*autorelease_imp)(autorelease_class, autorelease_sel, o);
return ((void*)o) + instance_size + offset;
#endif
}
@ -2070,33 +2066,6 @@ GSPrintf (FILE *fptr, NSString* format, ...)
# define AREM(c, o)
# endif
# if GS_WITH_GC
#include <gc/gc.h>
static BOOL
GSIsFinalizable(Class c)
{
static IMP finalizeIMP = 0;
if (0 == finalizeIMP)
{
finalizeIMP = [NSObject instanceMethodForSelector: @selector(finalize)];
}
if (class_getMethodImplementation(c, @selector(finalize)) != finalizeIMP)
return YES;
return NO;
}
static void
GSFinalize(void* object, void* data)
{
[(id)object finalize];
AREM(object_getClass((id)object), (id)object);
object_setClass((id)object, (Class)(void*)0xdeadface);
}
# endif /* GS_WITH_GC */
#endif /* defined(GNUSTEP_BASE_LIBRARY) */
void
@ -2112,37 +2081,10 @@ GSClassSwizzle(id instance, Class newClass)
* 'small object', in which case the class is unchanged and we need
* to allow for that.
*/
# if GS_WITH_GC
/* We only do allocation counting for objects that can be
* finalised - for other objects we have no way of decrementing
* the count when the object is collected.
*/
if (GSIsFinalizable(oldClass))
{
/* Already finalizable, so we just need to do any allocation
* accounting.
*/
AREM(oldClass, instance);
}
object_setClass(instance, newClass);
newClass = object_getClass(instance);
if (GSIsFinalizable(newClass))
{
/* New class is finalizable, so we must register the instance
* for finalisation and do allocation acounting for it.
*/
AADD(newClass, instance);
if (NO == GSIsFinalizable(oldClass))
{
GC_REGISTER_FINALIZER (instance, GSFinalize, NULL, NULL, NULL);
}
}
# else
AREM(oldClass, instance);
object_setClass(instance, newClass);
newClass = object_getClass(instance);
AADD(newClass, instance);
# endif /* GS_WITH_GC */
}
}

View file

@ -776,62 +776,6 @@ GSUnicode(const unichar *chars, unsigned length,
return i;
}
#if GS_WITH_GC
#define GROW() \
if (dst == 0) \
{ \
/* \
* Data is just being discarded anyway, so we can \
* reset the offset into the local buffer on the \
* stack and pretend the buffer has grown. \
*/ \
ptr = buf - dpos; \
bsize = dpos + BUFSIZ; \
if (extra != 0) \
{ \
bsize--; \
} \
} \
else if (zone == 0) \
{ \
result = NO; /* No buffer growth possible ... fail. */ \
goto done; \
} \
else \
{ \
unsigned grow = slen; \
\
if (grow < bsize + BUFSIZ) \
{ \
grow = bsize + BUFSIZ; \
} \
grow *= sizeof(unichar); \
\
if (ptr == buf || ptr == *dst) \
{ \
unichar *tmp; \
\
tmp = NSAllocateCollectable(grow + extra, 0); \
if (tmp != 0) \
{ \
memcpy(tmp, ptr, bsize * sizeof(unichar)); \
} \
ptr = tmp; \
} \
else \
{ \
ptr = NSReallocateCollectable(ptr, grow + extra, 0); \
} \
if (ptr == 0) \
{ \
return NO; /* Not enough memory */ \
} \
bsize = grow / sizeof(unichar); \
}
#else /* GS_WITH_GC */
#define GROW() \
if (dst == 0) \
{ \
@ -884,8 +828,6 @@ else \
bsize = grow / sizeof(unichar); \
}
#endif /* GS_WITH_GC */
/**
* Function to convert from 8-bit data to 16-bit unicode characters.
* <p>The dst argument is a pointer to a pointer to a buffer in which the
@ -1111,21 +1053,15 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
unsigned grow = (dpos + slen) * sizeof(unichar);
unichar *tmp;
#if GS_WITH_GC
tmp = NSAllocateCollectable(grow + extra, 0);
#else
tmp = NSZoneMalloc(zone, grow + extra);
#endif
if ((ptr == buf || ptr == *dst) && (tmp != 0))
{
memcpy(tmp, ptr, bsize * sizeof(unichar));
}
#if !GS_WITH_GC
if (ptr != buf && ptr != *dst)
{
NSZoneFree(zone, ptr);
}
#endif
ptr = tmp;
if (ptr == 0)
{
@ -1175,21 +1111,15 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
unsigned grow = (dpos + slen) * sizeof(unichar);
unichar *tmp;
#if GS_WITH_GC
tmp = NSAllocateCollectable(grow + extra, 0);
#else
tmp = NSZoneMalloc(zone, grow + extra);
#endif
if ((ptr == buf || ptr == *dst) && (tmp != 0))
{
memcpy(tmp, ptr, bsize * sizeof(unichar));
}
#if !GS_WITH_GC
if (ptr != buf && ptr != *dst)
{
NSZoneFree(zone, ptr);
}
#endif
ptr = tmp;
if (ptr == 0)
{
@ -1264,21 +1194,15 @@ tables:
unsigned grow = (dpos + slen) * sizeof(unichar);
unichar *tmp;
#if GS_WITH_GC
tmp = NSAllocateCollectable(grow + extra, 0);
#else
tmp = NSZoneMalloc(zone, grow + extra);
#endif
if ((ptr == buf || ptr == *dst) && (tmp != 0))
{
memcpy(tmp, ptr, bsize * sizeof(unichar));
}
#if !GS_WITH_GC
if (ptr != buf && ptr != *dst)
{
NSZoneFree(zone, ptr);
}
#endif
ptr = tmp;
if (ptr == 0)
{
@ -1436,17 +1360,12 @@ done:
/*
* Temporary string was requested ... make one.
*/
#if GS_WITH_GC
r = NSAllocateCollectable(bytes, 0);
memcpy(r, ptr, bytes);
#else
r = GSAutoreleasedBuffer(bytes);
memcpy(r, ptr, bytes);
if (ptr != buf && ptr != *dst)
{
NSZoneFree(zone, ptr);
}
#endif
ptr = r;
*dst = ptr;
}
@ -1462,11 +1381,7 @@ done:
{
unichar *tmp;
#if GS_WITH_GC
tmp = NSAllocateCollectable(bytes, 0);
#else
tmp = NSZoneMalloc(zone, bytes);
#endif
if (tmp != 0)
{
memcpy(tmp, ptr, bytes);
@ -1475,11 +1390,7 @@ done:
}
else
{
#if GS_WITH_GC
ptr = NSReallocateCollectable(ptr, bytes, 0);
#else
ptr = NSZoneRealloc(zone, ptr, bytes);
#endif
}
*dst = ptr;
}
@ -1493,12 +1404,10 @@ done:
*dst = ptr;
}
}
#if !GS_WITH_GC
else if (ptr != buf && dst != 0 && ptr != *dst)
{
NSZoneFree(zone, ptr);
}
#endif
if (dst)
NSCAssert(*dst != buf, @"attempted to pass out pointer to internal buffer");
@ -1508,62 +1417,6 @@ done:
#undef GROW
#if GS_WITH_GC
#define GROW() \
if (dst == 0) \
{ \
/* \
* Data is just being discarded anyway, so we can \
* reset the offset into the local buffer on the \
* stack and pretend the buffer has grown. \
*/ \
ptr = buf - dpos; \
bsize = dpos + BUFSIZ; \
if (extra != 0) \
{ \
bsize--; \
} \
} \
else if (zone == 0) \
{ \
result = NO; /* No buffer growth possible ... fail. */ \
goto done; \
} \
else \
{ \
unsigned grow = slen; \
\
if (grow < bsize + BUFSIZ) \
{ \
grow = bsize + BUFSIZ; \
} \
\
if (ptr == buf || ptr == *dst) \
{ \
unsigned char *tmp; \
\
tmp = NSAllocateCollectable(grow + extra, 0); \
if (tmp != 0) \
{ \
memcpy(tmp, ptr, bsize); \
} \
ptr = tmp; \
} \
else \
{ \
ptr = NSReallocateCollectable(ptr, grow + extra, 0); \
} \
if (ptr == 0) \
{ \
return NO; /* Not enough memory */ \
} \
bsize = grow; \
}
#else /* GS_WITH_GC */
#define GROW() \
if (dst == 0) \
{ \
@ -1615,8 +1468,6 @@ else \
bsize = grow; \
}
#endif /* GS_WITH_GC */
static inline int chop(unichar c, _ucc_ *table, int hi)
{
int lo = 0;
@ -2067,15 +1918,11 @@ bases:
{
uint8_t *tmp;
#if GS_WITH_GC
tmp = NSAllocateCollectable(slen + extra, 0);
#else
tmp = NSZoneMalloc(zone, slen + extra);
if (ptr != buf && ptr != *dst)
{
NSZoneFree(zone, ptr);
}
#endif
ptr = tmp;
if (ptr == 0)
{
@ -2432,17 +2279,12 @@ iconv_start:
/*
* Temporary string was requested ... make one.
*/
#if GS_WITH_GC
r = NSAllocateCollectable(bytes, 0);
memcpy(r, ptr, bytes);
#else
r = GSAutoreleasedBuffer(bytes);
memcpy(r, ptr, bytes);
if (ptr != buf && ptr != *dst)
{
NSZoneFree(zone, ptr);
}
#endif
ptr = r;
*dst = ptr;
}
@ -2458,11 +2300,7 @@ iconv_start:
{
unsigned char *tmp;
#if GS_WITH_GC
tmp = NSAllocateCollectable(bytes, 0);
#else
tmp = NSZoneMalloc(zone, bytes);
#endif
if (tmp != 0)
{
memcpy(tmp, ptr, bytes);
@ -2471,11 +2309,7 @@ iconv_start:
}
else
{
#if GS_WITH_GC
ptr = NSReallocateCollectable(ptr, bytes, 0);
#else
ptr = NSZoneRealloc(zone, ptr, bytes);
#endif
}
*dst = ptr;
}
@ -2489,12 +2323,10 @@ iconv_start:
*dst = ptr;
}
}
#if !GS_WITH_GC
else if (ptr != buf && dst != 0 && ptr != *dst)
{
NSZoneFree(zone, ptr);
}
#endif
if (dst)
NSCAssert(*dst != buf, @"attempted to pass out pointer to internal buffer");

View file

@ -42,9 +42,6 @@
static SEL eqSel;
static SEL oaiSel;
#if GS_WITH_GC
static Class GSArrayClass;
#else
static Class GSInlineArrayClass;
/* This class stores objects inline in data beyond the end of the instance.
* However, when GC is enabled the object data is typed, and all data after
@ -56,7 +53,6 @@ static Class GSInlineArrayClass;
{
}
@end
#endif
@class GSArray;
@ -105,11 +101,7 @@ static Class GSInlineArrayClass;
[self setVersion: 1];
eqSel = @selector(isEqual:);
oaiSel = @selector(objectAtIndex:);
#if GS_WITH_GC
GSArrayClass = [GSArray class];
#else
GSInlineArrayClass = [GSInlineArray class];
#endif
}
}
@ -129,14 +121,12 @@ static Class GSInlineArrayClass;
{
if (_contents_array)
{
#if !GS_WITH_GC
NSUInteger i;
for (i = 0; i < _count; i++)
{
[_contents_array[i] release];
}
#endif
NSZoneFree([self zone], _contents_array);
_contents_array = 0;
}
@ -155,12 +145,7 @@ static Class GSInlineArrayClass;
{
NSUInteger i;
#if GS_WITH_GC
_contents_array = NSAllocateCollectable(sizeof(id)*count,
NSScannedOption);
#else
_contents_array = NSZoneMalloc([self zone], sizeof(id)*count);
#endif
if (_contents_array == 0)
{
DESTROY(self);
@ -217,12 +202,7 @@ static Class GSInlineArrayClass;
at: &_count];
if (_count > 0)
{
#if GS_WITH_GC
_contents_array = NSAllocateCollectable(sizeof(id) * _count,
NSScannedOption);
#else
_contents_array = NSZoneCalloc([self zone], _count, sizeof(id));
#endif
if (_contents_array == 0)
{
[NSException raise: NSMallocException
@ -395,7 +375,6 @@ static Class GSInlineArrayClass;
@end
#if !GS_WITH_GC
@implementation GSInlineArray
- (void) dealloc
{
@ -439,7 +418,6 @@ static Class GSInlineArrayClass;
return self;
}
@end
#endif
@implementation GSMutableArray
@ -487,11 +465,7 @@ static Class GSInlineArrayClass;
{
NSArray *copy;
#if GS_WITH_GC
copy = (id)NSAllocateObject(GSArrayClass, 0, zone);
#else
copy = (id)NSAllocateObject(GSInlineArrayClass, sizeof(id)*_count, zone);
#endif
return [copy initWithObjects: _contents_array count: _count];
}
@ -528,11 +502,7 @@ static Class GSInlineArrayClass;
{
cap = 1;
}
#if GS_WITH_GC
_contents_array = NSAllocateCollectable(sizeof(id)*cap, NSScannedOption);
#else
_contents_array = NSZoneMalloc([self zone], sizeof(id)*cap);
#endif
_capacity = cap;
_grow_factor = cap > 1 ? cap/2 : 1;
return self;
@ -655,16 +625,13 @@ static Class GSInlineArrayClass;
if ((pos = _count) > 0)
{
#if GS_WITH_GC == 0
IMP rel = 0;
Class last = Nil;
#endif
_version++;
_count = 0;
while (pos-- > 0)
{
#if GS_WITH_GC == 0
id o = _contents_array[pos];
Class c = object_getClass(o);
@ -674,7 +641,6 @@ static Class GSInlineArrayClass;
rel = [o methodForSelector: @selector(release)];
}
(*rel)(o, @selector(release));
#endif
_contents_array[pos] = nil;
}
_version++;
@ -709,9 +675,7 @@ static Class GSInlineArrayClass;
if (index > 0)
{
BOOL (*imp)(id,SEL,id);
#if GS_WITH_GC == 0
BOOL retained = NO;
#endif
imp = (BOOL (*)(id,SEL,id))[anObject methodForSelector: eqSel];
while (index-- > 0)
@ -719,15 +683,13 @@ static Class GSInlineArrayClass;
if ((*imp)(anObject, eqSel, _contents_array[index]) == YES)
{
NSUInteger pos = index;
#if GS_WITH_GC == 0
id obj = _contents_array[index];
id obj = _contents_array[index];
if (retained == NO)
{
RETAIN(anObject);
retained = YES;
}
#endif
while (++pos < _count)
{
@ -738,12 +700,10 @@ static Class GSInlineArrayClass;
RELEASE(obj);
}
}
#if GS_WITH_GC == 0
if (retained == YES)
{
RELEASE(anObject);
}
#endif
}
_version++;
}
@ -784,9 +744,7 @@ static Class GSInlineArrayClass;
{
if (_contents_array[index] == anObject)
{
#if GS_WITH_GC == 0
id obj = _contents_array[index];
#endif
NSUInteger pos = index;
while (++pos < _count)
@ -810,15 +768,12 @@ static Class GSInlineArrayClass;
NSUInteger index;
NSUInteger tail;
NSUInteger end;
#if GS_WITH_GC == 0
IMP rel = 0;
Class last = Nil;
#endif
_version++;
index = aRange.location;
#if GS_WITH_GC == 0
/* Release all the objects we are removing.
*/
end = NSMaxRange(aRange);
@ -835,7 +790,7 @@ static Class GSInlineArrayClass;
(*rel)(o, @selector(release));
_contents_array[end] = nil;
}
#endif
/* Move any trailing objects to fill the hole we made.
*/
end = NSMaxRange(aRange);
@ -1172,11 +1127,7 @@ static Class GSInlineArrayClass;
+ (void) initialize
{
#if GS_WITH_GC
GSArrayClass = [GSArray class];
#else
GSInlineArrayClass = [GSInlineArray class];
#endif
}
- (id) autorelease
@ -1219,14 +1170,7 @@ static Class GSInlineArrayClass;
}
else
{
unsigned c;
#if GS_WITH_GC
GSArray *a;
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &c];
a = (id)NSAllocateObject(GSArrayClass, 0, [self zone]);
a->_contents_array = NSAllocateCollectable(sizeof(id)*c, NSScannedOption);
#else
unsigned c;
GSInlineArray *a;
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &c];
@ -1234,7 +1178,6 @@ static Class GSInlineArrayClass;
sizeof(id)*c, [self zone]);
a->_contents_array
= (id*)(((void*)a) + class_getInstanceSize([a class]));
#endif
if (c > 0)
{
[aCoder decodeArrayOfObjCType: @encode(id)
@ -1248,12 +1191,8 @@ static Class GSInlineArrayClass;
- (id) initWithObjects: (const id[])objects count: (NSUInteger)count
{
#if GS_WITH_GC
self = (id)NSAllocateObject(GSArrayClass, 0, [self zone]);
#else
self = (id)NSAllocateObject(GSInlineArrayClass, sizeof(id)*count,
[self zone]);
#endif
return [self initWithObjects: objects count: count];
}

View file

@ -124,13 +124,6 @@ cacheEqual(id A, id B)
#define GSI_MAP_VTYPES GSUNION_NSINT
#define GSI_MAP_NOCLEAN 1
#if GS_WITH_GC
#include <gc/gc_typed.h>
static GC_descr nodeDesc; // Type descriptor for map node.
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
#endif
#include "GNUstepBase/GSIMap.h"
static NSLock *attrLock = nil;
@ -463,15 +456,6 @@ _attributesAtIndexEffectiveRange(
NSMutableArray *a;
NSDictionary *d;
#if GS_WITH_GC
/* We create a typed memory descriptor for map nodes.
* Only the pointer to the key needs to be scanned.
*/
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
#endif
infSel = @selector(newWithZone:value:at:);
addSel = @selector(addObject:);
cntSel = @selector(count);

View file

@ -90,18 +90,8 @@
* Ensure that the version encoded is that used by the abstract class.
*/
[self setVersion: [super version]];
#if TYPE_ORDER == 0 && GS_WITH_GC
GSMakeWeakPointer(self, "data");
#endif
}
#if TYPE_ORDER == 0 && GS_WITH_GC
- (void) finalize
{
GSAssignZeroingWeakPointer((void**)&data, (void*)nil);
}
#endif
// Allocating and Initializing
- (id) initWithBytes: (const void *)value
@ -109,11 +99,7 @@
{
typedef __typeof__(data) _dt;
self = [super init];
#if TYPE_ORDER == 0 && GS_WITH_GC
GSAssignZeroingWeakPointer((void**)&data, (void*)(*(id*)value));
#else
data = *(_dt *)value;
#endif
return self;
}

View file

@ -36,13 +36,6 @@
#define GSI_MAP_KTYPES GSUNION_OBJ
#define GSI_MAP_VTYPES GSUNION_NSINT
#if GS_WITH_GC
#include <gc/gc_typed.h>
static GC_descr nodeDesc; // Type descriptor for map node.
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
#endif
#include "GNUstepBase/GSIMap.h"
@interface GSCountedSet : NSCountedSet
@ -101,14 +94,6 @@ static GC_descr nodeDesc; // Type descriptor for map node.
{
if (self == [GSCountedSet class])
{
#if GS_WITH_GC
/* We create a typed memory descriptor for map nodes.
* Only the pointer to the key needs to be scanned.
*/
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
#endif
}
}
@ -374,13 +359,11 @@ static GC_descr nodeDesc; // Type descriptor for map node.
{
result = node->key.obj;
node->value.nsu++;
#if !GS_WITH_GC
if (result != anObject)
{
[anObject release];
[result retain];
}
#endif
}
_version++;
return result;

View file

@ -47,13 +47,6 @@
#define GSI_MAP_RETAIN_KEY(M, X) ((X).obj) = \
[((id)(X).obj) copyWithZone: map->zone]
#if GS_WITH_GC
#include <gc/gc_typed.h>
static GC_descr nodeDesc; // Type descriptor for map node.
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
#endif
#include "GNUstepBase/GSIMap.h"
@interface GSDictionary : NSDictionary
@ -91,15 +84,6 @@ static SEL objSel;
{
if (self == [GSDictionary class])
{
#if GS_WITH_GC
/* We create a typed memory descriptor for map nodes.
* The pointers to the key and value need to be scanned.
*/
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
#endif
nxtSel = @selector(nextObject);
objSel = @selector(objectForKey:);
}

View file

@ -56,11 +56,7 @@ static GSMimeParser *mimeParser = nil;
NSData *data;
NSString *string;
#if GS_WITH_GC
dst = (char*)NSAllocateCollectable(dlen, 0);
#else
dst = (char*)NSZoneMalloc(NSDefaultMallocZone(), dlen);
#endif
while (spos < slen)
{
unsigned char c = src[spos++];

View file

@ -36,13 +36,8 @@
#define GSI_ARRAY_TYPES GSUNION_OBJ
#if GS_WITH_GC == 0
#define GSI_ARRAY_RELEASE(A, X) [(X).obj release]
#define GSI_ARRAY_RETAIN(A, X) [(X).obj retain]
#else
#define GSI_ARRAY_RELEASE(A, X)
#define GSI_ARRAY_RETAIN(A, X)
#endif
#include "GNUstepBase/GSIArray.h"

View file

@ -37,12 +37,6 @@
#define GSI_MAP_HAS_VALUE 0
#define GSI_MAP_KTYPES GSUNION_OBJ
#if GS_WITH_GC
#include <gc/gc_typed.h>
static GC_descr nodeDesc; // Type descriptor for map node.
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
#endif
#include "GNUstepBase/GSIMap.h"
@ -116,14 +110,6 @@ static Class mutableSetClass;
{
if (self == [GSSet class])
{
#if GS_WITH_GC
/* We create a typed memory descriptor for map nodes.
* Only the pointer to the key needs to be scanned.
*/
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
#endif
arrayClass = [NSArray class];
setClass = [GSSet class];
mutableSetClass = [GSMutableSet class];

View file

@ -1363,11 +1363,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
*/
if (original == bytes)
{
#if GS_WITH_GC
chars = NSAllocateCollectable(length, 0);
#else
chars = NSZoneMalloc(myZone, length);
#endif
memcpy(chars, bytes, length);
}
else
@ -1446,18 +1442,6 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
if (encoding == internalEncoding)
{
#if GS_WITH_GC
/* If we are using GC, copy and free any non-collectable buffer so
* we don't leak memory.
*/
if (GSPrivateIsCollectable(chars.c) == NO)
{
me = newCInline(length, myZone);
memcpy(me->_contents.c, chars.c, length);
NSZoneFree(NSZoneFromPointer(chars.c), chars.c);
return (id)me;
}
#endif
me = (GSStr)NSAllocateObject(GSCBufferStringClass, 0, myZone);
me->_contents.c = chars.c;
me->_count = length;
@ -1525,18 +1509,6 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
}
else
{
#if GS_WITH_GC
/* If we are using GC, copy and free any non-collectable buffer so
* we don't leak memory.
*/
if (GSPrivateIsCollectable(chars.u) == NO)
{
me = newUInline(length, myZone);
memcpy(me->_contents.u, chars.u, length * sizeof(unichar));
NSZoneFree(NSZoneFromPointer(chars.u), chars.u);
return (id)me;
}
#endif
me = (GSStr)NSAllocateObject(GSUnicodeBufferStringClass, 0, myZone);
me->_contents.u = chars.u;
me->_count = length;
@ -3253,11 +3225,7 @@ static void GSStrMakeSpace(GSStr s, unsigned size)
*/
if (s->_zone == 0)
{
#if GS_WITH_GC
s->_zone = GSAtomicMallocZone();
#else
s->_zone = [(NSString*)s zone];
#endif
}
if (s->_flags.wide == 1)
{
@ -3314,11 +3282,7 @@ static void GSStrWiden(GSStr s)
if (!s->_zone)
{
#if GS_WITH_GC
s->_zone = GSAtomicMallocZone();
#else
s->_zone = [(NSString*)s zone];
#endif
}
if (!GSToUnicode(&tmp, &len, s->_contents.c, s->_count,
@ -4699,11 +4663,7 @@ agree, create a new GSUInlineString otherwise.
*/
if (_zone == 0)
{
#if GS_WITH_GC
_zone = GSAtomicMallocZone();
#else
_zone = [self zone];
#endif
}
GSPrivateFormat((GSStr)self, fmt, ap, nil);
_flags.hash = 0; // Invalidate the hash for this string.
@ -4967,11 +4927,7 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
BOOL shouldFree = NO;
_flags.owned = YES;
#if GS_WITH_GC
_zone = GSAtomicMallocZone();
#else
_zone = [self zone];
#endif
if (length > 0)
{
@ -5148,11 +5104,7 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
}
_count = 0;
_capacity = capacity;
#if GS_WITH_GC
_zone = GSAtomicMallocZone();
#else
_zone = [self zone];
#endif
_contents.c = NSZoneMalloc(_zone, capacity + 1);
_flags.wide = 0;
_flags.owned = 1;

View file

@ -45,10 +45,6 @@
#define GSI_MAP_HASH(M, X) ((X).nsu)
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
#define GSI_MAP_NOCLEAN 1
#if GS_WITH_GC
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)NSAllocateCollectable(X * sizeof(GSIMapNode_t), 0)
#endif
#include "GNUstepBase/GSIMap.h"
@ -149,12 +145,7 @@ static Class NSMutableDataMallocClass;
/*
* Set up map tables.
*/
#if GS_WITH_GC
_clsMap = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t)*6,
NSScannedOption);
#else
_clsMap = (GSIMapTable)NSZoneMalloc(zone, sizeof(GSIMapTable_t)*6);
#endif
_cIdMap = &_clsMap[1];
_uIdMap = &_clsMap[2];
_ptrMap = &_clsMap[3];

View file

@ -662,12 +662,10 @@ static SEL rlSel;
objects[i] = [objects[i] copy];
}
self = [self initWithObjects: objects count: c];
#if GS_WITH_GC == 0
while (i > 0)
{
[objects[--i] release];
}
#endif
}
else
{
@ -752,12 +750,10 @@ static SEL rlSel;
count: items
at: contents];
self = [self initWithObjects: contents count: items];
#if GS_WITH_GC == 0
while (items-- > 0)
{
[contents[items] release];
}
#endif
GS_ENDIDBUF();
}
else
@ -2268,12 +2264,10 @@ compare(id elem1, id elem2, void* context)
(*rem)(self, remSel, i);
}
}
#if GS_WITH_GC == 0
if (rem != 0)
{
RELEASE(anObject);
}
#endif
}
}
@ -2360,12 +2354,10 @@ compare(id elem1, id elem2, void* context)
(*rem)(self, remSel, i);
}
}
#if GS_WITH_GC == 0
if (rem != 0)
{
RELEASE(anObject);
}
#endif
}
}

View file

@ -42,35 +42,14 @@
# endif
#endif
#if GS_WITH_GC || __OBJC_GC__
#if __OBJC_GC__
@interface GSAutoreleasePool : NSAutoreleasePool @end
#endif
@implementation NSAutoreleasePool
static NSAutoreleasePool *pool = nil;
#if GS_WITH_GC
+ (void) initialize
{
pool = NSAllocateObject(self, 0, NSDefaultMallocZone());
return;
}
+ (id) allocWithZone: (NSZone*)zone
{
return pool;
}
+ (id) new
{
return pool;
}
#endif
#ifdef __OBJC_GC__
static Class PoolClass;
+ (void) initialize
@ -103,7 +82,6 @@ static Class PoolClass;
}
return pool;
}
#endif
- (id) init
{
@ -218,8 +196,6 @@ static Class PoolClass;
#if !GS_WITH_GC
/* When this is `NO', autoreleased objects are never actually recorded
in an NSAutoreleasePool, and are not sent a `release' message.
Thus memory for objects use grows, and grows, and... */
@ -823,4 +799,4 @@ pop_pool_from_cache (struct autorelease_thread_vars *tv)
}
@end
#endif // !GS_WITH_GC

View file

@ -256,11 +256,7 @@ static NSRecursiveLock *classLock = nil;
{
NSAssert(0 == _NSCalendarInternal, NSInvalidArgumentException);
_NSCalendarInternal =
#if GS_WITH_GC
NSAllocateCollectable(sizeof(Calendar), NSScannedOption);
#else
NSZoneCalloc([self zone], sizeof(Calendar), 1);
#endif
my->firstWeekday = NSNotFound;
my->minimumDaysInFirstWeek = NSNotFound;
@ -854,11 +850,7 @@ typedef struct {
if (nil != (self = [super init]))
{
_NSDateComponentsInternal =
#if GS_WITH_GC
NSAllocateCollectable(sizeof(DateComp), NSScannedOption);
#else
NSZoneCalloc([self zone], sizeof(DateComp), 1);
#endif
NSZoneCalloc([self zone], sizeof(DateComp), 1);
my->era = NSDateComponentUndefined;
my->year = NSDateComponentUndefined;

View file

@ -107,14 +107,6 @@ typedef GSIMapNode_t *GSIMapNode;
#define GSI_MAP_ENUMERATOR NSHashEnumerator
#if GS_WITH_GC
#include <gc/gc_typed.h>
static GC_descr nodeS = 0;
static GC_descr nodeW = 0;
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), (GC_descr)M->zone)
#endif
#include "GNUstepBase/GSIMap.h"
/**** Function Implementations ****/
@ -256,9 +248,6 @@ NSCopyHashTableWithZone(NSHashTable *table, NSZone *zone)
{
t->cb.pf = o->cb.pf;
}
#if GS_WITH_GC
zone = ((GSIMapTable)table)->zone;
#endif
GSIMapInitWithZoneAndCapacity(t, zone, ((GSIMapTable)table)->nodeCount);
enumerator = GSIMapEnumeratorForMap((GSIMapTable)table);
@ -333,11 +322,7 @@ NSCreateHashTableWithZone(
table->legacy = YES;
table->cb.old = k;
#if GS_WITH_GC
GSIMapInitWithZoneAndCapacity(table, (NSZone*)nodeS, capacity);
#else
GSIMapInitWithZoneAndCapacity(table, zone, capacity);
#endif
return (NSHashTable*)table;
}
@ -837,18 +822,6 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
concreteClass = [NSConcreteHashTable class];
instanceSize = class_getInstanceSize(concreteClass);
}
#if GS_WITH_GC
/* We create a typed memory descriptor for hash nodes.
*/
if (nodeS == 0)
{
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
nodeW = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
nodeS = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
}
#endif
}
- (void) addObject: (id)anObject

View file

@ -140,16 +140,6 @@ typedef GSIMapNode_t *GSIMapNode;
#define GSI_MAP_ENUMERATOR NSMapEnumerator
#if GS_WITH_GC
#include <gc/gc_typed.h>
static GC_descr nodeSS = 0;
static GC_descr nodeSW = 0;
static GC_descr nodeWS = 0;
static GC_descr nodeWW = 0;
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), (GC_descr)M->zone)
#endif
#include "GNUstepBase/GSIMap.h"
/**** Function Implementations ****/
@ -388,9 +378,6 @@ NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone)
t->cb.pf.k = o->cb.pf.k;
t->cb.pf.v = o->cb.pf.v;
}
#if GS_WITH_GC
zone = ((GSIMapTable)table)->zone;
#endif
GSIMapInitWithZoneAndCapacity(t, zone, ((GSIMapTable)table)->nodeCount);
if (object_getClass(table) == concreteClass)
@ -501,11 +488,7 @@ NSCreateMapTableWithZone(
table->cb.old.k = k;
table->cb.old.v = v;
#if GS_WITH_GC
GSIMapInitWithZoneAndCapacity(table, (NSZone*)nodeSS, capacity);
#else
GSIMapInitWithZoneAndCapacity(table, zone, capacity);
#endif
return (NSMapTable*)table;
}
@ -1195,23 +1178,6 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
concreteClass = [NSConcreteMapTable class];
instanceSize = class_getInstanceSize(concreteClass);
}
#if GS_WITH_GC
/* We create a typed memory descriptor for map nodes.
*/
if (nodeSS == 0)
{
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
nodeWW = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
nodeSW = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
nodeSS = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
memset(&w[0], '\0', sizeof(w));
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
nodeWS = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
}
#endif
}
- (id) copyWithZone: (NSZone*)aZone

View file

@ -48,11 +48,7 @@
# define STRONG_ACQUIRE(x) objc_retain(x)
#else
# define WEAK_READ(x) (*x)
# if GS_WITH_GC
# define WEAK_WRITE(addr, x) GSAssignZeroingWeakPointer(addr, x)
# else
# define WEAK_WRITE(addr, x) (*(addr) = x)
# endif
# define WEAK_WRITE(addr, x) (*(addr) = x)
# define STRONG_WRITE(addr, x) ASSIGN(*((id*)addr), ((id)x))
# define STRONG_ACQUIRE(x) RETAIN(((id)x))
#endif

View file

@ -168,9 +168,7 @@ static void
relinquishRetainedMemory(const void *item,
NSUInteger (*size)(const void *item))
{
#if !GS_WITH_GC
[(NSObject*)item release];
#endif
}
@implementation NSConcretePointerFunctions

View file

@ -110,13 +110,6 @@ skip_argspec(const char *ptr)
#define GSI_MAP_HASH(M, X) ((X).nsu ^ ((X).nsu >> 3))
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
#define GSI_MAP_NOCLEAN 1
#if GS_WITH_GC
// FIXME ...
#include <gc/gc_typed.h>
static GC_descr nodeDesc; // Type descriptor for map node.
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
#endif
#include "GNUstepBase/GSIMap.h"
@ -643,16 +636,6 @@ static NSLock *cached_proxies_gate = nil;
{
NSNotificationCenter *nc;
#if GS_WITH_GC
/* We create a typed memory descriptor for map nodes.
* FIXME
*/
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
#endif
GSMakeWeakPointer(self, "delegate");
connectionClass = self;
dateClass = [NSDate class];
@ -896,7 +879,7 @@ static NSLock *cached_proxies_gate = nil;
*/
- (id) delegate
{
return GS_GC_UNHIDE(Idelegate);
return Idelegate;
}
- (NSString*) description
@ -1080,13 +1063,7 @@ static NSLock *cached_proxies_gate = nil;
* This maps request sequence numbers to the NSPortCoder objects representing
* replies arriving from the remote connection.
*/
#if GS_WITH_GC
IreplyMap
= (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
NSScannedOption);
#else
IreplyMap = (GSIMapTable)NSZoneMalloc(z, sizeof(GSIMapTable_t));
#endif
GSIMapInitWithZoneAndCapacity(IreplyMap, z, 4);
/*
@ -1094,40 +1071,22 @@ static NSLock *cached_proxies_gate = nil;
* We use this instead of an NSHashTable because we only care about
* the object's address, and don't want to send the -hash message to it.
*/
#if GS_WITH_GC
IlocalObjects
= (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
NSScannedOption);
#else
IlocalObjects
= (GSIMapTable)NSZoneMalloc(z, sizeof(GSIMapTable_t));
#endif
GSIMapInitWithZoneAndCapacity(IlocalObjects, z, 4);
/*
* This maps handles for local objects to their local proxies.
*/
#if GS_WITH_GC
IlocalTargets
= (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
NSScannedOption);
#else
IlocalTargets
= (GSIMapTable)NSZoneMalloc(z, sizeof(GSIMapTable_t));
#endif
GSIMapInitWithZoneAndCapacity(IlocalTargets, z, 4);
/*
* This maps targets to remote proxies.
*/
#if GS_WITH_GC
IremoteProxies
= (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t),
NSScannedOption);
#else
IremoteProxies
= (GSIMapTable)NSZoneMalloc(z, sizeof(GSIMapTable_t));
#endif
GSIMapInitWithZoneAndCapacity(IremoteProxies, z, 4);
IrequestDepth = 0;
@ -1732,7 +1691,7 @@ static NSLock *cached_proxies_gate = nil;
*/
- (void) setDelegate: (id)anObj
{
Idelegate = GS_GC_HIDE(anObj);
Idelegate = anObj;
IauthenticateIn =
[anObj respondsToSelector: @selector(authenticateComponents:withData:)];
IauthenticateOut =

View file

@ -205,11 +205,9 @@ static Class NSCountedSet_concrete_class;
(*addImp)(self, @selector(addObject:), os[j]);
}
}
#if !GS_WITH_GC
if (flag)
while (i--)
[os[i] release];
#endif
return self;
}
@ -257,13 +255,11 @@ static Class NSCountedSet_concrete_class;
{
o = anObject;
}
#if !GS_WITH_GC
if (o != anObject)
{
[anObject release];
[o retain];
}
#endif
return o;
}
@end

View file

@ -118,10 +118,6 @@
@class NSDataMalloc;
@class NSDataStatic;
@class NSMutableDataMalloc;
#if GS_WITH_GC
@class NSDataFinalized;
@class NSMutableDataFinalized;
#endif
/*
* Some static variables to cache classes and methods for quick access -
@ -132,10 +128,6 @@ static Class dataMalloc;
static Class mutableDataMalloc;
static Class NSDataAbstract;
static Class NSMutableDataAbstract;
#if GS_WITH_GC
static Class dataFinalized;
static Class mutableDataFinalized;
#endif
static SEL appendSel;
static IMP appendImp;
@ -191,11 +183,7 @@ encodebase64(unsigned char **dstRef,
destLen += (destLen / lineLength); // CR or LF
}
#if GS_WITH_GC
dst = NSAllocateCollectable(destLen, 0);
#else
dst = NSZoneMalloc(NSDefaultMallocZone(), destLen);
#endif
for (sIndex = 0; sIndex < length; sIndex += 3)
{
@ -318,16 +306,6 @@ readContentsOfFile(NSString* path, void** buf, off_t* len, NSZone* zone)
*/
while ((c = fread(buf, 1, BUFSIZ, theFile)) != 0)
{
#if GS_WITH_GC
if (tmp == 0)
{
tmp = NSAllocateCollectable(c, 0);
}
else
{
tmp = NSReallocateCollectable(tmp, fileLength + c, 0);
}
#else
if (tmp == 0)
{
tmp = NSZoneMalloc(zone, c);
@ -336,7 +314,6 @@ readContentsOfFile(NSString* path, void** buf, off_t* len, NSZone* zone)
{
tmp = NSZoneRealloc(zone, tmp, fileLength + c);
}
#endif
if (tmp == 0)
{
NSLog(@"Malloc failed for file (%@) of length %jd - %@", path,
@ -351,11 +328,7 @@ readContentsOfFile(NSString* path, void** buf, off_t* len, NSZone* zone)
{
off_t offset = 0;
#if GS_WITH_GC
tmp = NSAllocateCollectable(fileLength, 0);
#else
tmp = NSZoneMalloc(zone, fileLength);
#endif
if (tmp == 0)
{
NSLog(@"Malloc failed for file (%@) of length %jd - %@", path,
@ -371,11 +344,7 @@ readContentsOfFile(NSString* path, void** buf, off_t* len, NSZone* zone)
if (offset < fileLength)
{
fileLength = offset;
#if GS_WITH_GC
tmp = NSReallocateCollectable(tmp, fileLength, 0);
#else
tmp = NSZoneRealloc(zone, tmp, fileLength);
#endif
}
}
if (ferror(theFile))
@ -394,12 +363,9 @@ readContentsOfFile(NSString* path, void** buf, off_t* len, NSZone* zone)
* Just in case the failure action needs to be changed.
*/
failure:
#if !GS_WITH_GC
if (tmp != 0)
{
NSZoneFree(zone, tmp);
}
#endif
if (theFile != 0)
{
fclose(theFile);
@ -428,11 +394,7 @@ failure:
{
NSUInteger length;
__strong void *bytes;
#if GS_WITH_GC
BOOL owned;
#else
NSZone *zone;
#endif
NSUInteger capacity;
NSUInteger growth;
}
@ -440,14 +402,6 @@ failure:
- (void) _grow: (NSUInteger)minimum;
@end
#if GS_WITH_GC
@interface NSDataFinalized : NSDataMalloc
@end
@interface NSMutableDataFinalized : NSMutableDataMalloc
@end
#endif
#ifdef HAVE_MMAP
@interface NSDataMappedFile : NSDataMalloc
@end
@ -492,10 +446,6 @@ failure:
dataStatic = [NSDataStatic class];
dataMalloc = [NSDataMalloc class];
mutableDataMalloc = [NSMutableDataMalloc class];
#if GS_WITH_GC
dataFinalized = [NSDataFinalized class];
mutableDataFinalized = [NSMutableDataFinalized class];
#endif
appendSel = @selector(appendBytes:length:);
appendImp = [mutableDataMalloc instanceMethodForSelector: appendSel];
}
@ -884,18 +834,11 @@ failure:
void *fileBytes;
off_t fileLength;
#if GS_WITH_GC
if (readContentsOfFile(path, &fileBytes, &fileLength, 0) == NO)
{
return nil;
}
#else
if (readContentsOfFile(path, &fileBytes, &fileLength, [self zone]) == NO)
{
DESTROY(self);
return nil;
}
#endif
self = [self initWithBytesNoCopy: fileBytes
length: (NSUInteger)fileLength
freeWhenDone: YES];
@ -1041,11 +984,7 @@ failure:
GS_RANGE_CHECK(aRange, l);
#if GS_WITH_GC
buffer = NSAllocateCollectable(aRange.length, 0);
#else
buffer = NSZoneMalloc(NSDefaultMallocZone(), aRange.length);
#endif
if (buffer == 0)
{
[NSException raise: NSMallocException
@ -1240,11 +1179,7 @@ failure:
{
unsigned len = (length+1)*sizeof(char);
#if GS_WITH_GC
*(char**)data = (char*)NSAllocateCollectable(len, 0);
#else
*(char**)data = (char*)NSZoneMalloc(NSDefaultMallocZone(), len);
#endif
if (*(char**)data == 0)
{
[NSException raise: NSMallocException
@ -1305,11 +1240,7 @@ failure:
{
unsigned len = objc_sizeof_type(++type);
#if GS_WITH_GC
*(char**)data = (char*)NSAllocateCollectable(len, 0);
#else
*(char**)data = (char*)NSZoneMalloc(NSDefaultMallocZone(), len);
#endif
if (*(char**)data == 0)
{
[NSException raise: NSMallocException
@ -2297,11 +2228,7 @@ failure:
{
void *b;
#if GS_WITH_GC
b = NSAllocateCollectable(l, 0);
#else
b = NSZoneMalloc([self zone], l);
#endif
if (b == 0)
{
NSLog(@"[NSDataMalloc -initWithCoder:] unable to get %u bytes",
@ -3031,11 +2958,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
}
else
{
#if GS_WITH_GC
*(char**)data = (char*)NSAllocateCollectable(len+1, 0);
#else
*(char**)data = (char*)NSZoneMalloc(NSDefaultMallocZone(), len+1);
#endif
if (*(char**)data == 0)
{
[NSException raise: NSMallocException
@ -3093,11 +3016,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{
unsigned len = objc_sizeof_type(++type);
#if GS_WITH_GC
*(char**)data = (char*)NSAllocateCollectable(len, 0);
#else
*(char**)data = (char*)NSZoneMalloc(NSDefaultMallocZone(), len);
#endif
if (*(char**)data == 0)
{
[NSException raise: NSMallocException
@ -3376,12 +3295,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{
GSClassSwizzle(self, dataStatic);
}
#if GS_WITH_GC
else if (aBuffer != 0 && GSPrivateIsCollectable(aBuffer) == NO)
{
GSClassSwizzle(self, dataFinalized);
}
#endif
bytes = aBuffer;
length = bufferSize;
return self;
@ -3400,16 +3313,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
@end
#if GS_WITH_GC
@implementation NSDataFinalized
- (void) finalize
{
NSZoneFree(NSDefaultMallocZone(), bytes);
[super finalize];
}
@end
#endif
#ifdef HAVE_MMAP
@implementation NSDataMappedFile
@ -3636,7 +3539,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
- (void) dealloc
{
#if !GS_WITH_GC
if (bytes != 0)
{
if (zone != 0)
@ -3645,7 +3547,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
}
bytes = 0;
}
#endif
[super dealloc];
}
@ -3685,18 +3586,9 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
[self setLength: 0];
return self;
}
#if GS_WITH_GC
if (shouldFree == YES && GSPrivateIsCollectable(aBuffer) == NO)
{
GSClassSwizzle(self, mutableDataFinalized);
}
#endif
self = [self initWithCapacity: 0];
if (self)
{
#if GS_WITH_GC
owned = shouldFree; // Free memory on finalisation.
#else
if (shouldFree == NO)
{
zone = 0; // Don't free this memory.
@ -3705,7 +3597,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{
zone = NSZoneFromPointer(aBuffer);
}
#endif
bytes = aBuffer;
length = bufferSize;
capacity = bufferSize;
@ -3727,12 +3618,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{
if (size)
{
#if GS_WITH_GC
bytes = NSAllocateCollectable(size, 0);
#else
zone = [self zone];
bytes = NSZoneMalloc(zone, size);
#endif
if (bytes == 0)
{
NSLog(@"[NSMutableDataMalloc -initWithCapacity:] out of memory "
@ -4143,23 +4030,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{
void *tmp;
#if GS_WITH_GC
tmp = NSAllocateCollectable(size, 0);
if (tmp == 0)
{
[NSException raise: NSMallocException
format: @"Unable to set data capacity to '%d'", size];
}
if (bytes)
{
memcpy(tmp, bytes, capacity < size ? capacity : size);
if (owned == YES)
{
NSZoneFree(NSDefaultMallocZone(), bytes);
owned = NO;
}
}
#else
tmp = NSZoneMalloc(zone, size);
if (tmp == 0)
{
@ -4182,7 +4052,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
{
zone = NSDefaultMallocZone();
}
#endif
bytes = tmp;
capacity = size;
growth = capacity/2;
@ -4239,17 +4108,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
@end
#if GS_WITH_GC
@implementation NSMutableDataFinalized
- (void) finalize
{
if (owned == YES)
NSZoneFree(NSDefaultMallocZone(), bytes);
[super finalize];
}
@end
#endif
#ifdef HAVE_SHMCTL
@implementation NSMutableDataShared

View file

@ -735,14 +735,12 @@ GSDebugAllocationListRecordedObjects(Class c)
memcpy(tmp, the_table[i].recorded_objects,
the_table[i].num_recorded_objects * sizeof(id));
#if !GS_WITH_GC
/* Retain all the objects - NB: if retaining one of the objects as a
* side effect releases another one of them , we are broken ... */
for (k = 0; k < the_table[i].num_recorded_objects; k++)
{
[tmp[k] retain];
}
#endif
/* Then, we bravely unlock the lock */
unLock();
@ -752,13 +750,11 @@ GSDebugAllocationListRecordedObjects(Class c)
answer = [NSArray arrayWithObjects: tmp
count: the_table[i].num_recorded_objects];
#if !GS_WITH_GC
/* Now we release all the objects to balance the retain */
for (k = 0; k < the_table[i].num_recorded_objects; k++)
{
[tmp[k] release];
}
#endif
/* And free the space used by them */
NSZoneFree(NSDefaultMallocZone(), tmp);

View file

@ -601,12 +601,10 @@ static SEL appSel;
i++;
}
self = [self initWithObjects: o + c forKeys: o count: i];
#if !GS_WITH_GC
while (i-- > 0)
{
[o[c + i] release];
}
#endif
}
else
{
@ -1306,12 +1304,10 @@ compareIt(id o1, id o2, void* context)
initWithObjects: o + count
forKeys: o
count: count];
#if !GS_WITH_GC
while (i-- > 0)
{
[o[count + i] release];
}
#endif
GS_ENDIDBUF();
return newDictionary;

View file

@ -756,12 +756,10 @@ static NSDistributedNotificationCenter *netCenter = nil;
@"I attempted to start it at '%@'\n", cmd];
}
}
#if !GS_WITH_GC
else
{
[_remote retain];
}
#endif
c = [_remote connectionForProxy];
[_remote setProtocolForProxy: p];

View file

@ -2372,11 +2372,7 @@ static inline void gsedRelease(GSEnumeratedDirectory X)
const _CHAR *localPath;
_mgr = RETAIN(mgr);
#if GS_WITH_GC
_stack = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
#else
_stack = NSZoneMalloc([self zone], sizeof(GSIArray_t));
#endif
GSIArrayInitWithZoneAndCapacity(_stack, [self zone], 64);
_flags.isRecursive = recurse;

View file

@ -127,15 +127,6 @@ void CFRelease(id obj)
#else
static unsigned disabled = 0;
#if GS_WITH_GC
#include <gc/gc.h>
#import "Foundation/NSLock.h"
#import "Foundation/NSHashTable.h"
static NSLock *lock = nil;
static NSHashTable *uncollectable = 0;
#endif
@implementation NSGarbageCollector
@ -144,79 +135,33 @@ static NSHashTable *uncollectable = 0;
return collector;
}
#if GS_WITH_GC
+ (void) initialize
{
collector = [self alloc];
lock = [NSLock new];
}
#endif
- (void) collectIfNeeded
{
#if GS_WITH_GC
GC_collect_a_little();
#endif
return;
}
- (void) collectExhaustively
{
#if GS_WITH_GC
GC_gcollect();
#endif
return;
}
- (void) disable
{
#if GS_WITH_GC
[lock lock];
GC_disable();
disabled++;
[lock unlock];
#endif
return;
}
- (void) disableCollectorForPointer: (void *)ptr
{
#if GS_WITH_GC
[lock lock];
if (uncollectable == 0)
{
uncollectable = NSCreateHashTable(NSOwnedPointerHashCallBacks, 0);
}
NSHashInsertIfAbsent(uncollectable, ptr);
[lock unlock];
#endif
return;
}
- (void) enable
{
#if GS_WITH_GC
[lock lock];
if (disabled)
{
GC_enable();
disabled--;
}
[lock unlock];
#endif
return;
}
- (void) enableCollectorForPointer: (void *)ptr
{
#if GS_WITH_GC
[lock lock];
if (uncollectable != 0)
{
NSHashRemove(uncollectable, ptr);
}
[lock unlock];
#endif
return;
}

View file

@ -90,9 +90,7 @@ static Class concreteClass = 0;
k = [[NSPointerFunctions alloc] initWithOptions: options];
o = [self initWithPointerFunctions: k capacity: initialCapacity];
#if !GS_WITH_GC
[k release];
#endif
return o;
}

View file

@ -731,14 +731,8 @@ static NSUInteger posForIndex(GSIArray array, NSUInteger index)
}
else
{
#if GS_WITH_GC
_data = (GSIArray)NSAllocateCollectable(sizeof(GSIArray_t),
NSScannedOption);
GSIArrayInitWithZoneAndCapacity(_array, 0, 1);
#else
_data = (GSIArray)NSZoneMalloc([self zone], sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(_array, [self zone], 1);
#endif
GSIArrayAddItem(_array, (GSIArrayItem)aRange);
}
}
@ -759,14 +753,8 @@ static NSUInteger posForIndex(GSIArray array, NSUInteger index)
{
NSUInteger i;
#if GS_WITH_GC
_data = (GSIArray)NSAllocateCollectable(sizeof(GSIArray_t),
NSScannedOption);
GSIArrayInitWithZoneAndCapacity(_array, 0, 1);
#else
_data = (GSIArray)NSZoneMalloc([self zone], sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(_array, [self zone], count);
#endif
for (i = 0; i < count; i++)
{
GSIArrayAddItem(_array, GSIArrayItemAtIndex(_other, i));
@ -1043,14 +1031,8 @@ static NSUInteger posForIndex(GSIArray array, NSUInteger index)
}
if (_array == 0)
{
#if GS_WITH_GC
_data = (GSIArray)NSAllocateCollectable(sizeof(GSIArray_t),
NSScannedOption);
GSIArrayInitWithZoneAndCapacity(_array, 0, 1);
#else
_data = (GSIArray)NSZoneMalloc([self zone], sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(_array, [self zone], 1);
#endif
}
pos = posForIndex(_array, aRange.location);

View file

@ -992,16 +992,6 @@ cifframe_callback(ffi_cif *cif, void *retp, void **args, void *user)
@implementation GSKVOObservation
#if GS_WITH_GC
+ (void) initialize
{
GSMakeWeakPointer(self, "observer");
}
- (void) finalize
{
GSAssignZeroingWeakPointer((void**)&observer, nil);
}
#endif
@end
@implementation GSKVOPathInfo
@ -1165,15 +1155,6 @@ cifframe_callback(ffi_cif *cif, void *retp, void **args, void *user)
o->options = options;
observation = o;
}
#if GS_WITH_GC
else if (o->observer == nil)
{
/* The observer for thsi observation must have been collected.
*/
[pathInfo->observations removeObjectAtIndex: count];
continue;
}
#endif
pathInfo->allOptions |= o->options;
}
if (observation == nil)
@ -1302,14 +1283,6 @@ cifframe_callback(ffi_cif *cif, void *retp, void **args, void *user)
context = o->context;
break;
}
#if GS_WITH_GC
else if (o->observer == nil)
{
/* The observer for thsi observation must have been collected.
*/
[pathInfo->observations removeObjectAtIndex: count];
}
#endif
}
}
[iLock unlock];

View file

@ -45,17 +45,8 @@
#define GSI_MAP_HASH(M, X) ((X).nsu)
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
#undef GSI_MAP_NOCLEAN
#if GS_WITH_GC
#include <gc/gc_typed.h>
static GC_descr nodeDesc; // Type descriptor for map node.
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
#define GSI_MAP_RETAIN_KEY(M, X)
#define GSI_MAP_RELEASE_KEY(M, X)
#else
#define GSI_MAP_RETAIN_KEY(M, X) RETAIN(X.obj)
#define GSI_MAP_RELEASE_KEY(M, X) RELEASE(X.obj)
#endif
#include "GNUstepBase/GSIMap.h"
@ -488,15 +479,6 @@ static NSDictionary *makeReference(unsigned ref)
+ (void) initialize
{
#if GS_WITH_GC
/* We create a typed memory descriptor for map nodes.
*/
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
#endif
GSMakeWeakPointer(self, "delegate");
if (globalClassMap == 0)
@ -871,12 +853,7 @@ static NSDictionary *makeReference(unsigned ref)
/*
* Set up map tables.
*/
#if GS_WITH_GC
_cIdMap = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t)*5,
NSScannedOption);
#else
_cIdMap = (GSIMapTable)NSZoneMalloc(zone, sizeof(GSIMapTable_t)*5);
#endif
_uIdMap = &_cIdMap[1];
_repMap = &_cIdMap[2];
GSIMapInitWithZoneAndCapacity(_cIdMap, zone, 10);

View file

@ -38,13 +38,8 @@
/*
* Setup for inline operation of arrays.
*/
#if GS_WITH_GC
#define GSI_ARRAY_RETAIN(A, X)
#define GSI_ARRAY_RELEASE(A, X)
#else
#define GSI_ARRAY_RETAIN(A, X) [(X).obj retain]
#define GSI_ARRAY_RELEASE(A, X) [(X).obj release]
#endif
#define GSI_ARRAY_TYPES GSUNION_OBJ
@ -841,12 +836,7 @@ static NSMapTable *globalClassMap = 0;
_objects = [_archive objectForKey: @"$objects"];
_keyMap = [_archive objectForKey: @"$top"];
#if GS_WITH_GC
_objMap = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
#else
_objMap = NSZoneMalloc(_zone, sizeof(GSIArray_t));
#endif
count = [_objects count];
GSIArrayInitWithZoneAndCapacity(_objMap, _zone, count);
// Add marker for nil object

View file

@ -139,10 +139,8 @@ static Class concreteClass = 0;
o = [self initWithKeyPointerFunctions: k
valuePointerFunctions: v
capacity: initialCapacity];
#if !GS_WITH_GC
[k release];
[v release];
#endif
return o;
}

View file

@ -520,7 +520,7 @@ static Class runLoopClass;
if (recvPort == nil)
return nil;
else
return GS_GC_UNHIDE(recvPort);
return recvPort;
}
- (void) receivedEvent: (void*)data
@ -1061,9 +1061,9 @@ static Class runLoopClass;
if (sendPort == nil)
return nil;
else if (caller == YES)
return GS_GC_UNHIDE(sendPort); // We called, so port is not retained.
return sendPort; // We called, so port is not retained.
else
return sendPort; // Retained port.
return sendPort; // Retained port.
}
- (void) setState: (GSHandleState)s
@ -1375,13 +1375,13 @@ typedef struct {
if (send == YES)
{
if (handle->caller == YES)
handle->sendPort = GS_GC_HIDE(self);
handle->sendPort = self;
else
ASSIGN(handle->sendPort, self);
}
else
{
handle->recvPort = GS_GC_HIDE(self);
handle->recvPort = self;
}
NSMapInsert(handles, (void*)(uintptr_t)[handle descriptor], (void*)handle);
M_UNLOCK(myLock);
@ -1453,7 +1453,7 @@ typedef struct {
* Enumerate all our socket handles, and put them in as long as they
* are to be used for receiving.
*/
recvSelf = GS_GC_HIDE(self);
recvSelf = self;
me = NSEnumerateMapTable(handles);
while (NSNextMapEnumeratorPair(&me, &sock, (void**)&handle))
{

View file

@ -257,13 +257,6 @@ static void obsFree(Observation *o);
#define GSI_MAP_VEXTRA Observation*
#define GSI_MAP_EXTRA BOOL
#if GS_WITH_GC
#include <gc/gc_typed.h>
static GC_descr nodeDesc; // Type descriptor for map node.
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
#endif
#include "GNUstepBase/GSIMap.h"
/*
@ -370,11 +363,7 @@ obsNew(NCTable *t, SEL s, id o)
#endif
obs->selector = s;
#if GS_WITH_GC
GSAssignZeroingWeakPointer((void**)&obs->observer, (void*)o);
#else
obs->observer = o;
#endif
return obs;
}
@ -512,9 +501,6 @@ static void obsFree(Observation *o)
{
NCTable *t = o->link;
#if GS_WITH_GC
GSAssignZeroingWeakPointer((void**)&o->observer, 0);
#endif
o->link = (NCTable*)t->freeList;
t->freeList = o;
}
@ -624,24 +610,8 @@ purgeMapNode(GSIMapTable map, GSIMapNode node, id observer)
* purgeCollectedFromMapNode() does the same thing but also handles cleanup
* of the map node containing the list if necessary.
*/
#if GS_WITH_GC
#define purgeCollected(X) listPurge(X, nil)
static Observation*
purgeCollectedFromMapNode(GSIMapTable map, GSIMapNode node)
{
Observation *o;
o = node->value.ext = purgeCollected((Observation*)(node->value.ext));
if (o == ENDOBS)
{
GSIMapRemoveKey(map, node->key);
}
return o;
}
#else
#define purgeCollected(X) (X)
#define purgeCollectedFromMapNode(X, Y) ((Observation*)Y->value.ext)
#endif
@interface GSNotificationBlockOperation : NSOperation
@ -769,16 +739,7 @@ static NSNotificationCenter *default_center = nil;
{
if (self == [NSNotificationCenter class])
{
#if GS_WITH_GC
/* We create a typed memory descriptor for map nodes.
*/
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
#else
_zone = NSDefaultMallocZone();
#endif
if (concrete == 0)
{
concrete = [GSNotification class];
@ -1178,9 +1139,6 @@ static NSNotificationCenter *default_center = nil;
GSIArrayItem i[64];
GSIArray_t b;
GSIArray a = &b;
#if GS_WITH_GC
NSGarbageCollector *collector = [NSGarbageCollector defaultCollector];
#endif
if (name == nil)
{
@ -1199,12 +1157,7 @@ static NSNotificationCenter *default_center = nil;
* We use scanned memory in the array in the case where there are more
* than the 64 observers we allowed room for on the stack.
*/
#if GS_WITH_GC
GSIArrayInitWithZoneAndStaticCapacity(a, (NSZone*)1, 64, i);
[collector disable];
#else
GSIArrayInitWithZoneAndStaticCapacity(a, _zone, 64, i);
#endif
lockNCTable(TABLE);
/*
@ -1282,15 +1235,9 @@ static NSNotificationCenter *default_center = nil;
}
}
/*
* Finished with the table ... we can unlock it and re-enable garbage
* collection, safe in the knowledge that the observers we will be
* notifying won't get collected prematurely.
/* Finished with the table ... we can unlock it,
*/
unlockNCTable(TABLE);
#if GS_WITH_GC
[collector enable];
#endif
/*
* Now send all the notifications.

View file

@ -228,12 +228,7 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification,
{
NSNotificationQueueRegistration *item;
#if GS_WITH_GC
item = NSAllocateCollectable(sizeof(NSNotificationQueueRegistration),
NSScannedOption);
#else
item = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueRegistration));
#endif
if (item == 0)
{
[NSException raise: NSMallocException
@ -336,15 +331,9 @@ static NSArray *defaultMode = nil;
// init queue
_center = RETAIN(notificationCenter);
#if GS_WITH_GC
_asapQueue = NSAllocateCollectable(sizeof(NSNotificationQueueList),
NSScannedOption);
_idleQueue = NSAllocateCollectable(sizeof(NSNotificationQueueList),
NSScannedOption);
#else
_asapQueue = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueList));
_idleQueue = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueList));
#endif
if (_asapQueue == 0 || _idleQueue == 0)
{
DESTROY(self);

View file

@ -94,14 +94,6 @@ static SEL autorelease_sel;
static IMP autorelease_imp;
#if GS_WITH_GC
#include <gc/gc.h>
#include <gc/gc_typed.h>
#endif
static SEL finalize_sel;
static IMP finalize_imp;
static Class NSConstantStringClass;
@ -138,7 +130,6 @@ BOOL NSDeallocateZombies = NO;
static Class zombieClass = Nil;
static NSMapTable *zombieMap = 0;
#if !GS_WITH_GC
static void GSMakeZombie(NSObject *o, Class c)
{
object_setClass(o, zombieClass);
@ -149,7 +140,6 @@ static void GSMakeZombie(NSObject *o, Class c)
[allocationLock unlock];
}
}
#endif
static void GSLogZombie(id o, SEL sel)
{
@ -461,7 +451,6 @@ BOOL
NSDecrementExtraRefCountWasZero(id anObject)
#endif
{
#if !GS_WITH_GC
if (double_release_check_enabled)
{
NSUInteger release_count;
@ -523,7 +512,6 @@ NSDecrementExtraRefCountWasZero(id anObject)
return NO;
}
}
#endif /* !GS_WITH_GC */
return NO;
}
@ -541,11 +529,7 @@ NSExtraRefCount(id anObject)
return UINT_MAX-1;
}
#endif
#if GS_WITH_GC
return UINT_MAX - 1;
#else /* GS_WITH_GC */
return ((obj)anObject)[-1].retained;
#endif /* GS_WITH_GC */
}
#ifdef __OBJC_GC__
@ -577,9 +561,9 @@ inline void
NSIncrementExtraRefCount(id anObject)
#endif
{
#if GS_WITH_GC || __OBJC_GC__
#if __OBJC_GC__
return;
#else /* GS_WITH_GC */
#else /* __OBJC_GC__ */
if (allocationLock != 0)
{
#if defined(GSATOMICREAD)
@ -616,7 +600,7 @@ NSIncrementExtraRefCount(id anObject)
}
((obj)anObject)[-1].retained++;
}
#endif /* GS_WITH_GC */
#endif /* __OBJC_GC__ */
}
#ifndef NDEBUG
@ -667,95 +651,6 @@ callCXXConstructors(Class aClass, id anObject)
* depending on what information (if any) we are storing before
* the start of each object.
*/
#if GS_WITH_GC
static void
GSFinalize(void* object, void* data)
{
[(id)object finalize];
AREM(object_getClass((id)object), (id)object);
object_setClass((id)object, (Class)(void*)0xdeadface);
}
static BOOL
GSIsFinalizable(Class c)
{
if (class_getMethodImplementation(c, finalize_sel) != finalize_imp
&& class_respondsToSelector(c, finalize_sel))
return YES;
return NO;
}
inline id
NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone)
{
id new;
int size;
GC_descr gc_type;
NSCAssert((!class_isMetaClass(aClass)), @"Bad class for new object");
gc_type = (GC_descr)aClass->gc_object_type;
size = class_getInstanceSize(aClass) + extraBytes;
if (size % sizeof(void*) != 0)
{
/* Size must be a multiple of pointer size for the garbage collector
* to be able to allocate explicitly typed memory.
*/
size += sizeof(void*) - size % sizeof(void*);
}
if (gc_type == 0)
{
new = NSZoneCalloc(zone, 1, size);
NSLog(@"No garbage collection information for '%s'",
class_getName(aClass));
}
else
{
new = GC_calloc_explicitly_typed(1, size, gc_type);
}
if (new != nil)
{
object_setClass(new, aClass);
/* Don't bother doing this in a thread-safe way, because
* the cost of locking will be a lot more than the cost
* of doing the same call in two threads.
* The returned selector will persist and the runtime will
* ensure that both calls return the same selector, so we
* don't need to bother doing it ourselves.
*/
if (0 == cxx_construct)
{
cxx_construct = sel_registerName(".cxx_construct");
cxx_destruct = sel_registerName(".cxx_destruct");
}
callCXXConstructors(aClass, new);
/* We only need to finalize this object if it implements its a
* -finalize method or has C++ destructors.
*/
if (GSIsFinalizable(aClass)
|| class_respondsToSelector(aClass, cxx_destruct))
{
/* We only do allocation counting for objects that can be
* finalised - for other objects we have no way of decrementing
* the count when the object is collected.
*/
AADD(aClass, new);
GC_REGISTER_FINALIZER (new, GSFinalize, NULL, NULL, NULL);
}
}
return new;
}
inline void
NSDeallocateObject(id anObject)
{
}
#else /* GS_WITH_GC */
#if __OBJC_GC__
static inline id
@ -867,12 +762,10 @@ NSDeallocateObject(id anObject)
return;
}
#endif /* GS_WITH_GC */
BOOL
NSShouldRetainWithZone (NSObject *anObject, NSZone *requestedZone)
{
#if GS_WITH_GC || __OBJC_GC__
#if __OBJC_GC__
// If we're running in hybrid mode, we disable all of the clever zone stuff
// for non-GC code, so this is always true if we're compiled for GC, even if
// we're compiled for GC but not using GC.
@ -963,20 +856,6 @@ NSShouldRetainWithZone (NSObject *anObject, NSZone *requestedZone)
}
}
#if GS_WITH_GC
/* Function to log Boehm GC warnings
* NB. This must not allocate any collectable memory as it may result
* in a deadlock in the garbage collecting library.
*/
static void
GSGarbageCollectorLog(char *msg, GC_word arg)
{
char buf[strlen(msg)+1024];
snprintf(buf, sizeof(buf), msg, (unsigned long)arg);
fprintf(stderr, "Garbage collector: %s", buf);
}
#endif
/**
* Semi-private function in libobjc2 that initialises the classes used for
* blocks.
@ -1003,14 +882,6 @@ static id gs_weak_load(id obj)
{
if (self == [NSObject class])
{
#if GS_WITH_GC
/* Make sure that the garbage collection library is initialised.
* This is not necessary on most platforms, but is good practice.
*/
GC_init();
GC_set_warn_proc(GSGarbageCollectorLog);
#endif
#ifdef _WIN32
{
// See libgnustep-base-entry.m
@ -1852,7 +1723,6 @@ static id gs_weak_load(id obj)
*/
- (id) autorelease
{
#if !GS_WITH_GC
if (double_release_check_enabled)
{
NSUInteger release_count;
@ -1867,7 +1737,6 @@ static id gs_weak_load(id obj)
}
(*autorelease_imp)(autorelease_class, autorelease_sel, self);
#endif
return self;
}
@ -2093,7 +1962,6 @@ static id gs_weak_load(id obj)
*/
- (oneway void) release
{
#if (GS_WITH_GC == 0)
if (NSDecrementExtraRefCountWasZero(self))
{
# ifdef OBJC_CAP_ARC
@ -2101,7 +1969,6 @@ static id gs_weak_load(id obj)
# endif
[self dealloc];
}
#endif
}
/**
@ -2160,9 +2027,7 @@ static id gs_weak_load(id obj)
*/
- (id) retain
{
#if (GS_WITH_GC == 0)
NSIncrementExtraRefCount(self);
#endif
return self;
}
@ -2187,11 +2052,7 @@ static id gs_weak_load(id obj)
*/
- (NSUInteger) retainCount
{
#if GS_WITH_GC
return UINT_MAX;
#else
return NSExtraRefCount(self) + 1;
#endif
}
/**
@ -2217,7 +2078,7 @@ static id gs_weak_load(id obj)
*/
- (NSZone*) zone
{
#if GS_WITH_GC || __OBJC_GC__
#if __OBJC_GC__
/* MacOS-X 10.5 seems to return the default malloc zone if GC is enabled.
*/
return NSDefaultMallocZone();
@ -2226,7 +2087,7 @@ static id gs_weak_load(id obj)
#endif
}
#if !GS_WITH_GC && !__OBJC_GC__
#if !__OBJC_GC__
+ (NSZone *) zone
{
return NSDefaultMallocZone();

View file

@ -304,19 +304,7 @@ static Class concreteClass = Nil;
c = (NSConcretePointerArray*)NSCopyObject(self, 0, NSDefaultMallocZone());
c->_capacity = c->_count;
c->_grow_factor = c->_capacity/2;
#if GS_WITH_GC
if (_pf.options & NSPointerFunctionsZeroingWeakMemory)
{
c->_contents = NSAllocateCollectable(sizeof(id) * _count, 0);
}
else
{
c->_contents = NSAllocateCollectable(sizeof(id) * _count,
NSScannedOption);
}
#else
c->_contents = NSZoneCalloc([self zone], _count, sizeof(id));
#endif
for (i = 0; i < _count; i++)
{
NSLog(@"Copying %d, %p", i, _contents[i]);
@ -397,19 +385,7 @@ static Class concreteClass = Nil;
at: &_count];
if (_count > 0)
{
#if GS_WITH_GC
if (_pf.options & NSPointerFunctionsZeroingWeakMemory)
{
_contents = NSAllocateCollectable(sizeof(id) * _count, 0);
}
else
{
_contents = NSAllocateCollectable(sizeof(id) * _count,
NSScannedOption);
}
#else
_contents = NSZoneCalloc([self zone], _count, sizeof(id));
#endif
if (_contents == 0)
{
[NSException raise: NSMallocException
@ -558,9 +534,6 @@ static Class concreteClass = Nil;
new_gf = new_cap / 2;
if (_contents == 0)
{
#if GS_WITH_GC
ptr = (void**)NSZoneMalloc([self zone], size);
#else
if (_pf.options & NSPointerFunctionsZeroingWeakMemory)
{
ptr = (void**)NSAllocateCollectable(size, 0);
@ -569,13 +542,9 @@ static Class concreteClass = Nil;
{
ptr = (void**)NSAllocateCollectable(size, NSScannedOption);
}
#endif
}
else
{
#if GS_WITH_GC
ptr = (void**)NSZoneRealloc([self zone], _contents, size);
#else
if (_pf.options & NSPointerFunctionsZeroingWeakMemory)
{
ptr = (void**)NSReallocateCollectable(
@ -586,7 +555,6 @@ static Class concreteClass = Nil;
ptr = (void**)NSReallocateCollectable(
_contents, size, NSScannedOption);
}
#endif
}
if (ptr == 0)
{

View file

@ -64,13 +64,6 @@
#define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr)
#define GSI_MAP_NOCLEAN 1
#if GS_WITH_GC
#include <gc/gc_typed.h>
static GC_descr nodeDesc; // Type descriptor for map node.
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc)
#endif
#include "GNUstepBase/GSIMap.h"
/*
@ -369,14 +362,6 @@ static unsigned encodingVersion;
encodingVersion = [coder systemVersion];
[coder release];
#if GS_WITH_GC
/* We create a typed memory descriptor for map nodes.
*/
GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0};
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key));
GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value));
nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t));
#endif
connectionClass = [NSConnection class];
mutableArrayClass = [NSMutableArray class];
mutableDataClass = [NSMutableDataMalloc class];
@ -1896,14 +1881,8 @@ static unsigned encodingVersion;
/*
* Set up map tables.
*/
#if GS_WITH_GC
_clsMap
= (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t)*4,
NSScannedOption);
#else
_clsMap
= (GSIMapTable)NSZoneMalloc(_zone, sizeof(GSIMapTable_t)*4);
#endif
_cIdMap = &_clsMap[1];
_uIdMap = &_clsMap[2];
_ptrMap = &_clsMap[3];
@ -1995,12 +1974,7 @@ static unsigned encodingVersion;
*/
if (firstTime == YES)
{
#if GS_WITH_GC
_clsAry
= NSAllocateCollectable(sizeof(GSIArray_t)*3, NSScannedOption);
#else
_clsAry = NSZoneMalloc(_zone, sizeof(GSIArray_t)*3);
#endif
_objAry = &_clsAry[1];
_ptrAry = &_clsAry[2];
GSIArrayInitWithZoneAndCapacity(_clsAry, _zone, sizeC);

View file

@ -217,9 +217,7 @@
*/
- (id) autorelease
{
#if GS_WITH_GC == 0
[NSAutoreleasePool addObject: self];
#endif
return self;
}
@ -455,7 +453,6 @@
*/
- (oneway void) release
{
#if (GS_WITH_GC == 0)
if (NSDecrementExtraRefCountWasZero(self))
{
# ifdef OBJC_CAP_ARC
@ -463,7 +460,6 @@
# endif
[self dealloc];
}
#endif
}
/**

View file

@ -240,13 +240,8 @@ static NSDate *theFuture = nil;
#ifndef GSI_ARRAY_TYPES
#define GSI_ARRAY_TYPES GSUNION_OBJ
#if GS_WITH_GC == 0
#define GSI_ARRAY_RELEASE(A, X) [(X).obj release]
#define GSI_ARRAY_RETAIN(A, X) [(X).obj retain]
#else
#define GSI_ARRAY_RELEASE(A, X)
#define GSI_ARRAY_RETAIN(A, X)
#endif
#include "GNUstepBase/GSIArray.h"
#endif
@ -554,12 +549,8 @@ static inline BOOL timerInvalidated(NSTimer *t)
NSObjectMapValueCallBacks, 0);
_timedPerformers = [[NSMutableArray alloc] initWithCapacity: 8];
#ifdef HAVE_POLL_F
#if GS_WITH_GC
_extra = NSAllocateCollectable(sizeof(pollextra), NSScannedOption);
#else
_extra = NSZoneMalloc(NSDefaultMallocZone(), sizeof(pollextra));
memset(_extra, '\0', sizeof(pollextra));
#endif
#endif
}
return self;
@ -1113,12 +1104,10 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
when = theFuture;
}
}
#if !GS_WITH_GC
else
{
AUTORELEASE(when);
}
#endif
NSDebugMLLog(@"NSRunLoop", @"limit date %f in %@",
nil == when ? 0.0 : [when timeIntervalSinceReferenceDate], mode);

View file

@ -62,11 +62,6 @@
#define GSI_MAP_EQUAL(M, X,Y) [(X).obj isEqualToString: (Y).obj]
#define GSI_MAP_NOCLEAN 1
#if GS_WITH_GC
#define GSI_MAP_NODES(M, X) \
(GSIMapNode)NSAllocateCollectable(X * sizeof(GSIMapNode_t), 0)
#endif
#include "GNUstepBase/GSIMap.h"
/*
@ -555,11 +550,7 @@ deserializeFromInfo(_NSDeserializerInfo* info)
char *b;
size = (*info->deiImp)(info->data, deiSel, info->cursor);
#if GS_WITH_GC
b = NSAllocateCollectable(size, 0);
#else
b = NSZoneMalloc(NSDefaultMallocZone(), size);
#endif
(*info->debImp)(info->data, debSel, b, size, info->cursor);
s = [[StringClass alloc] initWithBytesNoCopy: b
length: size - 1
@ -591,11 +582,7 @@ deserializeFromInfo(_NSDeserializerInfo* info)
unichar *b;
size = (*info->deiImp)(info->data, deiSel, info->cursor);
#if GS_WITH_GC
b = NSAllocateCollectable(size*sizeof(unichar), 0);
#else
b = NSZoneMalloc(NSDefaultMallocZone(), size*sizeof(unichar));
#endif
(*info->debImp)(info->data, debSel, b, size*sizeof(unichar),
info->cursor);
s = [[StringClass alloc] initWithBytesNoCopy: b

View file

@ -267,12 +267,10 @@ static Class NSMutableSet_concrete_class;
[aCoder decodeValueOfObjCType: @encode(id) at: &objs[i]];
}
self = [self initWithObjects: objs count: count];
#if GS_WITH_GC == 0
while (count-- > 0)
{
[objs[count] release];
}
#endif
GS_ENDIDBUF();
}
}
@ -418,11 +416,13 @@ static Class NSMutableSet_concrete_class;
i++;
}
self = [self initWithObjects: os count: c];
#if !GS_WITH_GC
if (flag)
while (i--)
[os[i] release];
#endif
{
while (i--)
{
[os[i] release];
}
}
GS_ENDIDBUF();
return self;
}

View file

@ -757,7 +757,7 @@ static Class runLoopClass;
if (recvPort == nil)
return nil;
else
return GS_GC_UNHIDE(recvPort);
return recvPort;
}
- (void) receivedEventRead
@ -1456,9 +1456,9 @@ static Class runLoopClass;
if (sendPort == nil)
return nil;
else if (caller == YES)
return GS_GC_UNHIDE(sendPort); // We called, so port is not retained.
return sendPort; // We called, so port is not retained.
else
return sendPort; // Retained port.
return sendPort; // Retained port.
}
- (void) setState: (GSHandleState)s
@ -1760,7 +1760,7 @@ static Class tcpPortClass;
if (send == YES)
{
if (handle->caller == YES)
handle->sendPort = GS_GC_HIDE(self);
handle->sendPort = self;
else
ASSIGN(handle->sendPort, self);
}
@ -1853,7 +1853,7 @@ static Class tcpPortClass;
* Enumerate all our socket handles, and put them in as long as they
* are to be used for receiving.
*/
recvSelf = GS_GC_HIDE(self);
recvSelf = self;
me = NSEnumerateMapTable(events);
while (NSNextMapEnumeratorPair(&me, &event, (void**)&fd))
{
@ -1897,7 +1897,7 @@ static Class tcpPortClass;
* Enumerate all our socket handles, and put them in as long as they
* are to be used for receiving.
*/
recvSelf = GS_GC_HIDE(self);
recvSelf = self;
me = NSEnumerateMapTable(handles);
while (NSNextMapEnumeratorPair(&me, &sock, (void**)&handle))
{

View file

@ -732,20 +732,14 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
[NSException raise: NSCharacterConversionException
format: @"precompose/decompose length check failed"];
}
#if GS_WITH_GC
dst = NSAllocateCollectable(newLength * sizeof(unichar), 0);
#else
dst = NSZoneMalloc(NSDefaultMallocZone(), newLength * sizeof(unichar));
#endif
err = 0;
unorm2_normalize(normalizer, (UChar*)src, length,
(UChar*)dst, newLength, &err);
free(src);
if (U_FAILURE(err))
{
#if !GS_WITH_GC
NSZoneFree(NSDefaultMallocZone(), dst);
#endif
[NSException raise: NSCharacterConversionException
format: @"precompose/decompose failed"];
}
@ -1158,11 +1152,7 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
{
void *buf;
#if GS_WITH_GC
buf = NSAllocateCollectable(length, 0);
#else
buf = NSZoneMalloc([self zone], length);
#endif
memcpy(buf, bytes, length);
return [self initWithBytesNoCopy: buf
length: length
@ -5900,11 +5890,7 @@ static NSFileManager *fm = nil;
NSZone *zone;
[aCoder decodeValueOfObjCType: @encode(int) at: &enc];
#if GS_WITH_GC
zone = GSAtomicMallocZone();
#else
zone = [self zone];
#endif
if (enc == NSUnicodeStringEncoding)
{
@ -5922,11 +5908,7 @@ static NSFileManager *fm = nil;
{
unsigned char *chars;
#if GS_WITH_GC
chars = NSAllocateCollectable(count+1, 0);
#else
chars = NSZoneMalloc(zone, count+1);
#endif
[aCoder decodeArrayOfObjCType: @encode(unsigned char)
count: count
at: chars];

View file

@ -79,9 +79,6 @@
#import "GSPrivate.h"
#import "GSRunLoopCtxt.h"
#if GS_WITH_GC
# include <gc/gc.h>
#endif
#if __OBJC_GC__
# include <objc/objc-auto.h>
#endif
@ -687,13 +684,6 @@ gnustep_base_thread_callback(void)
* threaded BEFORE sending the notifications.
*/
entered_multi_threaded_state = YES;
#if GS_WITH_GC && defined(HAVE_GC_ALLOW_REGISTER_THREADS)
/* This function needs to be called before going multi-threaded
* so that the garbage collection library knows to support
* registration of new threads.
*/
GS_allow_register_threads();
#endif
NS_DURING
{
[GSPerformHolder class]; // Force initialization
@ -1129,26 +1119,6 @@ static void *nsthreadLauncher(void* thread)
#if __OBJC_GC__
objc_registerThreadWithCollector();
#endif
#if GS_WITH_GC && defined(HAVE_GC_REGISTER_MY_THREAD)
{
struct GC_stack_base base;
if (GC_get_stack_base(&base) == GC_SUCCESS)
{
int result;
result = GC_register_my_thread(&base);
if (result != GC_SUCCESS && result != GC_DUPLICATE)
{
fprintf(stderr, "Argh ... no thread support in garbage collection library\n");
}
}
else
{
fprintf(stderr, "Unable to determine stack base to register new thread for garbage collection\n");
}
}
#endif
/*
* Let observers know a new thread is starting.

View file

@ -1610,12 +1610,10 @@ static NSMapTable *absolutes = 0;
{
localZoneString = tzdir = nil;
}
#if !GS_WITH_GC
else
{
[tzdir retain];
}
#endif
}
#endif
if (localZoneString != nil && [localZoneString hasPrefix: tzdir])

View file

@ -260,11 +260,7 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
len += strlen(rel->fragment) + 1; // #fragment
}
#if GS_WITH_GC
ptr = buf = (char*)NSAllocateCollectable(len, 0);
#else
ptr = buf = (char*)NSZoneMalloc(NSDefaultMallocZone(), len);
#endif
if (rel->scheme != 0)
{
@ -843,11 +839,7 @@ static NSUInteger urlAlign;
BOOL canBeGeneric = YES;
size += sizeof(parsedURL) + urlAlign + 1;
#if GS_WITH_GC
buf = _data = (parsedURL*)NSAllocateCollectable(size, 0);
#else
buf = _data = (parsedURL*)NSZoneMalloc(NSDefaultMallocZone(), size);
#endif
memset(buf, '\0', size);
start = end = ptr = (char*)&buf[1];
[_urlString getCString: start

View file

@ -137,13 +137,8 @@ typedef struct
if (o != nil)
{
#if GS_WITH_GC
o->_NSURLConnectionInternal
= NSAllocateCollectable(sizeof(Internal), NSScannedOption);
#else
o->_NSURLConnectionInternal = NSZoneCalloc([self zone],
1, sizeof(Internal));
#endif
}
return o;
}

View file

@ -838,10 +838,8 @@ static NSURLProtocol *placeholder = nil;
nil]]];
return;
}
#if !GS_WITH_GC
[this->input retain];
[this->output retain];
#endif
if ([[url scheme] isEqualToString: @"https"] == YES)
{
static NSArray *keys;
@ -1768,10 +1766,8 @@ static NSURLProtocol *placeholder = nil;
userInfo: nil]];
return;
}
#if !GS_WITH_GC
[this->input retain];
[this->output retain];
#endif
if ([[url scheme] isEqualToString: @"https"] == YES)
{
[this->input setProperty: NSStreamSocketSecurityLevelNegotiatedSSL

View file

@ -1481,11 +1481,7 @@ static unsigned encodingVersion;
void *b;
NSData *d;
#if GS_WITH_GC
b = NSAllocateCollectable(l, 0);
#else
b = NSZoneMalloc(zone, l);
#endif
[self decodeArrayOfObjCType: @encode(unsigned char)
count: l
at: b];

View file

@ -332,247 +332,7 @@ NSZoneRealloc (NSZone *zone, void *ptr, NSUInteger size)
void NSZoneFree (NSZone *zone, void *ptr) { }
#elif GS_WITH_GC
#if defined(DEBUG)
#define GC_DEBUG 1
#endif /* DEBUG */
#include <gc/gc.h>
/*
* Dummy zones used with garbage collection.
* The 'atomic' zone is for memory that will be assumed not to contain
* pointers for garbage collection purposes.
*/
static NSZone atomic_zone =
{
0, 0, 0, 0, 0, 0, 0, 0, @"default", 0
};
void *
NSAllocateCollectable(NSUInteger size, NSUInteger options)
{
void *ptr;
if (options & NSScannedOption)
{
if (options & NSCollectorDisabledOption)
{
ptr = (void*)GC_MALLOC_UNCOLLECTABLE(size);
memset(ptr, '\0', size);
}
else
{
ptr = (void*)GC_MALLOC_IGNORE_OFF_PAGE(size);
memset(ptr, '\0', size);
}
}
else
{
if (options & NSCollectorDisabledOption)
{
ptr = (void*)calloc(1, size);
}
else
{
ptr = (void*)GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(size);
memset(ptr, '\0', size);
}
}
return ptr;
}
void *
NSReallocateCollectable(void *ptr, NSUInteger size, NSUInteger options)
{
if (ptr == 0)
{
ptr = NSAllocateCollectable(size, options);
}
else if (size > 0 && GC_base(ptr) == 0)
{
/* This is not collectable memory, so we don't know how big it is.
* that means we must use realloc first, to get a known size, and
* then, if needed, allocate a chunk the right size and copy to it.
*/
ptr = realloc(ptr, size);
if (ptr != 0)
{
if ((options & NSScannedOption)
|| !(options & NSCollectorDisabledOption))
{
void *tmp = NSAllocateCollectable(size, options);
memcpy(tmp, ptr, size);
free(ptr);
ptr = tmp;
}
}
}
else
{
void *tmp = NSAllocateCollectable(size, options);
unsigned length = GC_size(ptr);
if (length > size)
{
length = size;
}
if (tmp != 0 && length > 0)
{
memcpy(tmp, ptr, length);
}
GC_FREE(ptr);
ptr = tmp;
}
return ptr;
}
NSZone*
NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree)
{
NSLog(@" *** Creating a zone while running GC is ignored.");
return &default_zone;
}
inline NSZone*
NSDefaultMallocZone (void)
{
return &default_zone;
}
NSZone*
GSAtomicMallocZone (void)
{
return &atomic_zone;
}
NSZone*
NSZoneFromPointer (void *ptr)
{
return &default_zone;
}
void
NSRecycleZone (NSZone *zone)
{
}
BOOL
NSZoneCheck (NSZone *zone)
{
return YES;
}
struct
NSZoneStats NSZoneStats (NSZone *zone)
{
struct NSZoneStats stats = { 0 };
return stats;
}
void
GSMakeWeakPointer(Class theClass, const char *iVarName)
{
class_ivar_set_gcinvisible(theClass, iVarName, YES);
}
BOOL
GSAssignZeroingWeakPointer(void **destination, void *source)
{
if (destination == 0)
{
return NO; // Bad destination pointer
}
if (*destination == source)
{
return YES; // Already assigned.
}
if (source != 0 && GC_base(source) == 0)
{
return NO; // Source is not garbage collectable.
}
if (*destination != 0)
{
GC_unregister_disappearing_link(destination);
}
*destination = source;
if (source != 0)
{
GC_general_register_disappearing_link(destination, source);
}
return YES;
}
void*
NSZoneMalloc (NSZone *zone, NSUInteger size)
{
return NSZoneCalloc(zone, 1, size);
}
void*
NSZoneCalloc (NSZone *zone, NSUInteger elems, NSUInteger bytes)
{
size_t size = elems * bytes;
void *ptr;
if (zone == &atomic_zone)
{
ptr = (void*)GC_MALLOC_ATOMIC(size);
memset(ptr, '\0', size);
}
else
{
ptr = (void*)malloc(size);
if (ptr == 0)
{
ptr = GSOutOfMemory(size, NO);
}
if (ptr != 0)
{
memset(ptr, '\0', size);
}
}
return ptr;
}
void*
NSZoneRealloc (NSZone *zone, void *ptr, NSUInteger size)
{
if (GC_base(ptr) != 0)
{
ptr = GC_REALLOC(ptr, size);
}
else
{
ptr = realloc(ptr, size);
}
return ptr;
}
void
NSZoneFree (NSZone *zone, void *ptr)
{
if (GC_base(ptr) != 0)
{
GC_FREE(ptr);
}
else
{
free(ptr);
}
}
BOOL
GSPrivateIsCollectable(const void *ptr)
{
if (GC_base((void*)ptr) == 0) return NO;
else return YES;
}
#else /* GS_WITH_GC */
#else /* __OBJC_GC__ */
/* Alignment */
#ifdef ALIGN
@ -2169,4 +1929,4 @@ GSPrivateIsCollectable(const void *ptr)
return NO;
}
#endif /* GS_WITH_GC */
#endif /* __OBJC_GC__ */

View file

@ -108,11 +108,7 @@ callframe_from_signature (NSMethodSignature *info, void **retval)
* is sized exactly ... don't know why.
*/
full += ret + 8;
#if GS_WITH_GC
cframe = buf = NSAllocateCollectable(full, NSScannedOption);
#else
cframe = buf = NSZoneCalloc(NSDefaultMallocZone(), full, 1);
#endif
if (cframe)
{
*retval = buf + pos;
@ -120,11 +116,7 @@ callframe_from_signature (NSMethodSignature *info, void **retval)
}
else
{
#if GS_WITH_GC
cframe = buf = NSAllocateCollectable(size, NSScannedOption);
#else
cframe = buf = NSZoneCalloc(NSDefaultMallocZone(), size, 1);
#endif
}
if (cframe)

View file

@ -29,7 +29,6 @@
#define FDCOUNT 1024
#if GS_WITH_GC == 0
static SEL wRelSel;
static SEL wRetSel;
static IMP wRelImp;
@ -53,20 +52,15 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
wRelease,
0
};
#else
#define WatcherMapValueCallBacks NSNonOwnedPointerMapValueCallBacks
#endif
@implementation GSRunLoopCtxt
+ (void) initialize
{
#if GS_WITH_GC == 0
wRelSel = @selector(release);
wRetSel = @selector(retain);
wRelImp = [[GSRunLoopWatcher class] instanceMethodForSelector: wRelSel];
wRetImp = [[GSRunLoopWatcher class] instanceMethodForSelector: wRetSel];
#endif
}
- (void) dealloc
@ -176,19 +170,11 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
mode = [theMode copy];
extra = e;
#if GS_WITH_GC
z = (NSZone*)1;
performers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
timers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
watchers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
_trigger = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
#else
z = [self zone];
performers = NSZoneMalloc(z, sizeof(GSIArray_t));
timers = NSZoneMalloc(z, sizeof(GSIArray_t));
watchers = NSZoneMalloc(z, sizeof(GSIArray_t));
_trigger = NSZoneMalloc(z, sizeof(GSIArray_t));
#endif
GSIArrayInitWithZoneAndCapacity(performers, z, 8);
GSIArrayInitWithZoneAndCapacity(timers, z, 8);
GSIArrayInitWithZoneAndCapacity(watchers, z, 8);
@ -219,23 +205,13 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
pe->limit = fd + 1;
if (pe->index == 0)
{
#if GS_WITH_GC
pe->index
= NSAllocateCollectable(pe->limit * sizeof(*(pe->index)), 0);
#else
pe->index = NSZoneMalloc(NSDefaultMallocZone(),
pe->limit * sizeof(*(pe->index)));
#endif
}
else
{
#if GS_WITH_GC
pe->index = NSReallocateCollectable(pe->index,
pe->limit * sizeof(*(pe->index)), 0);
#else
pe->index = NSZoneRealloc(NSDefaultMallocZone(),
pe->index, pe->limit * sizeof(*(pe->index)));
#endif
}
do
{
@ -249,13 +225,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
if (ctxt->pollfds_count >= ctxt->pollfds_capacity)
{
ctxt->pollfds_capacity += 8;
#if GS_WITH_GC
pollfds = NSReallocateCollectable(pollfds,
ctxt->pollfds_capacity * sizeof (*pollfds), 0);
#else
pollfds = NSZoneRealloc(NSDefaultMallocZone(),
pollfds, ctxt->pollfds_capacity * sizeof (*pollfds));
#endif
ctxt->pollfds = pollfds;
}
index = ctxt->pollfds_count++;
@ -304,23 +275,13 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
pollfds_capacity = i + 2;
if (pollfds == 0)
{
#if GS_WITH_GC
pollfds
= NSAllocateCollectable(pollfds_capacity * sizeof(*pollfds), 0);
#else
pollfds = NSZoneMalloc(NSDefaultMallocZone(),
pollfds_capacity * sizeof(*pollfds));
#endif
}
else
{
#if GS_WITH_GC
pollfds = NSReallocateCollectable(pollfds,
pollfds_capacity * sizeof(*pollfds), 0);
#else
pollfds = NSZoneRealloc(NSDefaultMallocZone(),
pollfds, pollfds_capacity * sizeof(*pollfds));
#endif
}
}
pollfds_count = 0;

View file

@ -19,7 +19,6 @@
#define FDCOUNT 1024
#if GS_WITH_GC == 0
static SEL wRelSel;
static SEL wRetSel;
static IMP wRelImp;
@ -43,20 +42,15 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
wRelease,
0
};
#else
#define WatcherMapValueCallBacks NSNonOwnedPointerMapValueCallBacks
#endif
@implementation GSRunLoopCtxt
+ (void) initialize
{
#if GS_WITH_GC == 0
wRelSel = @selector(release);
wRetSel = @selector(retain);
wRelImp = [[GSRunLoopWatcher class] instanceMethodForSelector: wRelSel];
wRetImp = [[GSRunLoopWatcher class] instanceMethodForSelector: wRetSel];
#endif
}
- (void) dealloc
@ -151,19 +145,11 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
mode = [theMode copy];
extra = e;
#if GS_WITH_GC
z = (NSZone*)1;
performers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
timers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
watchers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
_trigger = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption);
#else
z = [self zone];
performers = NSZoneMalloc(z, sizeof(GSIArray_t));
timers = NSZoneMalloc(z, sizeof(GSIArray_t));
watchers = NSZoneMalloc(z, sizeof(GSIArray_t));
_trigger = NSZoneMalloc(z, sizeof(GSIArray_t));
#endif
GSIArrayInitWithZoneAndCapacity(performers, z, 8);
GSIArrayInitWithZoneAndCapacity(timers, z, 8);
GSIArrayInitWithZoneAndCapacity(watchers, z, 8);

View file

@ -593,9 +593,7 @@ static NSString *mainFont = nil;
- (void) outputNode: (GSXMLNode*)node to: (NSMutableString*)buf
{
#if GS_WITH_GC == 0
CREATE_AUTORELEASE_POOL(arp);
#endif
GSXMLNode *children = [node firstChild];
if ([node type] == XML_ELEMENT_NODE)

View file

@ -1354,9 +1354,7 @@ static BOOL snuggleStart(NSString *t)
withIndent: (unsigned)ind
to: (NSMutableString*)buf
{
#if GS_WITH_GC == 0
CREATE_AUTORELEASE_POOL(arp);
#endif
unsigned l = [str length];
NSRange r = [str rangeOfString: @"<example"];
unsigned i = 0;

View file

@ -1275,9 +1275,7 @@ recheck:
- (NSMutableDictionary*) parseDeclaration
{
NSMutableDictionary *d = [NSMutableDictionary dictionary];
#if GS_WITH_GC == 0
CREATE_AUTORELEASE_POOL(arp);
#endif
static NSSet *qualifiers = nil;
static NSSet *keep = nil;
NSMutableString *t = nil;
@ -2709,9 +2707,7 @@ fail:
- (NSMutableDictionary*) parseMethodIsDeclaration: (BOOL)flag
{
#if GS_WITH_GC == 0
CREATE_AUTORELEASE_POOL(arp);
#endif
NSMutableDictionary *method;
NSMutableString *mname;
NSString *token;

View file

@ -653,10 +653,8 @@ main(int argc, char **argv, char **env)
NSString *symbolDeclsFile = nil;
NSMutableDictionary *symbolDecls = nil;
NSMutableSet *deps = nil;
#if GS_WITH_GC == 0
NSAutoreleasePool *outer = nil;
NSAutoreleasePool *pool = nil;
#endif
NSString *arg;
NSString *opt;
NSSet *argSet;
@ -729,9 +727,7 @@ main(int argc, char **argv, char **env)
GSInitializeProcess(argc, argv, env);
#endif
#if GS_WITH_GC == 0
outer = [NSAutoreleasePool new];
#endif
#ifndef HAVE_LIBXML
NSLog(@"ERROR: The GNUstep Base Library was built\n"
@ -1254,9 +1250,7 @@ main(int argc, char **argv, char **env)
up = [defs stringForKey: @"Up"];
#if GS_WITH_GC == 0
pool = [NSAutoreleasePool new];
#endif
parser = [AGSParser new];
wm = [[defs dictionaryForKey: @"WordMap"] mutableCopy];
@ -1293,9 +1287,7 @@ main(int argc, char **argv, char **env)
[wm setObject: @"" forKey: @"__weak"];
}
[parser setWordMap: wm];
#if GS_WITH_GC == 0
RELEASE(wm);
#endif
output = [AGSOutput new];
if ([defs boolForKey: @"Standards"] == YES)
{
@ -1323,13 +1315,11 @@ main(int argc, char **argv, char **env)
NSDate *gDate = nil;
unsigned j;
#if GS_WITH_GC == 0
if (pool != nil)
{
RELEASE(pool);
pool = [NSAutoreleasePool new];
}
#endif
/*
* Note the name of the header file without path or extension.
@ -1571,9 +1561,7 @@ main(int argc, char **argv, char **env)
[symbolDecls writeToFile: symbolDeclsFile atomically: YES];
informalProtocols = RETAIN([output informalProtocols]);
#if GS_WITH_GC == 0
DESTROY(pool);
#endif
DESTROY(parser);
DESTROY(output);
}
@ -1597,13 +1585,11 @@ main(int argc, char **argv, char **env)
NSDictionary *attrs;
NSDate *gDate = nil;
#if GS_WITH_GC == 0
if (arp != nil)
{
RELEASE(arp);
arp = [NSAutoreleasePool new];
}
#endif
/*
* 6a) Chop off any path specification that might be there (for files
* given on the command line) and search for the file only in
@ -1689,9 +1675,7 @@ main(int argc, char **argv, char **env)
[projectRefs addInformalProtocols: informalProtocols];
DESTROY(informalProtocols);
}
#if GS_WITH_GC == 0
DESTROY(arp);
#endif
/*
* 7) Save project references if they have been modified
@ -1877,9 +1861,7 @@ main(int argc, char **argv, char **env)
*/
[globalRefs mergeRefs: [projectRefs refs] override: YES];
#if GS_WITH_GC == 0
RELEASE(pool);
#endif
}
/*
@ -2044,9 +2026,7 @@ main(int argc, char **argv, char **env)
count = [gFiles count];
if (generateHtml == YES && count > 0)
{
#if GS_WITH_GC == 0
pool = [NSAutoreleasePool new];
#endif
for (i = 0; i < count; i++)
{
@ -2059,13 +2039,11 @@ main(int argc, char **argv, char **env)
NSDate *gDate = nil;
NSDate *hDate = nil;
#if GS_WITH_GC == 0
if (pool != nil)
{
RELEASE(pool);
pool = [NSAutoreleasePool new];
}
#endif
/*
* 10a) As before in connection with (6a), drop path information
* and look for gsdoc files in 'documentationDirectory' or
@ -2162,9 +2140,7 @@ main(int argc, char **argv, char **env)
gsdocfile);
}
}
#if GS_WITH_GC == 0
RELEASE(pool);
#endif
}
/*
@ -2176,9 +2152,7 @@ main(int argc, char **argv, char **env)
count = [hFiles count];
if (count > 0)
{
#if GS_WITH_GC == 0
pool = [NSAutoreleasePool new];
#endif
for (i = 0; i < count; i++)
{
@ -2186,13 +2160,11 @@ main(int argc, char **argv, char **env)
NSString *src;
NSString *dst;
#if GS_WITH_GC == 0
if (pool != nil)
{
RELEASE(pool);
pool = [NSAutoreleasePool new];
}
#endif
file = [file lastPathComponent];
@ -2367,9 +2339,7 @@ main(int argc, char **argv, char **env)
NSLog(@"Type of file '%@' unrecognized ... skipping", src);
}
}
#if GS_WITH_GCC == 0
RELEASE(pool);
#endif
}
/*

View file

@ -1170,9 +1170,7 @@ main(int argc, char** argv, char** env)
RELEASE(pool);
{
#if GS_WITH_GC == 0
CREATE_AUTORELEASE_POOL(pool);
#endif
NSUserDefaults *defs;
int sym;

View file

@ -496,17 +496,13 @@ HandleLanguage(NSString *language_name, NSMutableDictionary *source_entries)
UpdateTable([source_entries objectForKey: table_name], filename);
}
#if GS_WITH_GC == 0
DESTROY(arp);
#endif
}
int main(int argc, char **argv)
{
#if GS_WITH_GC == 0
CREATE_AUTORELEASE_POOL(arp);
#endif
NSMutableDictionary *source_entries;
NSMutableArray *languages = [NSMutableArray arrayWithCapacity: 10];
@ -619,9 +615,8 @@ int main(int argc, char **argv)
}
}
#if GS_WITH_GC == 0
DESTROY(arp);
#endif
if (error)
return 1;
else

View file

@ -1213,16 +1213,11 @@ esac
#--------------------------------------------------------------------
# Set Apple/Darwin/OSX/NeXT information for other tests
#--------------------------------------------------------------------
OBJC_WITH_GC=no
OBJC_RUNTIME_LIB=`echo $LIBRARY_COMBO | tr '-' ' ' | awk '{print $1}'`
AC_MSG_CHECKING(the Objective-C runtime)
if test "$OBJC_RUNTIME_LIB" = "nx" -o "$OBJC_RUNTIME_LIB" = "apple"; then
AC_MSG_RESULT(NeXT)
OBJCFLAGS="$OBJCFLAGS -fnext-runtime -DNeXT_RUNTIME"
elif test "$OBJC_RUNTIME_LIB" = "gnugc"; then
AC_MSG_RESULT(GNU)
OBJCFLAGS="$OBJCFLAGS -fgnu-runtime"
OBJC_WITH_GC=yes
elif test "$OBJC_RUNTIME_LIB" = "ng"; then
AC_MSG_RESULT(Next Gen)
else
@ -1321,36 +1316,6 @@ if test $ac_cv_header_objc_objc_h = no; then
AC_MSG_ERROR(Could not find Objective-C headers)
fi
if test $OBJC_WITH_GC = yes; then
AC_CHECK_HEADERS(gc/gc.h, gc_ok=yes, gc_ok=no)
if test "$gc_ok" = no; then
AC_MSG_ERROR([Garbage collection was required, but the gc/gc.h header couldn't be found.])
fi
saved_LIBS="$LIBS"
LIBS+=" -lgc"
AC_CHECK_FUNC(GC_malloc, gc_ok=yes, gc_ok=no)
if test "$gc_ok" = no; then
AC_MSG_ERROR([Garbage collection was required, but the gc library couldn't be found.])
fi
AC_CHECK_FUNC(GC_register_my_thread)
if test "$ac_cv_func_GC_register_my_thread" = yes; then
AC_DEFINE(HAVE_GC_REGISTER_MY_THREAD,1,
[Define if GC_register_my_thread function is available])
fi
AC_CHECK_FUNC(GC_allow_register_threads)
if test "$ac_cv_func_GC_allow_register_threads" = yes; then
AC_DEFINE(HAVE_GC_ALLOW_REGISTER_THREADS,1,
[Define if GC_allow_register_threads function is available])
fi
LIBS="-lobjc_gc -ldl"
AC_CHECK_FUNC(class_ivar_set_gcinvisible, gc_ok=yes, gc_ok=no)
if test "$gc_ok" = no; then
AC_MSG_ERROR([Garbage collection was required, but the gc runtime couldn't be found.])
fi
LIBS="$saved_LIBS"
AC_SUBST(OBJC_WITH_GC)
fi
#--------------------------------------------------------------------
# Check for strange network stuff used by gdomap
#--------------------------------------------------------------------

View file

@ -36,10 +36,6 @@
/* Define if Foundation implements KeyValueCoding. */
#define FOUNDATION_HAS_KVC 1
#ifndef GS_WITH_GC
#define GS_WITH_GC 0
#endif
#ifndef HAVE_LIBC_H
#define HAVE_LIBC_H 1
#endif