win32.cc (_Jv_platform_nanotime): New function.

* win32.cc (_Jv_platform_nanotime): New function.
	* include/win32.h (_Jv_platform_nanotime): Declare.
	* posix.cc (_Jv_platform_nanotime): New function.
	* include/posix.h (_Jv_platform_nanotime): Declare.
	* java/lang/natSystem.cc (nanoTime): New method.
	* java/lang/System.java (nanoTime): Declare.
	* include/config.h.in, configure: Rebuilt.
	* configure.ac: Check for clock_gettime.

From-SVN: r111869
This commit is contained in:
Tom Tromey 2006-03-09 18:47:54 +00:00 committed by Tom Tromey
parent cbbb5b6da1
commit e59a1e40f3
14 changed files with 167 additions and 6 deletions

View File

@ -1,3 +1,14 @@
2006-03-09 Tom Tromey <tromey@redhat.com>
* win32.cc (_Jv_platform_nanotime): New function.
* include/win32.h (_Jv_platform_nanotime): Declare.
* posix.cc (_Jv_platform_nanotime): New function.
* include/posix.h (_Jv_platform_nanotime): Declare.
* java/lang/natSystem.cc (nanoTime): New method.
* java/lang/System.java (nanoTime): Declare.
* include/config.h.in, configure: Rebuilt.
* configure.ac: Check for clock_gettime.
2006-03-08 David Daney <ddaney@avtrex.com>
* configure.ac (LD): Add AC_CHECK_TOOL for ld.

View File

@ -469,7 +469,10 @@ JAVA_HOME = @JAVA_HOME@
JAVA_HOME_SET_FALSE = @JAVA_HOME_SET_FALSE@
JAVA_HOME_SET_TRUE = @JAVA_HOME_SET_TRUE@
JC1GCSPEC = @JC1GCSPEC@
LD = @LD@
LDFLAGS = @LDFLAGS@
LD_FINISH_STATIC_SPEC = @LD_FINISH_STATIC_SPEC@
LD_START_STATIC_SPEC = @LD_START_STATIC_SPEC@
LIBART_CFLAGS = @LIBART_CFLAGS@
LIBART_LIBS = @LIBART_LIBS@
LIBFFI = @LIBFFI@
@ -562,6 +565,7 @@ ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_GCJ = @ac_ct_GCJ@
ac_ct_LD = @ac_ct_LD@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@

84
libjava/configure vendored
View File

@ -12377,6 +12377,90 @@ fi
fi
done
echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lrt $LIBS"
if test x$gcc_no_link = xyes; then
{ { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5
echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;}
{ (exit 1); exit 1; }; }
fi
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char clock_gettime ();
int
main ()
{
clock_gettime ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_rt_clock_gettime=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_rt_clock_gettime=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
if test $ac_cv_lib_rt_clock_gettime = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_CLOCK_GETTIME 1
_ACEOF
case "$THREADSPEC" in
*-lrt*) ;;
*) THREADSPEC="$THREADSPEC -lrt" ;;
esac
fi
LIBS="$save_LIBS"
# We can save a little space at runtime if the mutex has m_count

View File

@ -1016,6 +1016,14 @@ else
AC_DEFINE(HAVE_SCHED_YIELD)
THREADLIBS="$THREADLIBS -lposix4"
THREADSPEC="$THREADSPEC -lposix4"])])])
AC_CHECK_LIB(rt, clock_gettime, [
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])
case "$THREADSPEC" in
*-lrt*) ;;
*) THREADSPEC="$THREADSPEC -lrt" ;;
esac])
LIBS="$save_LIBS"
# We can save a little space at runtime if the mutex has m_count

View File

@ -142,7 +142,10 @@ JAVA_HOME = @JAVA_HOME@
JAVA_HOME_SET_FALSE = @JAVA_HOME_SET_FALSE@
JAVA_HOME_SET_TRUE = @JAVA_HOME_SET_TRUE@
JC1GCSPEC = @JC1GCSPEC@
LD = @LD@
LDFLAGS = @LDFLAGS@
LD_FINISH_STATIC_SPEC = @LD_FINISH_STATIC_SPEC@
LD_START_STATIC_SPEC = @LD_START_STATIC_SPEC@
LIBART_CFLAGS = @LIBART_CFLAGS@
LIBART_LIBS = @LIBART_LIBS@
LIBFFI = @LIBFFI@
@ -235,6 +238,7 @@ ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_GCJ = @ac_ct_GCJ@
ac_ct_LD = @ac_ct_LD@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@

View File

@ -141,7 +141,10 @@ JAVA_HOME = @JAVA_HOME@
JAVA_HOME_SET_FALSE = @JAVA_HOME_SET_FALSE@
JAVA_HOME_SET_TRUE = @JAVA_HOME_SET_TRUE@
JC1GCSPEC = @JC1GCSPEC@
LD = @LD@
LDFLAGS = @LDFLAGS@
LD_FINISH_STATIC_SPEC = @LD_FINISH_STATIC_SPEC@
LD_START_STATIC_SPEC = @LD_START_STATIC_SPEC@
LIBART_CFLAGS = @LIBART_CFLAGS@
LIBART_LIBS = @LIBART_LIBS@
LIBFFI = @LIBFFI@
@ -234,6 +237,7 @@ ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_GCJ = @ac_ct_GCJ@
ac_ct_LD = @ac_ct_LD@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@

