Commit 8eeda6e0 by Adam Megacz Committed by Adam Megacz

win32.cc (_Jv_platform_gettimeofday): Now takes no args, returns jlong.

2002-03-07  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.

From-SVN: r50416
parent 3df32212
2002-03-07 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.
2002-03-07 Bryce McKinlay <bryce@waitaki.otago.ac.nz> 2002-03-07 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* java/net/natPlainSocketImpl.cc (_Jv_recv): Removed. * java/net/natPlainSocketImpl.cc (_Jv_recv): Removed.
......
...@@ -28,6 +28,13 @@ details. */ ...@@ -28,6 +28,13 @@ details. */
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <gcj/cni.h>
extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *); 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); extern void _Jv_platform_initialize (void);
...@@ -16,8 +16,9 @@ details. */ ...@@ -16,8 +16,9 @@ details. */
#undef __INSIDE_CYGWIN__ #undef __INSIDE_CYGWIN__
#include <winsock.h> #include <winsock.h>
#include <gcj/cni.h>
extern void _Jv_platform_initialize (void); extern void _Jv_platform_initialize (void);
extern void _Jv_platform_gettimeofday (struct timeval *); extern jlong _Jv_platform_gettimeofday ();
#endif /* __JV_WIN32_H__ */ #endif /* __JV_WIN32_H__ */
...@@ -158,9 +158,7 @@ java::lang::System::arraycopy (jobject src, jint src_offset, ...@@ -158,9 +158,7 @@ java::lang::System::arraycopy (jobject src, jint src_offset,
jlong jlong
java::lang::System::currentTimeMillis (void) java::lang::System::currentTimeMillis (void)
{ {
struct timeval tv; return _Jv_platform_gettimeofday ();
_Jv_platform_gettimeofday (&tv);
return (jlong) tv.tv_sec * 1000 + tv.tv_usec / 1000;
} }
jint jint
......
...@@ -24,27 +24,25 @@ extern "C" unsigned long long _clock (void); ...@@ -24,27 +24,25 @@ extern "C" unsigned long long _clock (void);
#endif #endif
// gettimeofday implementation. // gettimeofday implementation.
void jlong
_Jv_platform_gettimeofday (struct timeval *tv) _Jv_platform_gettimeofday ()
{ {
#if defined (HAVE_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) #elif defined (HAVE_TIME)
tv->tv_sec = time (NULL); return time (NULL) * 1000;
tv->tv_usec = 0;
#elif defined (HAVE_FTIME) #elif defined (HAVE_FTIME)
struct timeb t; struct timeb t;
ftime (&t); ftime (&t);
tv->tv_sec = t.time; return t.time * 1000 + t.millitm;
tv->tv_usec = t.millitm * 1000;
#elif defined (ECOS) #elif defined (ECOS)
// FIXME. // FIXME.
tv->tv_sec = _clock () / 1000; return _clock();
tv->tv_usec = 0;
#else #else
// In the absence of any function, time remains forever fixed. // In the absence of any function, time remains forever fixed.
tv->tv_sec = 23; return 23000;
tv->tv_usec = 0;
#endif #endif
} }
......
...@@ -10,6 +10,7 @@ details. */ ...@@ -10,6 +10,7 @@ details. */
#include <config.h> #include <config.h>
#include <jvm.h> #include <jvm.h>
#include <sys/timeb.h>
#include "platform.h" #include "platform.h"
#include <java/lang/ArithmeticException.h> #include <java/lang/ArithmeticException.h>
...@@ -39,10 +40,11 @@ _Jv_platform_initialize (void) ...@@ -39,10 +40,11 @@ _Jv_platform_initialize (void)
} }
// gettimeofday implementation. // gettimeofday implementation.
void jlong
_Jv_platform_gettimeofday (struct timeval *tv) _Jv_platform_gettimeofday ()
{ {
// FIXME struct timeb t;
return; ftime (&t);
return t.time * 1000 + t.millitm;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment