Skip to contentSkip to conversation

rename get_clock_realtime

PATCH Superseded Paolo Bonzini 2 participants 6 messages Jan 20, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rename get_clock_realtime

get_clock_realtime accesses the host_clock, not the rt_clock.

---
 qemu-timer.c |    2 +-
 qemu-timer.h |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
qemu-timer.c +1 -1
index cd026c6..4a14a6d 100644
@@ -436,7 +436,7 @@ int64_t qemu_get_clock_ns(QEMUClock *clock)
             return cpu_get_clock();
         }
     case QEMU_CLOCK_HOST:
-        now = get_clock_realtime();
+        now = get_clock_host();
         last = clock->last;
         clock->last = now;
         if (now < last) {
qemu-timer.h +2 -2
index de17f3b..b180fca 100644
@@ -93,7 +93,7 @@ static inline int64_t get_ticks_per_sec(void)
 }
 
 /* real time host monotonic timer */
-static inline int64_t get_clock_realtime(void)
+static inline int64_t get_clock_host(void)
 {
     struct timeval tv;
 
@@ -131,7 +131,7 @@ static inline int64_t get_clock(void)
     {
         /* XXX: using gettimeofday leads to problems if the date
            changes, so it should be avoided. */
-        return get_clock_realtime();
+        return get_clock_host();
     }
 }
 #endif
Signature · 1 line
1.7.7.1
#1 lore raw
Quoted 26 lines · Paolo Bonzini

get_clock_realtime accesses the host_clock, not the rt_clock.

---
 qemu-timer.c |    2 +-
 qemu-timer.h |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
qemu-timer.c +1 -1
index cd026c6..4a14a6d 100644
@@ -436,7 +436,7 @@ int64_t qemu_get_clock_ns(QEMUClock *clock)
             return cpu_get_clock();
         }
     case QEMU_CLOCK_HOST:
-        now = get_clock_realtime();
+        now = get_clock_host();
         last = clock->last;
         clock->last = now;
         if (now < last) {
qemu-timer.h +0 -0
index de17f3b..b180fca 100644

qemu-timer.h static inline int64_t get_ticks_per_sec(void) · line 96

Quoted 5 lines
qemu-timer.h +1 -1
@@ -93,7 +93,7 @@ static inline int64_t get_ticks_per_sec(void)
 }
 
 /* real time host monotonic timer */
-static inline int64_t get_clock_realtime(void)
+static inline int64_t get_clock_host(void)

It accesses the host realtime clock, so get_clock_host_realtime would be optimal. In that light, the comment above should be fixed as well.

Jan

Quoted 12 lines
qemu-timer.h +1 -1
 {
     struct timeval tv;
 
@@ -131,7 +131,7 @@ static inline int64_t get_clock(void)
     {
         /* XXX: using gettimeofday leads to problems if the date
            changes, so it should be avoided. */
-        return get_clock_realtime();
+        return get_clock_host();
     }
 }
 #endif
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#2 lore raw
Quoted 29 lines · Jan Kiszka
Quoted 28 lines · Paolo Bonzini

get_clock_realtime accesses the host_clock, not the rt_clock.

---
  qemu-timer.c |    2 +-
  qemu-timer.h |    4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)
qemu-timer.c +1 -1
index cd026c6..4a14a6d 100644
@@ -436,7 +436,7 @@ int64_t qemu_get_clock_ns(QEMUClock *clock)
              return cpu_get_clock();
          }
      case QEMU_CLOCK_HOST:
-        now = get_clock_realtime();
+        now = get_clock_host();
          last = clock->last;
          clock->last = now;
          if (now<  last) {
qemu-timer.h +0 -0
index de17f3b..b180fca 100644
@@ -93,7 +93,7 @@ static inline int64_t get_ticks_per_sec(void)
  }
 
Quoted 6 lines

qemu-timer.h static inline int64_t get_ticks_per_sec(void) · line 96

Quoted 3 lines
qemu-timer.h +1 -1
  /* real time host monotonic timer */
