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

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


The following commit(s) were added to refs/heads/releases/13.0 by this push:
     new aa4facaf195 lib/math32: Avoid __uint128_t casts for LDC ImportC
aa4facaf195 is described below

commit aa4facaf19568b412623427594915c502cc71cf9
Author: Ansh Rai <[email protected]>
AuthorDate: Tue Jul 21 15:05:56 2026 +0000

    lib/math32: Avoid __uint128_t casts for LDC ImportC
    
    Building the hello_d example with LDC ImportC fails because ImportC
    does not correctly handle direct __uint128_t C-style casts such as
    (__uint128_t)a and (__uint128_t)1.
    
    Replace the direct casts with equivalent typed temporaries, preserving
    the existing behavior while allowing hello_d to build successfully with
    LDC ImportC.
    
    Verified on sim:nsh with CONFIG_EXAMPLES_HELLO_D=y:
    
      nsh> hello_d
      Hello World, [skylake]!
      DHelloWorld.HelloWorld: Hello, World!!
    
    Signed-off-by: Ansh Rai <[email protected]>
---
 include/nuttx/lib/math32.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/nuttx/lib/math32.h b/include/nuttx/lib/math32.h
index 14fd78577bb..d793779b9b1 100644
--- a/include/nuttx/lib/math32.h
+++ b/include/nuttx/lib/math32.h
@@ -495,7 +495,8 @@ static inline_function uint64_t invdiv_umulh64(uint64_t a, 
uint64_t b)
    * the inline assembly.
    */
 
-  __uint128_t res128 = (__uint128_t)a * b;
+  __uint128_t a128 = a;
+  __uint128_t res128 = a128 * b;
   return res128 >> 64;
 #endif
 }
@@ -542,7 +543,8 @@ void invdiv_init_param64(uint64_t d, FAR invdiv_param64_t 
*param)
 
   param->mult = q[0] + 1;
 #else
-  param->mult  = ((__uint128_t)1 << 64) * t / d + 1;
+  __uint128_t one128 = 1;
+  param->mult = (one128 << 64) * t / d + 1;
 #endif
   param->shift = l - 1;
 }

Reply via email to