lib/math32: Avoid __uint128_t casts for LDC ImportC#19497
Merged
Conversation
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 <anshrai331@gmail.com>
ML-dev-crypto
requested review from
Donny9,
GUIDINGLI and
jerpelea
as code owners
July 21, 2026 15:27
xiaoxiang781216
approved these changes
Jul 21, 2026
acassis
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Building the
hello_dexample with LDC ImportC fails because ImportC does not correctly handle direct__uint128_tC-style casts such as(__uint128_t)aand(__uint128_t)1used ininclude/nuttx/lib/math32.h.These expressions compile successfully with the existing implementation, but ImportC fails while parsing them, preventing the D example from building.
Rewrite the affected expressions to initialize
__uint128_tvariables first and then perform the arithmetic. This preserves the existing behavior while allowing the code to compile successfully with LDC ImportC.Impact
Rewrite the two direct
__uint128_tcast expressions inmath32.hto use initialized__uint128_tvariables before the arithmetic operations.The computation remains unchanged while avoiding the current ImportC parser limitation.
Testing
Host: WSL2 Ubuntu 24.04 x86_64
Configuration:
sim:nshEnabled
CONFIG_EXAMPLES_HELLO_D.Before this change, the build failed while compiling
include/nuttx/lib/math32.hwith LDC ImportC.After applying this change, the project built successfully.
Verified the application from NSH: