This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Trying to merge java.lang.Float, java.lang.Double with Classpath -- help wanted


This was an attempt to merge java.lang.Float and java.lang.Double with
Classpath.  It didn't work, though.  I get:

In file included from ../../../gcc-main/libjava/java/lang/natVMDouble.cc:13:
./java/lang/VMDouble.h:10: error: qualified name does not name a class
../../../gcc-main/libjava/java/lang/natVMDouble.cc:23: error: `java::lang::VMDouble' is not a class-name or namespace-name
../../../gcc-main/libjava/java/lang/natVMDouble.cc:38: error: `java::lang::VMDouble' is not a class-name or namespace-name
../../../gcc-main/libjava/java/lang/natVMDouble.cc:46: error: `java::lang::VMDouble' is not a class-name or namespace-name
make[2]: *** [java/lang/natVMDouble.lo] Error 1

And a similar error for natVMFloat.lo.  Any ideas on how to fix this?
It makes no sense whatsoever to me.

There's also an automake issue mentioned below.

2003-09-21  Nathanael Nerode <neroden@gcc.gnu.org>

	* Makefile.am: Add VMDouble.java, VMFloat.java, natVMDouble.cc,
	natVMFloat.cc; remove natFloat.cc.
	* Makefile.in: Regenerate.
	* java/lang/VMDouble.java: New class, adapted from Classpath's
	vm/reference/java/lang/VMDouble.java.
	* java/lang/VMFloat.java: New class, adapted from Classpath's
	vm/reference/java/lang/VMFloat.java.
	* java/lang/natFloat.cc: Moved to natVMFloat.cc.
	* java/lang/natVMFloat.cc: Moved from natFloat.cc and modified
	appropriately.
	* java/lang/natVMDouble.cc: New file, consisting of methods
	pulled from natDouble.cc and modified appropriately.
	* java/lang/natDouble.cc: Removed methods present in natVMDouble.cc.

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.
	
	(merged from Classpath on 2003-09-21 by Nathanael Nerode)

---
I have an automake problem here:  Regenerating using the 'gcj special' automake
gives the following apparently spurious difference in all the Makefile.in
files, in all subdirs:
-TAR = gtar
+TAR = tar

It also gives the following change to Makefile.in:
-THANKS acinclude.m4 aclocal.m4 config.guess config.sub configure \
-configure.in install-sh libgcj-test.spec.in libgcj.pc.in libgcj.spec.in \
-ltmain.sh missing mkinstalldirs
+THANKS acinclude.m4 aclocal.m4 configure configure.in \
+libgcj-test.spec.in libgcj.pc.in libgcj.spec.in

These don't seem to be anything to do with me.  The second change seems
definitely correct, as well, but the first change is mystifying.

Incidentally, when can we switch to a more normal version of automake?
Furthermore, now that GNU Make is required, is automake even necessary?
---

Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.324
diff -u -r1.324 Makefile.am
--- Makefile.am	19 Sep 2003 21:12:57 -0000	1.324
+++ Makefile.am	21 Sep 2003 19:25:08 -0000
@@ -1837,6 +1837,8 @@
 java/lang/VerifyError.java \
 java/lang/VirtualMachineError.java \
 java/lang/VMClassLoader.java \
+java/lang/VMDouble.java \
+java/lang/VMFloat.java \
 java/lang/VMSecurityManager.java \
 java/lang/VMThrowable.java \
 java/lang/Void.java \
@@ -2653,7 +2655,6 @@
 java/lang/natClassLoader.cc \
 java/lang/natConcreteProcess.cc \
 java/lang/natDouble.cc \
-java/lang/natFloat.cc \
 java/lang/natMath.cc \
 java/lang/natObject.cc \
 java/lang/natRuntime.cc	\
@@ -2661,6 +2662,8 @@
 java/lang/natStringBuffer.cc \
 java/lang/natSystem.cc \
 java/lang/natThread.cc \
+java/lang/natVMDouble.cc \
+java/lang/natVMFloat.cc \
 java/lang/natVMSecurityManager.cc \
 java/lang/ref/natReference.cc \
 java/lang/reflect/natArray.cc \
Index: java/lang/Double.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/Double.java,v
retrieving revision 1.17
diff -u -r1.17 Double.java
--- java/lang/Double.java	3 Nov 2002 20:27:30 -0000	1.17
+++ java/lang/Double.java	21 Sep 2003 19:25:21 -0000
@@ -1,5 +1,6 @@
 /* Double.java -- object wrapper for double
-   Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+   Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -35,7 +36,6 @@
 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;
@@ -428,7 +428,10 @@
    * @return the bits of the <code>double</code>
    * @see #longBitsToDouble(long)
    */
-  public static native long doubleToLongBits(double value);
+  public static long doubleToLongBits(double value)
+  {
+    return VMDouble.doubleToLongBits(value);
+  }
 
   /**
    * Convert the double to the IEEE 754 floating-point "double format" bit
@@ -444,7 +447,10 @@
    * @return the bits of the <code>double</code>
    * @see #longBitsToDouble(long)
    */
-  public static native long doubleToRawLongBits(double value);
+  public static long doubleToRawLongBits(double value)
+  {
+    return VMDouble.doubleToRawLongBits(value);
+  }
 
   /**
    * Convert the argument in IEEE 754 floating-point "double format" bit
@@ -459,7 +465,10 @@
    * @see #doubleToLongBits(double)
    * @see #doubleToRawLongBits(double)
    */
-  public static native double longBitsToDouble(long bits);
+  public static double longBitsToDouble(long bits)
+  {
+    return VMDouble.longBitsToDouble(bits);
+  }
 
   /**
    * Compare two Doubles numerically by comparing their <code>double</code>
Index: java/lang/Float.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/Float.java,v
retrieving revision 1.14
diff -u -r1.14 Float.java
--- java/lang/Float.java	13 Jun 2002 18:16:25 -0000	1.14
+++ java/lang/Float.java	21 Sep 2003 19:25:24 -0000
@@ -1,5 +1,6 @@
 /* Float.java -- object wrapper for float
-   Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+   Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,8 +39,6 @@
 
 package java.lang;
 
-import gnu.classpath.Configuration;
-
 /**
  * Instances of class <code>Float</code> represent primitive
  * <code>float</code> values.
@@ -102,17 +101,6 @@
   private final float value;
 
   /**
-   * Load native routines necessary for this class.
-   */
-  static
-  {
-    if (Configuration.INIT_LOAD_LIBRARY)
-      {
-        System.loadLibrary("javalang");
-      }
-  }
-
-  /**
    * Create a <code>Float</code> from the primitive <code>float</code>
    * specified.
    *
@@ -438,7 +426,10 @@
    * @return the bits of the <code>float</code>
    * @see #intBitsToFloat(int)
    */
-  public static native int floatToIntBits(float value);
+  public static int floatToIntBits(float value)
+  {
+    return VMFloat.floatToIntBits(value);
+  }
 
   /**
    * Convert the float to the IEEE 754 floating-point "single format" bit
@@ -453,7 +444,10 @@
    * @return the bits of the <code>float</code>
    * @see #intBitsToFloat(int)
    */
-  public static native int floatToRawIntBits(float value);
+  public static int floatToRawIntBits(float value)
+  {
+    return VMFloat.floatToRawIntBits(value);
+  }
 
   /**
    * Convert the argument in IEEE 754 floating-point "single format" bit
@@ -468,7 +462,10 @@
    * @see #floatToIntBits(float)
    * @see #floatToRawIntBits(float)
    */
-  public static native float intBitsToFloat(int bits);
+  public static float intBitsToFloat(int bits)
+  {
+    return VMFloat.intBitsToFloat(bits);
+  }
 
   /**
    * Compare two Floats numerically by comparing their <code>float</code>
Index: java/lang/natDouble.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natDouble.cc,v
retrieving revision 1.16
diff -u -r1.16 natDouble.cc
--- java/lang/natDouble.cc	15 Apr 2002 03:11:12 -0000	1.16
+++ java/lang/natDouble.cc	21 Sep 2003 19:25:29 -0000
@@ -24,43 +24,6 @@
 
 #include "fdlibm.h"
 
-union u
-{
-  jlong l;
-  jdouble d;
-};
-
-jlong 
-java::lang::Double::doubleToLongBits(jdouble value)
-{
-  union u u;
-  u.d = value;
-  
-  jlong e = u.l & 0x7ff0000000000000LL;
-  jlong f = u.l & 0x000fffffffffffffLL;
-
-  if (e == 0x7ff0000000000000LL && f != 0L)
-    u.l = 0x7ff8000000000000LL;
-
-  return u.l;
-}
-
-jlong 
-java::lang::Double::doubleToRawLongBits(jdouble value)
-{
-  union u u;
-  u.d = value;
-  return u.l;
-}
-
-jdouble 
-java::lang::Double::longBitsToDouble(jlong bits)
-{
-  union u u;
-  u.l = bits;
-  return u.d;
-}
-
 jstring 
 java::lang::Double::toString(jdouble value, jboolean isFloat)
 {
Index: java/lang/natFloat.cc
===================================================================
RCS file: java/lang/natFloat.cc
diff -N java/lang/natFloat.cc
--- java/lang/natFloat.cc	9 Feb 2001 22:13:33 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,51 +0,0 @@
-// natFloat.cc - Implementation of java.lang.Float native methods.
-
-/* Copyright (C) 1998, 1999, 2001  Free Software Foundation
-
-   This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
-details.  */
-
-#include <config.h>
-
-#include <java/lang/Float.h>
-#include <jvm.h>
-
-union u
-{
-  jint l;
-  jfloat d;
-};
-
-jint 
-java::lang::Float::floatToIntBits(jfloat value)
-{
-  union u u;
-  u.d = value;
-  jint e = u.l & 0x7f800000;
-  jint f = u.l & 0x007fffff;
-
-  if (e == 0x7f800000 && f != 0)
-    u.l = 0x7fc00000;
-
-  return u.l;
-}
-
-jint 
-java::lang::Float::floatToRawIntBits(jfloat value)
-{
-  union u u;
-  u.d = value;  
-  return u.l;
-}
-
-jfloat 
-java::lang::Float::intBitsToFloat(jint bits)
-{
-  union u u;
-  u.l = bits;
-  return u.d;
-}
-
Index: java/lang/natVMDouble.cc
===================================================================
RCS file: java/lang/natVMDouble.cc
diff -N java/lang/natVMDouble.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ java/lang/natVMDouble.cc	21 Sep 2003 19:25:29 -0000
@@ -0,0 +1,51 @@
+// natVMDouble.cc - Implementation of java.lang.VMDouble native methods.
+
+/* Copyright (C) 1998, 1999, 2000, 2001, 2003  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#include <config.h>
+
+#include <java/lang/VMDouble.h>
+#include <jvm.h>
+
+union u
+{
+  jlong l;
+  jdouble d;
+};
+
+jlong 
+java::lang::VMDouble::doubleToLongBits(jdouble value)
+{
+  union u u;
+  u.d = value;
+  
+  jlong e = u.l & 0x7ff0000000000000LL;
+  jlong f = u.l & 0x000fffffffffffffLL;
+
+  if (e == 0x7ff0000000000000LL && f != 0L)
+    u.l = 0x7ff8000000000000LL;
+
+  return u.l;
+}
+
+jlong 
+java::lang::VMDouble::doubleToRawLongBits(jdouble value)
+{
+  union u u;
+  u.d = value;
+  return u.l;
+}
+
+jdouble 
+java::lang::VMDouble::longBitsToDouble(jlong bits)
+{
+  union u u;
+  u.l = bits;
+  return u.d;
+}
Index: java/lang/natVMFloat.cc
===================================================================
RCS file: java/lang/natVMFloat.cc
diff -N java/lang/natVMFloat.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ java/lang/natVMFloat.cc	21 Sep 2003 19:25:29 -0000
@@ -0,0 +1,51 @@
+// natVMFloat.cc - Implementation of java.lang.VMFloat native methods.
+
+/* Copyright (C) 1998, 1999, 2001, 2003  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#include <config.h>
+
+#include <java/lang/VMFloat.h>
+#include <jvm.h>
+
+union u
+{
+  jint l;
+  jfloat d;
+};
+
+jint 
+java::lang::VMFloat::floatToIntBits(jfloat value)
+{
+  union u u;
+  u.d = value;
+  jint e = u.l & 0x7f800000;
+  jint f = u.l & 0x007fffff;
+
+  if (e == 0x7f800000 && f != 0)
+    u.l = 0x7fc00000;
+
+  return u.l;
+}
+
+jint 
+java::lang::VMFloat::floatToRawIntBits(jfloat value)
+{
+  union u u;
+  u.d = value;  
+  return u.l;
+}
+
+jfloat 
+java::lang::VMFloat::intBitsToFloat(jint bits)
+{
+  union u u;
+  u.l = bits;
+  return u.d;
+}
+
Index: java/lang/VMFloat.java
===================================================================
RCS file: java/lang/VMFloat.java
diff -N java/lang/VMFloat.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ java/lang/VMFloat.java	21 Sep 2003 20:22:33 -0000
@@ -0,0 +1,105 @@
+/* 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;
+
+/**
+ * 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
Index: java/lang/VMDouble.java
===================================================================
RCS file: java/lang/VMDouble.java
diff -N java/lang/VMDouble.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ java/lang/VMDouble.java	21 Sep 2003 20:22:40 -0000
@@ -0,0 +1,108 @@
+/* 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;
+
+/**
+ * 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

-- 
Nathanael Nerode  <neroden at gcc.gnu.org>
http://home.twcny.rr.com/nerode/neroden/fdl.html


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]