casaroli commented on code in PR #21491:
URL: https://github.com/apache/nuttx/pull/21491#discussion_r4535182165


##########
include/nuttx/lib/math32.h:
##########
@@ -195,160 +203,186 @@ extern "C"
 
 /* Default C implementation for umul64_const()
  *
- * Prototype: uint64_t umul64_const(uint64_t retval, uint64_t m,
- *                                  uint64_t n, bool bias);
- * Semantic:  retval = ((bias ? m : 0) + m * n) >> 64
+ * Prototype: uint64_t umul64_const(uint64_t m, uint64_t n, int bias);
+ * Semantic:  return ((bias ? m : 0) + m * n) >> 64
  *
  * The product is a 128-bit value, scaled down to 64 bits.
  * Assuming constant propagation to optimize away unused conditional code.
  * Architectures may provide their own optimized assembly implementation.
  */
 
-#  ifdef up_umul64_const
-#    define umul64_const(res, m, n, bias) \
-      (res) = up_umul64_const(m, n, bias)
-#  else
-#    define umul64_const(res, m, n, bias) \
-      do \
-        { \
-          uint32_t __m_lo = (m) & 0xffffffff; \
-          uint32_t __m_hi = (m) >> 32; \
-          uint32_t __n_lo = (n) & 0xffffffff; \
-          uint32_t __n_hi = (n) >> 32; \
-          uint32_t __res_lo; \
-          uint32_t __res_hi; \
-          uint32_t __tmp; \
-          \
-          if (!(bias)) \
-            { \
-              (res) = ((uint64_t)__m_lo * __n_lo) >> 32; \
-            } \
-          else if (!((m) & ((1ULL << 63) | (1ULL << 31)))) \
-            { \
-              (res) = ((m) + (uint64_t)__m_lo * __n_lo) >> 32; \
-            } \
-          else \
-            { \
-              (res) = (m) + (uint64_t)__m_lo * __n_lo; \
-              __res_lo = (res) >> 32; \
-              __res_hi = (__res_lo < __m_hi); \
-              (res) = __res_lo | ((uint64_t)__res_hi << 32); \
-            } \
-          \
-          if (!((m) & ((1ULL << 63) | (1ULL << 31)))) \
-            { \
-              (res) += (uint64_t)__m_lo * __n_hi; \
-              (res) += (uint64_t)__m_hi * __n_lo; \
-              (res) >>= 32; \
-            } \
-          else \
-            { \
-              (res) += (uint64_t)__m_lo * __n_hi; \
-              __tmp = (res) >> 32; \
-              (res) += (uint64_t)__m_hi * __n_lo; \
-              __res_lo = (res) >> 32; \
-              __res_hi = (__res_lo < __tmp); \
-              (res) = __res_lo | ((uint64_t)__res_hi << 32); \
-            } \
-          \
-          (res) += (uint64_t)__m_hi * __n_hi; \
-        } \
-      while (0)
-#  endif
+/* Due to compilation issues, use inline functions instead of macros. */
 
