feat(libc): implement creal, cimag, conj, cproj, carg and cabs complex helpers #12947

Merged
heditrigui merged 6 commits from upstream-pr/12947 into main 2026-11-08 23:49:28 +00:00
heditrigui commented 2026-10-29 16:09:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by heditrigui on 2026-10-29T16:09:27Z.


What

Implement 18 C99 / FreeBSD 11 lib/msun complex arithmetic helper functions in libc (core/libs/prx/libc/src/FloatBuiltins.cpp) across float, double, and long double precisions:

  • creal, crealf, creall (NIDs xgC4Y4+dTOA, v0VslSVHuwc, 5+LpHzDWoF8): extract real component (__real__ z).
  • cimag, cimagf, cimagl (NIDs bp2rmLwsf7A, JS9RKdosxa0, x7aaTqwVSbg): extract imaginary component (__imag__ z).
  • conj, conjf, conjl (NIDs R6sIm4bD0F4, WJfkgdE9LME, GnEh47X+NFM): complex conjugation with negated imaginary component.
  • cproj, cprojf, cprojl (NIDs Y3MTZ9Ka4oM, LZdcIlEzRgk, b6Z5XNZdGIg): projection onto the Riemann sphere, mapping complex infinities to positive real infinity while preserving imaginary sign.
  • carg, cargf, cargl (NIDs u77BzyEecPM, +pYD-MFdyDI, 56MAXko+y6U): phase angle calculation via std::atan2(__imag__ z, __real__ z).
  • cabs, cabsf, cabsl (NIDs RiqahH9Kcys, +qV-mOKPTzM, MZp5SZBXqEE): modulus calculation via std::hypot(__real__ z, __imag__ z).
  • Declares all 18 exports in core/libs/prx/libc/include/Api.hpp.
  • Adds unit tests in core/libs/tests/GuestFloatBuiltins.cpp exercising real/imag component extraction, Pythagorean triple moduli, phase angles, complex conjugation, and finite/infinite Riemann sphere projection rules across all three precisions.
  • Documents reference alignment and technical debt in docs/dev/debt/libc.md.

Tested

