GC was deprecated several releases ago and notinally removed a couple of releases ago ... delete more remnants of the old code.

This commit is contained in:
rfm 2024-07-22 15:14:13 +01:00
parent a1514249f3
commit 52c127c950
15 changed files with 20 additions and 126 deletions

View file

@ -231,40 +231,6 @@ NSZoneStats (NSZone *zone);
void* void*
GSOutOfMemory(NSUInteger size, BOOL retry); GSOutOfMemory(NSUInteger size, BOOL retry);
/**
* Called during +initialize to tell the class that instances created
* in future should have the specified instance variable as a weak
* pointer for garbage collection.<br />
* NB. making a pointer weak does not mean that it is automatically
* zeroed when the object it points to is garbage collected. To get that
* behavior you must asign values to the pointer using the
* GSAssignZeroingWeakPointer() function.<br />
* This function has no effect if the system is
* not built for garbage collection.
*/
GS_EXPORT void
GSMakeWeakPointer(Class theClass, const char *iVarName);
/**
* This function must be used to assign a value to a zeroing weak pointer.<br />
* A zeroing weak pointer is one where, when the garbage collector collects
* the object pointed to, it also clears the weak pointer.<br />
* Assigning zero (nil) will always succeed and has the effect of telling the
* garbage collector that it no longer needs to track the previously assigned
* object. Apart from that case, a source needs to be garbage collectable for
* this function to work, and using a non-garbage collectable value will
* cause the function to return NO.<br />
* If the destination object (the weak pointer watching the source object)
* belongs to a chunk of memory which may be collected before the source
* object is collected, it is important that it is finalised and the
* finalisation code assigns zero to the pointer.<br />
* If garbage collection is not in use, this function performs a simple
* assignment returning YES, unless destination is null in which case it
* returns NO.
*/
GS_EXPORT BOOL
GSAssignZeroingWeakPointer(void **destination, void *source);
#endif #endif
GS_EXPORT NSUInteger GS_EXPORT NSUInteger

View file

