diff mbox

Use clock_gettime() on OpenBSD

Message ID 20130330062517.GG31912@rox.home.comstyle.com
State New
Headers show

Commit Message

Brad Smith March 30, 2013, 6:25 a.m. UTC
init_get_clock() already indicates to get_clock() to utilize
clock_gettime() with a monotonic clock but OpenBSD was missing
from the list of OS's to use a monotonic clock on.

What I don't understand is why is init_get_clock() not called
anywhere?

Comments

Peter Maydell March 30, 2013, 9:04 a.m. UTC | #1
On 30 March 2013 06:25, Brad Smith <brad@comstyle.com> wrote:
> init_get_clock() already indicates to get_clock() to utilize
> clock_gettime() with a monotonic clock but OpenBSD was missing
> from the list of OS's to use a monotonic clock on.
>
> What I don't understand is why is init_get_clock() not called
> anywhere?

It's marked as a constructor so the C runtime will call it.

> diff --git a/include/qemu/timer.h b/include/qemu/timer.h
> index 1766b2d..8b86fa5 100644
> --- a/include/qemu/timer.h
> +++ b/include/qemu/timer.h
> @@ -118,7 +118,8 @@ extern int use_rt_clock;
>  static inline int64_t get_clock(void)
>  {
>  #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
> -    || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
> +    || defined(__DragonFly__) || defined(__FreeBSD_kernel__) \
> +    || defined(__OpenBSD__)
>      if (use_rt_clock) {
>          struct timespec ts;
>          clock_gettime(CLOCK_MONOTONIC, &ts);

Rather than extending this already long OS dependent #if,
could you write a configure test for whatever we're using
and then just have a simple #ifdef CONFIG_WHATEVER ?

thanks
-- PMM
diff mbox

Patch

diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 1766b2d..8b86fa5 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -118,7 +118,8 @@  extern int use_rt_clock;
 static inline int64_t get_clock(void)
 {
 #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
-    || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
+    || defined(__DragonFly__) || defined(__FreeBSD_kernel__) \
+    || defined(__OpenBSD__)
     if (use_rt_clock) {
         struct timespec ts;
         clock_gettime(CLOCK_MONOTONIC, &ts);