summaryrefslogtreecommitdiff
path: root/vm/reference
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2003-07-16 12:21:07 +0000
committerMark Wielaard <mark@klomp.org>2003-07-16 12:21:07 +0000
commit4add1720a6c40699717b90347f457dbb9e635662 (patch)
tree7b1d71ebcfe4283103d56156eaae372c2533a030 /vm/reference
parentf2aa63a2800d793a3664f54ff3b0e3a33f1206cd (diff)
downloadclasspath-4add1720a6c40699717b90347f457dbb9e635662.tar.gz
2003-07-16 David Grove <groved@us.ibm.com
* java/lang/Double.java (doubleToLongBits): No longer native, delegates to VMDouble. (doubleToRawLongBits): Likewise. (longBitsToDouble): Likewise. * java/lang/Float.java (static): Moved to VMFloat. (floatToIntBits) No longer native, delegates to VMFloat. (floatToRawIntBits): Likewise. (intBitsToFloat): Likewise. * vm/reference/java/lang/VMDouble.java: New class. * vm/reference/java/lang/VMFloat.java: New class. * native/jni/java-lang/Makefile.am (libjavalang_la_SOURCES): Remove java_lang_Float.c, add java_lang_VMFloat.c and java_lang_VMDouble.c. * native/jni/java-lang/java_lang_Double.c (doubleToLongBits): Removed, moved to java_lang_VMDouble.c. (doubleToRawLongBits): Likewise. (longBitsToDouble): Likewise. * native/jni/java-lang/java_lang_Float.c: Removed file. * native/jni/java-lang/java_lang_VMDouble.c: New file. * native/jni/java-lang/java_lang_VMFloat.c: New file. * include/java_lang_Double.h: Regenerated. * include/java_lang_Float.h: Removed. * include/java_lang_VMDouble.h: New file. * include/java_lang_VMFloat.h: New file. * NEWS: Describe new VM Float/Double conversion methods.
Diffstat (limited to 'vm/reference')
-rw-r--r--vm/reference/java/lang/VMDouble.java114
-rw-r--r--vm/reference/java/lang/VMFloat.java111
2 files changed, 225 insertions, 0 deletions
diff --git a/vm/reference/java/lang/VMDouble.java b/vm/reference/java/lang/VMDouble.java
new file mode 100644
index 000000000..29d74beb0
--- /dev/null
+++ b/vm/reference/java/lang/VMDouble.java
@@ -0,0 +1,114 @@
+/* VMDouble.java -- VM Specific Double methods
+ Copyright (C) 2003 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang;
+
+import gnu.classpath.Configuration;
+
+/*
+ * This class is a reference version, mainly for compiling a class library
+ * jar. It is likely that VM implementers replace this with their own
+ * version that can communicate effectively with the VM.
+ */
+
+/**
+ * Code relocated from java.lang.Double by
+ * @author Dave Grove <groved@us.ibm.com>
+ */
+final class VMDouble
+{
+
+ /**
+ * Load native routines necessary for this class.
+ */
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
+ System.loadLibrary("javalang");
+ }
+ }
+
+ /**
+ * Convert the double to the IEEE 754 floating-point "double format" bit
+ * layout. Bit 63 (the most significant) is the sign bit, bits 62-52
+ * (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
+ * (masked by 0x000fffffffffffffL) are the mantissa. This function
+ * collapses all versions of NaN to 0x7ff8000000000000L. The result of this
+ * function can be used as the argument to
+ * <code>Double.longBitsToDouble(long)</code> to obtain the original
+ * <code>double</code> value.
+ *
+ * @param value the <code>double</code> to convert
+ * @return the bits of the <code>double</code>
+ * @see #longBitsToDouble(long)
+ */
+ public static native long doubleToLongBits(double value);
+
+ /**
+ * Convert the double to the IEEE 754 floating-point "double format" bit
+ * layout. Bit 63 (the most significant) is the sign bit, bits 62-52
+ * (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0
+ * (masked by 0x000fffffffffffffL) are the mantissa. This function
+ * leaves NaN alone, rather than collapsing to a canonical value. The
+ * result of this function can be used as the argument to
+ * <code>Double.longBitsToDouble(long)</code> to obtain the original
+ * <code>double</code> value.
+ *
+ * @param value the <code>double</code> to convert
+ * @return the bits of the <code>double</code>
+ * @see #longBitsToDouble(long)
+ */
+ public static native long doubleToRawLongBits(double value);
+
+ /**
+ * Convert the argument in IEEE 754 floating-point "double format" bit
+ * layout to the corresponding float. Bit 63 (the most significant) is the
+ * sign bit, bits 62-52 (masked by 0x7ff0000000000000L) represent the
+ * exponent, and bits 51-0 (masked by 0x000fffffffffffffL) are the mantissa.
+ * This function leaves NaN alone, so that you can recover the bit pattern
+ * with <code>Double.doubleToRawLongBits(double)</code>.
+ *
+ * @param bits the bits to convert
+ * @return the <code>double</code> represented by the bits
+ * @see #doubleToLongBits(double)
+ * @see #doubleToRawLongBits(double)
+ */
+ public static native double longBitsToDouble(long bits);
+
+
+} // class VMDouble
diff --git a/vm/reference/java/lang/VMFloat.java b/vm/reference/java/lang/VMFloat.java
new file mode 100644
index 000000000..59301c16d
--- /dev/null
+++ b/vm/reference/java/lang/VMFloat.java
@@ -0,0 +1,111 @@
+/* VMFloat.java -- VM Specific Float methods
+ Copyright (C) 2003 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang;
+
+import gnu.classpath.Configuration;
+
+/*
+ * This class is a reference version, mainly for compiling a class library
+ * jar. It is likely that VM implementers replace this with their own
+ * version that can communicate effectively with the VM.
+ */
+
+/**
+ * Code relocated from java.lang.Float by
+ * @author Dave Grove <groved@us.ibm.com>
+ */
+final class VMFloat
+{
+
+ /**
+ * Load native routines necessary for this class.
+ */
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
+ System.loadLibrary("javalang");
+ }
+ }
+
+ /**
+ * Convert the float to the IEEE 754 floating-point "single format" bit
+ * layout. Bit 31 (the most significant) is the sign bit, bits 30-23
+ * (masked by 0x7f800000) represent the exponent, and bits 22-0
+ * (masked by 0x007fffff) are the mantissa. This function collapses all
+ * versions of NaN to 0x7fc00000. The result of this function can be used
+ * as the argument to <code>Float.intBitsToFloat(int)</code> to obtain the
+ * original <code>float</code> value.
+ *
+ * @param value the <code>float</code> to convert
+ * @return the bits of the <code>float</code>
+ * @see #intBitsToFloat(int)
+ */
+ static native int floatToIntBits(float value);
+
+ /**
+ * Convert the float to the IEEE 754 floating-point "single format" bit
+ * layout. Bit 31 (the most significant) is the sign bit, bits 30-23
+ * (masked by 0x7f800000) represent the exponent, and bits 22-0
+ * (masked by 0x007fffff) are the mantissa. This function leaves NaN alone,
+ * rather than collapsing to a canonical value. The result of this function
+ * can be used as the argument to <code>Float.intBitsToFloat(int)</code> to
+ * obtain the original <code>float</code> value.
+ *
+ * @param value the <code>float</code> to convert
+ * @return the bits of the <code>float</code>
+ * @see #intBitsToFloat(int)
+ */
+ static native int floatToRawIntBits(float value);
+
+ /**
+ * Convert the argument in IEEE 754 floating-point "single format" bit
+ * layout to the corresponding float. Bit 31 (the most significant) is the
+ * sign bit, bits 30-23 (masked by 0x7f800000) represent the exponent, and
+ * bits 22-0 (masked by 0x007fffff) are the mantissa. This function leaves
+ * NaN alone, so that you can recover the bit pattern with
+ * <code>Float.floatToRawIntBits(float)</code>.
+ *
+ * @param bits the bits to convert
+ * @return the <code>float</code> represented by the bits
+ * @see #floatToIntBits(float)
+ * @see #floatToRawIntBits(float)
+ */
+ static native float intBitsToFloat(int bits);
+
+} // class VMFloat