This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 73b77ae69a24462b5fb09a55c630aa6efc515119
Author: ouyangxiangzhen <[email protected]>
AuthorDate: Fri Nov 6 09:48:50 2026 +0800

    lib/math32: replace typeof with sizeof() in the div_const macros
    
    The width dispatch of div_const()/div_const_roundup()/
    div_const_roundnearest() probed the dividend with sizeof(typeof(n)), a
    GNU extension: compilers without typeof (SDCC, IAR, TASKING classic,
    z88dk) fail to build the time conversion macros in <nuttx/clock.h> and
    the call sites in sched/wdog.  sizeof((n)) probes the same type without
    evaluating the argument and is plain C99.
    
    Note that sizeof() cannot probe bit-fields; widen them at the call site
    if needed (there are none in tree).
    
    Assisted-By: mimo-v2.6-pro
    Signed-off-by: ouyangxiangzhen <[email protected]>
---
 include/nuttx/lib/math32.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/nuttx/lib/math32.h b/include/nuttx/lib/math32.h
index b4694991691..f36700bf695 100644
--- a/include/nuttx/lib/math32.h
+++ b/include/nuttx/lib/math32.h
@@ -359,12 +359,12 @@ static inline_function uint64_t div64_const(uint64_t n, 
uint64_t base)
 #endif
 
 #define div_const(n, base) \
-  ((sizeof(typeof(n)) == sizeof(uint64_t)) ? div64_const(n, base) : ((n) / 
(base)))
+  ((sizeof((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) - 1u, 
base) : \
+  ((sizeof((n)) == sizeof(uint64_t)) ? div64_const((n) + (base) - 1u, base) : \
    (((n) + (base) - 1u) / (base)))
 #define div_const_roundnearest(n, base) \
-  ((sizeof(typeof(n)) == sizeof(uint64_t)) ? div64_const((n) + ((base) / 2u), 
base) : \
+  ((sizeof((n)) == sizeof(uint64_t)) ? div64_const((n) + ((base) / 2u), base) 
: \
    (((n) + ((base) / 2u)) / (base)))
 
 /* Division optimizing method proposed by T. Granlund and L. Montgomery.

Reply via email to