[pypy-svn] r68888 - in pypy/branch/logging2/pypy/translator: c/src platform

arigo at codespeak.net arigo at codespeak.net
Sun Nov 1 15:09:16 CET 2009


Author: arigo
Date: Sun Nov  1 15:09:16 2009
New Revision: 68888

Modified:
   pypy/branch/logging2/pypy/translator/c/src/asm_gcc_x86.h
   pypy/branch/logging2/pypy/translator/c/src/debug.h
   pypy/branch/logging2/pypy/translator/platform/linux.py
Log:
Port READ_TIMESTAMP to other platforms.


Modified: pypy/branch/logging2/pypy/translator/c/src/asm_gcc_x86.h
==============================================================================
--- pypy/branch/logging2/pypy/translator/c/src/asm_gcc_x86.h	(original)
+++ pypy/branch/logging2/pypy/translator/c/src/asm_gcc_x86.h	Sun Nov  1 15:09:16 2009
@@ -50,6 +50,10 @@
         : "0"(x), "g"(y)     /* inputs  */      \
         : "cc", "memory")    /* clobber */
 
+/* Pentium only! */
+#define READ_TIMESTAMP(val) \
+     asm volatile("rdtsc" : "=A" (val))
+
 
 /* prototypes */
 

Modified: pypy/branch/logging2/pypy/translator/c/src/debug.h
==============================================================================
--- pypy/branch/logging2/pypy/translator/c/src/debug.h	(original)
+++ pypy/branch/logging2/pypy/translator/c/src/debug.h	Sun Nov  1 15:09:16 2009
@@ -99,9 +99,24 @@
 }
 
 
-/* XXXXXXXXXX   x86 Pentium only! */
-#define READ_TIMESTAMP(val) \
-     __asm__ __volatile__("rdtsc" : "=A" (val))
+#ifndef READ_TIMESTAMP
+/* asm_xxx.h may contain a specific implementation of READ_TIMESTAMP.
+ * This is the default generic timestamp implementation.
+ */
+#  ifdef WIN32
+#    define READ_TIMESTAMP(val)  QueryPerformanceCounter(&(val))
+#  else
+#    include <time.h>
+#    define READ_TIMESTAMP(val)  (val) = pypy_read_timestamp()
+
+     static long long pypy_read_timestamp(void)
+     {
+       struct timespec tspec;
+       clock_gettime(CLOCK_MONOTONIC, &tspec);
+       return ((long long)tspec.tv_sec) * 1000000000LL + tspec.tv_nsec;
+     }
+#  endif
+#endif
 
 
 static bool_t startswith(const char *str, const char *substr)

Modified: pypy/branch/logging2/pypy/translator/platform/linux.py
==============================================================================
--- pypy/branch/logging2/pypy/translator/platform/linux.py	(original)
+++ pypy/branch/logging2/pypy/translator/platform/linux.py	Sun Nov  1 15:09:16 2009
@@ -8,7 +8,7 @@
 class Linux(BasePosix):
     name = "linux"
     
-    link_flags = ['-pthread']
+    link_flags = ['-pthread', '-lrt']
     cflags = ['-O3', '-pthread', '-fomit-frame-pointer']
     standalone_only = []
     shared_only = []



More information about the Pypy-commit mailing list