Dear Hans, dear Nils,
Zitat von Nils Bruin <
bruin...@gmail.com>:
> Do these need the same treatment?
My impression is that the sizeW member needs some care. It is of
course used in omalloc/, but also in kernel, namely:
1)
./kernel/kutil.cc: omCheckBinAddrSize(T->max,
(tailRing->PolyBin->sizeW)*SIZEOF_LONG);
./kernel/pDebug.cc: pPolyAssumeReturnMsg(omTestBinAddrSize(p,
(r->PolyBin->sizeW)*SIZEOF_LONG, level+1)
./kernel/pDebug.cc: pPolyAssumeReturnMsg(omTestBinAddrSize(p,
(r->PolyBin->sizeW)*SIZEOF_LONG, 1)
=> not critical, omCheckBinAddrSize and omTestBinAddrSize should
simply confirm that there is no error.
2)
./kernel/pInline1.h: pAssume1(bin != NULL && r->PolyBin->sizeW ==
bin->sizeW);
./kernel/pInline1.h: pAssume1(bin->sizeW == r->PolyBin->sizeW);
./kernel/pShallowCopyDelete.cc: assume(d_bin == d_r->PolyBin ||
d_bin->sizeW == d_r->PolyBin->sizeW);
./kernel/pInline2.h: pAssume2(bin != NULL && r->PolyBin->sizeW ==
bin->sizeW);
./kernel/pInline2.h: pAssume2(r->PolyBin->sizeW == bin->sizeW);
=> simple comparisons - one could make them hold true by defining
sizeW constant.
3)
./kernel/pDebug.cc:
omSizeWOfAddr(p)==r->PolyBin->sizeW) ||
./kernel/pDebug.cc: pPolyAssumeReturn(omIsBinPageAddr(p) &&
omSizeWOfAddr(p)==r->PolyBin->sizeW,p,r);
=> related with 2: if one keeps sizeW constant, then omSizeWOfAddr
should return the same constant.
4)
./kernel/tgb.cc: memmove (np, p, b->sizeW * sizeof (long));
=> may seem critical. Here, a chunk of memory is moved, and thus the
size really matters. Or does it? This line occurs as follows:
#ifdef HEAD_BIN
static inline poly p_MoveHead (poly p, omBin b)
{
poly np;
omTypeAllocBin (poly, np, b);
memmove (np, p, b->sizeW * sizeof (long));
omFreeBinAddr (p);
return np;
}
#endif
But fortunately, we have
> grep "define HEAD_BIN" -R .
./kernel/tgb_internal.h://#define HEAD_BIN
In other words, the definition of HEAD_BIN is commented out!
----------------
My conclusion:
It would make sense to have omBin->sizeW available (for the reason
expressed by Nils), and I think one could make sure "->sizeW" always
is, say, 1.
Best regards,