Bug 522126, part 3: Use POSIX-clock TimeStamp/TimeDuration implementation if configure.in says it's supported. r=luser
authorChris Jones <jones.chris.g@gmail.com>
Thu, 07 Jan 2010 11:21:33 -0600
changeset 36932 28d4c34835413e8281147f6fc903827df8cfe0fe
parent 36931 a2e7574e43ee9f596aa28158b30154b3bf5cc0db
child 36933 f405075062de2a63fce1afabad0fb73cdf8592e2
push id11063
push usercjones@mozilla.com
push dateThu, 07 Jan 2010 17:24:10 +0000
treeherdermozilla-central@28d4c3483541 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluser
bugs522126
milestone1.9.3a1pre
Bug 522126, part 3: Use POSIX-clock TimeStamp/TimeDuration implementation if configure.in says it's supported. r=luser
config/autoconf.mk.in
configure.in
toolkit/library/libxul-config.mk
xpcom/build/Makefile.in
xpcom/ds/Makefile.in
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -650,8 +650,11 @@ WRAP_SYSTEM_INCLUDES = @WRAP_SYSTEM_INCL
 HAVE_ARM_SIMD = @HAVE_ARM_SIMD@
 HAVE_ARM_NEON = @HAVE_ARM_NEON@
 
 MOZ_SPLASHSCREEN = @MOZ_SPLASHSCREEN@
 
 MOZ_THEME_FASTSTRIPE = @MOZ_THEME_FASTSTRIPE@
 
 MOZ_OFFICIAL_BRANDING = @MOZ_OFFICIAL_BRANDING@
+
+HAVE_CLOCK_MONOTONIC = @HAVE_CLOCK_MONOTONIC@
+REALTIME_LIBS = @REALTIME_LIBS@
--- a/configure.in
+++ b/configure.in
@@ -3595,16 +3595,35 @@ fi
 dnl Checks for library functions.
 dnl ========================================================
 AC_PROG_GCC_TRADITIONAL
 AC_FUNC_MEMCMP
 AC_CHECK_FUNCS(random strerror lchown fchmod snprintf statvfs memmove rint stat64 lstat64 truncate64 statvfs64 setbuf isatty)
 AC_CHECK_FUNCS(flockfile getpagesize)
 AC_CHECK_FUNCS(localtime_r strtok_r)
 
+dnl check for clock_gettime(), the CLOCK_MONOTONIC clock, and -lrt
+_SAVE_LDFLAGS=$LDFLAGS
+LDFLAGS="$LDFLAGS -lrt"
+AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC) and -lrt,
+               ac_cv_have_clock_monotonic,
+               [AC_TRY_LINK([#include <time.h>],
+                            [ struct timespec ts;
+                              clock_gettime(CLOCK_MONOTONIC, &ts); ],
+                            ac_cv_have_clock_monotonic=yes,
+                            ac_cv_have_clock_monotonic=no)])
+LDFLAGS=$_SAVE_LDFLAGS
+if test "$ac_cv_have_clock_monotonic" = "yes"; then
+    HAVE_CLOCK_MONOTONIC=1
+    REALTIME_LIBS=-lrt
+    AC_DEFINE(HAVE_CLOCK_MONOTONIC)
+    AC_SUBST(HAVE_CLOCK_MONOTONIC)
+    AC_SUBST(REALTIME_LIBS)
+fi
+
 dnl check for wcrtomb/mbrtowc
 dnl =======================================================================
 if test -z "$MACOS_DEPLOYMENT_TARGET" || test "$MACOS_DEPLOYMENT_TARGET" -ge "100300"; then
 AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 AC_CACHE_CHECK(for wcrtomb,
     ac_cv_have_wcrtomb,
     [AC_TRY_LINK([#include <wchar.h>],
--- a/toolkit/library/libxul-config.mk
+++ b/toolkit/library/libxul-config.mk
@@ -386,8 +386,12 @@ ifdef MOZ_NATIVE_HUNSPELL
 EXTRA_DSO_LDOPTS += $(MOZ_HUNSPELL_LIBS)
 endif
 
 ifdef MOZ_SYDNEYAUDIO
 ifeq ($(OS_ARCH),Linux)
 EXTRA_DSO_LDOPTS += $(MOZ_ALSA_LIBS)
 endif
 endif
+
+ifdef HAVE_CLOCK_MONOTONIC
+EXTRA_DSO_LDOPTS += $(REALTIME_LIBS)
+endif
--- a/xpcom/build/Makefile.in
+++ b/xpcom/build/Makefile.in
@@ -170,16 +170,20 @@ endif
 
 ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
 EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS)
 ifdef MOZ_PLATFORM_HILDON
 EXTRA_DSO_LDOPTS += $(LIBHILDONMIME_LIBS)
 endif
 endif
 
+ifdef HAVE_CLOCK_MONOTONIC
+EXTRA_DSO_LDOPTS += $(REALTIME_LIBS)
+endif
+
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,shell32 ole32 uuid version)
 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
 OS_LIBS += $(call EXPAND_LIBNAME,imagehlp)
 endif
 endif # WINNT
 
 ifeq ($(OS_ARCH),WINCE)
--- a/xpcom/ds/Makefile.in
+++ b/xpcom/ds/Makefile.in
@@ -45,17 +45,16 @@ include $(DEPTH)/config/autoconf.mk
 MODULE		= xpcom
 XPIDL_MODULE	= xpcom_ds
 LIBRARY_NAME	= xpcomds_s
 GRE_MODULE	= 1
 MOZILLA_INTERNAL_API = 1
 
 
 CPPSRCS		= \
-		TimeStamp.cpp \
 		nsArray.cpp \
 		nsAtomTable.cpp \
 		nsAtomService.cpp \
 		nsByteBuffer.cpp \
 		nsCheapSets.cpp \
 		nsCRT.cpp \
 		nsFixedSizeAllocator.cpp \
 		nsHashPropertyBag.cpp \
@@ -72,16 +71,22 @@ CPPSRCS		= \
 		nsSupportsArray.cpp \
 		nsSupportsArrayEnumerator.cpp \
 		nsSupportsPrimitives.cpp \
 		nsTimelineService.cpp \
 		nsUnicharBuffer.cpp \
 		nsVariant.cpp \
 		$(NULL)
 
+ifdef HAVE_CLOCK_MONOTONIC
+CPPSRCS += TimeStamp_posix.cpp
+else
+CPPSRCS += TimeStamp.cpp
+endif
+
 EXPORTS_NAMESPACES = mozilla
 
 EXPORTS_mozilla = \
   TimeStamp.h \
   $(NULL)
 
 EXPORTS		= \
 		nsAtomService.h \