diff --git a/pal/inc/pal.h b/pal/inc/pal.h index 981ff633672..66e3bc058c4 100644 --- a/pal/inc/pal.h +++ b/pal/inc/pal.h @@ -6411,6 +6411,7 @@ PALIMPORT double __cdecl _copysign(double, double); #if !defined(PAL_STDCPP_COMPAT) || defined(USING_PAL_STDLIB) +#ifdef PLATFORM_ACCEPTS_ABS_OVERLOAD #ifdef __cplusplus extern "C++" { @@ -6420,6 +6421,7 @@ inline __int64 abs(__int64 _X) { } #endif +#endif PALIMPORT void * __cdecl malloc(size_t); PALIMPORT void __cdecl free(void *); diff --git a/pal/src/configure.cmake b/pal/src/configure.cmake index 1771f763e5c..3b99c7de990 100644 --- a/pal/src/configure.cmake +++ b/pal/src/configure.cmake @@ -101,6 +101,21 @@ check_cxx_symbol_exists(_DEBUG sys/user.h USER_H_DEFINES_DEBUG) check_cxx_symbol_exists(_SC_PHYS_PAGES unistd.h HAVE__SC_PHYS_PAGES) check_cxx_symbol_exists(_SC_AVPHYS_PAGES unistd.h HAVE__SC_AVPHYS_PAGES) +check_cxx_source_runs(" +#include +#include + +extern \"C++\" { + inline long long abs(long long _X) { + return llabs(_X); + } +} + +int main(int argc, char **argv) { + long long X = 123456789 + argc; + printf(\"%lld\", abs(X)); + exit(0); +}" PLATFORM_ACCEPTS_ABS_OVERLOAD) check_cxx_source_runs(" #include #include diff --git a/pal/src/include/pal/palinternal.h b/pal/src/include/pal/palinternal.h index 9bbe9f4feab..0cc9eb862d9 100644 --- a/pal/src/include/pal/palinternal.h +++ b/pal/src/include/pal/palinternal.h @@ -677,4 +677,11 @@ inline T* InterlockedCompareExchangePointerT( #endif // __cplusplus +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + #endif /* _PAL_INTERNAL_H_ */