@ -490,8 +490,6 @@ GSPrivateSockaddrSetup(NSString *machine, uint16_t port,
+ (void) initialize + (void) initialize
{ {
GSMakeWeakPointer(self, "istream");
GSMakeWeakPointer(self, "ostream");
} }
+ (void) tryInput: (GSSocketInputStream*)i output: (GSSocketOutputStream*)o + (void) tryInput: (GSSocketInputStream*)i output: (GSSocketOutputStream*)o
@ -2002,7 +2000,6 @@ setNonBlocking(SOCKET fd)
+ (void) initialize + (void) initialize
{ {
GSMakeWeakPointer(self, "_sibling");
if (self == [GSSocketInputStream class]) if (self == [GSSocketInputStream class])
{ {
GSObjCAddClassBehavior(self, [GSSocketStream class]); GSObjCAddClassBehavior(self, [GSSocketStream class]);
@ -2497,7 +2494,6 @@ setNonBlocking(SOCKET fd)
+ (void) initialize + (void) initialize
{ {
GSMakeWeakPointer(self, "_sibling");
if (self == [GSSocketOutputStream class]) if (self == [GSSocketOutputStream class])
{ {
GSObjCAddClassBehavior(self, [GSSocketStream class]); GSObjCAddClassBehavior(self, [GSSocketStream class]);
@ -3010,7 +3006,6 @@ setNonBlocking(SOCKET fd)
+ (void) initialize + (void) initialize
{ {
GSMakeWeakPointer(self, "_sibling");
if (self == [GSSocketServerStream class]) if (self == [GSSocketServerStream class])
{ {
GSObjCAddClassBehavior(self, [GSSocketStream class]); GSObjCAddClassBehavior(self, [GSSocketStream class]);

View file

@ -141,7 +141,6 @@ static RunLoopEventType typeForStream(NSStream *aStream)
+ (void) initialize + (void) initialize
{ {
GSMakeWeakPointer(self, "delegate");
} }
- (void) close - (void) close
@ -165,7 +164,7 @@ static RunLoopEventType typeForStream(NSStream *aStream)
{ {
[self close]; [self close];
} }
GSAssignZeroingWeakPointer((void**)&_delegate, (void*)0); _delegate = nil;
} }
- (void) dealloc - (void) dealloc
@ -287,26 +286,11 @@ static RunLoopEventType typeForStream(NSStream *aStream)
|| [self streamStatus] == NSStreamStatusError) || [self streamStatus] == NSStreamStatusError)
{ {
_delegateValid = NO; _delegateValid = NO;
GSAssignZeroingWeakPointer((void**)&_delegate, (void*)0); _delegate = nil;
} }
else else
{ {
if (delegate == nil) _delegate = (nil == delegate) ? self : delegate;
{
_delegate = self;
}
if (delegate == self)
{
if (_delegate != nil && _delegate != self)
{
GSAssignZeroingWeakPointer((void**)&_delegate, (void*)0);
}
_delegate = delegate;
}
else
{
GSAssignZeroingWeakPointer((void**)&_delegate, (void*)delegate);
}
/* We don't want to send any events the the delegate after the /* We don't want to send any events the the delegate after the
* stream has been closed. * stream has been closed.
*/ */
@ -787,7 +771,6 @@ static RunLoopEventType typeForStream(NSStream *aStream)
if (self == [GSInputStream class]) if (self == [GSInputStream class])
{ {
GSObjCAddClassBehavior(self, [GSStream class]); GSObjCAddClassBehavior(self, [GSStream class]);
GSMakeWeakPointer(self, "delegate");
} }
} }
@ -820,7 +803,6 @@ static RunLoopEventType typeForStream(NSStream *aStream)
if (self == [GSOutputStream class]) if (self == [GSOutputStream class])
{ {
GSObjCAddClassBehavior(self, [GSStream class]); GSObjCAddClassBehavior(self, [GSStream class]);
GSMakeWeakPointer(self, "delegate");
} }
} }
@ -1091,7 +1073,6 @@ static RunLoopEventType typeForStream(NSStream *aStream)
+ (void) initialize + (void) initialize
{ {
GSMakeWeakPointer(self, "delegate");
} }
+ (id) serverStreamToAddr: (NSString*)addr port: (NSInteger)port + (id) serverStreamToAddr: (NSString*)addr port: (NSInteger)port

View file

@ -77,8 +77,7 @@ typedef GSIMapNode_t *GSIMapNode;
#define GSI_MAP_TABLE_S instanceSize #define GSI_MAP_TABLE_S instanceSize
#define IS_WEAK(M) \ #define IS_WEAK(M) \
(memoryType(M->cb.pf.options, NSPointerFunctionsZeroingWeakMemory) \ memoryType(M->cb.pf.options, NSPointerFunctionsWeakMemory)
|| memoryType(M->cb.pf.options, NSPointerFunctionsWeakMemory))
#define GSI_MAP_HASH(M, X)\ #define GSI_MAP_HASH(M, X)\
(M->legacy ? M->cb.old.hash(M, X.ptr) \ (M->legacy ? M->cb.old.hash(M, X.ptr) \
: pointerFunctionsHash(&M->cb.pf, X.ptr)) : pointerFunctionsHash(&M->cb.pf, X.ptr))

View file

@ -82,11 +82,9 @@ typedef GSIMapNode_t *GSIMapNode;
#define GSI_MAP_KTYPES GSUNION_PTR | GSUNION_OBJ #define GSI_MAP_KTYPES GSUNION_PTR | GSUNION_OBJ
#define GSI_MAP_VTYPES GSUNION_PTR | GSUNION_OBJ #define GSI_MAP_VTYPES GSUNION_PTR | GSUNION_OBJ
#define IS_WEAK_KEY(M) \ #define IS_WEAK_KEY(M) \
(memoryType(M->cb.pf.k.options, NSPointerFunctionsZeroingWeakMemory) \ memoryType(M->cb.pf.k.options, NSPointerFunctionsWeakMemory)
|| memoryType(M->cb.pf.k.options, NSPointerFunctionsWeakMemory))
#define IS_WEAK_VALUE(M) \ #define IS_WEAK_VALUE(M) \
(memoryType(M->cb.pf.v.options, NSPointerFunctionsZeroingWeakMemory) \ memoryType(M->cb.pf.v.options, NSPointerFunctionsWeakMemory)
|| memoryType(M->cb.pf.v.options, NSPointerFunctionsWeakMemory))
#define GSI_MAP_HASH(M, X)\ #define GSI_MAP_HASH(M, X)\
(M->legacy ? M->cb.old.k.hash(M, X.ptr) \ (M->legacy ? M->cb.old.k.hash(M, X.ptr) \
: pointerFunctionsHash(&M->cb.pf.k, X.ptr)) : pointerFunctionsHash(&M->cb.pf.k, X.ptr))

View file

@ -31,10 +31,8 @@
#if defined(OBJC_CAP_ARC) #if defined(OBJC_CAP_ARC)
# include <objc/objc-arc.h> # include <objc/objc-arc.h>
# define ARC_WEAK_READ(x) objc_loadWeak((id*)x) # define WEAK_READ(x) objc_loadWeak((id*)x)
# define ARC_WEAK_WRITE(addr, x) objc_storeWeak((id*)addr, (id)x) # define WEAK_WRITE(addr, x) objc_storeWeak((id*)addr, (id)x)
# define WEAK_READ(x) (*x)
# define WEAK_WRITE(addr, x) (*(addr) = x)
# define STRONG_WRITE(addr, x) objc_storeStrong((id*)addr, (id)x) # define STRONG_WRITE(addr, x) objc_storeStrong((id*)addr, (id)x)
# define STRONG_ACQUIRE(x) objc_retain(x) # define STRONG_ACQUIRE(x) objc_retain(x)
#else #else
@ -43,12 +41,6 @@
# define STRONG_WRITE(addr, x) ASSIGN(*((id*)addr), ((id)x)) # define STRONG_WRITE(addr, x) ASSIGN(*((id*)addr), ((id)x))
# define STRONG_ACQUIRE(x) RETAIN(((id)x)) # define STRONG_ACQUIRE(x) RETAIN(((id)x))
#endif #endif
#ifndef ARC_WEAK_WRITE
# define ARC_WEAK_WRITE(addr, x) WEAK_WRITE(addr, x)
#endif
#ifndef ARC_WEAK_READ
# define ARC_WEAK_READ(x) WEAK_READ(x)
#endif
/* Declare a structure type to copy pointer functions information /* Declare a structure type to copy pointer functions information
@ -106,10 +98,6 @@ inline static BOOL personalityType(int options, int flag)
static inline void *pointerFunctionsRead(PFInfo *PF, void **addr) static inline void *pointerFunctionsRead(PFInfo *PF, void **addr)
{ {
if (memoryType(PF->options, NSPointerFunctionsWeakMemory)) if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
{
return ARC_WEAK_READ((id*)addr);
}
if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
{ {
return WEAK_READ((id*)addr); return WEAK_READ((id*)addr);
} }
@ -122,10 +110,6 @@ static inline void *pointerFunctionsRead(PFInfo *PF, void **addr)
static inline void pointerFunctionsAssign(PFInfo *PF, void **addr, void *value) static inline void pointerFunctionsAssign(PFInfo *PF, void **addr, void *value)
{ {
if (memoryType(PF->options, NSPointerFunctionsWeakMemory)) if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
{
ARC_WEAK_WRITE(addr, value);
}
else if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
{ {
WEAK_WRITE(addr, value); WEAK_WRITE(addr, value);
} }
@ -203,9 +187,7 @@ pointerFunctionsRelinquish(PFInfo *PF, void **itemptr)
if (PF->relinquishFunction != 0) if (PF->relinquishFunction != 0)
(*PF->relinquishFunction)(*itemptr, PF->sizeFunction); (*PF->relinquishFunction)(*itemptr, PF->sizeFunction);
if (memoryType(PF->options, NSPointerFunctionsWeakMemory)) if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
ARC_WEAK_WRITE(itemptr, 0); WEAK_WRITE(itemptr, 0);
else if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
WEAK_WRITE(itemptr, (void*)0);
else else
*itemptr = 0; *itemptr = 0;
} }
@ -222,9 +204,7 @@ pointerFunctionsReplace(PFInfo *PF, void **dst, void *src)
if (PF->relinquishFunction != 0) if (PF->relinquishFunction != 0)
(*PF->relinquishFunction)(*dst, PF->sizeFunction); (*PF->relinquishFunction)(*dst, PF->sizeFunction);
if (memoryType(PF->options, NSPointerFunctionsWeakMemory)) if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
ARC_WEAK_WRITE(dst, 0); WEAK_WRITE(dst, 0);
else if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
WEAK_WRITE(dst, (void*)0);
else else
*dst = src; *dst = src;
} }

View file

@ -628,7 +628,6 @@ static NSLock *cached_proxies_gate = nil;
{ {
NSNotificationCenter *nc; NSNotificationCenter *nc;
GSMakeWeakPointer(self, "delegate");
connectionClass = self; connectionClass = self;
dateClass = [NSDate class]; dateClass = [NSDate class];
distantObjectClass = [NSDistantObject class]; distantObjectClass = [NSDistantObject class];
@ -2846,8 +2845,10 @@ static NSLock *cached_proxies_gate = nil;
[tmp release]; [tmp release];
tmp = encoder; tmp = encoder;
encoder = nil; encoder = nil;
NSDebugMLLog(@"RMC", @"RMC %d replying with %s and %u out parameters", NSDebugMLLog(@"RMC", @"RMC %d replying with %s"
seq, (YES == is_void ? "void result" : "result"), out_parameters); @" and %u/%u in/out parameters",
seq, (YES == is_void ? "void result" : "result"),
in_parameters, out_parameters);
[self _sendOutRmc: tmp type: METHOD_REPLY sequence: seq]; [self _sendOutRmc: tmp type: METHOD_REPLY sequence: seq];
} }

View file

@ -73,7 +73,7 @@ static Class concreteClass = 0;
+ (id) hashTableWithWeakObjects + (id) hashTableWithWeakObjects
{ {
return [self hashTableWithOptions: return [self hashTableWithOptions:
NSPointerFunctionsObjectPersonality | NSPointerFunctionsZeroingWeakMemory]; NSPointerFunctionsObjectPersonality | NSPointerFunctionsWeakMemory];
} }
+ (id) weakObjectsHashTable + (id) weakObjectsHashTable

View file

@ -1162,8 +1162,7 @@ cifframe_callback(ffi_cif *cif, void *retp, void **args, void *user)
if (observation == nil) if (observation == nil)
{ {
observation = [GSKVOObservation new]; observation = [GSKVOObservation new];
GSAssignZeroingWeakPointer((void**)&observation->observer, observation->observer = anObserver;
(void*)anObserver);
observation->context = aContext; observation->context = aContext;
observation->options = options; observation->options = options;
[pathInfo->observations addObject: observation]; [pathInfo->observations addObject: observation];

View file

@ -486,8 +486,6 @@ static NSDictionary *makeReference(unsigned ref)
+ (void) initialize + (void) initialize
{ {
GSMakeWeakPointer(self, "delegate");
if (globalClassMap == 0) if (globalClassMap == 0)
{ {
globalClassMap = globalClassMap =

View file

@ -298,8 +298,6 @@ static NSMapTable *globalClassMap = 0;
+ (void) initialize + (void) initialize
{ {
GSMakeWeakPointer(self, "delegate");
if (globalClassMap == 0) if (globalClassMap == 0)
{ {
globalClassMap = globalClassMap =

View file

@ -80,22 +80,22 @@ static Class concreteClass = 0;
{ {
return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality
valueOptions: NSPointerFunctionsObjectPersonality valueOptions: NSPointerFunctionsObjectPersonality
| NSPointerFunctionsZeroingWeakMemory]; | NSPointerFunctionsWeakMemory];
} }
+ (id) mapTableWithWeakToStrongObjects + (id) mapTableWithWeakToStrongObjects
{ {
return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality
| NSPointerFunctionsZeroingWeakMemory | NSPointerFunctionsWeakMemory
valueOptions: NSPointerFunctionsObjectPersonality]; valueOptions: NSPointerFunctionsObjectPersonality];
} }
+ (id) mapTableWithWeakToWeakObjects + (id) mapTableWithWeakToWeakObjects
{ {
return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality
| NSPointerFunctionsZeroingWeakMemory | NSPointerFunctionsWeakMemory
valueOptions: NSPointerFunctionsObjectPersonality valueOptions: NSPointerFunctionsObjectPersonality
| NSPointerFunctionsZeroingWeakMemory]; | NSPointerFunctionsWeakMemory];
} }
+ (id) strongToStrongObjectsMapTable + (id) strongToStrongObjectsMapTable

View file

@ -70,8 +70,6 @@ static Class NSPort_concrete_class;
{ {
NSUserDefaults *defs; NSUserDefaults *defs;
GSMakeWeakPointer(self, "delegate");
NSPort_abstract_class = self; NSPort_abstract_class = self;
NSPort_concrete_class = [NSMessagePort class]; NSPort_concrete_class = [NSMessagePort class];

View file

@ -1861,8 +1861,6 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes);
+ (void) initialize + (void) initialize
{ {
GSMakeWeakPointer(self, "_delegate");
GSMakeWeakPointer(self, "_owner");
} }
- (void) dealloc - (void) dealloc

View file

@ -1754,23 +1754,6 @@ GSAtomicMallocZone (void)
return &default_zone; return &default_zone;
} }
GS_DECLARE void
GSMakeWeakPointer(Class theClass, const char *iVarName)
{
return;
}
GS_DECLARE BOOL
GSAssignZeroingWeakPointer(void **destination, void *source)
{
if (destination == 0)
{
return NO;
}
*destination = source;
return YES;
}
GS_DECLARE void* GS_DECLARE void*
NSZoneMalloc (NSZone *zone, NSUInteger size) NSZoneMalloc (NSZone *zone, NSUInteger size)
{ {