File 3164-erts-Remove-benign-BIN_FLAG_DRV-for-normal-binaries.patch of Package erlang

From f1a295f71166b81bc8eb94355d09364798a5258c Mon Sep 17 00:00:00 2001
From: Sverker Eriksson <sverker@erlang.org>
Date: Tue, 24 Aug 2021 19:13:00 +0200
Subject: [PATCH 4/4] erts: Remove benign BIN_FLAG_DRV for normal binaries

Also remove CHICKEN_PAD from normal (re)allocated binaries.

16d23f7ea95 made all binaries set BIN_FLAG_DRV by mistake.

However, the BIN_FLAG_DRV has no practical runtime effect
as all binaries use binary_alloc anyway. Can be useful however
in troubleshooting to distinguish driver allocated binaries.
---
 erts/emulator/beam/erl_binary.h | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/erts/emulator/beam/erl_binary.h b/erts/emulator/beam/erl_binary.h
index ae5c07ee4d..bd3a0632d2 100644
--- a/erts/emulator/beam/erl_binary.h
+++ b/erts/emulator/beam/erl_binary.h
@@ -379,7 +379,7 @@ erts_bin_nrml_alloc_fnf(Uint size)
 
     if (!IS_BINARY_SIZE_OK(size))
         return NULL;
-    bsize = ERTS_SIZEOF_Binary(size) + CHICKEN_PAD;
+    bsize = ERTS_SIZEOF_Binary(size);
 
     res = erts_alloc_fnf(ERTS_ALC_T_DRV_BINARY, bsize);
     ERTS_CHK_BIN_ALIGNMENT(res);
@@ -430,7 +430,7 @@ erts_bin_nrml_alloc_fnf(Uint size)
 ERTS_GLB_INLINE Binary *
 erts_bin_nrml_alloc(Uint size)
 {
-    Binary *res = erts_bin_drv_alloc_fnf(size);
+    Binary *res = erts_bin_nrml_alloc_fnf(size);
 
     if (res) {
         return res;
@@ -446,13 +446,18 @@ erts_bin_realloc_fnf(Binary *bp, Uint size)
     Binary *nbp;
     Uint bsize;
     
-    type = (bp->intern.flags & BIN_FLAG_DRV) ? ERTS_ALC_T_DRV_BINARY
-                                             : ERTS_ALC_T_BINARY;
     ASSERT((bp->intern.flags & BIN_FLAG_MAGIC) == 0);
     if (!IS_BINARY_SIZE_OK(size))
         return NULL;
+    bsize = ERTS_SIZEOF_Binary(size);
 
-    bsize = ERTS_SIZEOF_Binary(size) + CHICKEN_PAD;
+    if (bp->intern.flags & BIN_FLAG_DRV) {
+        type = ERTS_ALC_T_DRV_BINARY;
+        bsize += CHICKEN_PAD;
+    }
+    else {
+        type = ERTS_ALC_T_BINARY;
+    }
 
     nbp = erts_realloc_fnf(type, (void *) bp, bsize);
     ERTS_CHK_BIN_ALIGNMENT(nbp);
-- 
2.31.1

openSUSE Build Service is sponsored by