-#  define div64_const32(n, b) \
-    do \
-      { \
-        uint64_t ___res; \
-        uint64_t ___x; \
-        uint64_t ___t; \
-        uint64_t ___m; \
-        uint64_t ___n = (n); \
-        uint32_t ___p; \
-        uint32_t ___bias; \
-        uint32_t ___b = (b); \
-        ___p = 1 << LOG2_FLOOR(___b); \
-        ___m = (~0ULL / ___b) * ___p; \
-        ___m += (((~0ULL % ___b + 1) * ___p) + ___b - 1) / ___b; \
-        ___x = ~0ULL / ___b * ___b - 1; \
-        ___res = ((___m & 0xffffffff) * (___x & 0xffffffff)) >> 32; \
-        ___t = ___res += (___m & 0xffffffff) * (___x >> 32); \
-        ___res += (___x & 0xffffffff) * (___m >> 32); \
-        ___t = (___res < ___t) ? (1ULL << 32) : 0; \
-        ___res = (___res >> 32) + ___t; \
-        ___res += (___m >> 32) * (___x >> 32); \
-        ___res /= ___p; \
-        if (~0ULL % (___b / (___b & -___b)) == 0) \
-          { \
-            ___n /= (___b & -___b); \
-            ___m = ~0ULL / (___b / (___b & -___b)); \
-            ___p = 1; \
-            ___bias = 1; \
-          } \
-        else if (___res != ___x / ___b) \
-          { \
-            ___bias = 1; \
-            ___m = (~0ULL / ___b) * ___p; \
-            ___m += ((~0ULL % ___b + 1) * ___p) / ___b; \
-          } \
-        else \
-          { \
-            uint32_t ___bits = -(___m & -___m); \
-            ___bits |= ___m >> 32; \
-            ___bits = (~___bits) << 1; \
-            if (!___bits) \
-              { \
-                ___p /= (___m & -___m); \
-                ___m /= (___m & -___m); \
-              } \
-            else \
-              { \
-                ___p >>= LOG2_FLOOR(___bits); \
-                ___m >>= LOG2_FLOOR(___bits); \
-              } \
-            ___bias = 0; \
-          } \
-        umul64_const(___res, ___m, ___n, ___bias); \
-        \
-        ___res /= ___p; \
-        (n) = ___res; \
-      } \
-    while (0)
-
-#if defined(CONFIG_HAVE_EXPRESSION_STATEMENT)
-#  define div64_const(n, base) \
-    ({ \
-      uint64_t __n = (n); \
-      uint32_t __base = (base); \
-      if (IS_POWER_OF_2(__base)) \
-        { \
-          (__n) >>= LOG2_FLOOR(__base); \
-        } \
-      else if (UINTPTR_MAX == UINT32_MAX) \
-        { \
-          div64_const32(__n, __base); \
-        } \
-      else \
-        { \
-          __n /= __base; \
-        } \
-        __n; \
-      })
-
-#  define div_const(n, base) \
-    ((sizeof(typeof(n)) == sizeof(uint64_t)) ? div64_const(n, base) : ((n) / 
(base)))
-#  define div_const_roundup(n, base) \
-    ((sizeof(typeof(n)) == sizeof(uint64_t)) ? div64_const((n) + (base) - 1, 
base) : \
-     (((n) + (base) - 1) / (base)))
-#  define div_const_roundnearest(n, base) \
-    ((sizeof(typeof(n)) == sizeof(uint64_t)) ? div64_const((n) + ((base) / 2), 
base) : \
-     (((n) + ((base) / 2)) / (base)))
+#ifdef up_umul64_const
+#  define umul64_const(m, n, bias) up_umul64_const(m, n, bias)
 #else
-#  define div_const(n, base) ((n) / (base))
-#  define div_const_roundup(n, base) (((n) + (base) - 1) / (base))
-#  define div_const_roundnearest(n, base) (((n) + ((base) / 2)) / (base))
+static inline_function uint64_t umul64_const(uint64_t m, uint64_t n,
+                                             int bias)
+{
+  uint32_t m_lo = (m) & 0xffffffff;
+  uint32_t m_hi = (m) >> 32;
+  uint32_t n_lo = (n) & 0xffffffff;
+  uint32_t n_hi = (n) >> 32;
+  uint32_t res_lo;
+  uint32_t res_hi;
+  uint32_t tmp;
+  uint64_t res;
+
+  if (!(bias))
+    {
+      res = ((uint64_t)m_lo * n_lo) >> 32;
+    }
+  else if (!((m) & ((1ULL << 63) | (1ULL << 31))))
+    {
+      res = ((m) + (uint64_t)m_lo * n_lo) >> 32;
+    }
+  else
+    {
+      res = (m) + (uint64_t)m_lo * n_lo;
+      res_lo = res >> 32;
+      res_hi = (res_lo < m_hi);
+      res = res_lo | ((uint64_t)res_hi << 32);
+    }
+
+  if (!((m) & ((1ULL << 63) | (1ULL << 31))))
+    {
+      res += (uint64_t)m_lo * n_hi;
+      res += (uint64_t)m_hi * n_lo;
+      res >>= 32;
+    }
+  else
+    {
+      res += (uint64_t)m_lo * n_hi;
+      tmp = res >> 32;
+      res += (uint64_t)m_hi * n_lo;
+      res_lo = res >> 32;
+      res_hi = (res_lo < tmp);
+      res = res_lo | ((uint64_t)res_hi << 32);
+    }
+
+  res += (uint64_t)m_hi * n_hi;
+
+  return res;
+}
 #endif
 
