--- a/JavaNativeMethodImpl_OpenJDK6.st Thu Nov 14 12:06:15 2013 +0000
+++ b/JavaNativeMethodImpl_OpenJDK6.st Thu Nov 14 23:24:02 2013 +0000
@@ -10072,7 +10072,7 @@
"Modified: / 09-02-2012 / 22:56:37 / mh <hlopik@gmail.com>"
!
-_java_lang_Double_doubleToRawLongBits: this _:a1 _: a2
+_java_lang_Double_doubleToRawLongBits: this _: d _: ignored
<javanative: 'java/lang/Double' name: 'doubleToRawLongBits(D)J'>
@@ -10114,76 +10114,78 @@
* @since 1.3
*/
"
- | f b |
- f := a1.
- (f = 0.0) ifTrue:[^0].
- (f = -0.0) ifTrue:[^(1 bitShift: 63)].
-
- b := ByteArray streamContents:[:s|Float storeBinaryIEEEDouble:f on:s MSB: UninterpretedBytes isBigEndian].
- ^ LargeInteger digitBytes: b MSB: UninterpretedBytes isBigEndian.
-
-
-"/ | f |
-"/ f := nativeContext argAt:1.
-"/ f class == Float ifFalse:[ ^self throwIllegalArgumentException: 'Not a float'].
-"/%{
-"/ __int64__ *i = &(__floatVal(f));
-"/ RETURN (__MKINT64( i ));
-"/%}.
-"/ self primitiveFailed.
+"/ | b |
+"/
+"/ (d = 0.0) ifTrue:[^0].
+"/ (d = -0.0) ifTrue:[^(1 bitShift: 63)].
+"/
+"/ b := ByteArray streamContents:[:s|Float storeBinaryIEEEDouble:d on:s MSB: UninterpretedBytes isBigEndian].
+"/ ^ LargeInteger digitBytes: b MSB: UninterpretedBytes isBigEndian.
+
+
+"/ d class == Float ifFalse:[ ^self throwIllegalArgumentException: 'Not a double'].
+%{
+ union {
+ double d;
+ __int64__ l;
+ } u;
+ u.d = __floatVal(d);
+ RETURN ( __MKINT64( &(u.l) ) );
+%}.
+ self primitiveFailed.
"Created: / 10-11-2010 / 14:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 16-12-2012 / 23:23:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_java_lang_Double_longBitsToDouble: this _:a1 _: a2
+ "Modified: / 14-11-2013 / 00:09:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+
+!
+
+_java_lang_Double_longBitsToDouble: this _:i _: a2
<javanative: 'java/lang/Double' name: 'longBitsToDouble(J)D'>
- |i aFloat|
-
- i := a1.
-
- aFloat := Float new.
- UninterpretedBytes isBigEndian ifTrue:[
- aFloat basicAt:1 put:((i bitShift:-56) bitAnd:16rFF).
- aFloat basicAt:2 put:((i bitShift:-48) bitAnd:16rFF).
- aFloat basicAt:3 put:((i bitShift:-40) bitAnd:16rFF).
- aFloat basicAt:4 put:((i bitShift:-32) bitAnd:16rFF).
- aFloat basicAt:5 put:((i bitShift:-24) bitAnd:16rFF).
- aFloat basicAt:6 put:((i bitShift:-16) bitAnd:16rFF).
- aFloat basicAt:7 put:((i bitShift:-8) bitAnd:16rFF).
- aFloat basicAt:8 put:(i bitAnd:16rFF).
- ] ifFalse:[
- aFloat basicAt:1 put:(i bitAnd:16rFF).
- aFloat basicAt:2 put:((i bitShift:-8) bitAnd:16rFF).
- aFloat basicAt:3 put:((i bitShift:-16) bitAnd:16rFF).
- aFloat basicAt:4 put:((i bitShift:-24) bitAnd:16rFF).
- aFloat basicAt:5 put:((i bitShift:-32) bitAnd:16rFF).
- aFloat basicAt:6 put:((i bitShift:-40) bitAnd:16rFF).
- aFloat basicAt:7 put:((i bitShift:-48) bitAnd:16rFF).
- aFloat basicAt:8 put:((i bitShift:-56) bitAnd:16rFF).
- ].
-
- ^ aFloat.
-
-
-"/ | i f|
+"/ | aFloat|
"/
-"/ i := nativeContext argAt:1.
-"/ f := Float new.
-"/%{
-"/ long long l;
-"/ l = __longIntVal(i);
-"/ double *d = &l;
-"/ __floatVal(f) = *d;
-"/%}.
-"/ ^f
-
- "Modified: / 16-12-2012 / 23:24:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_java_lang_Float_floatToRawIntBits: this _:a1
+"/ aFloat := Float new.
+"/ UninterpretedBytes isBigEndian ifTrue:[
+"/ aFloat basicAt:1 put:((i bitShift:-56) bitAnd:16rFF).
+"/ aFloat basicAt:2 put:((i bitShift:-48) bitAnd:16rFF).
+"/ aFloat basicAt:3 put:((i bitShift:-40) bitAnd:16rFF).
+"/ aFloat basicAt:4 put:((i bitShift:-32) bitAnd:16rFF).
+"/ aFloat basicAt:5 put:((i bitShift:-24) bitAnd:16rFF).
+"/ aFloat basicAt:6 put:((i bitShift:-16) bitAnd:16rFF).
+"/ aFloat basicAt:7 put:((i bitShift:-8) bitAnd:16rFF).
+"/ aFloat basicAt:8 put:(i bitAnd:16rFF).
+"/ ] ifFalse:[
+"/ aFloat basicAt:1 put:(i bitAnd:16rFF).
+"/ aFloat basicAt:2 put:((i bitShift:-8) bitAnd:16rFF).
+"/ aFloat basicAt:3 put:((i bitShift:-16) bitAnd:16rFF).
+"/ aFloat basicAt:4 put:((i bitShift:-24) bitAnd:16rFF).
+"/ aFloat basicAt:5 put:((i bitShift:-32) bitAnd:16rFF).
+"/ aFloat basicAt:6 put:((i bitShift:-40) bitAnd:16rFF).
+"/ aFloat basicAt:7 put:((i bitShift:-48) bitAnd:16rFF).
+"/ aFloat basicAt:8 put:((i bitShift:-56) bitAnd:16rFF).
+"/ ].
+"/
+"/ ^ aFloat.
+
+
+ | f |
+
+ f := Float new.
+%{
+ union {
+ double d;
+ __int64__ l;
+ } u;
+ __signedLong64IntVal(i, &(u.l));
+ __floatVal(f) = u.d;
+%}.
+ ^f
+
+ "Modified: / 14-11-2013 / 20:05:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Float_floatToRawIntBits: this _:f
<javanative: 'java/lang/Float' name: 'floatToRawIntBits(F)I'>
@@ -10224,35 +10226,38 @@
* @since 1.3
*/
"
- | f b |
- f := a1.
- f class == ShortFloat ifFalse:[ Reflection throwIllegalArgumentException:'Not a float'].
%{
- int *ival = &__shortFloatVal(f);
- RETURN (__MKINT(*ival));
-%}.
+ union {
+ float f;
+ INT i;
+ } u;
+ u.f = __shortFloatVal(f);
+ RETURN ( __MKINT( u.i ) );
+%}.
self primitiveFailed.
"Created: / 09-11-2010 / 20:59:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 16-12-2012 / 11:16:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-_java_lang_Float_intBitsToFloat: this _:a1
+ "Modified: / 14-11-2013 / 23:11:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+_java_lang_Float_intBitsToFloat: this _: ii
<javanative: 'java/lang/Float' name: 'intBitsToFloat(I)F'>
- | i f|
-
- i := a1.
- f := ShortFloat new.
+ | ff |
+
+ ff := ShortFloat new.
%{
- int ival = __intVal(i);
- float *fval = &ival;
- __shortFloatVal(f) = *fval;
+ union {
+ float f;
+ INT i;
+ } u;
+ u.i = __signedLongIntVal(ii);
+ __shortFloatVal(ff) = u.f;
%}.
- ^f
-
- "Modified: / 16-12-2012 / 10:39:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ ^ff
+
+ "Modified: / 14-11-2013 / 23:07:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_lang_Object_clone: this