src/share/vm/utilities/globalDefinitions.hpp

Print this page




1086 
1087 // bit-operations using a mask m
1088 inline void   set_bits    (intptr_t& x, intptr_t m) { x |= m; }
1089 inline void clear_bits    (intptr_t& x, intptr_t m) { x &= ~m; }
1090 inline intptr_t mask_bits      (intptr_t  x, intptr_t m) { return x & m; }
1091 inline jlong    mask_long_bits (jlong     x, jlong    m) { return x & m; }
1092 inline bool mask_bits_are_true (intptr_t flags, intptr_t mask) { return (flags & mask) == mask; }
1093 
1094 // bit-operations using the n.th bit
1095 inline void    set_nth_bit(intptr_t& x, int n) { set_bits  (x, nth_bit(n)); }
1096 inline void  clear_nth_bit(intptr_t& x, int n) { clear_bits(x, nth_bit(n)); }
1097 inline bool is_set_nth_bit(intptr_t  x, int n) { return mask_bits (x, nth_bit(n)) != NoBits; }
1098 
1099 // returns the bitfield of x starting at start_bit_no with length field_length (no sign-extension!)
1100 inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) {
1101   return mask_bits(x >> start_bit_no, right_n_bits(field_length));
1102 }
1103 
1104 
1105 //----------------------------------------------------------------------------------------------------
















1106 // Utility functions for integers
1107 
1108 // Avoid use of global min/max macros which may cause unwanted double
1109 // evaluation of arguments.
1110 #ifdef max
1111 #undef max
1112 #endif
1113 
1114 #ifdef min
1115 #undef min
1116 #endif
1117 
1118 #define max(a,b) Do_not_use_max_use_MAX2_instead
1119 #define min(a,b) Do_not_use_min_use_MIN2_instead
1120 
1121 // It is necessary to use templates here. Having normal overloaded
1122 // functions does not work because it is necessary to provide both 32-
1123 // and 64-bit overloaded functions, which does not work, and having
1124 // explicitly-typed versions of these routines (i.e., MAX2I, MAX2L)
1125 // will be even more error-prone than macros.




1086 
1087 // bit-operations using a mask m
1088 inline void   set_bits    (intptr_t& x, intptr_t m) { x |= m; }
1089 inline void clear_bits    (intptr_t& x, intptr_t m) { x &= ~m; }
1090 inline intptr_t mask_bits      (intptr_t  x, intptr_t m) { return x & m; }
1091 inline jlong    mask_long_bits (jlong     x, jlong    m) { return x & m; }
1092 inline bool mask_bits_are_true (intptr_t flags, intptr_t mask) { return (flags & mask) == mask; }
1093 
1094 // bit-operations using the n.th bit
1095 inline void    set_nth_bit(intptr_t& x, int n) { set_bits  (x, nth_bit(n)); }
1096 inline void  clear_nth_bit(intptr_t& x, int n) { clear_bits(x, nth_bit(n)); }
1097 inline bool is_set_nth_bit(intptr_t  x, int n) { return mask_bits (x, nth_bit(n)) != NoBits; }
1098 
1099 // returns the bitfield of x starting at start_bit_no with length field_length (no sign-extension!)
1100 inline intptr_t bitfield(intptr_t x, int start_bit_no, int field_length) {
1101   return mask_bits(x >> start_bit_no, right_n_bits(field_length));
1102 }
1103 
1104 
1105 //----------------------------------------------------------------------------------------------------
1106 // Utility functions for characters
1107 
1108 // isblank() in ctype.h only includes space and tab.
1109 // iswhite() includes space, tab, new-line, vertical-tab, formfeed,
1110 // carrage-return. This larger set of characters might be found in a
1111 // text file.
1112 #define iswhite(c) \
1113   ((c == ' ')  || \
1114    (c == '\t') || \
1115    (c == '\n') || \
1116    (c == '\v') || \
1117    (c == '\f') || \
1118    (c == '\r'))
1119 
1120 
1121 //----------------------------------------------------------------------------------------------------
1122 // Utility functions for integers
1123 
1124 // Avoid use of global min/max macros which may cause unwanted double
1125 // evaluation of arguments.
1126 #ifdef max
1127 #undef max
1128 #endif
1129 
1130 #ifdef min
1131 #undef min
1132 #endif
1133 
1134 #define max(a,b) Do_not_use_max_use_MAX2_instead
1135 #define min(a,b) Do_not_use_min_use_MIN2_instead
1136 
1137 // It is necessary to use templates here. Having normal overloaded
1138 // functions does not work because it is necessary to provide both 32-
1139 // and 64-bit overloaded functions, which does not work, and having
1140 // explicitly-typed versions of these routines (i.e., MAX2I, MAX2L)
1141 // will be even more error-prone than macros.