]> git.proxmox.com Git - qemu.git/blobdiff - qemu-timer.h
chardev: Use real-time clock for open timer
[qemu.git] / qemu-timer.h
index 5175419e5f9f8ee63d43b4ec4e480d4b3d1bb606..da7e97cd5aaa82b055222ae7775a82c404a034d3 100644 (file)
@@ -5,6 +5,10 @@
 #include "main-loop.h"
 #include "notify.h"
 
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#endif
+
 /* timers */
 
 #define SCALE_MS 1000000
@@ -214,7 +218,7 @@ static inline int64_t cpu_get_real_ticks(void)
     return val;
 }
 
-#elif defined(__sparc_v8plus__) || defined(__sparc_v8plusa__) || defined(__sparc_v9__)
+#elif defined(__sparc__)
 
 static inline int64_t cpu_get_real_ticks (void)
 {
@@ -223,6 +227,8 @@ static inline int64_t cpu_get_real_ticks (void)
     asm volatile("rd %%tick,%0" : "=r"(rval));
     return rval;
 #else
+    /* We need an %o or %g register for this.  For recent enough gcc
+       there is an "h" constraint for that.  Don't bother with that.  */
     union {
         uint64_t i64;
         struct {
@@ -230,8 +236,8 @@ static inline int64_t cpu_get_real_ticks (void)
             uint32_t low;
         }       i32;
     } rval;
-    asm volatile("rd %%tick,%1; srlx %1,32,%0"
-                 : "=r"(rval.i32.high), "=r"(rval.i32.low));
+    asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1"
+                 : "=r"(rval.i32.high), "=r"(rval.i32.low) : : "g1");
     return rval.i64;
 #endif
 }