1093 //* the argument must be exactly a power of 2 1094 inline int exact_log2_long(jlong x) { 1095 assert(is_power_of_2_long(x), "x must be a power of 2: " JLONG_FORMAT, x); 1096 return log2_long(x); 1097 } 1098 1099 inline bool is_odd (intx x) { return x & 1; } 1100 inline bool is_even(intx x) { return !is_odd(x); } 1101 1102 // abs methods which cannot overflow and so are well-defined across 1103 // the entire domain of integer types. 1104 static inline unsigned int uabs(unsigned int n) { 1105 union { 1106 unsigned int result; 1107 int value; 1108 }; 1109 result = n; 1110 if (value < 0) result = 0-result; 1111 return result; 1112 } 1113 static inline unsigned long uabs(unsigned long n) { 1114 union { 1115 unsigned long result; 1116 long value; 1117 }; 1118 result = n; 1119 if (value < 0) result = 0-result; 1120 return result; 1121 } 1122 static inline unsigned long uabs(jlong n) { return uabs((unsigned long)n); } 1123 static inline unsigned int uabs(int n) { return uabs((unsigned int)n); } 1124 1125 // "to" should be greater than "from." 1126 inline intx byte_size(void* from, void* to) { 1127 return (address)to - (address)from; 1128 } 1129 1130 //---------------------------------------------------------------------------------------------------- 1131 // Avoid non-portable casts with these routines (DEPRECATED) 1132 1133 // NOTE: USE Bytes class INSTEAD WHERE POSSIBLE 1134 // Bytes is optimized machine-specifically and may be much faster then the portable routines below. 1135 1136 // Given sequence of four bytes, build into a 32-bit word 1137 // following the conventions used in class files. 1138 // On the 386, this could be realized with a simple address cast. 1139 // 1140 1141 // This routine takes eight bytes: 1142 inline u8 build_u8_from( u1 c1, u1 c2, u1 c3, u1 c4, u1 c5, u1 c6, u1 c7, u1 c8 ) { | 1093 //* the argument must be exactly a power of 2 1094 inline int exact_log2_long(jlong x) { 1095 assert(is_power_of_2_long(x), "x must be a power of 2: " JLONG_FORMAT, x); 1096 return log2_long(x); 1097 } 1098 1099 inline bool is_odd (intx x) { return x & 1; } 1100 inline bool is_even(intx x) { return !is_odd(x); } 1101 1102 // abs methods which cannot overflow and so are well-defined across 1103 // the entire domain of integer types. 1104 static inline unsigned int uabs(unsigned int n) { 1105 union { 1106 unsigned int result; 1107 int value; 1108 }; 1109 result = n; 1110 if (value < 0) result = 0-result; 1111 return result; 1112 } 1113 static inline julong uabs(julong n) { 1114 union { 1115 julong result; 1116 jlong value; 1117 }; 1118 result = n; 1119 if (value < 0) result = 0-result; 1120 return result; 1121 } 1122 static inline julong uabs(jlong n) { return uabs((julong)n); } 1123 static inline unsigned int uabs(int n) { return uabs((unsigned int)n); } 1124 1125 // "to" should be greater than "from." 1126 inline intx byte_size(void* from, void* to) { 1127 return (address)to - (address)from; 1128 } 1129 1130 //---------------------------------------------------------------------------------------------------- 1131 // Avoid non-portable casts with these routines (DEPRECATED) 1132 1133 // NOTE: USE Bytes class INSTEAD WHERE POSSIBLE 1134 // Bytes is optimized machine-specifically and may be much faster then the portable routines below. 1135 1136 // Given sequence of four bytes, build into a 32-bit word 1137 // following the conventions used in class files. 1138 // On the 386, this could be realized with a simple address cast. 1139 // 1140 1141 // This routine takes eight bytes: 1142 inline u8 build_u8_from( u1 c1, u1 c2, u1 c3, u1 c4, u1 c5, u1 c6, u1 c7, u1 c8 ) { |