You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/03/01 16:43:11 UTC
svn commit: r382065 [5/10] - in /incubator/harmony/enhanced/classlib/trunk:
modules/security/make/ modules/security/make/native/linux/
modules/security/make/native/windows/ native-src/ native-src/linux.IA32/
native-src/linux.IA32/archive/ native-src/li...
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/cbigint.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/cbigint.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/cbigint.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/cbigint.h Wed Mar 1 07:42:53 2006
@@ -0,0 +1,60 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if !defined(cbigint_h)
+#define cbigint_h
+#include "fltconst.h"
+#include "jcl.h"
+#define LOW_U32_FROM_VAR(u64) LOW_U32_FROM_LONG64(u64)
+#define LOW_U32_FROM_PTR(u64ptr) LOW_U32_FROM_LONG64_PTR(u64ptr)
+#define HIGH_U32_FROM_VAR(u64) HIGH_U32_FROM_LONG64(u64)
+#define HIGH_U32_FROM_PTR(u64ptr) HIGH_U32_FROM_LONG64_PTR(u64ptr)
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+ void multiplyHighPrecision (U_64 * arg1, IDATA length1, U_64 * arg2,
+ IDATA length2, U_64 * result, IDATA length);
+ U_32 simpleAppendDecimalDigitHighPrecision (U_64 * arg1, IDATA length,
+ U_64 digit);
+ jdouble toDoubleHighPrecision (U_64 * arg, IDATA length);
+ IDATA tenToTheEHighPrecision (U_64 * result, IDATA length, jint e);
+ U_64 doubleMantissa (jdouble z);
+ IDATA compareHighPrecision (U_64 * arg1, IDATA length1, U_64 * arg2,
+ IDATA length2);
+ IDATA highestSetBitHighPrecision (U_64 * arg, IDATA length);
+ void subtractHighPrecision (U_64 * arg1, IDATA length1, U_64 * arg2,
+ IDATA length2);
+ IDATA doubleExponent (jdouble z);
+ U_32 simpleMultiplyHighPrecision (U_64 * arg1, IDATA length, U_64 arg2);
+ IDATA addHighPrecision (U_64 * arg1, IDATA length1, U_64 * arg2,
+ IDATA length2);
+ void simpleMultiplyAddHighPrecisionBigEndianFix (U_64 * arg1, IDATA length,
+ U_64 arg2, U_32 * result);
+ IDATA lowestSetBit (U_64 * y);
+ IDATA timesTenToTheEHighPrecision (U_64 * result, IDATA length, jint e);
+ void simpleMultiplyAddHighPrecision (U_64 * arg1, IDATA length, U_64 arg2,
+ U_32 * result);
+ IDATA highestSetBit (U_64 * y);
+ IDATA lowestSetBitHighPrecision (U_64 * arg, IDATA length);
+ void simpleShiftLeftHighPrecision (U_64 * arg1, IDATA length, IDATA arg2);
+ UDATA floatMantissa (jfloat z);
+ U_64 simpleMultiplyHighPrecision64 (U_64 * arg1, IDATA length, U_64 arg2);
+ IDATA simpleAddHighPrecision (U_64 * arg1, IDATA length, U_64 arg2);
+ IDATA floatExponent (jfloat z);
+#if defined(__cplusplus)
+}
+#endif
+#endif /* cbigint_h */
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/dblparse.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/dblparse.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/dblparse.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/dblparse.c Wed Mar 1 07:42:53 2006
@@ -0,0 +1,876 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <math.h>
+#include "jcl.h"
+#include "cbigint.h"
+#include "jclglob.h"
+
+#if defined(LINUX)
+#define USE_LL
+#endif
+
+#define LOW_I32_FROM_VAR(u64) LOW_I32_FROM_LONG64(u64)
+#define LOW_I32_FROM_PTR(u64ptr) LOW_I32_FROM_LONG64_PTR(u64ptr)
+#define HIGH_I32_FROM_VAR(u64) HIGH_I32_FROM_LONG64(u64)
+#define HIGH_I32_FROM_PTR(u64ptr) HIGH_I32_FROM_LONG64_PTR(u64ptr)
+
+#define MAX_ACCURACY_WIDTH 17
+
+#define DEFAULT_WIDTH MAX_ACCURACY_WIDTH
+
+JNIEXPORT jdouble JNICALL
+Java_com_ibm_oti_util_FloatingPointParser_parseDblImpl (JNIEnv * env,
+ jclass clazz,
+ jstring s, jint e);
+JNIEXPORT void JNICALL
+Java_com_ibm_oti_util_NumberConverter_bigIntDigitGeneratorInstImpl (JNIEnv *
+ env,
+ jobject
+ inst,
+ jlong f,
+ jint e,
+ jboolean
+ isDenormalized,
+ jboolean
+ mantissaIsZero,
+ jint p);
+
+jdouble createDouble (JNIEnv * env, const char *s, jint e);
+jdouble createDouble1 (JNIEnv * env, U_64 * f, IDATA length, jint e);
+jdouble doubleAlgorithm (JNIEnv * env, U_64 * f, IDATA length, jint e,
+ jdouble z);
+U_64 dblparse_shiftRight64 (U_64 * lp, volatile int mbe);
+
+static const jdouble tens[] = {
+ 1.0,
+ 1.0e1,
+ 1.0e2,
+ 1.0e3,
+ 1.0e4,
+ 1.0e5,
+ 1.0e6,
+ 1.0e7,
+ 1.0e8,
+ 1.0e9,
+ 1.0e10,
+ 1.0e11,
+ 1.0e12,
+ 1.0e13,
+ 1.0e14,
+ 1.0e15,
+ 1.0e16,
+ 1.0e17,
+ 1.0e18,
+ 1.0e19,
+ 1.0e20,
+ 1.0e21,
+ 1.0e22
+};
+
+#define tenToTheE(e) (*(tens + (e)))
+#define LOG5_OF_TWO_TO_THE_N 23
+#define INV_LOG_OF_TEN_BASE_2 (0.30102999566398114)
+#define DOUBLE_MIN_VALUE 5.0e-324
+
+#define sizeOfTenToTheE(e) (((e) / 19) + 1)
+
+#if defined(USE_LL)
+#define INFINITE_LONGBITS (0x7FF0000000000000LL)
+#else
+#if defined(USE_L)
+#define INFINITE_LONGBITS (0x7FF0000000000000L)
+#else
+#define INFINITE_LONGBITS (0x7FF0000000000000)
+#endif /* USE_L */
+#endif /* USE_LL */
+
+#define MINIMUM_LONGBITS (0x1)
+
+#if defined(USE_LL)
+#define MANTISSA_MASK (0x000FFFFFFFFFFFFFLL)
+#define EXPONENT_MASK (0x7FF0000000000000LL)
+#define NORMAL_MASK (0x0010000000000000LL)
+#else
+#if defined(USE_L)
+#define MANTISSA_MASK (0x000FFFFFFFFFFFFFL)
+#define EXPONENT_MASK (0x7FF0000000000000L)
+#define NORMAL_MASK (0x0010000000000000L)
+#else
+#define MANTISSA_MASK (0x000FFFFFFFFFFFFF)
+#define EXPONENT_MASK (0x7FF0000000000000)
+#define NORMAL_MASK (0x0010000000000000)
+#endif /* USE_L */
+#endif /* USE_LL */
+
+#define DOUBLE_TO_LONGBITS(dbl) (*((U_64 *)(&dbl)))
+
+/* Keep a count of the number of times we decrement and increment to
+ * approximate the double, and attempt to detect the case where we
+ * could potentially toggle back and forth between decrementing and
+ * incrementing. It is possible for us to be stuck in the loop when
+ * incrementing by one or decrementing by one may exceed or stay below
+ * the value that we are looking for. In this case, just break out of
+ * the loop if we toggle between incrementing and decrementing for more
+ * than twice.
+ */
+#define INCREMENT_DOUBLE(_x, _decCount, _incCount) \
+ { \
+ ++DOUBLE_TO_LONGBITS(_x); \
+ _incCount++; \
+ if( (_incCount > 2) && (_decCount > 2) ) { \
+ if( _decCount > _incCount ) { \
+ DOUBLE_TO_LONGBITS(_x) += _decCount - _incCount; \
+ } else if( _incCount > _decCount ) { \
+ DOUBLE_TO_LONGBITS(_x) -= _incCount - _decCount; \
+ } \
+ break; \
+ } \
+ }
+#define DECREMENT_DOUBLE(_x, _decCount, _incCount) \
+ { \
+ --DOUBLE_TO_LONGBITS(_x); \
+ _decCount++; \
+ if( (_incCount > 2) && (_decCount > 2) ) { \
+ if( _decCount > _incCount ) { \
+ DOUBLE_TO_LONGBITS(_x) += _decCount - _incCount; \
+ } else if( _incCount > _decCount ) { \
+ DOUBLE_TO_LONGBITS(_x) -= _incCount - _decCount; \
+ } \
+ break; \
+ } \
+ }
+#define ERROR_OCCURED(x) (HIGH_I32_FROM_VAR(x) < 0)
+
+#define allocateU64(x, n) if (!((x) = (U_64*) hymem_allocate_memory((n) * sizeof(U_64)))) goto OutOfMemory;
+#define release(r) if ((r)) hymem_free_memory((r));
+
+/*NB the Number converter methods are synchronized so it is possible to
+ *have global data for use by bigIntDigitGenerator */
+#define RM_SIZE 21
+#define STemp_SIZE 22
+static U_64 R[RM_SIZE], S[STemp_SIZE], M[RM_SIZE], Temp[STemp_SIZE];
+
+jdouble
+createDouble (JNIEnv * env, const char *s, jint e)
+{
+ /* assumes s is a null terminated string with at least one
+ * character in it */
+ U_64 def[DEFAULT_WIDTH];
+ U_64 defBackup[DEFAULT_WIDTH];
+ U_64 *f, *fNoOverflow, *g, *tempBackup;
+ U_32 overflow;
+ jdouble result;
+ IDATA index = 1;
+ int unprocessedDigits = 0;
+ PORT_ACCESS_FROM_ENV (env);
+
+ f = def;
+ fNoOverflow = defBackup;
+ *f = 0;
+ tempBackup = g = 0;
+ do
+ {
+ if (*s >= '0' && *s <= '9')
+ {
+ /* Make a back up of f before appending, so that we can
+ * back out of it if there is no more room, i.e. index >
+ * MAX_ACCURACY_WIDTH.
+ */
+ memcpy (fNoOverflow, f, sizeof (U_64) * index);
+ overflow =
+ simpleAppendDecimalDigitHighPrecision (f, index, *s - '0');
+ if (overflow)
+ {
+ f[index++] = overflow;
+ /* There is an overflow, but there is no more room
+ * to store the result. We really only need the top 52
+ * bits anyway, so we must back out of the overflow,
+ * and ignore the rest of the string.
+ */
+ if (index >= MAX_ACCURACY_WIDTH)
+ {
+ index--;
+ memcpy (f, fNoOverflow, sizeof (U_64) * index);
+ break;
+ }
+ if (tempBackup)
+ {
+ fNoOverflow = tempBackup;
+ }
+ }
+ }
+ else
+ index = -1;
+ }
+ while (index > 0 && *(++s) != '\0');
+
+ /* We've broken out of the parse loop either because we've reached
+ * the end of the string or we've overflowed the maximum accuracy
+ * limit of a double. If we still have unprocessed digits in the
+ * given string, then there are three possible results:
+ * 1. (unprocessed digits + e) == 0, in which case we simply
+ * convert the existing bits that are already parsed
+ * 2. (unprocessed digits + e) < 0, in which case we simply
+ * convert the existing bits that are already parsed along
+ * with the given e
+ * 3. (unprocessed digits + e) > 0 indicates that the value is
+ * simply too big to be stored as a double, so return Infinity
+ */
+ if ((unprocessedDigits = strlen (s)) > 0)
+ {
+ e += unprocessedDigits;
+ if (index > -1)
+ {
+ if (e == 0)
+ result = toDoubleHighPrecision (f, index);
+ else if (e < 0)
+ result = createDouble1 (env, f, index, e);
+ else
+ {
+ DOUBLE_TO_LONGBITS (result) = INFINITE_LONGBITS;
+ }
+ }
+ else
+ {
+ LOW_I32_FROM_VAR (result) = -1;
+ HIGH_I32_FROM_VAR (result) = -1;
+ }
+ }
+ else
+ {
+ if (index > -1)
+ {
+ if (e == 0)
+ result = toDoubleHighPrecision (f, index);
+ else
+ result = createDouble1 (env, f, index, e);
+ }
+ else
+ {
+ LOW_I32_FROM_VAR (result) = -1;
+ HIGH_I32_FROM_VAR (result) = -1;
+ }
+ }
+
+ return result;
+
+}
+
+jdouble
+createDouble1 (JNIEnv * env, U_64 * f, IDATA length, jint e)
+{
+ IDATA numBits;
+ jdouble result;
+
+#define APPROX_MIN_MAGNITUDE -309
+
+#define APPROX_MAX_MAGNITUDE 309
+
+ numBits = highestSetBitHighPrecision (f, length) + 1;
+ numBits -= lowestSetBitHighPrecision (f, length);
+ if (numBits < 54 && e >= 0 && e < LOG5_OF_TWO_TO_THE_N)
+ {
+ return toDoubleHighPrecision (f, length) * tenToTheE (e);
+ }
+ else if (numBits < 54 && e < 0 && (-e) < LOG5_OF_TWO_TO_THE_N)
+ {
+ return toDoubleHighPrecision (f, length) / tenToTheE (-e);
+ }
+ else if (e >= 0 && e < APPROX_MAX_MAGNITUDE)
+ {
+ result = toDoubleHighPrecision (f, length) * pow (10.0, e);
+ }
+ else if (e >= APPROX_MAX_MAGNITUDE)
+ {
+ /* Convert the partial result to make sure that the
+ * non-exponential part is not zero. This check fixes the case
+ * where the user enters 0.0e309! */
+ result = toDoubleHighPrecision (f, length);
+ /* Don't go straight to zero as the fact that x*0 = 0 independent of x might
+ cause the algorithm to produce an incorrect result. Instead try the min value
+ first and let it fall to zero if need be. */
+
+ if (result == 0.0)
+
+ DOUBLE_TO_LONGBITS (result) = MINIMUM_LONGBITS;
+ else
+ DOUBLE_TO_LONGBITS (result) = INFINITE_LONGBITS;
+ }
+ else if (e > APPROX_MIN_MAGNITUDE)
+ {
+ result = toDoubleHighPrecision (f, length) / pow (10.0, -e);
+ }
+
+ if (e <= APPROX_MIN_MAGNITUDE)
+ {
+
+ result = toDoubleHighPrecision (f, length) * pow (10.0, e + 52);
+ result = result * pow (10.0, -52);
+
+ }
+
+ /* Don't go straight to zero as the fact that x*0 = 0 independent of x might
+ cause the algorithm to produce an incorrect result. Instead try the min value
+ first and let it fall to zero if need be. */
+
+ if (result == 0.0)
+
+ DOUBLE_TO_LONGBITS (result) = MINIMUM_LONGBITS;
+
+ return doubleAlgorithm (env, f, length, e, result);
+}
+
+U_64
+dblparse_shiftRight64 (U_64 * lp, volatile int mbe)
+{
+ U_64 b1Value = 0;
+ U_32 hi = HIGH_U32_FROM_LONG64_PTR (lp);
+ U_32 lo = LOW_U32_FROM_LONG64_PTR (lp);
+ int srAmt;
+
+ if (mbe == 0)
+ return 0;
+ if (mbe >= 128)
+ {
+ HIGH_U32_FROM_LONG64_PTR (lp) = 0;
+ LOW_U32_FROM_LONG64_PTR (lp) = 0;
+ return 0;
+ }
+
+ /* Certain platforms do not handle de-referencing a 64-bit value
+ * from a pointer on the stack correctly (e.g. MVL-hh/XScale)
+ * because the pointer may not be properly aligned, so we'll have
+ * to handle two 32-bit chunks. */
+ if (mbe < 32)
+ {
+ LOW_U32_FROM_LONG64 (b1Value) = 0;
+ HIGH_U32_FROM_LONG64 (b1Value) = lo << (32 - mbe);
+ LOW_U32_FROM_LONG64_PTR (lp) = (hi << (32 - mbe)) | (lo >> mbe);
+ HIGH_U32_FROM_LONG64_PTR (lp) = hi >> mbe;
+ }
+ else if (mbe == 32)
+ {
+ LOW_U32_FROM_LONG64 (b1Value) = 0;
+ HIGH_U32_FROM_LONG64 (b1Value) = lo;
+ LOW_U32_FROM_LONG64_PTR (lp) = hi;
+ HIGH_U32_FROM_LONG64_PTR (lp) = 0;
+ }
+ else if (mbe < 64)
+ {
+ srAmt = mbe - 32;
+ LOW_U32_FROM_LONG64 (b1Value) = lo << (32 - srAmt);
+ HIGH_U32_FROM_LONG64 (b1Value) = (hi << (32 - srAmt)) | (lo >> srAmt);
+ LOW_U32_FROM_LONG64_PTR (lp) = hi >> srAmt;
+ HIGH_U32_FROM_LONG64_PTR (lp) = 0;
+ }
+ else if (mbe == 64)
+ {
+ LOW_U32_FROM_LONG64 (b1Value) = lo;
+ HIGH_U32_FROM_LONG64 (b1Value) = hi;
+ LOW_U32_FROM_LONG64_PTR (lp) = 0;
+ HIGH_U32_FROM_LONG64_PTR (lp) = 0;
+ }
+ else if (mbe < 96)
+ {
+ srAmt = mbe - 64;
+ b1Value = *lp;
+ HIGH_U32_FROM_LONG64_PTR (lp) = 0;
+ LOW_U32_FROM_LONG64_PTR (lp) = 0;
+ LOW_U32_FROM_LONG64 (b1Value) >>= srAmt;
+ LOW_U32_FROM_LONG64 (b1Value) |= (hi << (32 - srAmt));
+ HIGH_U32_FROM_LONG64 (b1Value) >>= srAmt;
+ }
+ else if (mbe == 96)
+ {
+ LOW_U32_FROM_LONG64 (b1Value) = hi;
+ HIGH_U32_FROM_LONG64 (b1Value) = 0;
+ HIGH_U32_FROM_LONG64_PTR (lp) = 0;
+ LOW_U32_FROM_LONG64_PTR (lp) = 0;
+ }
+ else
+ {
+ LOW_U32_FROM_LONG64 (b1Value) = hi >> (mbe - 96);
+ HIGH_U32_FROM_LONG64 (b1Value) = 0;
+ HIGH_U32_FROM_LONG64_PTR (lp) = 0;
+ LOW_U32_FROM_LONG64_PTR (lp) = 0;
+ }
+
+ return b1Value;
+}
+
+#if defined(WIN32)
+/* disable global optimizations on the microsoft compiler for the
+ * doubleAlgorithm function otherwise it won't compile */
+#pragma optimize("g",off)
+#endif
+
+/* The algorithm for the function doubleAlgorithm() below can be found
+ * in:
+ *
+ * "How to Read Floating-Point Numbers Accurately", William D.
+ * Clinger, Proceedings of the ACM SIGPLAN '90 Conference on
+ * Programming Language Design and Implementation, June 20-22,
+ * 1990, pp. 92-101.
+ *
+ * There is a possibility that the function will end up in an endless
+ * loop if the given approximating floating-point number (a very small
+ * floating-point whose value is very close to zero) straddles between
+ * two approximating integer values. We modified the algorithm slightly
+ * to detect the case where it oscillates back and forth between
+ * incrementing and decrementing the floating-point approximation. It
+ * is currently set such that if the oscillation occurs more than twice
+ * then return the original approximation.
+ */
+jdouble
+doubleAlgorithm (JNIEnv * env, U_64 * f, IDATA length, jint e, jdouble z)
+{
+ U_64 m;
+ IDATA k, comparison, comparison2;
+ U_64 *x, *y, *D, *D2;
+ IDATA xLength, yLength, DLength, D2Length, decApproxCount, incApproxCount;
+ PORT_ACCESS_FROM_ENV (env);
+
+ x = y = D = D2 = 0;
+ xLength = yLength = DLength = D2Length = 0;
+ decApproxCount = incApproxCount = 0;
+
+ do
+ {
+ m = doubleMantissa (z);
+ k = doubleExponent (z);
+
+ if (x && x != f)
+ jclmem_free_memory (env, x);
+ release (y);
+ release (D);
+ release (D2);
+
+ if (e >= 0 && k >= 0)
+ {
+ xLength = sizeOfTenToTheE (e) + length;
+ allocateU64 (x, xLength);
+ memset (x + length, 0, sizeof (U_64) * (xLength - length));
+ memcpy (x, f, sizeof (U_64) * length);
+ timesTenToTheEHighPrecision (x, xLength, e);
+
+ yLength = (k >> 6) + 2;
+ allocateU64 (y, yLength);
+ memset (y + 1, 0, sizeof (U_64) * (yLength - 1));
+ *y = m;
+ simpleShiftLeftHighPrecision (y, yLength, k);
+ }
+ else if (e >= 0)
+ {
+ xLength = sizeOfTenToTheE (e) + length + ((-k) >> 6) + 1;
+ allocateU64 (x, xLength);
+ memset (x + length, 0, sizeof (U_64) * (xLength - length));
+ memcpy (x, f, sizeof (U_64) * length);
+ timesTenToTheEHighPrecision (x, xLength, e);
+ simpleShiftLeftHighPrecision (x, xLength, -k);
+
+ yLength = 1;
+ allocateU64 (y, 1);
+ *y = m;
+ }
+ else if (k >= 0)
+ {
+ xLength = length;
+ x = f;
+
+ yLength = sizeOfTenToTheE (-e) + 2 + (k >> 6);
+ allocateU64 (y, yLength);
+ memset (y + 1, 0, sizeof (U_64) * (yLength - 1));
+ *y = m;
+ timesTenToTheEHighPrecision (y, yLength, -e);
+ simpleShiftLeftHighPrecision (y, yLength, k);
+ }
+ else
+ {
+ xLength = length + ((-k) >> 6) + 1;
+ allocateU64 (x, xLength);
+ memset (x + length, 0, sizeof (U_64) * (xLength - length));
+ memcpy (x, f, sizeof (U_64) * length);
+ simpleShiftLeftHighPrecision (x, xLength, -k);
+
+ yLength = sizeOfTenToTheE (-e) + 1;
+ allocateU64 (y, yLength);
+ memset (y + 1, 0, sizeof (U_64) * (yLength - 1));
+ *y = m;
+ timesTenToTheEHighPrecision (y, yLength, -e);
+ }
+
+ comparison = compareHighPrecision (x, xLength, y, yLength);
+ if (comparison > 0)
+ { /* x > y */
+ DLength = xLength;
+ allocateU64 (D, DLength);
+ memcpy (D, x, DLength * sizeof (U_64));
+ subtractHighPrecision (D, DLength, y, yLength);
+ }
+ else if (comparison)
+ { /* y > x */
+ DLength = yLength;
+ allocateU64 (D, DLength);
+ memcpy (D, y, DLength * sizeof (U_64));
+ subtractHighPrecision (D, DLength, x, xLength);
+ }
+ else
+ { /* y == x */
+ DLength = 1;
+ allocateU64 (D, 1);
+ *D = 0;
+ }
+
+ D2Length = DLength + 1;
+ allocateU64 (D2, D2Length);
+ m <<= 1;
+ multiplyHighPrecision (D, DLength, &m, 1, D2, D2Length);
+ m >>= 1;
+
+ comparison2 = compareHighPrecision (D2, D2Length, y, yLength);
+ if (comparison2 < 0)
+ {
+ if (comparison < 0 && m == NORMAL_MASK)
+ {
+ simpleShiftLeftHighPrecision (D2, D2Length, 1);
+ if (compareHighPrecision (D2, D2Length, y, yLength) > 0)
+ {
+ DECREMENT_DOUBLE (z, decApproxCount, incApproxCount);
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+ else if (comparison2 == 0)
+ {
+ if ((LOW_U32_FROM_VAR (m) & 1) == 0)
+ {
+ if (comparison < 0 && m == NORMAL_MASK)
+ {
+ DECREMENT_DOUBLE (z, decApproxCount, incApproxCount);
+ }
+ else
+ {
+ break;
+ }
+ }
+ else if (comparison < 0)
+ {
+ DECREMENT_DOUBLE (z, decApproxCount, incApproxCount);
+ break;
+ }
+ else
+ {
+ INCREMENT_DOUBLE (z, decApproxCount, incApproxCount);
+ break;
+ }
+ }
+ else if (comparison < 0)
+ {
+ DECREMENT_DOUBLE (z, decApproxCount, incApproxCount);
+ }
+ else
+ {
+ if (DOUBLE_TO_LONGBITS (z) == INFINITE_LONGBITS)
+ break;
+ INCREMENT_DOUBLE (z, decApproxCount, incApproxCount);
+ }
+ }
+ while (1);
+
+ if (x && x != f)
+ jclmem_free_memory (env, x);
+ release (y);
+ release (D);
+ release (D2);
+ return z;
+
+OutOfMemory:
+ if (x && x != f)
+ jclmem_free_memory (env, x);
+ release (y);
+ release (D);
+ release (D2);
+
+ DOUBLE_TO_LONGBITS (z) = -2;
+
+ return z;
+}
+
+#if defined(WIN32)
+#pragma optimize("",on) /*restore optimizations */
+#endif
+
+JNIEXPORT jdouble JNICALL
+Java_com_ibm_oti_util_FloatingPointParser_parseDblImpl (JNIEnv * env,
+ jclass clazz,
+ jstring s, jint e)
+{
+ jdouble dbl;
+ const char *str = (*env)->GetStringUTFChars (env, s, 0);
+ dbl = createDouble (env, str, e);
+ (*env)->ReleaseStringUTFChars (env, s, str);
+
+ if (!ERROR_OCCURED (dbl))
+ {
+ return dbl;
+ }
+ else if (LOW_I32_FROM_VAR (dbl) == (I_32) - 1)
+ { /* NumberFormatException */
+ clazz = (*env)->FindClass (env, "java/lang/NumberFormatException");
+ if (clazz == 0)
+ return 0.0;
+ (*env)->ThrowNew (env, clazz, "");
+ }
+ else
+ { /* OutOfMemoryError */
+ clazz = (*env)->FindClass (env, "java/lang/OutOfMemoryError");
+ if (clazz == 0)
+ return 0.0;
+ (*env)->ThrowNew (env, clazz, "");
+ }
+
+ return 0.0;
+}
+
+/* The algorithm for this particular function can be found in:
+ *
+ * Printing Floating-Point Numbers Quickly and Accurately, Robert
+ * G. Burger, and R. Kent Dybvig, Programming Language Design and
+ * Implementation (PLDI) 1996, pp.108-116.
+ *
+ * The previous implementation of this function combined m+ and m- into
+ * one single M which caused some inaccuracy of the last digit. The
+ * particular case below shows this inaccuracy:
+ *
+ * System.out.println(new Double((1.234123412431233E107)).toString());
+ * System.out.println(new Double((1.2341234124312331E107)).toString());
+ * System.out.println(new Double((1.2341234124312332E107)).toString());
+ *
+ * outputs the following:
+ *
+ * 1.234123412431233E107
+ * 1.234123412431233E107
+ * 1.234123412431233E107
+ *
+ * instead of:
+ *
+ * 1.234123412431233E107
+ * 1.2341234124312331E107
+ * 1.2341234124312331E107
+ *
+ */
+JNIEXPORT void JNICALL
+Java_com_ibm_oti_util_NumberConverter_bigIntDigitGeneratorInstImpl (JNIEnv *
+ env,
+ jobject
+ inst,
+ jlong f,
+ jint e,
+ jboolean
+ isDenormalized,
+ jboolean
+ mantissaIsZero,
+ jint p)
+{
+ int RLength, SLength, TempLength, mplus_Length, mminus_Length;
+ int high, low, i;
+ jint k, firstK, U;
+ jint getCount, setCount;
+ jint *uArray;
+
+ jclass clazz;
+ jfieldID fid;
+ jintArray uArrayObject;
+
+ U_64 R[RM_SIZE], S[STemp_SIZE], mplus[RM_SIZE], mminus[RM_SIZE],
+ Temp[STemp_SIZE];
+
+ memset (R, 0, RM_SIZE * sizeof (U_64));
+ memset (S, 0, STemp_SIZE * sizeof (U_64));
+ memset (mplus, 0, RM_SIZE * sizeof (U_64));
+ memset (mminus, 0, RM_SIZE * sizeof (U_64));
+ memset (Temp, 0, STemp_SIZE * sizeof (U_64));
+
+ if (e >= 0)
+ {
+ *R = f;
+ *mplus = *mminus = 1;
+ simpleShiftLeftHighPrecision (mminus, RM_SIZE, e);
+ if (f != (2 << (p - 1)))
+ {
+ simpleShiftLeftHighPrecision (R, RM_SIZE, e + 1);
+ *S = 2;
+ /*
+ * m+ = m+ << e results in 1.0e23 to be printed as
+ * 0.9999999999999999E23
+ * m+ = m+ << e+1 results in 1.0e23 to be printed as
+ * 1.0e23 (caused too much rounding)
+ * 470fffffffffffff = 2.0769187434139308E34
+ * 4710000000000000 = 2.076918743413931E34
+ */
+ simpleShiftLeftHighPrecision (mplus, RM_SIZE, e);
+ }
+ else
+ {
+ simpleShiftLeftHighPrecision (R, RM_SIZE, e + 2);
+ *S = 4;
+ simpleShiftLeftHighPrecision (mplus, RM_SIZE, e + 1);
+ }
+ }
+ else
+ {
+ if (isDenormalized || (f != (2 << (p - 1))))
+ {
+ *R = f << 1;
+ *S = 1;
+ simpleShiftLeftHighPrecision (S, STemp_SIZE, 1 - e);
+ *mplus = *mminus = 1;
+ }
+ else
+ {
+ *R = f << 2;
+ *S = 1;
+ simpleShiftLeftHighPrecision (S, STemp_SIZE, 2 - e);
+ *mplus = 2;
+ *mminus = 1;
+ }
+ }
+
+ k = (int) ceil ((e + p - 1) * INV_LOG_OF_TEN_BASE_2 - 1e-10);
+
+ if (k > 0)
+ {
+ timesTenToTheEHighPrecision (S, STemp_SIZE, k);
+ }
+ else
+ {
+ timesTenToTheEHighPrecision (R, RM_SIZE, -k);
+ timesTenToTheEHighPrecision (mplus, RM_SIZE, -k);
+ timesTenToTheEHighPrecision (mminus, RM_SIZE, -k);
+ }
+
+ RLength = mplus_Length = mminus_Length = RM_SIZE;
+ SLength = TempLength = STemp_SIZE;
+
+ memset (Temp + RM_SIZE, 0, (STemp_SIZE - RM_SIZE) * sizeof (U_64));
+ memcpy (Temp, R, RM_SIZE * sizeof (U_64));
+
+ while (RLength > 1 && R[RLength - 1] == 0)
+ --RLength;
+ while (mplus_Length > 1 && mplus[mplus_Length - 1] == 0)
+ --mplus_Length;
+ while (mminus_Length > 1 && mminus[mminus_Length - 1] == 0)
+ --mminus_Length;
+ while (SLength > 1 && S[SLength - 1] == 0)
+ --SLength;
+ TempLength = (RLength > mplus_Length ? RLength : mplus_Length) + 1;
+ addHighPrecision (Temp, TempLength, mplus, mplus_Length);
+
+ if (compareHighPrecision (Temp, TempLength, S, SLength) >= 0)
+ {
+ firstK = k;
+ }
+ else
+ {
+ firstK = k - 1;
+ simpleAppendDecimalDigitHighPrecision (R, ++RLength, 0);
+ simpleAppendDecimalDigitHighPrecision (mplus, ++mplus_Length, 0);
+ simpleAppendDecimalDigitHighPrecision (mminus, ++mminus_Length, 0);
+ while (RLength > 1 && R[RLength - 1] == 0)
+ --RLength;
+ while (mplus_Length > 1 && mplus[mplus_Length - 1] == 0)
+ --mplus_Length;
+ while (mminus_Length > 1 && mminus[mminus_Length - 1] == 0)
+ --mminus_Length;
+ }
+
+ clazz = (*env)->GetObjectClass (env, inst);
+ fid = (*env)->GetFieldID (env, clazz, "uArray", "[I");
+ uArrayObject = (jintArray) (*env)->GetObjectField (env, inst, fid);
+ uArray = (*env)->GetIntArrayElements (env, uArrayObject, 0);
+
+ getCount = setCount = 0;
+ do
+ {
+ U = 0;
+ for (i = 3; i >= 0; --i)
+ {
+ TempLength = SLength + 1;
+ Temp[SLength] = 0;
+ memcpy (Temp, S, SLength * sizeof (U_64));
+ simpleShiftLeftHighPrecision (Temp, TempLength, i);
+ if (compareHighPrecision (R, RLength, Temp, TempLength) >= 0)
+ {
+ subtractHighPrecision (R, RLength, Temp, TempLength);
+ U += 1 << i;
+ }
+ }
+
+ low = compareHighPrecision (R, RLength, mminus, mminus_Length) <= 0;
+
+ memset (Temp + RLength, 0, (STemp_SIZE - RLength) * sizeof (U_64));
+ memcpy (Temp, R, RLength * sizeof (U_64));
+ TempLength = (RLength > mplus_Length ? RLength : mplus_Length) + 1;
+ addHighPrecision (Temp, TempLength, mplus, mplus_Length);
+
+ high = compareHighPrecision (Temp, TempLength, S, SLength) >= 0;
+
+ if (low || high)
+ break;
+
+ simpleAppendDecimalDigitHighPrecision (R, ++RLength, 0);
+ simpleAppendDecimalDigitHighPrecision (mplus, ++mplus_Length, 0);
+ simpleAppendDecimalDigitHighPrecision (mminus, ++mminus_Length, 0);
+ while (RLength > 1 && R[RLength - 1] == 0)
+ --RLength;
+ while (mplus_Length > 1 && mplus[mplus_Length - 1] == 0)
+ --mplus_Length;
+ while (mminus_Length > 1 && mminus[mminus_Length - 1] == 0)
+ --mminus_Length;
+ uArray[setCount++] = U;
+ }
+ while (1);
+
+ simpleShiftLeftHighPrecision (R, ++RLength, 1);
+ if (low && !high)
+ uArray[setCount++] = U;
+ else if (high && !low)
+ uArray[setCount++] = U + 1;
+ else if (compareHighPrecision (R, RLength, S, SLength) < 0)
+ uArray[setCount++] = U;
+ else
+ uArray[setCount++] = U + 1;
+
+ (*env)->ReleaseIntArrayElements (env, uArrayObject, uArray, 0);
+
+ fid = (*env)->GetFieldID (env, clazz, "setCount", "I");
+ (*env)->SetIntField (env, inst, fid, setCount);
+
+ fid = (*env)->GetFieldID (env, clazz, "getCount", "I");
+ (*env)->SetIntField (env, inst, fid, getCount);
+
+ fid = (*env)->GetFieldID (env, clazz, "firstK", "I");
+ (*env)->SetIntField (env, inst, fid, firstK);
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/fltparse.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/fltparse.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/fltparse.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/fltparse.c Wed Mar 1 07:42:53 2006
@@ -0,0 +1,557 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <math.h>
+#include "jcl.h"
+#include "cbigint.h"
+#include "jclglob.h"
+
+#if defined(LINUX)
+#define USE_LL
+#endif
+
+#define LOW_I32_FROM_PTR(ptr64) (*(I_32 *) (ptr64))
+
+#define MAX_ACCURACY_WIDTH 8
+
+#define DEFAULT_WIDTH MAX_ACCURACY_WIDTH
+
+JNIEXPORT jfloat JNICALL
+Java_com_ibm_oti_util_FloatingPointParser_parseFltImpl (JNIEnv * env,
+ jclass clazz,
+ jstring s, jint e);
+
+jfloat createFloat1 (JNIEnv * env, U_64 * f, IDATA length, jint e);
+jfloat floatAlgorithm (JNIEnv * env, U_64 * f, IDATA length, jint e,
+ jfloat z);
+jfloat createFloat (JNIEnv * env, const char *s, jint e);
+
+static const U_32 tens[] = {
+ 0x3f800000,
+ 0x41200000,
+ 0x42c80000,
+ 0x447a0000,
+ 0x461c4000,
+ 0x47c35000,
+ 0x49742400,
+ 0x4b189680,
+ 0x4cbebc20,
+ 0x4e6e6b28,
+ 0x501502f9 /* 10 ^ 10 in float */
+};
+
+#define tenToTheE(e) (*((jfloat *) (tens + (e))))
+#define LOG5_OF_TWO_TO_THE_N 11
+
+#define sizeOfTenToTheE(e) (((e) / 19) + 1)
+
+#define INFINITE_INTBITS (0x7F800000)
+#define MINIMUM_INTBITS (1)
+
+#define MANTISSA_MASK (0x007FFFFF)
+#define EXPONENT_MASK (0x7F800000)
+#define NORMAL_MASK (0x00800000)
+#define FLOAT_TO_INTBITS(flt) (*((U_32 *)(&flt)))
+
+/* Keep a count of the number of times we decrement and increment to
+ * approximate the double, and attempt to detect the case where we
+ * could potentially toggle back and forth between decrementing and
+ * incrementing. It is possible for us to be stuck in the loop when
+ * incrementing by one or decrementing by one may exceed or stay below
+ * the value that we are looking for. In this case, just break out of
+ * the loop if we toggle between incrementing and decrementing for more
+ * than twice.
+ */
+#define INCREMENT_FLOAT(_x, _decCount, _incCount) \
+ { \
+ ++FLOAT_TO_INTBITS(_x); \
+ _incCount++; \
+ if( (_incCount > 2) && (_decCount > 2) ) { \
+ if( _decCount > _incCount ) { \
+ FLOAT_TO_INTBITS(_x) += _decCount - _incCount; \
+ } else if( _incCount > _decCount ) { \
+ FLOAT_TO_INTBITS(_x) -= _incCount - _decCount; \
+ } \
+ break; \
+ } \
+ }
+#define DECREMENT_FLOAT(_x, _decCount, _incCount) \
+ { \
+ --FLOAT_TO_INTBITS(_x); \
+ _decCount++; \
+ if( (_incCount > 2) && (_decCount > 2) ) { \
+ if( _decCount > _incCount ) { \
+ FLOAT_TO_INTBITS(_x) += _decCount - _incCount; \
+ } else if( _incCount > _decCount ) { \
+ FLOAT_TO_INTBITS(_x) -= _incCount - _decCount; \
+ } \
+ break; \
+ } \
+ }
+
+#define allocateU64(ptr, n) if (!((ptr) = (U_64*) hymem_allocate_memory((n) * sizeof(U_64)))) goto OutOfMemory;
+#define release(r) if ((r)) hymem_free_memory((r));
+
+jfloat
+createFloat (JNIEnv * env, const char *s, jint e)
+{
+ /* assumes s is a null terminated string with at least one
+ * character in it */
+ U_64 def[DEFAULT_WIDTH];
+ U_64 defBackup[DEFAULT_WIDTH];
+ U_64 *f, *fNoOverflow, *g, *tempBackup;
+ U_32 overflow;
+ jfloat result;
+ IDATA index = 1;
+ int unprocessedDigits = 0;
+ PORT_ACCESS_FROM_ENV (env);
+
+ f = def;
+ fNoOverflow = defBackup;
+ *f = 0;
+ tempBackup = g = 0;
+ do
+ {
+ if (*s >= '0' && *s <= '9')
+ {
+ /* Make a back up of f before appending, so that we can
+ * back out of it if there is no more room, i.e. index >
+ * MAX_ACCURACY_WIDTH.
+ */
+ memcpy (fNoOverflow, f, sizeof (U_64) * index);
+ overflow =
+ simpleAppendDecimalDigitHighPrecision (f, index, *s - '0');
+ if (overflow)
+ {
+
+ f[index++] = overflow;
+ /* There is an overflow, but there is no more room
+ * to store the result. We really only need the top 52
+ * bits anyway, so we must back out of the overflow,
+ * and ignore the rest of the string.
+ */
+ if (index >= MAX_ACCURACY_WIDTH)
+ {
+ index--;
+ memcpy (f, fNoOverflow, sizeof (U_64) * index);
+ break;
+ }
+ if (tempBackup)
+ {
+ fNoOverflow = tempBackup;
+ }
+ }
+ }
+ else
+ index = -1;
+ }
+ while (index > 0 && *(++s) != '\0');
+
+ /* We've broken out of the parse loop either because we've reached
+ * the end of the string or we've overflowed the maximum accuracy
+ * limit of a double. If we still have unprocessed digits in the
+ * given string, then there are three possible results:
+ * 1. (unprocessed digits + e) == 0, in which case we simply
+ * convert the existing bits that are already parsed
+ * 2. (unprocessed digits + e) < 0, in which case we simply
+ * convert the existing bits that are already parsed along
+ * with the given e
+ * 3. (unprocessed digits + e) > 0 indicates that the value is
+ * simply too big to be stored as a double, so return Infinity
+ */
+ if ((unprocessedDigits = strlen (s)) > 0)
+ {
+ e += unprocessedDigits;
+ if (index > -1)
+ {
+ if (e <= 0)
+ {
+ result = createFloat1 (env, f, index, e);
+ }
+ else
+ {
+ FLOAT_TO_INTBITS (result) = INFINITE_INTBITS;
+ }
+ }
+ else
+ {
+ result = *(jfloat *) & index;
+ }
+ }
+ else
+ {
+ if (index > -1)
+ {
+ result = createFloat1 (env, f, index, e);
+ }
+ else
+ {
+ result = *(jfloat *) & index;
+ }
+ }
+
+ return result;
+
+}
+
+jfloat
+createFloat1 (JNIEnv * env, U_64 * f, IDATA length, jint e)
+{
+ IDATA numBits;
+ jdouble dresult;
+ jfloat result;
+
+ numBits = highestSetBitHighPrecision (f, length) + 1;
+ numBits -= lowestSetBitHighPrecision (f, length);
+ if (numBits < 25 && e >= 0 && e < LOG5_OF_TWO_TO_THE_N)
+ {
+ return ((jfloat) LOW_I32_FROM_PTR (f)) * tenToTheE (e);
+ }
+ else if (numBits < 25 && e < 0 && (-e) < LOG5_OF_TWO_TO_THE_N)
+ {
+ return ((jfloat) LOW_I32_FROM_PTR (f)) / tenToTheE (-e);
+ }
+ else if (e >= 0 && e < 39)
+ {
+ result = (jfloat) (toDoubleHighPrecision (f, length) * pow (10.0, e));
+ }
+ else if (e >= 39)
+ {
+ /* Convert the partial result to make sure that the
+ * non-exponential part is not zero. This check fixes the case
+ * where the user enters 0.0e309! */
+ result = (jfloat) toDoubleHighPrecision (f, length);
+
+ if (result == 0.0)
+
+ FLOAT_TO_INTBITS (result) = MINIMUM_INTBITS;
+ else
+ FLOAT_TO_INTBITS (result) = INFINITE_INTBITS;
+ }
+ else if (e > -309)
+ {
+ int dexp;
+ U_32 fmant, fovfl;
+ U_64 dmant;
+ dresult = toDoubleHighPrecision (f, length) / pow (10.0, -e);
+ if (IS_DENORMAL_DBL (dresult))
+ {
+ FLOAT_TO_INTBITS (result) = 0;
+ return result;
+ }
+ dexp = doubleExponent (dresult) + 51;
+ dmant = doubleMantissa (dresult);
+ /* Is it too small to be represented by a single-precision
+ * float? */
+ if (dexp <= -155)
+ {
+ FLOAT_TO_INTBITS (result) = 0;
+ return result;
+ }
+ /* Is it a denormalized single-precision float? */
+ if ((dexp <= -127) && (dexp > -155))
+ {
+ /* Only interested in 24 msb bits of the 53-bit double mantissa */
+ fmant = (U_32) (dmant >> 29);
+ fovfl = ((U_32) (dmant & 0x1FFFFFFF)) << 3;
+ while ((dexp < -127) && ((fmant | fovfl) != 0))
+ {
+ if ((fmant & 1) != 0)
+ {
+ fovfl |= 0x80000000;
+ }
+ fovfl >>= 1;
+ fmant >>= 1;
+ dexp++;
+ }
+ if ((fovfl & 0x80000000) != 0)
+ {
+ if ((fovfl & 0x7FFFFFFC) != 0)
+ {
+ fmant++;
+ }
+ else if ((fmant & 1) != 0)
+ {
+ fmant++;
+ }
+ }
+ else if ((fovfl & 0x40000000) != 0)
+ {
+ if ((fovfl & 0x3FFFFFFC) != 0)
+ {
+ fmant++;
+ }
+ }
+ FLOAT_TO_INTBITS (result) = fmant;
+ }
+ else
+ {
+ result = (jfloat) dresult;
+ }
+ }
+
+ /* Don't go straight to zero as the fact that x*0 = 0 independent
+ * of x might cause the algorithm to produce an incorrect result.
+ * Instead try the min value first and let it fall to zero if need
+ * be.
+ */
+ if (e <= -309 || FLOAT_TO_INTBITS (result) == 0)
+ FLOAT_TO_INTBITS (result) = MINIMUM_INTBITS;
+
+ return floatAlgorithm (env, f, length, e, (jfloat) result);
+}
+
+#if defined(WIN32)
+/* disable global optimizations on the microsoft compiler for the
+ * floatAlgorithm function otherwise it won't properly compile */
+#pragma optimize("g",off)
+#endif
+
+/* The algorithm for the function floatAlgorithm() below can be found
+ * in:
+ *
+ * "How to Read Floating-Point Numbers Accurately", William D.
+ * Clinger, Proceedings of the ACM SIGPLAN '90 Conference on
+ * Programming Language Design and Implementation, June 20-22,
+ * 1990, pp. 92-101.
+ *
+ * There is a possibility that the function will end up in an endless
+ * loop if the given approximating floating-point number (a very small
+ * floating-point whose value is very close to zero) straddles between
+ * two approximating integer values. We modified the algorithm slightly
+ * to detect the case where it oscillates back and forth between
+ * incrementing and decrementing the floating-point approximation. It
+ * is currently set such that if the oscillation occurs more than twice
+ * then return the original approximation.
+ */
+jfloat
+floatAlgorithm (JNIEnv * env, U_64 * f, IDATA length, jint e, jfloat z)
+{
+ U_64 m;
+ IDATA k, comparison, comparison2;
+ U_64 *x, *y, *D, *D2;
+ IDATA xLength, yLength, DLength, D2Length;
+ IDATA decApproxCount, incApproxCount;
+ PORT_ACCESS_FROM_ENV (env);
+
+ x = y = D = D2 = 0;
+ xLength = yLength = DLength = D2Length = 0;
+ decApproxCount = incApproxCount = 0;
+
+ do
+ {
+ m = floatMantissa (z);
+ k = floatExponent (z);
+
+ if (x && x != f)
+ jclmem_free_memory (env, x);
+ release (y);
+ release (D);
+ release (D2);
+
+ if (e >= 0 && k >= 0)
+ {
+ xLength = sizeOfTenToTheE (e) + length;
+ allocateU64 (x, xLength);
+ memset (x + length, 0, sizeof (U_64) * (xLength - length));
+ memcpy (x, f, sizeof (U_64) * length);
+ timesTenToTheEHighPrecision (x, xLength, e);
+
+ yLength = (k >> 6) + 2;
+ allocateU64 (y, yLength);
+ memset (y + 1, 0, sizeof (U_64) * (yLength - 1));
+ *y = m;
+ simpleShiftLeftHighPrecision (y, yLength, k);
+ }
+ else if (e >= 0)
+ {
+ xLength = sizeOfTenToTheE (e) + length + ((-k) >> 6) + 1;
+ allocateU64 (x, xLength);
+ memset (x + length, 0, sizeof (U_64) * (xLength - length));
+ memcpy (x, f, sizeof (U_64) * length);
+ timesTenToTheEHighPrecision (x, xLength, e);
+ simpleShiftLeftHighPrecision (x, xLength, -k);
+
+ yLength = 1;
+ allocateU64 (y, 1);
+ *y = m;
+ }
+ else if (k >= 0)
+ {
+ xLength = length;
+ x = f;
+
+ yLength = sizeOfTenToTheE (-e) + 2 + (k >> 6);
+ allocateU64 (y, yLength);
+ memset (y + 1, 0, sizeof (U_64) * (yLength - 1));
+ *y = m;
+ timesTenToTheEHighPrecision (y, yLength, -e);
+ simpleShiftLeftHighPrecision (y, yLength, k);
+ }
+ else
+ {
+ xLength = length + ((-k) >> 6) + 1;
+ allocateU64 (x, xLength);
+ memset (x + length, 0, sizeof (U_64) * (xLength - length));
+ memcpy (x, f, sizeof (U_64) * length);
+ simpleShiftLeftHighPrecision (x, xLength, -k);
+
+ yLength = sizeOfTenToTheE (-e) + 1;
+ allocateU64 (y, yLength);
+ memset (y + 1, 0, sizeof (U_64) * (yLength - 1));
+ *y = m;
+ timesTenToTheEHighPrecision (y, yLength, -e);
+ }
+
+ comparison = compareHighPrecision (x, xLength, y, yLength);
+ if (comparison > 0)
+ { /* x > y */
+ DLength = xLength;
+ allocateU64 (D, DLength);
+ memcpy (D, x, DLength * sizeof (U_64));
+ subtractHighPrecision (D, DLength, y, yLength);
+ }
+ else if (comparison)
+ { /* y > x */
+ DLength = yLength;
+ allocateU64 (D, DLength);
+ memcpy (D, y, DLength * sizeof (U_64));
+ subtractHighPrecision (D, DLength, x, xLength);
+ }
+ else
+ { /* y == x */
+ DLength = 1;
+ allocateU64 (D, 1);
+ *D = 0;
+ }
+
+ D2Length = DLength + 1;
+ allocateU64 (D2, D2Length);
+ m <<= 1;
+ multiplyHighPrecision (D, DLength, &m, 1, D2, D2Length);
+ m >>= 1;
+
+ comparison2 = compareHighPrecision (D2, D2Length, y, yLength);
+ if (comparison2 < 0)
+ {
+ if (comparison < 0 && m == NORMAL_MASK)
+ {
+ simpleShiftLeftHighPrecision (D2, D2Length, 1);
+ if (compareHighPrecision (D2, D2Length, y, yLength) > 0)
+ {
+ DECREMENT_FLOAT (z, decApproxCount, incApproxCount);
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+ else if (comparison2 == 0)
+ {
+ if ((m & 1) == 0)
+ {
+ if (comparison < 0 && m == NORMAL_MASK)
+ {
+ DECREMENT_FLOAT (z, decApproxCount, incApproxCount);
+ }
+ else
+ {
+ break;
+ }
+ }
+ else if (comparison < 0)
+ {
+ DECREMENT_FLOAT (z, decApproxCount, incApproxCount);
+ break;
+ }
+ else
+ {
+ INCREMENT_FLOAT (z, decApproxCount, incApproxCount);
+ break;
+ }
+ }
+ else if (comparison < 0)
+ {
+ DECREMENT_FLOAT (z, decApproxCount, incApproxCount);
+ }
+ else
+ {
+ if (FLOAT_TO_INTBITS (z) == EXPONENT_MASK)
+ break;
+ INCREMENT_FLOAT (z, decApproxCount, incApproxCount);
+ }
+ }
+ while (1);
+
+ if (x && x != f)
+ jclmem_free_memory (env, x);
+ release (y);
+ release (D);
+ release (D2);
+ return z;
+
+OutOfMemory:
+ if (x && x != f)
+ jclmem_free_memory (env, x);
+ release (y);
+ release (D);
+ release (D2);
+
+ FLOAT_TO_INTBITS (z) = -2;
+
+ return z;
+}
+
+#if defined(WIN32)
+#pragma optimize("",on) /*restore optimizations */
+#endif
+
+JNIEXPORT jfloat JNICALL
+Java_com_ibm_oti_util_FloatingPointParser_parseFltImpl (JNIEnv * env,
+ jclass clazz,
+ jstring s, jint e)
+{
+ jfloat flt;
+ const char *str = (*env)->GetStringUTFChars (env, s, 0);
+ flt = createFloat (env, str, e);
+ (*env)->ReleaseStringUTFChars (env, s, str);
+
+ if (((I_32) FLOAT_TO_INTBITS (flt)) >= 0)
+ {
+ return flt;
+ }
+ else if (((I_32) FLOAT_TO_INTBITS (flt)) == (I_32) - 1)
+ {
+ clazz = (*env)->FindClass (env, "java/lang/NumberFormatException");
+ if (clazz == 0)
+ return 0.0;
+ (*env)->ThrowNew (env, clazz, "");
+ }
+ else
+ { /* OutOfMemoryError */
+ clazz = (*env)->FindClass (env, "java/lang/OutOfMemoryError");
+ if (clazz == 0)
+ return 0.0;
+ (*env)->ThrowNew (env, clazz, "");
+ }
+
+ return 0.0;
+}
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/jclglob.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/jclglob.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/jclglob.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/jclglob.h Wed Mar 1 07:42:53 2006
@@ -0,0 +1,30 @@
+/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if !defined(jclglob_h)
+#define jclglob_h
+#include "jcl.h"
+extern void *Math_JCL_ID_CACHE;
+#define JCL_ID_CACHE Math_JCL_ID_CACHE
+typedef struct MathJniIDCache
+{
+
+ void *dummy; /* Placeholder. Some compilers reject empty structs. */
+
+} MathJniIDCache;
+#define JniIDCache MathJniIDCache
+/* Now that the module-specific defines are in place, include the shared file */
+#include "libglob.h"
+#endif /* jclglob_h */
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/math_copyright.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/math_copyright.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/math_copyright.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/math_copyright.c Wed Mar 1 07:42:53 2006
@@ -0,0 +1,19 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* A copyright string included in each DLL and executable */
+
+const char hyCopyright[] =
+ "(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.";
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/mathglob.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/mathglob.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/mathglob.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/math/mathglob.c Wed Mar 1 07:42:53 2006
@@ -0,0 +1,118 @@
+/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* HarmonyDoxygen */
+/**
+ * @file
+ * @ingroup HarmonyNatives
+ * @brief Harmony Math natives initialization API.
+ */
+
+#include <string.h>
+#include "jcl.h"
+#include "jclglob.h"
+
+static UDATA keyInitCount = 0;
+
+void *JCL_ID_CACHE = NULL;
+
+static void freeReferences (JNIEnv * env);
+
+/**
+ * This DLL is being loaded, do any initialization required.
+ * This may be called more than once.
+ */
+jint JNICALL
+JNI_OnLoad (JavaVM * vm, void *reserved)
+{
+ JniIDCache *idCache;
+ JNIEnv *env;
+ void *keyInitCountPtr = GLOBAL_DATA (keyInitCount);
+ void **jclIdCache = GLOBAL_DATA (JCL_ID_CACHE);
+
+ if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2) == JNI_OK)
+ {
+ PORT_ACCESS_FROM_ENV (env);
+
+ if (HY_VMLS_FNTBL (env)->
+ HYVMLSAllocKeys (env, keyInitCountPtr, jclIdCache, NULL))
+ {
+ goto fail;
+ }
+
+ /* This allocate must actually be done by hymem_allocate_memory. */
+ idCache = (JniIDCache *) hymem_allocate_memory (sizeof (JniIDCache));
+ if (!idCache)
+ goto fail2;
+
+ memset (idCache, 0, sizeof (JniIDCache));
+ HY_VMLS_SET (env, *jclIdCache, idCache);
+
+ /* Attach to the common library */
+ if (JNI_OK != ClearLibAttach (env))
+ {
+ goto fail2;
+ }
+
+ return JNI_VERSION_1_2;
+ }
+
+fail2:
+ HY_VMLS_FNTBL (env)->HYVMLSFreeKeys (env, keyInitCountPtr, jclIdCache, NULL);
+fail:
+ return 0;
+}
+
+/**
+ * This DLL is being unloaded, do any clean up required.
+ * This may be called more than once!!
+ */
+void JNICALL
+JNI_OnUnload (JavaVM * vm, void *reserved)
+{
+ JNIEnv *env;
+ void *keyInitCountPtr = GLOBAL_DATA (keyInitCount);
+ void **jclIdCache = GLOBAL_DATA (JCL_ID_CACHE);
+
+ if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2) == JNI_OK)
+ {
+ JniIDCache *idCache = (JniIDCache *) HY_VMLS_GET (env, *jclIdCache);
+
+ if (idCache)
+ {
+ PORT_ACCESS_FROM_ENV (env);
+
+ /* Detach from the common library */
+ ClearLibDetach (env);
+
+ /* Free any global references */
+ freeReferences (env);
+
+ /* Free VMLS keys */
+ idCache = (JniIDCache *) HY_VMLS_GET (env, *jclIdCache);
+ HY_VMLS_FNTBL (env)->HYVMLSFreeKeys (env, keyInitCountPtr,
+ jclIdCache, NULL);
+ hymem_free_memory (idCache);
+ }
+ }
+}
+
+/**
+ * @internal
+ */
+static void
+freeReferences (JNIEnv * env)
+{
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar 1 07:42:53 2006
@@ -0,0 +1 @@
+*.obj
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/IMemorySystem.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/IMemorySystem.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/IMemorySystem.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/IMemorySystem.h Wed Mar 1 07:42:53 2006
@@ -0,0 +1,34 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_ibm_platform_IMemorySystem */
+
+#ifndef _Included_com_ibm_platform_IMemorySystem
+#define _Included_com_ibm_platform_IMemorySystem
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_ibm_platform_IMemorySystem_MMAP_READ_ONLY
+#define com_ibm_platform_IMemorySystem_MMAP_READ_ONLY 1L
+#undef com_ibm_platform_IMemorySystem_MMAP_READ_WRITE
+#define com_ibm_platform_IMemorySystem_MMAP_READ_WRITE 2L
+#undef com_ibm_platform_IMemorySystem_MMAP_WRITE_COPY
+#define com_ibm_platform_IMemorySystem_MMAP_WRITE_COPY 4L
+#ifdef __cplusplus
+}
+#endif
+#endif
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSFileSystem.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSFileSystem.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSFileSystem.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSFileSystem.c Wed Mar 1 07:42:53 2006
@@ -0,0 +1,285 @@
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * Common natives supporting the file system interface.
+ */
+
+#include <harmony.h>
+#include <string.h>
+
+#include "OSFileSystem.h"
+#include "IFileSystem.h"
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: readDirectImpl
+ * Signature: (JJI)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_readDirectImpl
+ (JNIEnv * env, jobject thiz, jlong fd, jlong buf, jint offset, jint nbytes)
+{
+ PORT_ACCESS_FROM_ENV (env);
+ return (jlong) hyfile_read ((IDATA) fd, (void *) (buf+offset), (IDATA) nbytes);
+}
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: writeDirectImpl
+ * Signature: (JJI)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_writeDirectImpl
+ (JNIEnv * env, jobject thiz, jlong fd, jlong buf, jint offset, jint nbytes)
+{
+ PORT_ACCESS_FROM_ENV (env);
+ return (jlong) hyfile_write ((IDATA) fd, (const void *) (buf+offset),
+ (IDATA) nbytes);
+}
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: readImpl
+ * Signature: (J[BII)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_readImpl
+ (JNIEnv * env, jobject thiz, jlong fd, jbyteArray byteArray, jint offset,
+ jint nbytes)
+{
+ PORT_ACCESS_FROM_ENV (env);
+ jboolean isCopy;
+ jbyte *bytes = (*env)->GetByteArrayElements (env, byteArray, &isCopy);
+ jlong result;
+
+ result =
+ (jlong) hyfile_read ((IDATA) fd, (void *) (bytes + offset),
+ (IDATA) nbytes);
+ if (isCopy == JNI_TRUE)
+ {
+ (*env)->ReleaseByteArrayElements (env, byteArray, bytes, 0);
+ }
+
+ return result;
+}
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: writeImpl
+ * Signature: (J[BII)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_writeImpl
+ (JNIEnv * env, jobject thiz, jlong fd, jbyteArray byteArray, jint offset, jint nbytes)
+{
+ PORT_ACCESS_FROM_ENV (env);
+ jboolean isCopy;
+ jbyte *bytes = (*env)->GetByteArrayElements (env, byteArray, &isCopy);
+ jlong result;
+
+ result =
+ (jlong) hyfile_write ((IDATA) fd, (void *) (bytes + offset),
+ (IDATA) nbytes);
+ if (isCopy == JNI_TRUE)
+ {
+ (*env)->ReleaseByteArrayElements (env, byteArray, bytes, 0);
+ }
+
+ return result;
+}
+
+/**
+ * Seeks a file descriptor to a given file position.
+ *
+ * @param env pointer to Java environment
+ * @param thiz pointer to object receiving the message
+ * @param fd handle of file to be seeked
+ * @param offset distance of movement in bytes relative to whence arg
+ * @param whence enum value indicating from where the offset is relative
+ * The valid values are defined in fsconstants.h.
+ * @return the new file position from the beginning of the file, in bytes;
+ * or -1 if a problem occurs.
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_seekImpl
+ (JNIEnv * env, jobject thiz, jlong fd, jlong offset, jint whence)
+{
+ PORT_ACCESS_FROM_ENV (env);
+ I_32 hywhence = 0; /* The HY PPL equivalent of our whence arg.*/
+
+ /* Convert whence argument */
+ switch (whence)
+ {
+ case com_ibm_platform_IFileSystem_SEEK_SET:
+ hywhence = HySeekSet;
+ break;
+ case com_ibm_platform_IFileSystem_SEEK_CUR:
+ hywhence = HySeekCur;
+ break;
+ case com_ibm_platform_IFileSystem_SEEK_END:
+ hywhence = HySeekEnd;
+ break;
+ default:
+ return -1;
+ }
+
+ return (jlong) hyfile_seek ((IDATA) fd, (IDATA) offset, hywhence);
+}
+
+/**
+ * Flushes a file state to disk.
+ *
+ * @param env pointer to Java environment
+ * @param thiz pointer to object receiving the message
+ * @param fd handle of file to be flushed
+ * @param metadata if true also flush metadata, otherwise just flush data is possible.
+ * @return zero on success and -1 on failure
+ *
+ * Method: fflushImpl
+ * Signature: (JZ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_fflushImpl
+ (JNIEnv * env, jobject thiz, jlong fd, jboolean metadata)
+{
+ PORT_ACCESS_FROM_ENV (env);
+
+ return (jint) hyfile_sync ((IDATA) fd);
+}
+
+/**
+ * Closes the given file handle
+ *
+ * @param env pointer to Java environment
+ * @param thiz pointer to object receiving the message
+ * @param fd handle of file to be closed
+ * @return zero on success and -1 on failure
+ *
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: closeImpl
+ * Signature: (J)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_closeImpl
+ (JNIEnv * env, jobject thiz, jlong fd)
+{
+ PORT_ACCESS_FROM_ENV (env);
+
+ return (jint) hyfile_close ((IDATA) fd);
+}
+
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: truncateImpl
+ * Signature: (JJ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_truncateImpl
+ (JNIEnv * env, jobject thiz, jlong fd, jlong size)
+{
+ PORT_ACCESS_FROM_ENV (env);
+
+ return (jint)hyfile_set_length((IDATA)fd, (I_64)size);
+
+}
+
+#define jclSeparator DIR_SEPARATOR
+/**
+ * This will convert all separators to the proper platform separator
+ * and remove duplicates on non POSIX platforms.
+ */
+void convertToPlatform (char *path)
+{
+ char *pathIndex;
+ int length = strlen (path);
+
+ /* Convert all separators to the same type */
+ pathIndex = path;
+ while (*pathIndex != '\0')
+ {
+ if ((*pathIndex == '\\' || *pathIndex == '/')
+ && (*pathIndex != jclSeparator))
+ *pathIndex = jclSeparator;
+ pathIndex++;
+ }
+
+ /* Remove duplicate separators */
+ if (jclSeparator == '/')
+ return; /* Do not do POSIX platforms */
+
+ /* Remove duplicate initial separators */
+ pathIndex = path;
+ while ((*pathIndex != '\0') && (*pathIndex == jclSeparator))
+ {
+ pathIndex++;
+ }
+ if ((pathIndex > path) && (length > (pathIndex - path))
+ && (*(pathIndex + 1) == ':'))
+ {
+ /* For Example '////c:/*' */
+ int newlen = length - (pathIndex - path);
+ memmove (path, pathIndex, newlen);
+ path[newlen] = '\0';
+ }
+ else
+ {
+ if ((pathIndex - path > 3) && (length > (pathIndex - path)))
+ {
+ /* For Example '////serverName/*' */
+ int newlen = length - (pathIndex - path) + 2;
+ memmove (path, pathIndex - 2, newlen);
+ path[newlen] = '\0';
+ }
+ }
+ /* This will have to handle extra \'s but currently doesn't */
+}
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: openImpl
+ * Signature: ([BI)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_openImpl
+ (JNIEnv * env, jobject obj, jbyteArray path, jint jflags){
+ PORT_ACCESS_FROM_ENV (env);
+ I_32 flags = 0;
+ I_32 mode = 0;
+ IDATA portFD;
+ jsize length;
+ char pathCopy[HyMaxPath];
+
+ switch(jflags){
+ case com_ibm_platform_IFileSystem_O_RDONLY:
+ flags = HyOpenRead;
+ mode = 0;
+ break;
+ case com_ibm_platform_IFileSystem_O_WRONLY:
+ flags = HyOpenCreate | HyOpenWrite | HyOpenTruncate;
+ mode = 0666;
+ break;
+ case com_ibm_platform_IFileSystem_O_RDWR:
+ flags = HyOpenRead | HyOpenWrite | HyOpenCreate;
+ mode = 0666;
+ break;
+ case com_ibm_platform_IFileSystem_O_APPEND:
+ flags = HyOpenWrite | HyOpenCreate | HyOpenAppend;
+ mode = 0666;
+ break;
+ }
+
+ length = (*env)->GetArrayLength (env, path);
+ length = length < HyMaxPath - 1 ? length : HyMaxPath - 1;
+ ((*env)->GetByteArrayRegion (env, path, 0, length, pathCopy));
+ pathCopy[length] = '\0';
+ convertToPlatform (pathCopy);
+
+ portFD = hyfile_open (pathCopy, flags, mode);
+ return (jlong)portFD;
+ }
+
+
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSFileSystem.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSFileSystem.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSFileSystem.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSFileSystem.h Wed Mar 1 07:42:53 2006
@@ -0,0 +1,142 @@
+/* Copyright 2004, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <jni.h>
+/* Header for class com_ibm_platform_OSFileSystem */
+
+#ifndef _Included_com_ibm_platform_OSFileSystem
+#define _Included_com_ibm_platform_OSFileSystem
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: lockImpl
+ * Signature: (JJJIZ)I
+ */
+ JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_lockImpl
+ (JNIEnv *, jobject, jlong, jlong, jlong, jint, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: getPageSize
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_getPageSize
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: unlockImpl
+ * Signature: (JJJ)I
+ */
+ JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_unlockImpl
+ (JNIEnv *, jobject, jlong, jlong, jlong);
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: fflushImpl
+ * Signature: (JZ)I
+ */
+ JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_fflushImpl
+ (JNIEnv *, jobject, jlong, jboolean);
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: seekImpl
+ * Signature: (JJI)J
+ */
+ JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_seekImpl
+ (JNIEnv *, jobject, jlong, jlong, jint);
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: readDirectImpl
+ * Signature: (JJII)J
+ */
+ JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_readDirectImpl
+ (JNIEnv *, jobject, jlong, jlong, jint, jint);
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: writeDirectImpl
+ * Signature: (JJII)J
+ */
+ JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_writeDirectImpl
+ (JNIEnv *, jobject, jlong, jlong, jint, jint);
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: readImpl
+ * Signature: (J[BII)J
+ */
+ JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_readImpl
+ (JNIEnv *, jobject, jlong, jbyteArray, jint, jint);
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: writeImpl
+ * Signature: (J[BII)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_writeImpl
+ (JNIEnv *, jobject, jlong, jbyteArray, jint, jint);
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: readvImpl
+ * Signature: (J[J[I[II)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_readvImpl
+ (JNIEnv *, jobject, jlong, jlongArray, jintArray, jintArray, jint);
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: writevImpl
+ * Signature: (J[J[I[II)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_writevImpl
+ (JNIEnv *, jobject, jlong, jlongArray, jintArray, jintArray, jint);
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: closeImpl
+ * Signature: (J)I
+ */
+ JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_closeImpl
+ (JNIEnv *, jobject, jlong);
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: truncateImpl
+ * Signature: (JJ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSFileSystem_truncateImpl
+ (JNIEnv *, jobject, jlong, jlong);
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: openImpl
+ * Signature: ([BI)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_openImpl
+ (JNIEnv *, jobject, jbyteArray, jint);
+
+/*
+ * Class: com_ibm_platform_OSFileSystem
+ * Method: transferImpl
+ * Signature: (JLjava/io/FileDescriptor;JJ)J
+ */
+JNIEXPORT jlong JNICALL Java_com_ibm_platform_OSFileSystem_transferImpl
+ (JNIEnv *, jobject, jlong, jobject, jlong, jlong);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSNetworkSystem.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSNetworkSystem.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSNetworkSystem.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/OSNetworkSystem.h Wed Mar 1 07:42:53 2006
@@ -0,0 +1,365 @@
+/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <jni.h>
+/* Header for class com_ibm_platform_OSNetworkSystem */
+#define SOCKET_CONNECT_STEP_START 0
+#define SOCKET_CONNECT_STEP_CHECK 1
+#define SOCKET_OP_NONE 0
+#define SOCKET_OP_READ 1
+#define SOCKET_OP_WRITE 2
+#define SOCKET_READ_WRITE 3
+
+
+#ifndef _Included_com_ibm_platform_OSNetworkSystem
+#define _Included_com_ibm_platform_OSNetworkSystem
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: oneTimeInitializationDatagram
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_oneTimeInitializationDatagram
+ (JNIEnv *, jclass, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: oneTimeInitializationSocket
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_oneTimeInitializationSocket
+ (JNIEnv *, jclass, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: createSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_createSocketImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: createDatagramSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_createDatagramSocketImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: readSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;[BIII)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_readSocketImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: writeSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;[BII)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_writeSocketImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: setNonBlockingImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_setNonBlockingImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: connectSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;ILjava/net/InetAddress;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_connectSocketImpl
+ (JNIEnv *, jclass, jobject, jint, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: connectWithTimeoutSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;IILjava/net/InetAddress;IILjava/lang/Long;)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_connectWithTimeoutSocketImpl
+ (JNIEnv *, jclass, jobject, jint, jint, jobject, jint, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: connectStreamWithTimeoutSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;IIILjava/net/InetAddress;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_connectStreamWithTimeoutSocketImpl
+ (JNIEnv *, jclass, jobject, jint, jint, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: socketBindImpl
+ * Signature: (Ljava/io/FileDescriptor;ILjava/net/InetAddress;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_socketBindImpl
+ (JNIEnv *, jclass, jobject, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: listenStreamSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;I)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_listenStreamSocketImpl
+ (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: availableStreamImpl
+ * Signature: (Ljava/io/FileDescriptor;)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_availableStreamImpl
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: acceptSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/SocketImpl;Ljava/io/FileDescriptor;I)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_acceptSocketImpl
+ (JNIEnv *, jclass, jobject, jobject, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: supportsUrgentDataImpl
+ * Signature: (Ljava/io/FileDescriptor;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_ibm_platform_OSNetworkSystem_supportsUrgentDataImpl
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: sendUrgentDataImpl
+ * Signature: (Ljava/io/FileDescriptor;B)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_sendUrgentDataImpl
+ (JNIEnv *, jclass, jobject, jbyte);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: connectDatagramImpl2
+ * Signature: (Ljava/io/FileDescriptor;IILjava/net/InetAddress;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_connectDatagramImpl2
+ (JNIEnv *, jclass, jobject, jint, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: disconnectDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_disconnectDatagramImpl
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: socketBindImpl2
+ * Signature: (Ljava/io/FileDescriptor;IZLjava/net/InetAddress;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_ibm_platform_OSNetworkSystem_socketBindImpl2
+ (JNIEnv *, jclass, jobject, jint, jboolean, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: peekDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/InetAddress;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_peekDatagramImpl
+ (JNIEnv *, jclass, jobject, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: receiveDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/DatagramPacket;[BIIIZ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_receiveDatagramImpl
+ (JNIEnv *, jclass, jobject, jobject, jbyteArray, jint, jint, jint, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: recvConnectedDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/DatagramPacket;[BIIIZ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_recvConnectedDatagramImpl
+ (JNIEnv *, jclass, jobject, jobject, jbyteArray, jint, jint, jint, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: sendDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;[BIIIZILjava/net/InetAddress;)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_sendDatagramImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint, jint, jboolean, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: sendConnectedDatagramImpl
+ * Signature: (Ljava/io/FileDescriptor;[BIIZ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_sendConnectedDatagramImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: createServerStreamSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_createServerStreamSocketImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: createMulticastSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_createMulticastSocketImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: receiveStreamImpl
+ * Signature: (Ljava/io/FileDescriptor;[BIII)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_receiveStreamImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: sendStreamImpl
+ * Signature: (Ljava/io/FileDescriptor;[BII)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_sendStreamImpl
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: shutdownInputImpl
+ * Signature: (Ljava/io/FileDescriptor;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_shutdownInputImpl
+ (JNIEnv *, jobject, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: shutdownOutputImpl
+ * Signature: (Ljava/io/FileDescriptor;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_shutdownOutputImpl
+ (JNIEnv *, jobject, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: acceptStreamSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/SocketImpl;Ljava/io/FileDescriptor;I)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_acceptStreamSocketImpl
+ (JNIEnv *, jclass, jobject, jobject, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: createStreamSocketImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_createStreamSocketImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: sendDatagramImpl2
+ * Signature: (Ljava/io/FileDescriptor;[BIIILjava/net/InetAddress;)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_sendDatagramImpl2
+ (JNIEnv *, jclass, jobject, jbyteArray, jint, jint, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: selectImpl
+ * Signature: ([Ljava/io/FileDescriptor;[Ljava/io/FileDescriptor;II[IJ)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_selectImpl
+ (JNIEnv *, jclass, jobjectArray, jobjectArray, jint, jint, jintArray, jlong);
+
+ /*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: getSocketLocalAddressImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)Ljava/net/InetAddress;
+ */
+JNIEXPORT jobject JNICALL Java_com_ibm_platform_OSNetworkSystem_getSocketLocalAddressImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: getSocketLocalPortImpl
+ * Signature: (Ljava/io/FileDescriptor;Z)I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_getSocketLocalPortImpl
+ (JNIEnv *, jclass, jobject, jboolean);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: getSocketOptionImpl
+ * Signature: (Ljava/io/FileDescriptor;I)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL Java_com_ibm_platform_OSNetworkSystem_getSocketOptionImpl
+ (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: setSocketOptionImpl
+ * Signature: (Ljava/io/FileDescriptor;ILjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_setSocketOptionImpl
+ (JNIEnv *, jclass, jobject, jint, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: getSocketFlags
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_ibm_platform_OSNetworkSystem_getSocketFlagsImpl
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: socketCloseImpl
+ * Signature: (Ljava/io/FileDescriptor;)V
+ */
+JNIEXPORT void JNICALL Java_com_ibm_platform_OSNetworkSystem_socketCloseImpl
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: com_ibm_platform_OSNetworkSystem
+ * Method: getHostByAddrImpl
+ * Signature: ([B)Ljava/net/InetAddress;
+ */
+JNIEXPORT jobject JNICALL Java_com_ibm_platform_OSNetworkSystem_getHostByAddrImpl
+ (JNIEnv *, jclass, jbyteArray);
+
+JNIEXPORT jobject JNICALL Java_com_ibm_platform_OSNetworkSystem_getHostByNameImpl
+ (JNIEnv *, jclass,jstring,jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/nio_copyright.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/nio_copyright.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/nio_copyright.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/nio_copyright.c Wed Mar 1 07:42:53 2006
@@ -0,0 +1,19 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* A copyright string included in each DLL and executable */
+
+const char hyCopyright[] =
+ "(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.";