Re: [PATCH] libm: Add CMPLX, CMPLXF and CMPLXL macros
Corinna Vinschen <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> > > 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 <[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