+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.
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@
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@
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
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
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@
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@
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@
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@
/* 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
// 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.
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*);
// 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.
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
/* 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.
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> ...
* <code>dest[destStart+len-1]</code>. First, the arguments are validated:
// 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.
return _Jv_platform_gettimeofday ();
}
+jlong
+java::lang::System::nanoTime ()
+{
+ return _Jv_platform_nanotime ();
+}
+
jint
java::lang::System::identityHashCode (jobject obj)
{
// 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.
#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)
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@
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@
// 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.
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