[master] dcabe3497 Who said they wanted to keep 32bit alive as an option? 🤔

Nils Goroll nils.goroll at uplex.de
Fri Jul 4 17:04:04 UTC 2025


commit dcabe34978c974ac715baf1ec231e685cf57a48d
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Sat Oct 12 23:45:49 2024 +0200

    Who said they wanted to keep 32bit alive as an option? ��

diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c
index ce185fd1b..cf10dd696 100644
--- a/bin/varnishd/storage/storage_simple.c
+++ b/bin/varnishd/storage/storage_simple.c
@@ -329,12 +329,33 @@ struct sml_hdl {
 	struct storage		*last;	// to resume, held back by _return()
 };
 
+static inline uint64_t
+st2lease(const struct storage *st)
+{
+	uint64_t r = (uintptr_t)st;
+
+	if (sizeof(void *) < 8) //lint !e506 !e774
+		r <<= 1;
+
+	return (r);
+}
+
+static inline struct storage *
+lease2st(uint64_t l)
+{
+
+	if (sizeof(void *) < 8) //lint !e506 !e774
+		l >>= 1;
+
+	return ((void *)l);
+}
+
 static inline void
 sml_ai_viov_fill(struct viov *viov, struct storage *st)
 {
 	viov->iov.iov_base = st->ptr;
 	viov->iov.iov_len = st->len;
-	viov->lease = (uintptr_t)st;
+	viov->lease = st2lease(st);
 	VAI_ASSERT_LEASE(viov->lease);
 }
 
@@ -453,7 +474,7 @@ sml_ai_lease_boc(struct worker *wrk, vai_hdl vhdl, struct vscarab *scarab)
 			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
-			viov->lease = (uintptr_t)hdl->st;
+			viov->lease = st2lease(hdl->st);
 			hdl->st_off = 0;
 			hdl->st = next;
 		}
@@ -497,7 +518,7 @@ sml_ai_return(struct worker *wrk, vai_hdl vhdl, struct vscaret *scaret)
 	VSCARET_FOREACH(p, scaret) {
 		if (*p == VAI_LEASE_NORET)
 			continue;
-		CAST_OBJ_NOTNULL(st, (void *)*p, STORAGE_MAGIC);
+		CAST_OBJ_NOTNULL(st, lease2st(*p), STORAGE_MAGIC);
 		if (st == hdl->last)
 			continue;
 		VSCARET_ADD(todo, *p);
@@ -506,7 +527,7 @@ sml_ai_return(struct worker *wrk, vai_hdl vhdl, struct vscaret *scaret)
 
 	Lck_Lock(&hdl->boc->mtx);
 	VSCARET_FOREACH(p, todo) {
-		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;
@@ -514,7 +535,7 @@ sml_ai_return(struct worker *wrk, vai_hdl vhdl, struct vscaret *scaret)
 	Lck_Unlock(&hdl->boc->mtx);
 
 	VSCARET_FOREACH(p, todo) {
-		CAST_OBJ_NOTNULL(st, (void *)*p, STORAGE_MAGIC);
+		CAST_OBJ_NOTNULL(st, lease2st(*p), STORAGE_MAGIC);
 		sml_stv_free(hdl->stv, st);
 	}
 }


More information about the varnish-commit mailing list