/[classpath]/classpath/native/jni/java-lang/java_lang_Double.c
ViewVC logotype

Diff of /classpath/native/jni/java-lang/java_lang_Double.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by egagnon, Mon Mar 29 07:07:27 2004 UTC revision 1.14 by smarothy, Sun Oct 10 18:33:10 2004 UTC
# Line 50  exception statement from your version. * Line 50  exception statement from your version. *
50  static jmethodID isNaNID;  static jmethodID isNaNID;
51  static jdouble NEGATIVE_INFINITY;  static jdouble NEGATIVE_INFINITY;
52  static jdouble POSITIVE_INFINITY;  static jdouble POSITIVE_INFINITY;
53    static jdouble NaN;
54    
55  /*  /*
56   * Class:     java_lang_Double   * Class:     java_lang_Double
# Line 61  JNIEXPORT void JNICALL Java_java_lang_Do Line 62  JNIEXPORT void JNICALL Java_java_lang_Do
62  {  {
63    jfieldID negInfID;    jfieldID negInfID;
64    jfieldID posInfID;    jfieldID posInfID;
65      jfieldID nanID;
66    
67    isNaNID = (*env)->GetStaticMethodID(env, cls, "isNaN", "(D)Z");    isNaNID = (*env)->GetStaticMethodID(env, cls, "isNaN", "(D)Z");
68    if (isNaNID == NULL)    if (isNaNID == NULL)
# Line 80  JNIEXPORT void JNICALL Java_java_lang_Do Line 82  JNIEXPORT void JNICALL Java_java_lang_Do
82        DBG("unable to determine field id of POSITIVE_INFINITY\n")        DBG("unable to determine field id of POSITIVE_INFINITY\n")
83        return;        return;
84      }      }
85      nanID = (*env)->GetStaticFieldID(env, cls, "NaN", "D");
86      if (posInfID == NULL)
87        {
88          DBG("unable to determine field id of NaN\n")
89          return;
90        }
91    POSITIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, posInfID);    POSITIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, posInfID);
92    NEGATIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, negInfID);    NEGATIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, negInfID);
93      NaN = (*env)->GetStaticDoubleField(env, cls, nanID);
94    
95  #ifdef DEBUG  #ifdef DEBUG
96    fprintf(stderr, "java.lang.Double.initIDs() POSITIVE_INFINITY = %g\n", POSITIVE_INFINITY);    fprintf(stderr, "java.lang.Double.initIDs() POSITIVE_INFINITY = %g\n", POSITIVE_INFINITY);
97    fprintf(stderr, "java.lang.Double.initIDs() NEGATIVE_INFINITY = %g\n", NEGATIVE_INFINITY);    fprintf(stderr, "java.lang.Double.initIDs() NEGATIVE_INFINITY = %g\n", NEGATIVE_INFINITY);
98      fprintf(stderr, "java.lang.Double.initIDs() NaN = %g\n", NaN);
99  #endif  #endif
100  }  }
101    
# Line 252  JNIEXPORT jdouble JNICALL Java_java_lang Line 262  JNIEXPORT jdouble JNICALL Java_java_lang
262            ++last_non_ws;            ++last_non_ws;
263          }          }
264    
265          /* Check for infinity and NaN */
266          unsigned char *temp = p;
267          if(temp[0] == '+' || temp[0] == '-')
268            temp++;
269          if(strncmp("Infinity", temp, (size_t) 8) == 0)
270            {
271              if(p[0] == '-')
272                return NEGATIVE_INFINITY;
273              return POSITIVE_INFINITY;
274            }
275          if(strncmp("NaN", temp, (size_t) 3) == 0)
276            return NaN;
277    
278        /* Skip a trailing `f' or `d'.  */        /* Skip a trailing `f' or `d'.  */
279        if (last_non_ws > p        if (last_non_ws > p
280            && (last_non_ws[-1] == 'f'            && (last_non_ws[-1] == 'f'
# Line 266  JNIEXPORT jdouble JNICALL Java_java_lang Line 289  JNIEXPORT jdouble JNICALL Java_java_lang
289            memset (&reent, 0, sizeof reent);            memset (&reent, 0, sizeof reent);
290    
291  #ifdef KISSME_LINUX_USER  #ifdef KISSME_LINUX_USER
292              /* FIXME: The libc strtod may not be reliable. */          
293            val = strtod (p, &endptr);            val = strtod (p, &endptr);
294  #else  #else
295            val = _strtod_r (&reent, p, &endptr);            val = _strtod_r (&reent, p, &endptr);

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26