Ran python tools/check_conventions.py --base upstream/main cleanly (0 errors).
Ran python core/libs/tests/test_public_headers.py --audit-only cleanly (373 libraries, 14,018 exports verified).
Verified library progress increment with tools/progress.py (libc done increased from 1457 to 1475).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5071502281 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12947). Originally posted by [heditrigui](https://github.com/heditrigui) on 2026-10-29T16:09:27Z. --- ### What Implement 18 C99 / FreeBSD 11 `lib/msun` complex arithmetic helper functions in libc (`core/libs/prx/libc/src/FloatBuiltins.cpp`) across `float`, `double`, and `long double` precisions: - `creal`, `crealf`, `creall` (NIDs `xgC4Y4+dTOA`, `v0VslSVHuwc`, `5+LpHzDWoF8`): extract real component (`__real__ z`). - `cimag`, `cimagf`, `cimagl` (NIDs `bp2rmLwsf7A`, `JS9RKdosxa0`, `x7aaTqwVSbg`): extract imaginary component (`__imag__ z`). - `conj`, `conjf`, `conjl` (NIDs `R6sIm4bD0F4`, `WJfkgdE9LME`, `GnEh47X+NFM`): complex conjugation with negated imaginary component. - `cproj`, `cprojf`, `cprojl` (NIDs `Y3MTZ9Ka4oM`, `LZdcIlEzRgk`, `b6Z5XNZdGIg`): projection onto the Riemann sphere, mapping complex infinities to positive real infinity while preserving imaginary sign. - `carg`, `cargf`, `cargl` (NIDs `u77BzyEecPM`, `+pYD-MFdyDI`, `56MAXko+y6U`): phase angle calculation via `std::atan2(__imag__ z, __real__ z)`. - `cabs`, `cabsf`, `cabsl` (NIDs `RiqahH9Kcys`, `+qV-mOKPTzM`, `MZp5SZBXqEE`): modulus calculation via `std::hypot(__real__ z, __imag__ z)`. - Declares all 18 exports in `core/libs/prx/libc/include/Api.hpp`. - Adds unit tests in `core/libs/tests/GuestFloatBuiltins.cpp` exercising real/imag component extraction, Pythagorean triple moduli, phase angles, complex conjugation, and finite/infinite Riemann sphere projection rules across all three precisions. - Documents reference alignment and technical debt in `docs/dev/debt/libc.md`. ### Tested Ran `python tools/check_conventions.py --base upstream/main` cleanly (0 errors). Ran `python core/libs/tests/test_public_headers.py --audit-only` cleanly (373 libraries, 14,018 exports verified). Verified library progress increment with `tools/progress.py` (libc done increased from 1457 to 1475). ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current main; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation .md files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
rooklz commented 2026-10-29 16:17:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T16:17:42Z.

Review: DISMISSED


Review of d27e36c9cd: the NIDs are right and the behaviour is close, but the code doesn't compile on any compiler I tried. Needs changes.

NIDs: all 18 match tools/nid_names.py --name creal ... cabsl. No other export or stub on main uses them.

1. FloatBuiltins.cpp doesn't compile (blocking). On x86-64 Linux, macOS and MinGW, INFINITY is a float, so MakeComplex(INFINITY, std::copysign(0.0, ...)) in cproj and MakeComplex(INFINITY, std::copysign(0.0L, ...)) in cprojl are ambiguous between the three MakeComplex overloads:

clang++ (Apple 21 / Homebrew LLVM): error: call to 'MakeComplex' is ambiguous   (cproj, cprojl)
g++-16: error: call of overloaded 'MakeComplex(float, long double)' is ambiguous (cprojl; g++ accepts cproj, clang rejects both)

Fix: pass a typed infinity, e.g. std::numeric_limits<double>::infinity() / <float> / <long double> (<limits> is needed).

2. GuestFloatBuiltins.cpp doesn't compile (blocking). __complex__ T val{} with a dependent T is rejected by both compilers. Clang reads it as plain _Complex (double) followed by a redeclaration of T ("declaration of 'T' shadows template parameter"). g++ says "expected initializer before 'val'". T _Complex and an alias template fail the same way. The test also calls makeComplex(INFINITY, 2.) / (1., -INFINITY) / (-INFINITY, 1.L) with mixed types, so deduction fails there too. Three plain non-template overloads plus typed infinities compile everywhere (see the rows below). The relinker CI lanes don't build libc, and the libc lanes were still pending when I checked, so CI hasn't shown this yet.

3. carg/cargf/cabs/cabsf bypass libc's own atan2f/hypot/hypotf. FreeBSD msun s_carg*.c/s_cabs*.c call the library's atan2*/hypot*, and main already exports those (Math.cpp: atan2f_nid_postfix is msun e_atan2f.c, documented in debt; hypot_nid_postfix and hypotf_nid_postfix (via double) too). std::atan2(float, float) is the host libm. In a 20M-input differential (macOS libm, x86_64 + arm64), cargf differs from main's atan2f_nid_postfix on 3,945,322 / 20,000,000 inputs, e.g. (0x1.e3465ap-1, 0x1.319e92p-3): PR gives 0x1.41208ap-3 and atan2f gives 0x1.412088p-3. cabs/cabsf agreed bit-for-bit with main's hypot exports on all 20M inputs, but delegating keeps them consistent if those exports change. Suggested:

float APS5_VABI cargf_nid_postfix(__complex__ float z) { return atan2f_nid_postfix(__imag__ z, __real__ z); }
double APS5_VABI carg_nid_postfix(__complex__ double z) { return atan2_nid_postfix(__imag__ z, __real__ z); }
long double APS5_VABI cargl_nid_postfix(__complex__ long double z) { return atan2l_nid_postfix(__imag__ z, __real__ z); }
float APS5_VABI cabsf_nid_postfix(__complex__ float z) { return hypotf_nid_postfix(__real__ z, __imag__ z); }
double APS5_VABI cabs_nid_postfix(__complex__ double z) { return hypot_nid_postfix(__real__ z, __imag__ z); }
long double APS5_VABI cabsl_nid_postfix(__complex__ long double z) { return hypotl_nid_postfix(__real__ z, __imag__ z); }

After that, the debt line can point to the existing atan2l/hypotl host-libm entry for the last-bit caveat.

4. Test gaps (mutation testing). I ran 11 single-line mutants against the fixed version. With the PR's rows, 5 survive:

  • carg arguments swapped (atan2(re, im)): (1,1) is symmetric
  • cprojf/cprojl dropping copysign (+0 imaginary): no row checks the sign of a zero imaginary part for float/long double
  • cprojf testing only isinf(imag): the float infinite row has an infinite real part
  • cabsl going through double: 3-4-5 fits in a double
  • cargf via host std::atan2

These rows kill 11/11 on x86_64 (80-bit long double, like the guest). On arm64, long double is double, so the cabsl narrowing row is equivalent there:

    Require(carg_nid_postfix(TestComplex(-1., 0.)) == std::atan2(0., -1.));
    Require(cargf_nid_postfix(TestComplex(0x1.e3465ap-1f, 0x1.319e92p-3f)) == 0x1.412088p-3f);
    Require(cargf_nid_postfix(TestComplex(-0x1.00924ap+6f, -0x1.5eaaaap+6f)) == -0x1.19ea4p+1f);
    const __complex__ float pjf2 = cprojf_nid_postfix(TestComplex(std::numeric_limits<float>::infinity(), -1.f));
    Require(__imag__ pjf2 == 0.f && std::signbit(__imag__ pjf2));
    const __complex__ long double pjl2 = cprojl_nid_postfix(TestComplex(1.L, -std::numeric_limits<long double>::infinity()));
    Require(std::isinf(__real__ pjl2) && __real__ pjl2 > 0.L && __imag__ pjl2 == 0.L && std::signbit(__imag__ pjl2));
    Require(cabsl_nid_postfix(TestComplex(3e3000L, 4e3000L)) == 5e3000L);

with file-scope helpers replacing the lambda:

static __complex__ float TestComplex(float real, float imaginary) { __complex__ float value; __real__ value = real; __imag__ value = imaginary; return value; }
static __complex__ double TestComplex(double real, double imaginary) { __complex__ double value; __real__ value = real; __imag__ value = imaginary; return value; }
static __complex__ long double TestComplex(long double real, long double imaginary) { __complex__ long double value; __real__ value = real; __imag__ value = imaginary; return value; }

The second cargf row fails on the head implementation once it compiles, and passes with the delegation from item 3.

What I ran (macOS arm64; the x86_64 runs used Rosetta): a standalone harness containing your 18 functions verbatim, main's MakeComplex overloads, main's atan2f/atanf/hypotf/hypot sliced from Math.cpp, and your test rows. With fixes 1 and 2 applied and the new rows added, it passes under clang++ x86_64 and arm64 with -fsanitize=address,undefined, and under g++-16 -O2. git merge-tree against bb04a4f1ea is clean, git diff --check is clean, check_conventions --base upstream/main passes, and the debt line is 522 chars. pr_overlap reports no conflicting lines and no shared exports. I didn't measure anything on a console, so the PR's "console behavior is unverified" debt note still applies.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5701125701 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12947#pullrequestreview-5701125701). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-29T16:17:42Z. **Review:** DISMISSED --- Review of d27e36c9cd: the NIDs are right and the behaviour is close, but the code doesn't compile on any compiler I tried. Needs changes. **NIDs:** all 18 match `tools/nid_names.py --name creal ... cabsl`. No other export or stub on main uses them. **1. FloatBuiltins.cpp doesn't compile (blocking).** On x86-64 Linux, macOS and MinGW, `INFINITY` is a `float`, so `MakeComplex(INFINITY, std::copysign(0.0, ...))` in `cproj` and `MakeComplex(INFINITY, std::copysign(0.0L, ...))` in `cprojl` are ambiguous between the three `MakeComplex` overloads: ``` clang++ (Apple 21 / Homebrew LLVM): error: call to 'MakeComplex' is ambiguous (cproj, cprojl) g++-16: error: call of overloaded 'MakeComplex(float, long double)' is ambiguous (cprojl; g++ accepts cproj, clang rejects both) ``` Fix: pass a typed infinity, e.g. `std::numeric_limits<double>::infinity()` / `<float>` / `<long double>` (`<limits>` is needed). **2. GuestFloatBuiltins.cpp doesn't compile (blocking).** `__complex__ T val{}` with a dependent `T` is rejected by both compilers. Clang reads it as plain `_Complex` (double) followed by a redeclaration of `T` ("declaration of 'T' shadows template parameter"). g++ says "expected initializer before 'val'". `T _Complex` and an alias template fail the same way. The test also calls `makeComplex(INFINITY, 2.)` / `(1., -INFINITY)` / `(-INFINITY, 1.L)` with mixed types, so deduction fails there too. Three plain non-template overloads plus typed infinities compile everywhere (see the rows below). The relinker CI lanes don't build libc, and the libc lanes were still pending when I checked, so CI hasn't shown this yet. **3. `carg`/`cargf`/`cabs`/`cabsf` bypass libc's own `atan2f`/`hypot`/`hypotf`.** FreeBSD msun `s_carg*.c`/`s_cabs*.c` call the library's `atan2*`/`hypot*`, and main already exports those (`Math.cpp`: `atan2f_nid_postfix` is msun `e_atan2f.c`, documented in debt; `hypot_nid_postfix` and `hypotf_nid_postfix` (via double) too). `std::atan2(float, float)` is the host libm. In a 20M-input differential (macOS libm, x86_64 + arm64), `cargf` differs from main's `atan2f_nid_postfix` on **3,945,322 / 20,000,000** inputs, e.g. `(0x1.e3465ap-1, 0x1.319e92p-3)`: PR gives `0x1.41208ap-3` and atan2f gives `0x1.412088p-3`. `cabs`/`cabsf` agreed bit-for-bit with main's hypot exports on all 20M inputs, but delegating keeps them consistent if those exports change. Suggested: ```cpp float APS5_VABI cargf_nid_postfix(__complex__ float z) { return atan2f_nid_postfix(__imag__ z, __real__ z); } double APS5_VABI carg_nid_postfix(__complex__ double z) { return atan2_nid_postfix(__imag__ z, __real__ z); } long double APS5_VABI cargl_nid_postfix(__complex__ long double z) { return atan2l_nid_postfix(__imag__ z, __real__ z); } float APS5_VABI cabsf_nid_postfix(__complex__ float z) { return hypotf_nid_postfix(__real__ z, __imag__ z); } double APS5_VABI cabs_nid_postfix(__complex__ double z) { return hypot_nid_postfix(__real__ z, __imag__ z); } long double APS5_VABI cabsl_nid_postfix(__complex__ long double z) { return hypotl_nid_postfix(__real__ z, __imag__ z); } ``` After that, the debt line can point to the existing `atan2l`/`hypotl` host-libm entry for the last-bit caveat. **4. Test gaps (mutation testing).** I ran 11 single-line mutants against the fixed version. With the PR's rows, 5 survive: - `carg` arguments swapped (`atan2(re, im)`): (1,1) is symmetric - `cprojf`/`cprojl` dropping `copysign` (+0 imaginary): no row checks the sign of a zero imaginary part for float/long double - `cprojf` testing only `isinf(imag)`: the float infinite row has an infinite real part - `cabsl` going through `double`: 3-4-5 fits in a double - `cargf` via host `std::atan2` These rows kill 11/11 on x86_64 (80-bit long double, like the guest). On arm64, `long double` is `double`, so the `cabsl` narrowing row is equivalent there: ```cpp Require(carg_nid_postfix(TestComplex(-1., 0.)) == std::atan2(0., -1.)); Require(cargf_nid_postfix(TestComplex(0x1.e3465ap-1f, 0x1.319e92p-3f)) == 0x1.412088p-3f); Require(cargf_nid_postfix(TestComplex(-0x1.00924ap+6f, -0x1.5eaaaap+6f)) == -0x1.19ea4p+1f); const __complex__ float pjf2 = cprojf_nid_postfix(TestComplex(std::numeric_limits<float>::infinity(), -1.f)); Require(__imag__ pjf2 == 0.f && std::signbit(__imag__ pjf2)); const __complex__ long double pjl2 = cprojl_nid_postfix(TestComplex(1.L, -std::numeric_limits<long double>::infinity())); Require(std::isinf(__real__ pjl2) && __real__ pjl2 > 0.L && __imag__ pjl2 == 0.L && std::signbit(__imag__ pjl2)); Require(cabsl_nid_postfix(TestComplex(3e3000L, 4e3000L)) == 5e3000L); ``` with file-scope helpers replacing the lambda: ```cpp static __complex__ float TestComplex(float real, float imaginary) { __complex__ float value; __real__ value = real; __imag__ value = imaginary; return value; } static __complex__ double TestComplex(double real, double imaginary) { __complex__ double value; __real__ value = real; __imag__ value = imaginary; return value; } static __complex__ long double TestComplex(long double real, long double imaginary) { __complex__ long double value; __real__ value = real; __imag__ value = imaginary; return value; } ``` The second `cargf` row fails on the head implementation once it compiles, and passes with the delegation from item 3. **What I ran** (macOS arm64; the x86_64 runs used Rosetta): a standalone harness containing your 18 functions verbatim, main's `MakeComplex` overloads, main's `atan2f`/`atanf`/`hypotf`/`hypot` sliced from `Math.cpp`, and your test rows. With fixes 1 and 2 applied and the new rows added, it passes under clang++ x86_64 and arm64 with `-fsanitize=address,undefined`, and under g++-16 -O2. `git merge-tree` against bb04a4f1ea is clean, `git diff --check` is clean, `check_conventions --base upstream/main` passes, and the debt line is 522 chars. `pr_overlap` reports no conflicting lines and no shared exports. I didn't measure anything on a console, so the PR's "console behavior is unverified" debt note still applies. AI-assisted: yes
rooklz commented 2026-10-29 16:35:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T16:35:33Z.

Review: DISMISSED


Follow-up on 11d451294a. Item 1 is fixed: FloatBuiltins.cpp now compiles cleanly under clang++ (Apple 21, x86_64 and arm64) and g++-16 with -fsyntax-only. Thanks.

Item 2 still blocks. core/libs/tests/GuestFloatBuiltins.cpp still doesn't compile, and the libc test lanes will fail on it:

clang++ -arch x86_64: GuestFloatBuiltins.cpp:150:21: error: declaration of 'T' shadows template parameter
                      GuestFloatBuiltins.cpp:162:53: error: no matching function for call to object of type '(lambda ...)'
x86_64-w64-mingw32-g++: GuestFloatBuiltins.cpp:150:23: error: expected initializer before 'val'
                        GuestFloatBuiltins.cpp:162:64: error: no match for call to '(CheckComplex()::<lambda(T, T)>) (float, double)'

On this head, replacing the lambda with the three file-scope TestComplex overloads from my earlier review, and the INFINITY arguments with std::numeric_limits<T>::infinity(), gives 0 errors under both compilers (#include <limits>; I made no other changes).

Items 3 (delegate carg*/cabs* to the existing atan2*/hypot* exports; cargf differs from atan2f_nid_postfix on ~20% of inputs) and 4 (rows that kill the 5 surviving mutants) are still open. The rows in my first review still apply as written.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5701383661 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12947#pullrequestreview-5701383661). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-29T16:35:33Z. **Review:** DISMISSED --- Follow-up on 11d451294a. Item 1 is fixed: `FloatBuiltins.cpp` now compiles cleanly under clang++ (Apple 21, x86_64 and arm64) and g++-16 with `-fsyntax-only`. Thanks. **Item 2 still blocks.** `core/libs/tests/GuestFloatBuiltins.cpp` still doesn't compile, and the libc test lanes will fail on it: ``` clang++ -arch x86_64: GuestFloatBuiltins.cpp:150:21: error: declaration of 'T' shadows template parameter GuestFloatBuiltins.cpp:162:53: error: no matching function for call to object of type '(lambda ...)' x86_64-w64-mingw32-g++: GuestFloatBuiltins.cpp:150:23: error: expected initializer before 'val' GuestFloatBuiltins.cpp:162:64: error: no match for call to '(CheckComplex()::<lambda(T, T)>) (float, double)' ``` On this head, replacing the lambda with the three file-scope `TestComplex` overloads from my earlier review, and the `INFINITY` arguments with `std::numeric_limits<T>::infinity()`, gives 0 errors under both compilers (`#include <limits>`; I made no other changes). Items 3 (delegate `carg*`/`cabs*` to the existing `atan2*`/`hypot*` exports; `cargf` differs from `atan2f_nid_postfix` on ~20% of inputs) and 4 (rows that kill the 5 surviving mutants) are still open. The rows in my first review still apply as written. AI-assisted: yes
adriadam10 commented 2026-10-29 17:02:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-29T17:02:42Z.

Review: CHANGES_REQUESTED


Thanks, FloatBuiltins.cpp now compiles and the bodies match the C99 definitions. Still blocking:

  • core/libs/tests/GuestFloatBuiltins.cpp:149-154: the templated lambda []<typename T>(T r, T i) { __complex__ T val{}; ... } does not compile with GCC/MinGW (expected initializer before 'val') nor clang, as already reported above. Replace it with three plain overloads (float, double, long double) or build the values with __real__/__imag__ on typed locals.
  • Lines 162, 164, 175 and 186: makeComplex(INFINITY, 2.) mixes float and double, so T cannot be deduced. Use an infinity of the destination precision (static_cast<double>(INFINITY), HUGE_VALL, ...).
  • The test pins carg against std::atan2 of the same call, which cannot fail if the implementation is wrong. Compare against literal bit patterns (e.g. atan2(1,1) = 0x3FE921FB54442D18, and carg(-1 + 0i) = pi, carg(-1 - 0i) = -pi).
  • Add rows for signed zero and NaN: conj(+0 + 0i) imaginary must be -0, cproj(-inf + -0i) gives +inf, -0, cproj(nan + inf i) projects, cabs(inf, nan) is +inf.

Please run the test with the rest of the guest libc tests on Windows (MinGW) before pushing; the Build job covers it.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5701794092 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12947#pullrequestreview-5701794092). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-29T17:02:42Z. **Review:** CHANGES_REQUESTED --- Thanks, `FloatBuiltins.cpp` now compiles and the bodies match the C99 definitions. Still blocking: - `core/libs/tests/GuestFloatBuiltins.cpp:149-154`: the templated lambda `[]<typename T>(T r, T i) { __complex__ T val{}; ... }` does not compile with GCC/MinGW (`expected initializer before 'val'`) nor clang, as already reported above. Replace it with three plain overloads (`float`, `double`, `long double`) or build the values with `__real__`/`__imag__` on typed locals. - Lines 162, 164, 175 and 186: `makeComplex(INFINITY, 2.)` mixes `float` and `double`, so `T` cannot be deduced. Use an infinity of the destination precision (`static_cast<double>(INFINITY)`, `HUGE_VALL`, ...). - The test pins `carg` against `std::atan2` of the same call, which cannot fail if the implementation is wrong. Compare against literal bit patterns (e.g. `atan2(1,1)` = `0x3FE921FB54442D18`, and `carg(-1 + 0i)` = pi, `carg(-1 - 0i)` = -pi). - Add rows for signed zero and NaN: `conj(+0 + 0i)` imaginary must be `-0`, `cproj(-inf + -0i)` gives `+inf, -0`, `cproj(nan + inf i)` projects, `cabs(inf, nan)` is `+inf`. Please run the test with the rest of the guest libc tests on Windows (MinGW) before pushing; the Build job covers it.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!12947
No description provided.