View File

@ -61,6 +61,9 @@
/* Define to 1 if you have the `chmod' function. */
#undef HAVE_CHMOD
/* Define if you have clock_gettime() */
#undef HAVE_CLOCK_GETTIME
/* Define to 1 if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H

View File

@ -1,6 +1,6 @@
// posix.h -- Helper functions for POSIX-flavored OSs.
/* Copyright (C) 2000, 2002, 2003 Free Software Foundation
/* Copyright (C) 2000, 2002, 2003, 2006 Free Software Foundation
This file is part of libgcj.
@ -79,6 +79,7 @@ details. */
extern int _Jv_select (int n, fd_set *, fd_set *, fd_set *, struct timeval *);
extern jlong _Jv_platform_gettimeofday ();
extern jlong _Jv_platform_nanotime ();
extern void _Jv_platform_initialize (void);
extern void _Jv_platform_initProperties (java::util::Properties*);

View File

@ -1,6 +1,6 @@
// win32.h -- Helper functions for Microsoft-flavored OSs.
/* Copyright (C) 2002, 2003 Free Software Foundation
/* Copyright (C) 2002, 2003, 2006 Free Software Foundation
This file is part of libgcj.
@ -154,6 +154,7 @@ _Jv_ThrowSocketException ();
extern void _Jv_platform_initialize (void);
extern void _Jv_platform_initProperties (java::util::Properties*);
extern jlong _Jv_platform_gettimeofday ();
extern jlong _Jv_platform_nanotime ();
extern int _Jv_pipe (int filedes[2]);
extern void

View File

@ -1,5 +1,5 @@
/* System.java -- useful methods to interface with the system
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -207,6 +207,15 @@ public final class System
*/
public static native long currentTimeMillis();
/**
* Get the current time, measured in nanoseconds. The result is as
* precise as possible, and is measured against a fixed epoch.
* However, unlike currentTimeMillis(), the epoch chosen is
* arbitrary and may vary by platform, etc.
* @since 1.5
*/
public static native long nanoTime();
/**
* Copy one array onto another from <code>src[srcStart]</code> ...
* <code>src[srcStart+len-1]</code> to <code>dest[destStart]</code> ...

View File

@ -1,6 +1,6 @@
// natSystem.cc - Native code implementing System class.
/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation
/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2006 Free Software Foundation
This file is part of libgcj.
@ -124,6 +124,12 @@ java::lang::System::currentTimeMillis (void)
return _Jv_platform_gettimeofday ();
}
jlong
java::lang::System::nanoTime ()
{
return _Jv_platform_nanotime ();
}
jint
java::lang::System::identityHashCode (jobject obj)
{

View File

@ -1,6 +1,6 @@
// posix.cc -- Helper functions for POSIX-flavored OSs.
/* Copyright (C) 2000, 2001, 2002 Free Software Foundation
/* Copyright (C) 2000, 2001, 2002, 2006 Free Software Foundation
This file is part of libgcj.
@ -66,6 +66,22 @@ _Jv_platform_gettimeofday ()
#endif
}
jlong
_Jv_platform_nanotime ()
{
#ifdef HAVE_CLOCK_GETTIME
struct timespec now;
if (clock_gettime (CLOCK_REALTIME, &now) == 0)
{
jlong result = (jlong) now.tv_sec;
result = result * 1000 * 1000 + now.tv_nsec;
return result;
}
// clock_gettime failed, but we can fall through.
#endif // HAVE_CLOCK_GETTIME
return _Jv_platform_gettimeofday () * 1000LL;
}
// Platform-specific VM initialization.
void
_Jv_platform_initialize (void)

View File

@ -130,7 +130,10 @@ JAVA_HOME = @JAVA_HOME@
JAVA_HOME_SET_FALSE = @JAVA_HOME_SET_FALSE@
JAVA_HOME_SET_TRUE = @JAVA_HOME_SET_TRUE@
JC1GCSPEC = @JC1GCSPEC@
LD = @LD@
LDFLAGS = @LDFLAGS@
LD_FINISH_STATIC_SPEC = @LD_FINISH_STATIC_SPEC@
LD_START_STATIC_SPEC = @LD_START_STATIC_SPEC@
LIBART_CFLAGS = @LIBART_CFLAGS@
LIBART_LIBS = @LIBART_LIBS@
LIBFFI = @LIBFFI@
@ -223,6 +226,7 @@ ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_GCJ = @ac_ct_GCJ@
ac_ct_LD = @ac_ct_LD@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@

View File

@ -1,6 +1,6 @@
// win32.cc - Helper functions for Microsoft-flavored OSs.
/* Copyright (C) 2002, 2003 Free Software Foundation
/* Copyright (C) 2002, 2003, 2006 Free Software Foundation
This file is part of libgcj.
@ -279,6 +279,12 @@ _Jv_platform_gettimeofday ()
return t.time * 1000LL + t.millitm;
}
jlong
_Jv_platform_nanotime ()
{
return _Jv_platform_gettimeofday () * 1000LL;
}
// The following definitions "fake out" mingw to think that -mthreads
// was enabled and that mingwthr.dll was linked. GCJ-compiled
// applications don't need this helper library because we can safely