-static inline int64_t get_clock_realtime(void)
+static inline int64_t get_clock_host(void)

It accesses the host realtime clock, so get_clock_host_realtime would be optimal. In that light, the comment above should be fixed as well.

Yeah, however, realtime is quite confusing because CLOCK_MONOTONIC is part of the "real-time clock API". The code is much clearer than the comment, I'll remove it completely. v2 on the way.

Paolo

#3 lore raw

PATCH v2 1/1 rename get_clock_realtime

get_clock_realtime accesses the host_clock, not the rt_clock.

---

	v1->v2: remove incorrect comment
 qemu-timer.c |    2 +-
 qemu-timer.h |    5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)
qemu-timer.c +1 -1
index cd026c6..4a14a6d 100644
@@ -436,7 +436,7 @@ int64_t qemu_get_clock_ns(QEMUClock *clock)
             return cpu_get_clock();
         }
     case QEMU_CLOCK_HOST:
-        now = get_clock_realtime();
+        now = get_clock_host();
         last = clock->last;
         clock->last = now;
         if (now < last) {
qemu-timer.h +2 -3
index de17f3b..a61f209 100644
@@ -92,8 +92,7 @@ static inline int64_t get_ticks_per_sec(void)
     return 1000000000LL;
 }
 
-/* real time host monotonic timer */
-static inline int64_t get_clock_realtime(void)
+static inline int64_t get_clock_host(void)
 {
     struct timeval tv;
 
@@ -131,7 +130,7 @@ static inline int64_t get_clock(void)
     {
         /* XXX: using gettimeofday leads to problems if the date
            changes, so it should be avoided. */
-        return get_clock_realtime();
+        return get_clock_host();
     }
 }
 #endif
Signature · 1 line
1.7.7.1
#4 lore raw
In reply to Paolo Bonzini
Quoted 37 lines · Paolo Bonzini
Quoted 29 lines · Jan Kiszka
Quoted 28 lines · Paolo Bonzini

get_clock_realtime accesses the host_clock, not the rt_clock.

---
  qemu-timer.c |    2 +-
  qemu-timer.h |    4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)
qemu-timer.c +1 -1
index cd026c6..4a14a6d 100644
@@ -436,7 +436,7 @@ int64_t qemu_get_clock_ns(QEMUClock *clock)
              return cpu_get_clock();
          }
      case QEMU_CLOCK_HOST:
-        now = get_clock_realtime();
+        now = get_clock_host();
          last = clock->last;
          clock->last = now;
          if (now<  last) {
qemu-timer.h +0 -0
index de17f3b..b180fca 100644
@@ -93,7 +93,7 @@ static inline int64_t get_ticks_per_sec(void)
  }
 
Quoted 6 lines

qemu-timer.h static inline int64_t get_ticks_per_sec(void) · line 96

Quoted 3 lines
qemu-timer.h +1 -1
  /* real time host monotonic timer */
-static inline int64_t get_clock_realtime(void)
+static inline int64_t get_clock_host(void)

It accesses the host realtime clock, so get_clock_host_realtime would be optimal. In that light, the comment above should be fixed as well.

Quoted 3 lines

Yeah, however, realtime is quite confusing because CLOCK_MONOTONIC is part of the "real-time clock API". The code is much clearer than the comment, I'll remove it completely. v2 on the way.

There is CLOCK_MONOTONIC and CLOCK_REALTIME, and this function uses the latter.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#5 lore raw
Quoted 5 lines · Jan Kiszka
Quoted 3 lines
Quoted 3 lines

Yeah, however, realtime is quite confusing because CLOCK_MONOTONIC is part of the "real-time clock API". The code is much clearer than the comment, I'll remove it completely. v2 on the way.

There is CLOCK_MONOTONIC and CLOCK_REALTIME, and this function uses the latter.

Actually it uses gettimeofday, but I see what you mean.

But QEMU_CLOCK_REALTIME and rt_clock refer to CLOCK_MONOTONIC and are _not_ read by get_clock_realtime. This actually is what prompted me to rename get_clock_realtime (see commit message).

Paolo