Skip to content

Commit

Permalink
Who said they wanted to keep 32bit alive as an option? 🤔
Browse files Browse the repository at this point in the history
  • Loading branch information
nigoroll committed Oct 21, 2024
1 parent 189d807 commit 058edd0
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions bin/varnishd/storage/storage_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,34 @@ struct sml_hdl {
uint64_t avail, returned;
};

static inline uint64_t
st2lease(const struct storage *st)
{
uint64_t r = (uintptr_t)st;

if (sizeof(void *) < 8)
r <<= 1;

return (r);
}

static inline struct storage *
lease2st(uint64_t l)
{

if (sizeof(void *) < 8)
l >>= 1;

return ((void *)l);
}

static inline void
sml_ai_vaiov_fill(struct vaiov *vaiov, struct storage *st)
{
INIT_OBJ(vaiov, VAIOV_MAGIC);
vaiov->iov.iov_base = st->ptr;
vaiov->iov.iov_len = st->len;
vaiov->lease = (uintptr_t)st;
vaiov->lease = st2lease(st);
VAI_ASSERT_LEASE(vaiov->lease);
}

Expand Down Expand Up @@ -460,7 +481,7 @@ sml_ai_lease_boc(struct worker *wrk, vai_hdl vhdl, struct vaiov *vaiov, int vaio
VSLb(wrk->vsl, SLT_Debug, "off %zu + l %zu == space st %p next st %p stvprv %p",
hdl->st_off, l, hdl->st, next, hdl->boc->stevedore_priv);
#endif
vaiov->lease = (uintptr_t)hdl->st;
vaiov->lease = st2lease(hdl->st);
hdl->st_off = 0;
hdl->st = next;
}
Expand Down Expand Up @@ -499,7 +520,7 @@ sml_ai_return(struct worker *wrk, vai_hdl vhdl, uint64_t *leases, int leasecnt)
for (p = leases, end = leases + leasecnt; p < end; p++) {
if (*p == sml_ai_lease_frag)
continue;
CAST_OBJ_NOTNULL(st, (void *)*p, STORAGE_MAGIC);
CAST_OBJ_NOTNULL(st, lease2st(*p), STORAGE_MAGIC);
VTAILQ_REMOVE(&hdl->obj->list, st, list);
if (st == hdl->boc->stevedore_priv)
hdl->boc->stevedore_priv = trim_once;
Expand All @@ -509,7 +530,7 @@ sml_ai_return(struct worker *wrk, vai_hdl vhdl, uint64_t *leases, int leasecnt)
for (p = leases; p < end; p++) {
if (*p == sml_ai_lease_frag)
continue;
CAST_OBJ_NOTNULL(st, (void *)*p, STORAGE_MAGIC);
CAST_OBJ_NOTNULL(st, lease2st(*p), STORAGE_MAGIC);
sml_stv_free(hdl->stv, st);
}
}
Expand Down

0 comments on commit 058edd0

Please sign in to comment.