Revert "Retain count fixes"

This reverts commit 544dcce482.
This commit is contained in:
rfm 2024-11-10 20:13:39 +00:00
parent 6681a3da47
commit c981920679
6 changed files with 21 additions and 111 deletions

View file

@ -87,16 +87,18 @@ typedef GSIMapNode_t *GSIMapNode;
(M->legacy ? M->cb.old.release(M, X.ptr) \
: IS_WEAK(M) ? nil : pointerFunctionsRelinquish(&M->cb.pf, &X.ptr))
#define GSI_MAP_RETAIN_KEY(M, X)\
(M->legacy ? M->cb.old.retain(M, X.ptr) : (IS_WEAK(M) ? nil : X.ptr))
(M->legacy ? M->cb.old.retain(M, X.ptr) \
: IS_WEAK(M) ? nil : pointerFunctionsAssign(\
&M->cb.pf, &X.ptr, pointerFunctionsAcquire(&M->cb.pf, X.ptr)))
#define GSI_MAP_ZEROED(M)\
(M->legacy ? 0 \
: (IS_WEAK(M) ? YES : NO))
#define GSI_MAP_WRITE_KEY(M, addr, x) \
if (M->legacy) \
*(addr) = x;\
else\
pointerFunctionsReplace(&M->cb.pf, (void**)addr, (x).obj);
if (M->legacy) \
*(addr) = x;\
else\
pointerFunctionsAssign(&M->cb.pf, (void**)addr, (x).obj);
#define GSI_MAP_READ_KEY(M,addr) \
(M->legacy ? *(addr) :\
(__typeof__(*addr))pointerFunctionsRead(&M->cb.pf, (void**)addr))

View file

@ -94,12 +94,16 @@ typedef GSIMapNode_t *GSIMapNode;
(M->legacy ? M->cb.old.k.release(M, X.ptr) \
: IS_WEAK_KEY(M) ? nil : pointerFunctionsRelinquish(&M->cb.pf.k, &X.ptr))
#define GSI_MAP_RETAIN_KEY(M, X)\
(M->legacy ? M->cb.old.k.retain(M, X.ptr) : (IS_WEAK_KEY(M) ? nil : X.ptr))
(M->legacy ? M->cb.old.k.retain(M, X.ptr) \
: IS_WEAK_KEY(M) ? nil : pointerFunctionsAssign(&M->cb.pf.k, &X.ptr,\
pointerFunctionsAcquire(&M->cb.pf.k, X.ptr)))
#define GSI_MAP_RELEASE_VAL(M, X)\
(M->legacy ? M->cb.old.v.release(M, X.ptr) \
: IS_WEAK_VALUE(M) ? nil : pointerFunctionsRelinquish(&M->cb.pf.v, &X.ptr))
#define GSI_MAP_RETAIN_VAL(M, X)\
(M->legacy ? M->cb.old.v.retain(M, X.ptr) : (IS_WEAK_VALUE(M) ? nil : &X.ptr))
(M->legacy ? M->cb.old.v.retain(M, X.ptr) \
: IS_WEAK_VALUE(M) ? nil : pointerFunctionsAssign(&M->cb.pf.v, &X.ptr,\
pointerFunctionsAcquire(&M->cb.pf.v, X.ptr)))
/* The GSI_MAP_WRITE_KEY() and GSI_MAP_WRITE_VAL() macros are expectd to
* write without retain (GSI_MAP RETAIN macros are executed separately)
@ -110,12 +114,14 @@ typedef GSIMapNode_t *GSIMapNode;
if (M->legacy) \
*(addr) = x;\
else\
pointerFunctionsReplace(&M->cb.pf.k, (void**)addr, (x).obj);
(IS_WEAK_KEY(M) ? pointerFunctionsAssign(&M->cb.pf.k, (void**)addr,\
(x).obj) : (*(id*)(addr) = (x).obj));
#define GSI_MAP_WRITE_VAL(M, addr, x) \
if (M->legacy) \
*(addr) = x;\
else\
pointerFunctionsReplace(&M->cb.pf.v, (void**)addr, (x).obj);
(IS_WEAK_VALUE(M) ? pointerFunctionsAssign(&M->cb.pf.v, (void**)addr,\
(x).obj) : (*(id*)(addr) = (x).obj));
#define GSI_MAP_READ_KEY(M,addr) \
(M->legacy ? *(addr)\
: (__typeof__(*addr))pointerFunctionsRead(&M->cb.pf.k, (void**)addr))

View file

@ -187,8 +187,6 @@ pointerFunctionsRelinquish(PFInfo *PF, void **itemptr)
(*PF->relinquishFunction)(*itemptr, PF->sizeFunction);
if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
WEAK_WRITE(itemptr, 0);
else if (memoryType(PF->options, NSPointerFunctionsStrongMemory))
STRONG_WRITE(itemptr, 0);
else
*itemptr = 0;
}
@ -205,7 +203,7 @@ pointerFunctionsReplace(PFInfo *PF, void **dst, void *src)
if (PF->relinquishFunction != 0)
(*PF->relinquishFunction)(*dst, PF->sizeFunction);
if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
WEAK_WRITE(dst, src);
WEAK_WRITE(dst, 0);
else
*dst = src;
}