RE: [PATCH] libm: Add CMPLX, CMPLXF and CMPLXL macros
Yuriy Kolerov <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <CY8PR12MB7516C5E5DE4F1D19D4BA8652A8F52@CY8PR12MB7516.namprd12.prod.outlook.com> |
Hi Corinna, Yes, I see. Sorry, I missed that while rebasing my patches. Regards, Yuriy Kolerov -----Original Message----- From: Corinna Vinschen <[email protected]> Sent: Monday, February 3, 2025 4:16 PM To: Yuriy Kolerov <[email protected]> Cc: [email protected] 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 <[email protected]> > > 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 <[email protected]> > > Signed-off-by: Yuriy Kolerov <[email protected]> > --- > 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