[PATCH] libm: Add CMPLX, CMPLXF and CMPLXL macros

Yuriy Kolerov Yuriy.Kolerov@synopsys.com
Mon Feb 3 17:27:14 GMT 2025


Hi Corinna,

Yes, I see. Sorry, I missed that while rebasing my patches.

Regards,
Yuriy Kolerov

-----Original Message-----
From: Corinna Vinschen <vinschen@redhat.com> 
Sent: Monday, February 3, 2025 4:16 PM
To: Yuriy Kolerov <ykolerov@synopsys.com>
Cc: newlib@sourceware.org
Subject: Re: [PATCH] libm: Add CMPLX, CMPLXF and CMPLXL macros

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://urldefense.com/v3/__https://github.com/picolibc/picolibc/commi
> t/197657202913__;!!A4F2R9G_pg!erpVdhCZzAZUHSMjMkze6yzlGsJZ8D26oU_WOZXv
> 3HSIO3FmG2uS1VS7A3UwIPTHO2MsSjMfgWNzj_oAxgz1eKc$
> 
>     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://urldefense.com/v3/__https://github.com/picolibc/picolibc/commi
> t/a00c65d42760__;!!A4F2R9G_pg!erpVdhCZzAZUHSMjMkze6yzlGsJZ8D26oU_WOZXv
> 3HSIO3FmG2uS1VS7A3UwIPTHO2MsSjMfgWNzj_oAx12zglc$
> 
>     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