File tree Expand file tree Collapse file tree 3 files changed +22
-36
lines changed Expand file tree Collapse file tree 3 files changed +22
-36
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,6 @@ add_flang_library(FortranEvaluate
5858 tools.cpp
5959 type .cpp
6060 variable .cpp
61- wrappers.c
6261
6362 LINK_LIBS
6463 FortranCommon
Original file line number Diff line number Diff line change @@ -278,25 +278,37 @@ static std::complex<HostT> StdPowF2B(
278278}
279279
280280#ifdef _AIX
281+ #ifdef __clang_major__
282+ #pragma clang diagnostic ignored "-Wc99-extensions"
283+ #endif
284+
281285extern " C" {
282- void csqrtf_wrapper ( const float [], float [] );
283- void csqrt_wrapper ( const double [], double [] );
284- } // extern "C"
286+ float _Complex csqrtf ( float _Complex );
287+ double _Complex csqrt ( double _Complex );
288+ }
285289#endif
286290
287291template <typename HostT>
288292static std::complex <HostT> CSqrt (const std::complex <HostT> &x) {
289293 std::complex <HostT> res;
290- #if _AIX
291- HostT y[2 ]{x.real (), x.imag ()};
292- HostT r[2 ];
294+ #ifdef _AIX
293295 if constexpr (std::is_same_v<HostT, float >) {
294- csqrtf_wrapper (y, r);
296+ float _Complex c;
297+ reinterpret_cast <HostT (&)[2 ]>(c)[0 ] = x.real ();
298+ reinterpret_cast <HostT (&)[2 ]>(c)[1 ] = x.imag ();
299+ float _Complex r{csqrtf (c)};
300+ res.real (reinterpret_cast <HostT (&)[2 ]>(r)[0 ]);
301+ res.imag (reinterpret_cast <HostT (&)[2 ]>(r)[1 ]);
295302 } else if constexpr (std::is_same_v<HostT, double >) {
296- csqrt_wrapper (y, r);
303+ double _Complex c;
304+ reinterpret_cast <HostT (&)[2 ]>(c)[0 ] = x.real ();
305+ reinterpret_cast <HostT (&)[2 ]>(c)[1 ] = x.imag ();
306+ double _Complex r{csqrt (c)};
307+ res.real (reinterpret_cast <HostT (&)[2 ]>(r)[0 ]);
308+ res.imag (reinterpret_cast <HostT (&)[2 ]>(r)[1 ]);
309+ } else {
310+ assert (" bad complex component type" );
297311 }
298- res.real (r[0 ]);
299- res.imag (r[1 ]);
300312#else
301313 res = std::sqrt (x);
302314#endif
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments