WIN-32: _Jv_platform_gettimeofday now takes no args, returns jlong

Adam Megacz patches@lists.megacz.com
Wed Mar 6 18:29:00 GMT 2002


As discussed here:

  http://gcc.gnu.org/ml/java/2002-02/msg00130.html

Ok to commit?

  - a

2002-03-06  Adam Megacz  <adam@xwt.org>

        * win32.cc (_Jv_platform_gettimeofday): Now takes no args,
        returns jlong. Added implementation
        * posix.cc (_Jv_platform_gettimeofday): Now takes no args,
        returns jlong.
        * win32.h (_Jv_platform_gettimeofday): Now takes no args,
        returns jlong.
        * posix.h (_Jv_platform_gettimeofday): Now takes no args,
        returns jlong.
        * java/lang/natSystem.cc (currentTimeMillis): Now uses updated
        _Jv_platform_gettimeofday signature.


Index: posix.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/posix.cc,v
retrieving revision 1.3
diff -u -r1.3 posix.cc
--- posix.cc	2002/02/07 18:59:50	1.3
+++ posix.cc	2002/03/07 02:14:56
@@ -24,27 +24,25 @@
 #endif
 
 // gettimeofday implementation.
-void
-_Jv_platform_gettimeofday (struct timeval *tv)
+jlong
+_Jv_platform_gettimeofday ()
 {
 #if defined (HAVE_GETTIMEOFDAY)
-  gettimeofday (tv, NULL);
+  timeval tv;
+  gettimeofday (&tv, NULL);
+  return tv.tv_sec * 1000 + tv.tv_usec / 1000;
 #elif defined (HAVE_TIME)
-  tv->tv_sec = time (NULL);
-  tv->tv_usec = 0;
+  return time (NULL) * 1000;
 #elif defined (HAVE_FTIME)
   struct timeb t;
   ftime (&t);
-  tv->tv_sec = t.time;
-  tv->tv_usec = t.millitm * 1000;
+  return t.time * 1000 + t.millitm;
 #elif defined (ECOS)
   // FIXME.
-  tv->tv_sec = _clock () / 1000;
-  tv->tv_usec = 0;
+  return _clock();
 #else
   // In the absence of any function, time remains forever fixed.
-  tv->tv_sec = 23;
-  tv->tv_usec = 0;
+  return 23000;
 #endif
 }
 
Index: win32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/win32.cc,v
retrieving revision 1.4
diff -u -r1.4 win32.cc
--- win32.cc	2002/02/12 04:35:32	1.4
+++ win32.cc	2002/03/07 02:14:56
@@ -10,6 +10,7 @@
 
 #include <config.h>
 #include <jvm.h>
+#include <sys/timeb.h>
 
 #include "platform.h"
 #include <java/lang/ArithmeticException.h>
@@ -39,10 +40,11 @@
 }
 
 // gettimeofday implementation.
-void
-_Jv_platform_gettimeofday (struct timeval *tv)
+jlong
+_Jv_platform_gettimeofday ()
 {
-  // FIXME
-  return;
+  struct timeb t;
+  ftime (&t);
+  return t.time * 1000 + t.millitm;
 }
 
Index: include/posix.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/posix.h,v
retrieving revision 1.3
diff -u -r1.3 posix.h
--- posix.h	2002/02/07 18:59:51	1.3
+++ posix.h	2002/03/07 02:14:56
@@ -28,6 +28,13 @@
 #include <unistd.h>
 #endif
 
+#include <gcj/cni.h>
+
 extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *);
-extern void _Jv_platform_gettimeofday (struct timeval *);
+extern jlong _Jv_platform_gettimeofday ();
 extern void _Jv_platform_initialize (void);
+
+
+
+
+
Index: include/win32.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/win32.h,v
retrieving revision 1.3
diff -u -r1.3 win32.h
--- win32.h	2002/02/12 02:25:07	1.3
+++ win32.h	2002/03/07 02:14:56
@@ -16,8 +16,9 @@
 
 #undef __INSIDE_CYGWIN__
 #include <winsock.h>
+#include <gcj/cni.h>
 
 extern void _Jv_platform_initialize (void);
-extern void _Jv_platform_gettimeofday (struct timeval *);
+extern jlong _Jv_platform_gettimeofday ();
 
 #endif /* __JV_WIN32_H__ */
Index: java/lang/natSystem.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natSystem.cc,v
retrieving revision 1.49
diff -u -r1.49 natSystem.cc
--- natSystem.cc	2002/02/27 05:32:26	1.49
+++ natSystem.cc	2002/03/07 02:14:56
@@ -158,9 +158,7 @@
 jlong
 java::lang::System::currentTimeMillis (void)
 {
-  struct timeval tv;
-  _Jv_platform_gettimeofday (&tv);
-  return (jlong) tv.tv_sec * 1000 + tv.tv_usec / 1000;
+  return _Jv_platform_gettimeofday ();
 }
 
 jint



More information about the Java-patches mailing list