[PATCH] libm: Add CMPLX, CMPLXF and CMPLXL macros
Corinna Vinschen
vinschen@redhat.com
Mon Feb 3 14:15:30 GMT 2025
Hi Yuriy,
On Jan 31 23:14, Yuriy Kolerov wrote:
> This is a backport of the same patch from Picolibc repository
> with all fixes:
>
> https://github.com/picolibc/picolibc/commit/197657202913
>
> libm: Add CMPLX, CMPLXF and CMPLXL macros
>
> These use __builtin_complex if available, otherwise they open
> code as suggested by the C standard.
>
> Signed-off-by: Keith Packard <keithp@keithp.com>
>
> https://github.com/picolibc/picolibc/commit/a00c65d42760
>
> complex.h: Add type casting to CMPLX, CMPLXF and CMPLXL macros
>
> Adding type casting to CMPLX, CMPLXF and CMPLXL macros to
> ensure type safety constructing complex numbers using
> __builtin_complex function. The real and imaginary parts
> passed to __builtin_complex function are explicity cast to
> double, float and long double respectively, to match the
> types expected by the function.
>
> This change improves code clarity and prevents unintended
> type conversions when using macros to construct complex
> numbers.
>
> Signed-off-by: Mostafa Salman <mostafas@synopsys.com>
>
> Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
> ---
> newlib/libc/include/complex.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
The CMPLXx() macros are already in that file, right at the start,
lines 20 to 30.
Corinna
More information about the Newlib
mailing list