From 463c03f1bc2380d46a39e63efd00df157a18fee2 Mon Sep 17 00:00:00 2001 From: Gary Benson Date: Thu, 18 Jan 2007 11:32:40 +0000 Subject: natVMPipeEcos.cc: Renamed from gnu/java/nio/natPipeImplEcos.cc. 2007-01-18 Gary Benson * gnu/java/nio/natVMPipeEcos.cc: Renamed from gnu/java/nio/natPipeImplEcos.cc. * gnu/java/nio/natVMPipePosix.cc: Renamed from gnu/java/nio/natPipeImplPosix.cc. * gnu/java/nio/natVMPipeWin32.cc: Renamed from gnu/java/nio/natPipeImplWin32.cc. * gnu/java/nio/natVMSelectorEcos.cc: Renamed from gnu/java/nio/natSelectorImplEcos.cc. * gnu/java/nio/natVMSelectorPosix.cc: Renamed from gnu/java/nio/natSelectorImplPosix.cc. * gnu/java/nio/natVMSelectorWin32.cc: Renamed from gnu/java/nio/natSelectorImplWin32.cc. * java/io/natVMObjectInputStream.cc: Renamed from java/io/natObjectInputStream.cc. * java/lang/natVMDouble.cc: Renamed from java/lang/natDouble.cc. * java/lang/natVMFloat.cc: Renamed from java/lang/natFloat.cc. * Makefile.am, configure.ac: Reflect the above. * Makefile.in, configure: Rebuilt. From-SVN: r120895 --- libjava/java/io/natObjectInputStream.cc | 70 ---------- libjava/java/io/natVMObjectInputStream.cc | 71 ++++++++++ libjava/java/lang/natDouble.cc | 214 ----------------------------- libjava/java/lang/natFloat.cc | 52 -------- libjava/java/lang/natVMDouble.cc | 215 ++++++++++++++++++++++++++++++ libjava/java/lang/natVMFloat.cc | 52 ++++++++ 6 files changed, 338 insertions(+), 336 deletions(-) delete mode 100644 libjava/java/io/natObjectInputStream.cc create mode 100644 libjava/java/io/natVMObjectInputStream.cc delete mode 100644 libjava/java/lang/natDouble.cc delete mode 100644 libjava/java/lang/natFloat.cc create mode 100644 libjava/java/lang/natVMDouble.cc create mode 100644 libjava/java/lang/natVMFloat.cc (limited to 'libjava/java') diff --git a/libjava/java/io/natObjectInputStream.cc b/libjava/java/io/natObjectInputStream.cc deleted file mode 100644 index 6212396..0000000 --- a/libjava/java/io/natObjectInputStream.cc +++ /dev/null @@ -1,70 +0,0 @@ -// natObjectInputStream.cc - Native part of VMObjectInputStream class. - -/* Copyright (C) 1998, 1999, 2000, 2001, 2005, 2006 Free Software Foundation - - This ObjectInputStream is part of libgcj. - -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the ObjectInputStream "LIBGCJ_LICENSE" for -details. */ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef DEBUG -#include -#include -#endif - -jobject -java::io::VMObjectInputStream::allocateObject (jclass klass, jclass, - ::java::lang::reflect::Constructor *ctr) -{ - jobject obj = NULL; - using namespace java::lang::reflect; - - try - { - JvAssert (klass && ! klass->isArray ()); - if (klass->isInterface() || Modifier::isAbstract(klass->getModifiers())) - obj = NULL; - else - { - obj = _Jv_AllocObject (klass); - } - } - catch (jthrowable t) - { - return NULL; - } - - jmethodID meth = _Jv_FromReflectedConstructor (ctr); - - // This is a bit inefficient, and a bit of a hack, since we don't - // actually use the Method and since what is returned isn't - // technically a Method. We can't use Method.invoke as it looks up - // the declared method. - JArray *arg_types - = (JArray *) JvNewObjectArray (0, &java::lang::Class::class$, - NULL); - - // We lie about this being a constructor. If we put `true' here - // then _Jv_CallAnyMethodA would try to allocate the object for us. - _Jv_CallAnyMethodA (obj, JvPrimClass (void), meth, false, arg_types, NULL); - - return obj; -} diff --git a/libjava/java/io/natVMObjectInputStream.cc b/libjava/java/io/natVMObjectInputStream.cc new file mode 100644 index 0000000..86410a4 --- /dev/null +++ b/libjava/java/io/natVMObjectInputStream.cc @@ -0,0 +1,71 @@ +// natVMObjectInputStream.cc - Native part of VMObjectInputStream class. + +/* Copyright (C) 1998, 1999, 2000, 2001, 2005, 2006, 2007 + 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 ObjectInputStream "LIBGCJ_LICENSE" for +details. */ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG +#include +#include +#endif + +jobject +java::io::VMObjectInputStream::allocateObject (jclass klass, jclass, + ::java::lang::reflect::Constructor *ctr) +{ + jobject obj = NULL; + using namespace java::lang::reflect; + + try + { + JvAssert (klass && ! klass->isArray ()); + if (klass->isInterface() || Modifier::isAbstract(klass->getModifiers())) + obj = NULL; + else + { + obj = _Jv_AllocObject (klass); + } + } + catch (jthrowable t) + { + return NULL; + } + + jmethodID meth = _Jv_FromReflectedConstructor (ctr); + + // This is a bit inefficient, and a bit of a hack, since we don't + // actually use the Method and since what is returned isn't + // technically a Method. We can't use Method.invoke as it looks up + // the declared method. + JArray *arg_types + = (JArray *) JvNewObjectArray (0, &java::lang::Class::class$, + NULL); + + // We lie about this being a constructor. If we put `true' here + // then _Jv_CallAnyMethodA would try to allocate the object for us. + _Jv_CallAnyMethodA (obj, JvPrimClass (void), meth, false, arg_types, NULL); + + return obj; +} diff --git a/libjava/java/lang/natDouble.cc b/libjava/java/lang/natDouble.cc deleted file mode 100644 index 87123bc..0000000 --- a/libjava/java/lang/natDouble.cc +++ /dev/null @@ -1,214 +0,0 @@ -// natDouble.cc - Implementation of java.lang.VMDouble native methods. - -/* Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006, 2007 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 - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "fdlibm.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; -} - -jstring -java::lang::VMDouble::toString(jdouble value, jboolean isFloat) -{ - if (Double::isNaN (value)) - return JvNewStringLatin1 ("NaN", sizeof ("NaN") - 1); - - if (value == Double::POSITIVE_INFINITY) - return JvNewStringLatin1 ("Infinity", sizeof ("Infinity") - 1); - - if (value == Double::NEGATIVE_INFINITY) - return JvNewStringLatin1 ("-Infinity", sizeof ("-Infinity") - 1); - - char buffer[50], result[50]; - int decpt, sign; - - _dtoa (value, 0, 20, &decpt, &sign, NULL, buffer, (int)isFloat); - - value = fabs (value); - - char *s = buffer; - char *d = result; - - if (sign) - *d++ = '-'; - - if ((value >= 1e-3 && value < 1e7) || value == 0) - { - if (decpt <= 0) - *d++ = '0'; - else - { - for (int i = 0; i < decpt; i++) - if (*s) - *d++ = *s++; - else - *d++ = '0'; - } - - *d++ = '.'; - - if (*s == 0) - { - *d++ = '0'; - decpt++; - } - - while (decpt++ < 0) - *d++ = '0'; - - while (*s) - *d++ = *s++; - - *d = 0; - - return JvNewStringLatin1 (result, strlen (result)); - } - - *d++ = *s++; - decpt--; - *d++ = '.'; - - if (*s == 0) - *d++ = '0'; - - while (*s) - *d++ = *s++; - - *d++ = 'E'; - - if (decpt < 0) - { - *d++ = '-'; - decpt = -decpt; - } - - { - char exp[4]; - char *e = exp + sizeof exp; - - *--e = 0; - do - { - *--e = '0' + decpt % 10; - decpt /= 10; - } - while (decpt > 0); - - while (*e) - *d++ = *e++; - } - - *d = 0; - - return JvNewStringLatin1 (result, strlen (result)); -} - -jdouble -java::lang::VMDouble::parseDouble(jstring str) -{ - int length = str->length(); - - while (length > 0 - && Character::isWhitespace(str->charAt(length - 1))) - length--; - - // The String could end with a f/F/d/D which is valid but we don't need. - bool saw_trailer = false; - if (length > 0) - { - jchar last = str->charAt(length-1); - if (last == 'f' || last == 'F' || last == 'd' || last == 'D') - { - length--; - saw_trailer = true; - } - } - - jsize start = 0; - while (length > 0 - && Character::isWhitespace(str->charAt(start))) - start++, length--; - - if (length > 0) - { - // Note that UTF can expand 3x. - char *data = (char *) __builtin_alloca (3 * length + 1); - jsize blength = _Jv_GetStringUTFRegion (str, start, length, data); - data[blength] = 0; - - if (! saw_trailer) - { - if (! strcmp (data, "NaN") || ! strcmp (data, "+NaN") - || ! strcmp (data, "-NaN")) - return Double::NaN; - else if (! strcmp (data, "Infinity") || ! strcmp (data, "+Infinity")) - return Double::POSITIVE_INFINITY; - else if (! strcmp (data, "-Infinity")) - return Double::NEGATIVE_INFINITY; - } - - struct _Jv_reent reent; - memset (&reent, 0, sizeof reent); - - char *endptr; - double val = _strtod_r (&reent, data, &endptr); - if (endptr == data + blength) - return val; - } - throw new NumberFormatException(str); -} diff --git a/libjava/java/lang/natFloat.cc b/libjava/java/lang/natFloat.cc deleted file mode 100644 index f090b81..0000000 --- a/libjava/java/lang/natFloat.cc +++ /dev/null @@ -1,52 +0,0 @@ -// natFloat.cc - Implementation of java.lang.VMFloat native methods. - -/* Copyright (C) 1998, 1999, 2001, 2006 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 - -#include -#include -#include - -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; -} - diff --git a/libjava/java/lang/natVMDouble.cc b/libjava/java/lang/natVMDouble.cc new file mode 100644 index 0000000..f770bc4 --- /dev/null +++ b/libjava/java/lang/natVMDouble.cc @@ -0,0 +1,215 @@ +// natVMDouble.cc - Implementation of java.lang.VMDouble native methods. + +/* Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006, 2007 + 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 + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "fdlibm.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; +} + +jstring +java::lang::VMDouble::toString(jdouble value, jboolean isFloat) +{ + if (Double::isNaN (value)) + return JvNewStringLatin1 ("NaN", sizeof ("NaN") - 1); + + if (value == Double::POSITIVE_INFINITY) + return JvNewStringLatin1 ("Infinity", sizeof ("Infinity") - 1); + + if (value == Double::NEGATIVE_INFINITY) + return JvNewStringLatin1 ("-Infinity", sizeof ("-Infinity") - 1); + + char buffer[50], result[50]; + int decpt, sign; + + _dtoa (value, 0, 20, &decpt, &sign, NULL, buffer, (int)isFloat); + + value = fabs (value); + + char *s = buffer; + char *d = result; + + if (sign) + *d++ = '-'; + + if ((value >= 1e-3 && value < 1e7) || value == 0) + { + if (decpt <= 0) + *d++ = '0'; + else + { + for (int i = 0; i < decpt; i++) + if (*s) + *d++ = *s++; + else + *d++ = '0'; + } + + *d++ = '.'; + + if (*s == 0) + { + *d++ = '0'; + decpt++; + } + + while (decpt++ < 0) + *d++ = '0'; + + while (*s) + *d++ = *s++; + + *d = 0; + + return JvNewStringLatin1 (result, strlen (result)); + } + + *d++ = *s++; + decpt--; + *d++ = '.'; + + if (*s == 0) + *d++ = '0'; + + while (*s) + *d++ = *s++; + + *d++ = 'E'; + + if (decpt < 0) + { + *d++ = '-'; + decpt = -decpt; + } + + { + char exp[4]; + char *e = exp + sizeof exp; + + *--e = 0; + do + { + *--e = '0' + decpt % 10; + decpt /= 10; + } + while (decpt > 0); + + while (*e) + *d++ = *e++; + } + + *d = 0; + + return JvNewStringLatin1 (result, strlen (result)); +} + +jdouble +java::lang::VMDouble::parseDouble(jstring str) +{ + int length = str->length(); + + while (length > 0 + && Character::isWhitespace(str->charAt(length - 1))) + length--; + + // The String could end with a f/F/d/D which is valid but we don't need. + bool saw_trailer = false; + if (length > 0) + { + jchar last = str->charAt(length-1); + if (last == 'f' || last == 'F' || last == 'd' || last == 'D') + { + length--; + saw_trailer = true; + } + } + + jsize start = 0; + while (length > 0 + && Character::isWhitespace(str->charAt(start))) + start++, length--; + + if (length > 0) + { + // Note that UTF can expand 3x. + char *data = (char *) __builtin_alloca (3 * length + 1); + jsize blength = _Jv_GetStringUTFRegion (str, start, length, data); + data[blength] = 0; + + if (! saw_trailer) + { + if (! strcmp (data, "NaN") || ! strcmp (data, "+NaN") + || ! strcmp (data, "-NaN")) + return Double::NaN; + else if (! strcmp (data, "Infinity") || ! strcmp (data, "+Infinity")) + return Double::POSITIVE_INFINITY; + else if (! strcmp (data, "-Infinity")) + return Double::NEGATIVE_INFINITY; + } + + struct _Jv_reent reent; + memset (&reent, 0, sizeof reent); + + char *endptr; + double val = _strtod_r (&reent, data, &endptr); + if (endptr == data + blength) + return val; + } + throw new NumberFormatException(str); +} diff --git a/libjava/java/lang/natVMFloat.cc b/libjava/java/lang/natVMFloat.cc new file mode 100644 index 0000000..54ae519 --- /dev/null +++ b/libjava/java/lang/natVMFloat.cc @@ -0,0 +1,52 @@ +// natVMFloat.cc - Implementation of java.lang.VMFloat native methods. + +/* Copyright (C) 1998, 1999, 2001, 2006, 2007 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 + +#include +#include +#include + +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; +} + -- cgit v1.1