Skip to content

Commit

Permalink
kernel: make SET_PTR_BAG internal for GASMAN and Julia GC
Browse files Browse the repository at this point in the history
For Boehm / HPC-GAP, it is still needed in a few places
  • Loading branch information
fingolfin committed Jul 4, 2022
1 parent 968c0a4 commit 680ef33
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/gasman.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ static inline Bag *DATA(BagHeader *bag)
return (Bag *)(bag + 1);
}

static inline void SET_PTR_BAG(Bag bag, Bag *val)
{
GAP_ASSERT(bag != 0);
*(Bag**)bag = val;
}

/****************************************************************************
**
Expand Down
2 changes: 2 additions & 0 deletions src/gasman.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,13 @@ EXPORT_INLINE const Bag *CONST_PTR_BAG(Bag bag)
return *(const Bag * const *)bag;
}

#if defined(USE_BOEHM_GC)
EXPORT_INLINE void SET_PTR_BAG(Bag bag, Bag *val)
{
GAP_ASSERT(bag != 0);
*(Bag**)bag = val;
}
#endif


/****************************************************************************
Expand Down
5 changes: 5 additions & 0 deletions src/julia_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ static inline Bag * DATA(BagHeader * bag)
return (Bag *)(((char *)bag) + sizeof(BagHeader));
}

static inline void SET_PTR_BAG(Bag bag, Bag *val)
{
GAP_ASSERT(bag != 0);
*(Bag**)bag = val;
}

static TNumExtraMarkFuncBags ExtraMarkFuncBags;

Expand Down
4 changes: 1 addition & 3 deletions src/weakptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,14 @@ static inline void GROW_WPOBJ(Obj wp, UInt need)
if (plen > INT_INTOBJ_MAX)
plen = INT_INTOBJ_MAX;

#ifdef USE_BOEHM_GC
#if defined(USE_BOEHM_GC) && defined(HPCGAP)
Obj copy = NewBag(T_WPOBJ, (plen+1) * sizeof(Obj));
STORE_LEN_WPOBJ(copy, STORED_LEN_WPOBJ(wp));

UInt i;
for (i = 1; i <= STORED_LEN_WPOBJ(wp); i++) {
volatile Obj tmp = ELM_WPOBJ(wp, i);
#ifdef HPCGAP
MEMBAR_READ();
#endif
if (IS_BAG_REF(tmp) && ELM_WPOBJ(wp, i)) {
FORGET_WP(wp, i);
REGISTER_WP(copy, i, tmp);
Expand Down

0 comments on commit 680ef33

Please sign in to comment.