void entryPack(Entry *e, uchar *p, int index) { ulong t32; int flags; p += index * VtEntrySize; U32PUT(p, e->gen); U16PUT(p+4, e->psize); U16PUT(p+6, e->dsize); flags = e->flags | ((e->depth << VtEntryDepthShift) & VtEntryDepthMask); U8PUT(p+8, flags); memset(p+9, 0, 5); U48PUT(p+14, e->size, t32); if(flags & VtEntryLocal){ if(globalToLocal(e->score) == NilBlock) abort(); memset(p+20, 0, 7); U8PUT(p+27, e->archive); U32PUT(p+28, e->snap); U32PUT(p+32, e->tag); memmove(p+36, e->score+16, 4); }else memmove(p+20, e->score, VtScoreSize); }
void vtentrypack(VtEntry *e, uchar *p, int index) { ulong t32; int flags; uchar *op; int depth; int psize, dsize; p += index * VtEntrySize; op = p; depth = e->type&VtTypeDepthMask; flags = (e->flags&~(_VtEntryDir|_VtEntryDepthMask)); flags |= depth << _VtEntryDepthShift; if(e->type - depth == VtDirType) flags |= _VtEntryDir; U32PUT(p, e->gen); p += 4; psize = e->psize; dsize = e->dsize; if(psize >= (1<<16) || dsize >= (1<<16)) { flags |= _VtEntryBig; psize = vttobig(psize); dsize = vttobig(dsize); if(psize < 0 || dsize < 0) sysfatal("invalid entry psize/dsize: %ld/%ld", e->psize, e->dsize); } U16PUT(p, psize); p += 2; U16PUT(p, dsize); p += 2; U8PUT(p, flags); p++; memset(p, 0, 5); p += 5; U48PUT(p, e->size, t32); p += 6; memmove(p, e->score, VtScoreSize); p += VtScoreSize; assert(p-op == VtEntrySize); }