Commit 6ce5b1ef authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add generic uint{32,64} OA_ accessor functions, use for VXID.

parent dd7083a2
......@@ -1068,6 +1068,10 @@ int ObjCopyAttr(struct objcore *ocd, struct objcore *ocs, struct dstat *ds,
int ObjSetDouble(struct objcore *, struct dstat *, enum obj_attr, double);
int ObjGetDouble(struct objcore *, struct dstat *, enum obj_attr, double *);
int ObjSetU32(struct objcore *, struct dstat *, enum obj_attr, uint32_t);
int ObjGetU32(struct objcore *, struct dstat *, enum obj_attr, uint32_t *);
int ObjSetU64(struct objcore *, struct dstat *, enum obj_attr, uint64_t);
int ObjGetU64(struct objcore *, struct dstat *, enum obj_attr, uint64_t *);
/* cache_panic.c */
void PAN_Init(void);
......
......@@ -102,7 +102,6 @@ vbf_beresp2obj(struct busyobj *bo)
uint16_t nhttp;
struct object *obj;
struct http *hp, *hp2;
void *vp;
l = 0;
......@@ -152,8 +151,7 @@ vbf_beresp2obj(struct busyobj *bo)
VSB_delete(vary);
}
vp = ObjSetattr(bo->fetch_objcore, bo->stats, OA_VXID, 4);
vbe32enc(vp, bo->vsl->wid);
AZ(ObjSetU32(bo->fetch_objcore, bo->stats, OA_VXID, bo->vsl->wid));
WS_Assert(bo->ws_o);
/* Filter into object */
......
......@@ -297,13 +297,10 @@ ObjCopyAttr(struct objcore *ocd, struct objcore *ocs, struct dstat *ds,
unsigned
ObjGetXID(struct objcore *oc, struct dstat *ds)
{
ssize_t l;
void *p;
uint32_t u;
p = ObjGetattr(oc, ds, OA_VXID, &l);
AN(p);
assert(l == 4);
return (vbe32dec(p));
AZ(ObjGetU32(oc, ds, OA_VXID, &u));
return (u);
}
/*--------------------------------------------------------------------
......@@ -347,3 +344,58 @@ ObjGetDouble(struct objcore *oc, struct dstat *ds, enum obj_attr a, double *d)
}
return (0);
}
/*--------------------------------------------------------------------
*/
int
ObjSetU64(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint64_t t)
{
void *vp;
vp = ObjSetattr(oc, ds, a, sizeof t);
if (vp == NULL)
return (-1);
vbe64enc(vp, t);
return (0);
}
int
ObjGetU64(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint64_t *d)
{
void *vp;
ssize_t l;
vp = ObjGetattr(oc, ds, a, &l);
if (vp == NULL || l != sizeof *d)
return (-1);
if (d != NULL)
*d = vbe64dec(vp);
return (0);
}
int
ObjSetU32(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint32_t t)
{
void *vp;
vp = ObjSetattr(oc, ds, a, sizeof t);
if (vp == NULL)
return (-1);
vbe32enc(vp, t);
return (0);
}
int
ObjGetU32(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint32_t *d)
{
void *vp;
ssize_t l;
vp = ObjGetattr(oc, ds, a, &l);
if (vp == NULL || l != sizeof *d)
return (-1);
if (d != NULL)
*d = vbe32dec(vp);
return (0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment