[pypy-svn] r70083 - pypy/trunk/pypy/translator/c/src

arigo at codespeak.net arigo at codespeak.net
Sun Dec 13 13:04:52 CET 2009


Author: arigo
Date: Sun Dec 13 13:04:52 2009
New Revision: 70083

Modified:
   pypy/trunk/pypy/translator/c/src/debug.h
Log:
Fix for OSes that don't run on a 32-bit Intel and that don't have
the POSIX function clock_gettime().  This includes notably Mac OS/X
on 64-bit platforms.


Modified: pypy/trunk/pypy/translator/c/src/debug.h
==============================================================================
--- pypy/trunk/pypy/translator/c/src/debug.h	(original)
+++ pypy/trunk/pypy/translator/c/src/debug.h	Sun Dec 13 13:04:52 2009
@@ -119,13 +119,21 @@
 #    define READ_TIMESTAMP(val)  QueryPerformanceCounter(&(val))
 #  else
 #    include <time.h>
+#    include <sys/time.h>
 #    define READ_TIMESTAMP(val)  (val) = pypy_read_timestamp()
 
      static long long pypy_read_timestamp(void)
      {
+#    ifdef CLOCK_THREAD_CPUTIME_ID
        struct timespec tspec;
        clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tspec);
        return ((long long)tspec.tv_sec) * 1000000000LL + tspec.tv_nsec;
+#    else
+       /* argh, we don't seem to have clock_gettime().  Bad OS. */
+       struct timeval tv;
+       gettimeofday(tv, NULL);
+       return ((long long)tv.tv_sec) * 1000000LL + tv.tv_usec;
+#    endif
      }
 #  endif
 #endif



More information about the Pypy-commit mailing list