1.1 --- a/src/share/vm/utilities/globalDefinitions.hpp Thu May 22 11:36:23 2014 -0400 1.2 +++ b/src/share/vm/utilities/globalDefinitions.hpp Tue Jul 29 13:54:16 2014 +0200 1.3 @@ -558,6 +558,27 @@ 1.4 return fabs(value); 1.5 } 1.6 1.7 +//---------------------------------------------------------------------------------------------------- 1.8 +// Special casts 1.9 +// Cast floats into same-size integers and vice-versa w/o changing bit-pattern 1.10 +typedef union { 1.11 + jfloat f; 1.12 + jint i; 1.13 +} FloatIntConv; 1.14 + 1.15 +typedef union { 1.16 + jdouble d; 1.17 + jlong l; 1.18 + julong ul; 1.19 +} DoubleLongConv; 1.20 + 1.21 +inline jint jint_cast (jfloat x) { return ((FloatIntConv*)&x)->i; } 1.22 +inline jfloat jfloat_cast (jint x) { return ((FloatIntConv*)&x)->f; } 1.23 + 1.24 +inline jlong jlong_cast (jdouble x) { return ((DoubleLongConv*)&x)->l; } 1.25 +inline julong julong_cast (jdouble x) { return ((DoubleLongConv*)&x)->ul; } 1.26 +inline jdouble jdouble_cast (jlong x) { return ((DoubleLongConv*)&x)->d; } 1.27 + 1.28 inline jint low (jlong value) { return jint(value); } 1.29 inline jint high(jlong value) { return jint(value >> 32); } 1.30