Skip to content

Commit 959e69a

Browse files
authored
[Clang] Fix HIP wrapper inclusion of 'algorithm' when using libc++ (#67981)
Summary: The `algorithm` header included here sometimes caused issues when using `libc++` over `libstdc++`. This was primarily because of the order they were included in. This patch just gets rid of this dependency as it was only used for min and max which are trivial to reimplement. Fixes: #67938
1 parent d58fb40 commit 959e69a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

clang/lib/Headers/__clang_hip_math.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
#endif
1515

1616
#if !defined(__HIPCC_RTC__)
17-
#if defined(__cplusplus)
18-
#include <algorithm>
19-
#endif
2017
#include <limits.h>
2118
#include <stdint.h>
2219
#ifdef __OPENMP_AMDGCN__
@@ -1311,11 +1308,11 @@ double min(double __x, double __y) { return __builtin_fmin(__x, __y); }
13111308

13121309
#if !defined(__HIPCC_RTC__) && !defined(__OPENMP_AMDGCN__)
13131310
__host__ inline static int min(int __arg1, int __arg2) {
1314-
return std::min(__arg1, __arg2);
1311+
return __arg1 < __arg2 ? __arg1 : __arg2;
13151312
}
13161313

13171314
__host__ inline static int max(int __arg1, int __arg2) {
1318-
return std::max(__arg1, __arg2);
1315+
return __arg1 > __arg2 ? __arg1 : __arg2;
13191316
}
13201317
#endif // !defined(__HIPCC_RTC__) && !defined(__OPENMP_AMDGCN__)
13211318
#endif

0 commit comments

Comments
 (0)