< prev index next >

src/share/vm/utilities/globalDefinitions.hpp

Print this page
rev 9439 : imported patch further-jon-reviews


 548 
 549 
 550 //----------------------------------------------------------------------------------------------------
 551 // Utility macros for compilers
 552 // used to silence compiler warnings
 553 
 554 #define Unused_Variable(var) var
 555 
 556 
 557 //----------------------------------------------------------------------------------------------------
 558 // Miscellaneous
 559 
 560 // 6302670 Eliminate Hotspot __fabsf dependency
 561 // All fabs() callers should call this function instead, which will implicitly
 562 // convert the operand to double, avoiding a dependency on __fabsf which
 563 // doesn't exist in early versions of Solaris 8.
 564 inline double fabsd(double value) {
 565   return fabs(value);
 566 }
 567 







 568 //----------------------------------------------------------------------------------------------------
 569 // Special casts
 570 // Cast floats into same-size integers and vice-versa w/o changing bit-pattern
 571 typedef union {
 572   jfloat f;
 573   jint i;
 574 } FloatIntConv;
 575 
 576 typedef union {
 577   jdouble d;
 578   jlong l;
 579   julong ul;
 580 } DoubleLongConv;
 581 
 582 inline jint    jint_cast    (jfloat  x)  { return ((FloatIntConv*)&x)->i; }
 583 inline jfloat  jfloat_cast  (jint    x)  { return ((FloatIntConv*)&x)->f; }
 584 
 585 inline jlong   jlong_cast   (jdouble x)  { return ((DoubleLongConv*)&x)->l;  }
 586 inline julong  julong_cast  (jdouble x)  { return ((DoubleLongConv*)&x)->ul; }
 587 inline jdouble jdouble_cast (jlong   x)  { return ((DoubleLongConv*)&x)->d;  }




 548 
 549 
 550 //----------------------------------------------------------------------------------------------------
 551 // Utility macros for compilers
 552 // used to silence compiler warnings
 553 
 554 #define Unused_Variable(var) var
 555 
 556 
 557 //----------------------------------------------------------------------------------------------------
 558 // Miscellaneous
 559 
 560 // 6302670 Eliminate Hotspot __fabsf dependency
 561 // All fabs() callers should call this function instead, which will implicitly
 562 // convert the operand to double, avoiding a dependency on __fabsf which
 563 // doesn't exist in early versions of Solaris 8.
 564 inline double fabsd(double value) {
 565   return fabs(value);
 566 }
 567 
 568 // Returns numerator/denominator as percentage value from 0 to 100. If denominator
 569 // is zero, return 0.0.
 570 template<typename T>
 571 inline double percent_of(T numerator, T denominator) {
 572   return denominator != 0 ? (double)numerator / denominator * 100.0 : 0.0;
 573 }
 574 
 575 //----------------------------------------------------------------------------------------------------
 576 // Special casts
 577 // Cast floats into same-size integers and vice-versa w/o changing bit-pattern
 578 typedef union {
 579   jfloat f;
 580   jint i;
 581 } FloatIntConv;
 582 
 583 typedef union {
 584   jdouble d;
 585   jlong l;
 586   julong ul;
 587 } DoubleLongConv;
 588 
 589 inline jint    jint_cast    (jfloat  x)  { return ((FloatIntConv*)&x)->i; }
 590 inline jfloat  jfloat_cast  (jint    x)  { return ((FloatIntConv*)&x)->f; }
 591 
 592 inline jlong   jlong_cast   (jdouble x)  { return ((DoubleLongConv*)&x)->l;  }
 593 inline julong  julong_cast  (jdouble x)  { return ((DoubleLongConv*)&x)->ul; }
 594 inline jdouble jdouble_cast (jlong   x)  { return ((DoubleLongConv*)&x)->d;  }


< prev index next >