mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 16:50:42 +00:00
Try to address issue of treating pointer function values as bitmap.
This commit is contained in:
parent
c1833e1130
commit
b0263ae4a8
4 changed files with 26 additions and 27 deletions
|
@ -77,7 +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) \
|
||||||
M->cb.pf.options & (NSPointerFunctionsZeroingWeakMemory | NSPointerFunctionsWeakMemory)
|
memoryType(M->cb.pf.options, NSPointerFunctionsZeroingWeakMemory) | 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))
|
||||||
|
|
|
@ -81,6 +81,11 @@ inline static BOOL memoryType(int options, int flag)
|
||||||
return (options & 0xff) == flag;
|
return (options & 0xff) == flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline static BOOL personalityType(int options, int flag)
|
||||||
|
{
|
||||||
|
return (options & 0xff00) == flag;
|
||||||
|
}
|
||||||
|
|
||||||
/* Declare the concrete pointer functions class as a wrapper around
|
/* Declare the concrete pointer functions class as a wrapper around
|
||||||
* an instance of the PFInfo structure.
|
* an instance of the PFInfo structure.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -191,19 +191,19 @@ relinquishRetainedMemory(const void *item,
|
||||||
* should be used to relinquish contents of a container with these
|
* should be used to relinquish contents of a container with these
|
||||||
* options.
|
* options.
|
||||||
*/
|
*/
|
||||||
if (options & NSPointerFunctionsZeroingWeakMemory)
|
if (memoryType(options, NSPointerFunctionsZeroingWeakMemory))
|
||||||
{
|
{
|
||||||
_x.relinquishFunction = 0;
|
_x.relinquishFunction = 0;
|
||||||
}
|
}
|
||||||
else if (options & NSPointerFunctionsOpaqueMemory)
|
else if (memoryType(options, NSPointerFunctionsOpaqueMemory))
|
||||||
{
|
{
|
||||||
_x.relinquishFunction = 0;
|
_x.relinquishFunction = 0;
|
||||||
}
|
}
|
||||||
else if (options & NSPointerFunctionsMallocMemory)
|
else if (memoryType(options, NSPointerFunctionsMallocMemory))
|
||||||
{
|
{
|
||||||
_x.relinquishFunction = relinquishMallocMemory;
|
_x.relinquishFunction = relinquishMallocMemory;
|
||||||
}
|
}
|
||||||
else if (options & NSPointerFunctionsMachVirtualMemory)
|
else if (memoryType(options, NSPointerFunctionsMachVirtualMemory))
|
||||||
{
|
{
|
||||||
_x.relinquishFunction = relinquishMallocMemory;
|
_x.relinquishFunction = relinquishMallocMemory;
|
||||||
}
|
}
|
||||||
|
@ -214,16 +214,16 @@ relinquishRetainedMemory(const void *item,
|
||||||
|
|
||||||
/* Now we look at the personality options to determine other functions.
|
/* Now we look at the personality options to determine other functions.
|
||||||
*/
|
*/
|
||||||
if (options & NSPointerFunctionsOpaquePersonality)
|
if (personalityType(options, NSPointerFunctionsOpaquePersonality))
|
||||||
{
|
{
|
||||||
_x.acquireFunction = acquireExistingMemory;
|
_x.acquireFunction = acquireExistingMemory;
|
||||||
_x.descriptionFunction = describePointer;
|
_x.descriptionFunction = describePointer;
|
||||||
_x.hashFunction = hashShifted;
|
_x.hashFunction = hashShifted;
|
||||||
_x.isEqualFunction = equalDirect;
|
_x.isEqualFunction = equalDirect;
|
||||||
}
|
}
|
||||||
else if (options & NSPointerFunctionsObjectPointerPersonality)
|
else if (personalityType(options, NSPointerFunctionsObjectPointerPersonality))
|
||||||
{
|
{
|
||||||
if (options & NSPointerFunctionsZeroingWeakMemory)
|
if (memoryType(options, NSPointerFunctionsZeroingWeakMemory))
|
||||||
{
|
{
|
||||||
_x.acquireFunction = acquireExistingMemory;
|
_x.acquireFunction = acquireExistingMemory;
|
||||||
}
|
}
|
||||||
|
@ -235,21 +235,21 @@ relinquishRetainedMemory(const void *item,
|
||||||
_x.hashFunction = hashShifted;
|
_x.hashFunction = hashShifted;
|
||||||
_x.isEqualFunction = equalDirect;
|
_x.isEqualFunction = equalDirect;
|
||||||
}
|
}
|
||||||
else if (options & NSPointerFunctionsCStringPersonality)
|
else if (personalityType(options, NSPointerFunctionsCStringPersonality))
|
||||||
{
|
{
|
||||||
_x.acquireFunction = acquireMallocMemory;
|
_x.acquireFunction = acquireMallocMemory;
|
||||||
_x.descriptionFunction = describeString;
|
_x.descriptionFunction = describeString;
|
||||||
_x.hashFunction = hashString;
|
_x.hashFunction = hashString;
|
||||||
_x.isEqualFunction = equalString;
|
_x.isEqualFunction = equalString;
|
||||||
}
|
}
|
||||||
else if (options & NSPointerFunctionsStructPersonality)
|
else if (personalityType(options, NSPointerFunctionsStructPersonality))
|
||||||
{
|
{
|
||||||
_x.acquireFunction = acquireMallocMemory;
|
_x.acquireFunction = acquireMallocMemory;
|
||||||
_x.descriptionFunction = describePointer;
|
_x.descriptionFunction = describePointer;
|
||||||
_x.hashFunction = hashMemory;
|
_x.hashFunction = hashMemory;
|
||||||
_x.isEqualFunction = equalMemory;
|
_x.isEqualFunction = equalMemory;
|
||||||
}
|
}
|
||||||
else if (options & NSPointerFunctionsIntegerPersonality)
|
else if (personalityType(options, NSPointerFunctionsIntegerPersonality))
|
||||||
{
|
{
|
||||||
_x.acquireFunction = acquireExistingMemory;
|
_x.acquireFunction = acquireExistingMemory;
|
||||||
_x.descriptionFunction = describeInteger;
|
_x.descriptionFunction = describeInteger;
|
||||||
|
@ -258,7 +258,7 @@ relinquishRetainedMemory(const void *item,
|
||||||
}
|
}
|
||||||
else /* objects */
|
else /* objects */
|
||||||
{
|
{
|
||||||
if (options & NSPointerFunctionsZeroingWeakMemory)
|
if (memoryType(options, NSPointerFunctionsZeroingWeakMemory))
|
||||||
{
|
{
|
||||||
_x.acquireFunction = acquireExistingMemory;
|
_x.acquireFunction = acquireExistingMemory;
|
||||||
}
|
}
|
||||||
|
@ -344,16 +344,18 @@ relinquishRetainedMemory(const void *item,
|
||||||
~(NSPointerFunctionsZeroingWeakMemory
|
~(NSPointerFunctionsZeroingWeakMemory
|
||||||
|NSPointerFunctionsOpaqueMemory
|
|NSPointerFunctionsOpaqueMemory
|
||||||
|NSPointerFunctionsMallocMemory
|
|NSPointerFunctionsMallocMemory
|
||||||
|NSPointerFunctionsMachVirtualMemory);
|
|NSPointerFunctionsMachVirtualMemory
|
||||||
|
|NSPointerFunctionsWeakMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setUsesWeakReadAndWriteBarriers: (BOOL)flag
|
- (void) setUsesWeakReadAndWriteBarriers: (BOOL)flag
|
||||||
{
|
{
|
||||||
_x.options |= NSPointerFunctionsZeroingWeakMemory;
|
|
||||||
_x.options &=
|
_x.options &=
|
||||||
~(NSPointerFunctionsOpaqueMemory
|
~(NSPointerFunctionsOpaqueMemory
|
||||||
|NSPointerFunctionsMallocMemory
|
|NSPointerFunctionsMallocMemory
|
||||||
|NSPointerFunctionsMachVirtualMemory);
|
|NSPointerFunctionsMachVirtualMemory
|
||||||
|
|NSPointerFunctionsWeakMemory);
|
||||||
|
_x.options |= NSPointerFunctionsZeroingWeakMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSUInteger (*)(const void *item)) sizeFunction
|
- (NSUInteger (*)(const void *item)) sizeFunction
|
||||||
|
@ -363,20 +365,12 @@ relinquishRetainedMemory(const void *item,
|
||||||
|
|
||||||
- (BOOL) usesStrongWriteBarrier
|
- (BOOL) usesStrongWriteBarrier
|
||||||
{
|
{
|
||||||
if ((_x.options &
|
return memoryType(_x.options, NSPointerFunctionsStrongMemory);
|
||||||
(NSPointerFunctionsZeroingWeakMemory
|
|
||||||
|NSPointerFunctionsOpaqueMemory
|
|
||||||
|NSPointerFunctionsMallocMemory
|
|
||||||
|NSPointerFunctionsMachVirtualMemory)) == NSPointerFunctionsStrongMemory)
|
|
||||||
return YES;
|
|
||||||
return NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) usesWeakReadAndWriteBarriers
|
- (BOOL) usesWeakReadAndWriteBarriers
|
||||||
{
|
{
|
||||||
if (_x.options & NSPointerFunctionsZeroingWeakMemory)
|
return memoryType(_x.options, NSPointerFunctionsZeroingWeakMemory);
|
||||||
return YES;
|
|
||||||
return NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -534,7 +534,7 @@ static Class concreteClass = Nil;
|
||||||
new_gf = new_cap / 2;
|
new_gf = new_cap / 2;
|
||||||
if (_contents == 0)
|
if (_contents == 0)
|
||||||
{
|
{
|
||||||
if (_pf.options & NSPointerFunctionsZeroingWeakMemory)
|
if (memoryType(_pf.options, NSPointerFunctionsZeroingWeakMemory))
|
||||||
{
|
{
|
||||||
ptr = (void**)NSAllocateCollectable(size, 0);
|
ptr = (void**)NSAllocateCollectable(size, 0);
|
||||||
}
|
}
|
||||||
|
@ -545,7 +545,7 @@ static Class concreteClass = Nil;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_pf.options & NSPointerFunctionsZeroingWeakMemory)
|
if (memoryType(_pf.options, NSPointerFunctionsZeroingWeakMemory))
|
||||||
{
|
{
|
||||||
ptr = (void**)NSReallocateCollectable(
|
ptr = (void**)NSReallocateCollectable(
|
||||||
_contents, size, 0);
|
_contents, size, 0);
|
||||||
|
|
Loading…
Reference in a new issue