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

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

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

revision 1.10 by mark, Sun Jan 9 19:29:38 2005 UTC revision 1.11 by glavaux, Fri Apr 8 13:01:42 2005 UTC
# Line 49  exception statement from your version. * Line 49  exception statement from your version. *
49   */   */
50  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
51  Java_java_lang_VMSystem_setIn (JNIEnv * env,  Java_java_lang_VMSystem_setIn (JNIEnv * env,
52                                 jclass thisClass __attribute__((__unused__)),                                 jclass thisClass __attribute__ ((__unused__)),
53                                 jobject obj)                                 jobject obj)
54  {  {
55    jclass cls;    jclass cls;
56    jfieldID field;    jfieldID field;
57    
58    cls = JCL_FindClass(env, "java/lang/System");    cls = JCL_FindClass (env, "java/lang/System");
59    if (!cls)    if (!cls)
60      return;      return;
61    
62    field = (*env)->GetStaticFieldID(env, cls, "in",    field = (*env)->GetStaticFieldID (env, cls, "in", "Ljava/io/InputStream;");
                                    "Ljava/io/InputStream;");  
63    if (!field)    if (!field)
64      return;      return;
65    (*env)->SetStaticObjectField(env, cls, field, obj);    (*env)->SetStaticObjectField (env, cls, field, obj);
66  }  }
67    
68  /*  /*
# Line 73  Java_java_lang_VMSystem_setIn (JNIEnv * Line 72  Java_java_lang_VMSystem_setIn (JNIEnv *
72   */   */
73  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
74  Java_java_lang_VMSystem_setOut (JNIEnv * env,  Java_java_lang_VMSystem_setOut (JNIEnv * env,
75                                  jclass thisClass __attribute__((__unused__)),                                  jclass thisClass __attribute__ ((__unused__)),
76                                  jobject obj)                                  jobject obj)
77  {  {
78    jclass cls;    jclass cls;
79    jfieldID field;    jfieldID field;
80    
81    cls = JCL_FindClass(env, "java/lang/System");    cls = JCL_FindClass (env, "java/lang/System");
82    if (!cls)    if (!cls)
83      return;      return;
84    
85    field = (*env)->GetStaticFieldID(env, cls, "out",    field = (*env)->GetStaticFieldID (env, cls, "out", "Ljava/io/PrintStream;");
                                    "Ljava/io/PrintStream;");  
86    if (!field)    if (!field)
87      return;      return;
88    (*env)->SetStaticObjectField(env, cls, field, obj);    (*env)->SetStaticObjectField (env, cls, field, obj);
89  }  }
90    
91  /*  /*
# Line 97  Java_java_lang_VMSystem_setOut (JNIEnv * Line 95  Java_java_lang_VMSystem_setOut (JNIEnv *
95   */   */
96  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
97  Java_java_lang_VMSystem_setErr (JNIEnv * env,  Java_java_lang_VMSystem_setErr (JNIEnv * env,
98                                  jclass thisClass __attribute__((__unused__)),                                  jclass thisClass __attribute__ ((__unused__)),
99                                  jobject obj)                                  jobject obj)
100  {  {
101    jclass cls;    jclass cls;
102    jfieldID field;    jfieldID field;
103    
104    cls = JCL_FindClass(env, "java/lang/System");    cls = JCL_FindClass (env, "java/lang/System");
105    if (!cls)    if (!cls)
106      return;      return;
107    
108    field = (*env)->GetStaticFieldID(env, cls, "err",    field = (*env)->GetStaticFieldID (env, cls, "err", "Ljava/io/PrintStream;");
                                    "Ljava/io/PrintStream;");  
109    if (!field)    if (!field)
110      return;      return;
111    (*env)->SetStaticObjectField(env, cls, field, obj);    (*env)->SetStaticObjectField (env, cls, field, obj);
112  }  }
113    
114  /*  /*
# Line 120  Java_java_lang_VMSystem_setErr (JNIEnv * Line 117  Java_java_lang_VMSystem_setErr (JNIEnv *
117   * Signature: ()J   * Signature: ()J
118   */   */
119  JNIEXPORT jlong JNICALL  JNIEXPORT jlong JNICALL
120  Java_java_lang_VMSystem_currentTimeMillis    Java_java_lang_VMSystem_currentTimeMillis
121  (JNIEnv * env __attribute__((__unused__)),    (JNIEnv * env __attribute__ ((__unused__)),
122   jclass thisClass __attribute__((__unused__)))     jclass thisClass __attribute__ ((__unused__)))
123  {  {
124    /* Note: this implementation copied directly from Japhar's, by Chris Toshok. */    /* Note: this implementation copied directly from Japhar's, by Chris Toshok. */
125    jlong result;    jlong result;
126    struct timeval tp;    struct timeval tp;
127    
128    if (gettimeofday(&tp, NULL) == -1)    if (gettimeofday (&tp, NULL) == -1)
129      (*env)->FatalError(env, "gettimeofday call failed.");      (*env)->FatalError (env, "gettimeofday call failed.");
130    
131    result = (jlong)tp.tv_sec;    result = (jlong) tp.tv_sec;
132    result *= 1000;    result *= 1000;
133    result += (tp.tv_usec / 1000);    result += (tp.tv_usec / 1000);
134    
# Line 139  Java_java_lang_VMSystem_currentTimeMilli Line 136  Java_java_lang_VMSystem_currentTimeMilli
136  }  }
137    
138  JNIEXPORT jstring JNICALL  JNIEXPORT jstring JNICALL
139  Java_java_lang_VMSystem_getenv (JNIEnv *env,  Java_java_lang_VMSystem_getenv (JNIEnv * env,
140                                  jclass klass __attribute__((__unused__)),                                  jclass klass __attribute__ ((__unused__)),
141                                  jstring jname)                                  jstring jname)
142  {  {
143    const char *cname;    const char *cname;
144    const char *envname;    const char *envname;
145    
146    cname = JCL_jstring_to_cstring(env, jname);    cname = JCL_jstring_to_cstring (env, jname);
147    if (cname == NULL)    if (cname == NULL)
148      return NULL;      return NULL;
149    
150    envname = getenv(cname);    envname = getenv (cname);
151    if (envname == NULL)    if (envname == NULL)
152      return NULL;      return NULL;
153    
154    JCL_free_cstring(env, jname, cname);    JCL_free_cstring (env, jname, cname);
155    return (*env)->NewStringUTF(env, envname);    return (*env)->NewStringUTF (env, envname);
156  }  }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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