Skip to content

Commit 2215134

Browse files
committed
Fix windows build failure
1 parent d5219a9 commit 2215134

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

flang/lib/Evaluate/intrinsics-library.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,20 +282,26 @@ extern "C" {
282282
void csqrtf_wrapper(const float[], float[]);
283283
void csqrt_wrapper(const double[], double[]);
284284
} // extern "C"
285+
#endif
285286

286287
template <typename HostT>
287-
static std::complex<HostT> CSQRT(const std::complex<HostT> &x) {
288+
static std::complex<HostT> CSqrt(const std::complex<HostT> &x) {
289+
std::complex<HostT> res;
290+
#if _AIX
288291
HostT y[2]{x.real(), x.imag()};
289292
HostT r[2];
290293
if constexpr (std::is_same_v<HostT, float>) {
291294
csqrtf_wrapper(y, r);
292295
} else if constexpr (std::is_same_v<HostT, double>) {
293296
csqrt_wrapper(y, r);
294297
}
295-
std::complex<HostT> res(r[0], r[1]);
298+
res.real(r[0]);
299+
res.imag(r[1]);
300+
#else
301+
res = std::sqrt(x);
302+
#endif
296303
return res;
297304
}
298-
#endif
299305

300306
template <typename HostT>
301307
struct HostRuntimeLibrary<std::complex<HostT>, LibraryVersion::Libm> {
@@ -322,11 +328,7 @@ struct HostRuntimeLibrary<std::complex<HostT>, LibraryVersion::Libm> {
322328
FolderFactory<F2B, F2B{StdPowF2B}>::Create("pow"),
323329
FolderFactory<F, F{std::sin}>::Create("sin"),
324330
FolderFactory<F, F{std::sinh}>::Create("sinh"),
325-
#ifdef _AIX
326-
FolderFactory<F, F{CSQRT}>::Create("sqrt"),
327-
#else
328-
FolderFactory<F, F{std::sqrt}>::Create("sqrt"),
329-
#endif
331+
FolderFactory<F, F{CSqrt}>::Create("sqrt"),
330332
FolderFactory<F, F{std::tan}>::Create("tan"),
331333
FolderFactory<F, F{std::tanh}>::Create("tanh"),
332334
};

flang/lib/Evaluate/wrappers.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifdef _AIX
910
#include <complex.h>
1011

1112
void csqrtf_wrapper(const float x[2], float res[2]) {
@@ -21,3 +22,4 @@ void csqrt_wrapper(const double x[2], double res[2]) {
2122
res[0] = creal(r);
2223
res[1] = cimag(r);
2324
}
25+
#endif

0 commit comments

Comments
 (0)