+static inline_function uint64_t div64_const32(uint64_t n, uint32_t b)
+{
+  uint64_t res;
+  uint64_t x;
+  uint64_t t;
+  uint64_t m;
+  uint32_t p;
+  uint32_t bias;
+
+  DEBUGASSERT(b > 1);
+
+  p = 1u << LOG2_FLOOR(b);
+  m = (~0ULL / b) * p;
+  m += (((~0ULL % b + 1u) * p) + b - 1u) / b;
+  x = ~0ULL / b * b - 1u;
+  res = ((m & 0xffffffffu) * (x & 0xffffffffu)) >> 32;
+  t = res += (m & 0xffffffffu) * (x >> 32);
+  res += (x & 0xffffffffu) * (m >> 32);
+  t = (res < t) ? (1ULL << 32) : 0u;
+  res = (res >> 32) + t;
+  res += (m >> 32) * (x >> 32);
+  res /= p;
+
+  if (~0ULL % (b / (b & -b)) == 0u)
+    {
+      n /= (b & -b);
+      m = ~0ULL / (b / (b & -b));
+      p = 1u;
+      bias = 1u;
+    }
+  else if (res != x / b)
+    {
+      bias = 1u;
+      m = (~0ULL / b) * p;
+      m += ((~0ULL % b + 1u) * p) / b;
+    }
+  else
+    {
+      uint32_t bits = -(m & -m);
+      bits |= m >> 32;
+      bits = (~bits) << 1;
+      if (!bits)
+        {
+          p /= (m & -m);
+          m /= (m & -m);
+        }
+      else
+        {
+          p >>= LOG2_FLOOR(bits);
+          m >>= LOG2_FLOOR(bits);
+        }
+
+      bias = 0u;
+    }
+
+  res = umul64_const(m, n, bias);
+  res /= p;
+
+  return res;
+}
+
+#ifdef CONFIG_DEBUG_NOOPT
+
+/* Without optimization the magic number setup is not folded at compile
+ * time but runs on every call (it even contains several divisions),
+ * which is far slower than a plain division.
+ */
+
+#  define div64_const(n, base) ((n) / (base))
+#else
+
+/* The divisor is expected to be a compile-time constant so that the
+ * magic multiplier setup below is folded away; for runtime-invariant
+ * divisors use the invdiv API instead.
+ */
+
+static inline_function uint64_t div64_const(uint64_t n, uint64_t base)
+{
+  DEBUGASSERT(base > 0);
+
+  if (IS_POWER_OF_2(base))
+    {
+      n >>= LOG2_FLOOR(base);
+    }
+  else if (base <= UINT32_MAX)
+    {
+      n = div64_const32(n, (uint32_t)base);
+    }
+  else
+    {
+      n /= base;
+    }
+
+  return n;
+}
+#endif
+
+/* The div_const*() family takes non-negative arguments only,
+ * negative values are outside the contract.
+ */
+
+#define div_const(n, base) \
+  ((is_constexpr(base) && !is_constexpr(n) && \
+    sizeof((n)) == sizeof(uint64_t) && UINTPTR_MAX == UINT32_MAX) ? \

Review Comment:
   On 32-bit targets this path makes `b-g431b-esc1:nsh` too big for its flash. 
The CI job `Linux (arm-stm32l-u-g)` fails with "region `flash' overflowed by 
132 bytes" (and `nucleo-g431kb:nsh` by 188 bytes). The same job passes on other 
PRs today. With GCC 13.2, this config has 127 bytes free on master, and this PR 
adds 256 bytes of `.text` (`nxsig_clockwait` +84, `clock_systime_timespec` +72, 
`sysinfo` +70, ostest wdog +28).
   
   Fix: make room in these two defconfigs in this PR, or keep the plain 
division in `-Os` builds (`__OPTIMIZE_SIZE__`).



##########
include/nuttx/lib/math32.h:
##########
@@ -195,160 +203,186 @@ extern "C"
 
 /* Default C implementation for umul64_const()
  *
- * Prototype: uint64_t umul64_const(uint64_t retval, uint64_t m,
- *                                  uint64_t n, bool bias);
- * Semantic:  retval = ((bias ? m : 0) + m * n) >> 64
+ * Prototype: uint64_t umul64_const(uint64_t m, uint64_t n, int bias);
+ * Semantic:  return ((bias ? m : 0) + m * n) >> 64
  *
  * The product is a 128-bit value, scaled down to 64 bits.
  * Assuming constant propagation to optimize away unused conditional code.
  * Architectures may provide their own optimized assembly implementation.
  */
 
-#  ifdef up_umul64_const
-#    define umul64_const(res, m, n, bias) \
-      (res) = up_umul64_const(m, n, bias)
-#  else
-#    define umul64_const(res, m, n, bias) \
-      do \
-        { \
-          uint32_t __m_lo = (m) & 0xffffffff; \
-          uint32_t __m_hi = (m) >> 32; \
-          uint32_t __n_lo = (n) & 0xffffffff; \
-          uint32_t __n_hi = (n) >> 32; \
-          uint32_t __res_lo; \
-          uint32_t __res_hi; \
-          uint32_t __tmp; \
-          \
-          if (!(bias)) \
-            { \
-              (res) = ((uint64_t)__m_lo * __n_lo) >> 32; \
-            } \
-          else if (!((m) & ((1ULL << 63) | (1ULL << 31)))) \
-            { \
-              (res) = ((m) + (uint64_t)__m_lo * __n_lo) >> 32; \
-            } \
-          else \
-            { \
-              (res) = (m) + (uint64_t)__m_lo * __n_lo; \
-              __res_lo = (res) >> 32; \
-              __res_hi = (__res_lo < __m_hi); \
-              (res) = __res_lo | ((uint64_t)__res_hi << 32); \
-            } \
-          \
-          if (!((m) & ((1ULL << 63) | (1ULL << 31)))) \
-            { \
-              (res) += (uint64_t)__m_lo * __n_hi; \
-              (res) += (uint64_t)__m_hi * __n_lo; \
-              (res) >>= 32; \
-            } \
-          else \
-            { \
-              (res) += (uint64_t)__m_lo * __n_hi; \
-              __tmp = (res) >> 32; \
-              (res) += (uint64_t)__m_hi * __n_lo; \
-              __res_lo = (res) >> 32; \
-              __res_hi = (__res_lo < __tmp); \
-              (res) = __res_lo | ((uint64_t)__res_hi << 32); \
-            } \
-          \
-          (res) += (uint64_t)__m_hi * __n_hi; \
-        } \
-      while (0)
-#  endif
+/* Due to compilation issues, use inline functions instead of macros. */
 
-#  define div64_const32(n, b) \
-    do \
-      { \
-        uint64_t ___res; \
-        uint64_t ___x; \
-        uint64_t ___t; \
-        uint64_t ___m; \
-        uint64_t ___n = (n); \
-        uint32_t ___p; \
-        uint32_t ___bias; \
-        uint32_t ___b = (b); \
-        ___p = 1 << LOG2_FLOOR(___b); \
-        ___m = (~0ULL / ___b) * ___p; \
-        ___m += (((~0ULL % ___b + 1) * ___p) + ___b - 1) / ___b; \
-        ___x = ~0ULL / ___b * ___b - 1; \
-        ___res = ((___m & 0xffffffff) * (___x & 0xffffffff)) >> 32; \
-        ___t = ___res += (___m & 0xffffffff) * (___x >> 32); \
-        ___res += (___x & 0xffffffff) * (___m >> 32); \
-        ___t = (___res < ___t) ? (1ULL << 32) : 0; \
-        ___res = (___res >> 32) + ___t; \
-        ___res += (___m >> 32) * (___x >> 32); \
-        ___res /= ___p; \
-        if (~0ULL % (___b / (___b & -___b)) == 0) \
-          { \
-            ___n /= (___b & -___b); \
-            ___m = ~0ULL / (___b / (___b & -___b)); \
-            ___p = 1; \
-            ___bias = 1; \
-          } \
-        else if (___res != ___x / ___b) \
-          { \
-            ___bias = 1; \
-            ___m = (~0ULL / ___b) * ___p; \
-            ___m += ((~0ULL % ___b + 1) * ___p) / ___b; \
-          } \
-        else \
-          { \
-            uint32_t ___bits = -(___m & -___m); \
-            ___bits |= ___m >> 32; \
-            ___bits = (~___bits) << 1; \
-            if (!___bits) \
-              { \
-                ___p /= (___m & -___m); \
-                ___m /= (___m & -___m); \
-              } \
-            else \
-              { \
-                ___p >>= LOG2_FLOOR(___bits); \
-                ___m >>= LOG2_FLOOR(___bits); \
-              } \
-            ___bias = 0; \
-          } \
-        umul64_const(___res, ___m, ___n, ___bias); \
-        \
-        ___res /= ___p; \
-        (n) = ___res; \
-      } \
-    while (0)
-
-#if defined(CONFIG_HAVE_EXPRESSION_STATEMENT)
-#  define div64_const(n, base) \
-    ({ \
-      uint64_t __n = (n); \
-      uint32_t __base = (base); \
-      if (IS_POWER_OF_2(__base)) \
-        { \
-          (__n) >>= LOG2_FLOOR(__base); \
-        } \
-      else if (UINTPTR_MAX == UINT32_MAX) \
-        { \
-          div64_const32(__n, __base); \
-        } \
-      else \
-        { \
-          __n /= __base; \
-        } \
-        __n; \
-      })
-
-#  define div_const(n, base) \
-    ((sizeof(typeof(n)) == sizeof(uint64_t)) ? div64_const(n, base) : ((n) / 
(base)))
-#  define div_const_roundup(n, base) \
-    ((sizeof(typeof(n)) == sizeof(uint64_t)) ? div64_const((n) + (base) - 1, 
base) : \
-     (((n) + (base) - 1) / (base)))
-#  define div_const_roundnearest(n, base) \
-    ((sizeof(typeof(n)) == sizeof(uint64_t)) ? div64_const((n) + ((base) / 2), 
base) : \
-     (((n) + ((base) / 2)) / (base)))
+#ifdef up_umul64_const
+#  define umul64_const(m, n, bias) up_umul64_const(m, n, bias)
 #else
-#  define div_const(n, base) ((n) / (base))
-#  define div_const_roundup(n, base) (((n) + (base) - 1) / (base))
-#  define div_const_roundnearest(n, base) (((n) + ((base) / 2)) / (base))
+static inline_function uint64_t umul64_const(uint64_t m, uint64_t n,
+                                             int bias)
+{
+  uint32_t m_lo = (m) & 0xffffffff;
+  uint32_t m_hi = (m) >> 32;
+  uint32_t n_lo = (n) & 0xffffffff;
+  uint32_t n_hi = (n) >> 32;
+  uint32_t res_lo;
+  uint32_t res_hi;
+  uint32_t tmp;
+  uint64_t res;
+
+  if (!(bias))
+    {
+      res = ((uint64_t)m_lo * n_lo) >> 32;
+    }
+  else if (!((m) & ((1ULL << 63) | (1ULL << 31))))
+    {
+      res = ((m) + (uint64_t)m_lo * n_lo) >> 32;
+    }
+  else
+    {
+      res = (m) + (uint64_t)m_lo * n_lo;
+      res_lo = res >> 32;
+      res_hi = (res_lo < m_hi);
+      res = res_lo | ((uint64_t)res_hi << 32);
+    }
+
+  if (!((m) & ((1ULL << 63) | (1ULL << 31))))
+    {
+      res += (uint64_t)m_lo * n_hi;
+      res += (uint64_t)m_hi * n_lo;
+      res >>= 32;
+    }
+  else
+    {
+      res += (uint64_t)m_lo * n_hi;
+      tmp = res >> 32;
+      res += (uint64_t)m_hi * n_lo;
+      res_lo = res >> 32;
+      res_hi = (res_lo < tmp);
+      res = res_lo | ((uint64_t)res_hi << 32);
+    }
+
+  res += (uint64_t)m_hi * n_hi;
+
+  return res;
+}
 #endif
 
+static inline_function uint64_t div64_const32(uint64_t n, uint32_t b)
+{
+  uint64_t res;
+  uint64_t x;
+  uint64_t t;
+  uint64_t m;
+  uint32_t p;
+  uint32_t bias;
+
+  DEBUGASSERT(b > 1);
+
+  p = 1u << LOG2_FLOOR(b);
+  m = (~0ULL / b) * p;
+  m += (((~0ULL % b + 1u) * p) + b - 1u) / b;
+  x = ~0ULL / b * b - 1u;
+  res = ((m & 0xffffffffu) * (x & 0xffffffffu)) >> 32;
+  t = res += (m & 0xffffffffu) * (x >> 32);
+  res += (x & 0xffffffffu) * (m >> 32);
+  t = (res < t) ? (1ULL << 32) : 0u;
+  res = (res >> 32) + t;
+  res += (m >> 32) * (x >> 32);
+  res /= p;
+
+  if (~0ULL % (b / (b & -b)) == 0u)
+    {
+      n /= (b & -b);
+      m = ~0ULL / (b / (b & -b));
+      p = 1u;
+      bias = 1u;
+    }
+  else if (res != x / b)
+    {
+      bias = 1u;
+      m = (~0ULL / b) * p;
+      m += ((~0ULL % b + 1u) * p) / b;
+    }
+  else
+    {
+      uint32_t bits = -(m & -m);
+      bits |= m >> 32;
+      bits = (~bits) << 1;
+      if (!bits)
+        {
+          p /= (m & -m);
+          m /= (m & -m);
+        }
+      else
+        {
+          p >>= LOG2_FLOOR(bits);
+          m >>= LOG2_FLOOR(bits);
+        }
+
+      bias = 0u;
+    }
+
+  res = umul64_const(m, n, bias);
+  res /= p;
+
+  return res;
+}
+
+#ifdef CONFIG_DEBUG_NOOPT
+
+/* Without optimization the magic number setup is not folded at compile
+ * time but runs on every call (it even contains several divisions),
+ * which is far slower than a plain division.
+ */
+
+#  define div64_const(n, base) ((n) / (base))

Review Comment:
   With `CONFIG_DEBUG_NOOPT`, `div_const()` keeps the plain type of `(n) / 
(base)`. In all other builds its type is `uint64_t`. So the `PRIu64` that the 
last commit puts in the four ESP `wlerr()` calls is wrong in a NOOPT build. For 
`MSEC2TICK(block_time_ms)` with this header, riscv-none-elf-gcc 14.3 
`-DCONFIG_DEBUG_NOOPT` gives "format '%llu' expects argument of type 'long long 
unsigned int', but argument 2 has type 'long unsigned int' [-Werror=format=]". 
xtensa-esp32-elf-gcc gives the same error.
   
   Fix: `#  define div64_const(n, base) ((uint64_t)(n) / (base))`, so that 
`div_const()` has the same type in every build.



##########
include/nuttx/lib/math32.h:
##########
@@ -44,23 +45,30 @@
                                 (((n) - (d)/2)/(d)) : (((n) + (d)/2)/(d)))
 
 /* Returns one plus the index of the most significant 1-bit of n,
- * or if n is zero, returns zero.
+ * or if n is zero, returns zero.  The argument is evaluated multiple
+ * times and must be free of side effects.
  */
 
-#if UINTPTR_MAX > UINT32_MAX
-#  define FLS(n) ((n) & UINT64_C(0xffffffff00000000) ? 32 + \
-                  FLS32((size_t)(n) >> 32) : FLS32(n))
-#else
-#  define FLS(n) FLS32(n)
-#endif
-
 #define FLS32(n) ((n) & 0xffff0000 ? 16 + FLS16((n) >> 16) : FLS16(n))
 #define FLS16(n) ((n) & 0xff00     ?  8 + FLS8 ((n) >>  8) : FLS8 (n))
 #define FLS8(n)  ((n) & 0xf0       ?  4 + FLS4 ((n) >>  4) : FLS4 (n))
 #define FLS4(n)  ((n) & 0xc        ?  2 + FLS2 ((n) >>  2) : FLS2 (n))
 #define FLS2(n)  ((n) & 0x2        ?  1 + FLS1 ((n) >>  1) : FLS1 (n))
 #define FLS1(n)  ((n) & 0x1        ?  1 : 0)
 
+/* Widen before shifting so narrow types never see oversized shift counts. */
+
+#define FLS64(n) ((uint64_t)(n) >> 32 ? \
+                  32 + FLS32((uint32_t)((uint64_t)(n) >> 32)) : FLS32(n))
+
+#ifdef __INT128_DEFINED
+#  define FLS128(n) ((_uint128_t)(n) >> 64 ? \
+                     64 + FLS64((uint64_t)((_uint128_t)(n) >> 64)) : FLS64(n))
+#  define FLS(n) (sizeof((n)) <= sizeof(uint64_t) ? FLS64(n) : FLS128(n))

Review Comment:
   With `__INT128_DEFINED`, every `FLS()` now expands both `FLS64()` and 
`FLS128()`. With `CONFIG_DEBUG_ASSERTIONS_EXPRESSION`, the string of 
`DEBUGASSERT(nodesize >= MM_MIN_CHUNK)` in `mm/mm_heap/mm.h` grows from 17,947 
to 67,165 bytes. This is the +49 KB `.rodata` on qemu-intel64. No caller in the 
tree gives a 128-bit value to `FLS()`.
   
   Fix: `#  define FLS(n) FLS64(n)` on all targets, and let 128-bit users call 
`FLS128()` directly. The string is then 19,691 bytes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to