Open sendaoYan opened 3 days ago
diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp
index c71df9bf52c..cb204a7b92b 100644
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp
@@ -1141,9 +1141,6 @@ inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) {
#undef min
#endif
-#define max(a,b) Do_not_use_max_use_MAX2_instead
-#define min(a,b) Do_not_use_min_use_MIN2_instead
-
// It is necessary to use templates here. Having normal overloaded
// functions does not work because it is necessary to provide both 32-
// and 64-bit overloaded functions, which does not work, and having
@@ -1158,6 +1155,13 @@ template<class T> inline T MIN4(T a, T b, T c, T d) { return MIN2(MIN3(a, b, c),
template<class T> inline T ABS(T x) { return (x > 0) ? x : -x; }
+// Return the given value clamped to the range [min ... max]
+template<typename T>
+inline T clamp(T value, T min, T max) {
+ assert(min <= max, "must be");
+ return MIN2(MAX2(value, min), max);
+}
+
// true if x is a power of 2, false otherwise
inline bool is_power_of_2(intptr_t x) {
return ((x != NoBits) && (mask_bits(x, x - 1) == NoBits));
build-precompiled.log make-riscv64.log make-fastdebug-aarch64.log make-fastdebug-x86_64.log make-release-aarch64.log make-release-x86_64.log make-slowdebug-aarch64.log make-slowdebug-x86_64.log