Skip to contentSkip to conversation

timer: move APIs together according to their category

PATCH In review Xuebing Wang 3 participants 11 messages Feb 25, 2014 – Feb 27, 2014

lore
Share & tools
lore
#0 lore raw

cover timer: move APIs together according to their category

There are 6 categories of APIs:
- QEMUClockType
- QEMUTimerList
- QEMUTimerListGroup
- QEMUTimer
- General utility functions
- Low level clock functions

Problems / solutions with previous API implementations:
1) Can not think of cases that we need QEMUTimerList APIs.
Reference: kernel_tree/Documentation/SubmittingPatches
-- Section "4) Don't over-design"
Purpose: simplify API
Solution: remove them from APIs
2) Implementations of some APIs are interwined
Purpose: put them together according to their categories, thus new
engineers are easy to understand them
Solution: put them together
3) Unnecessary header files are included
Purpose: simplify the included header files
Solution: only include the minimally required header file

This patchset includes below changes:
- put QEMUTimerList related functions together and make them private
- put QEMUClockType related functions together
- move QEMUTimerListGroup function to be below QEMUClockType
- put QEMUTimer related functions together
- put general utility functions together
- clean unnecessary #include and use minimal required #include

Xuebing Wang (7):
timer: move QEMUTimerList functions together
timer: make QEMUTimerList functions private (remove from APIs)
timer: move QEMUClockType related functions together
timer: move QEMUTimerListGroup function to be below QEMUClockType
timer: move QEMUTimer related functions together
timer: move general utility functions together
timer: clean unnecessary #include and use minimal required #include

 include/qemu/timer.h |   94 --------
 qemu-timer.c         |  595 +++++++++++++++++++++++++++++---------------------
 2 files changed, 341 insertions(+), 348 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/7 timer: move QEMUTimerList functions together

This patch does below:
- Move function timerlist_has_timers() to be first QEMUTimerList function
because there is a chance that we will make it private
- Move QEMUTimerList related functions together
- Remove below comments for function timerlist_deadline_ns(), because:
-- There is already information in the header file include/qemu/timer.h -- "As above" part of the information is wrong
/*
* As above, but return -1 for no deadline, and do not cap to 2^32
* as we know the result is always positive.
*/

---
 include/qemu/timer.h |   28 +++---
 qemu-timer.c         |  231 +++++++++++++++++++++++++-------------------------
 2 files changed, 129 insertions(+), 130 deletions(-)
include/qemu/timer.h +14 -14
index 7f9a074..55cd3a7 100644
@@ -254,6 +254,20 @@ bool qemu_clock_run_all_timers(void);
  */
 
 /**
+ * timerlist_has_timers:
+ * @timer_list: the timer list to operate on
+ *
+ * Determine whether a timer list has active timers
+ *
+ * Note that this function should not be used when other threads also access
+ * the timer list.  The return value may be outdated by the time it is acted
+ * upon.
+ *
+ * Returns: true if the timer list has timers.
+ */
+bool timerlist_has_timers(QEMUTimerList *timer_list);
+
+/**
  * timerlist_new:
  * @type: the clock type to associate with the timerlist
  * @cb: the callback to call on notification
@@ -276,20 +290,6 @@ QEMUTimerList *timerlist_new(QEMUClockType type,
 void timerlist_free(QEMUTimerList *timer_list);
 
 /**
- * timerlist_has_timers:
- * @timer_list: the timer list to operate on
- *
- * Determine whether a timer list has active timers
- *
- * Note that this function should not be used when other threads also access
- * the timer list.  The return value may be outdated by the time it is acted
- * upon.
- *
- * Returns: true if the timer list has timers.
- */
-bool timerlist_has_timers(QEMUTimerList *timer_list);
-
-/**
  * timerlist_expired:
  * @timer_list: the timer list to operate on
  *
qemu-timer.c +115 -116

284 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/7 timer: make QEMUTimerList functions private (remove from APIs)

In reply to Xuebing Wang

This patch does below:
- Make QEMUTimerList functions private (remove from APIs)
- Comment out function QEMUTimerList timerlist_get_clock() in order
to fix compile error

---
 include/qemu/timer.h |   94 ------------------------------------------------
 qemu-timer.c         |   97 ++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 87 insertions(+), 104 deletions(-)
include/qemu/timer.h +0 -94
index 55cd3a7..8644913 100644
@@ -250,100 +250,6 @@ bool qemu_clock_run_timers(QEMUClockType type);
 bool qemu_clock_run_all_timers(void);
 
 /*
- * QEMUTimerList
- */
-
-/**
- * timerlist_has_timers:
- * @timer_list: the timer list to operate on
- *
- * Determine whether a timer list has active timers
- *
- * Note that this function should not be used when other threads also access
- * the timer list.  The return value may be outdated by the time it is acted
- * upon.
- *
- * Returns: true if the timer list has timers.
- */
-bool timerlist_has_timers(QEMUTimerList *timer_list);
-
-/**
- * timerlist_new:
- * @type: the clock type to associate with the timerlist
- * @cb: the callback to call on notification
- * @opaque: the opaque pointer to pass to the callback
- *
- * Create a new timerlist associated with the clock of
- * type @type.
- *
- * Returns: a pointer to the QEMUTimerList created
- */
-QEMUTimerList *timerlist_new(QEMUClockType type,
-                             QEMUTimerListNotifyCB *cb, void *opaque);
-
-/**
- * timerlist_free:
- * @timer_list: the timer list to free
- *
- * Frees a timer_list. It must have no active timers.
- */
-void timerlist_free(QEMUTimerList *timer_list);
-
-/**
- * timerlist_expired:
- * @timer_list: the timer list to operate on
- *
- * Determine whether a timer list has any timers which
- * are expired.
- *
- * Returns: true if the timer list has timers which
- * have expired.
- */
-bool timerlist_expired(QEMUTimerList *timer_list);
-
-/**
- * timerlist_deadline_ns:
- * @timer_list: the timer list to operate on
- *
- * Determine the deadline for a timer_list, i.e.
- * the number of nanoseconds until the first timer
- * expires. Return -1 if there are no timers.
- *
- * Returns: the number of nanoseconds until the earliest
- * timer expires -1 if none
- */
-int64_t timerlist_deadline_ns(QEMUTimerList *timer_list);
-
-/**
- * timerlist_get_clock:
- * @timer_list: the timer list to operate on
- *
- * Determine the clock type associated with a timer list.
- *
- * Returns: the clock type associated with the
- * timer list.
- */
-QEMUClockType timerlist_get_clock(QEMUTimerList *timer_list);
-
-/**
- * timerlist_run_timers:
- * @timer_list: the timer list to use
- *
- * Call all expired timers associated with the timer list.
- *
- * Returns: true if any timer expired
- */
-bool timerlist_run_timers(QEMUTimerList *timer_list);
-
-/**
- * timerlist_notify:
- * @timer_list: the timer list to use
- *
- * call the notifier callback associated with the timer list.
- */
-void timerlist_notify(QEMUTimerList *timer_list);
-
-/*
  * QEMUTimerListGroup
  */
 
qemu-timer.c +87 -10

141 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/7 timer: move QEMUClockType related functions together

In reply to Xuebing Wang
---
 qemu-timer.c |  160 ++++++++++++++++++++++++++++++----------------------------
 1 file changed, 82 insertions(+), 78 deletions(-)
qemu-timer.c +82 -78
index 2db87ba..471150c 100644
@@ -314,6 +314,10 @@ static void timerlist_rearm(QEMUTimerList *timer_list)
     timerlist_notify(timer_list);
 }
 
+/*
+ * QEMUClockType
+ */
+
 static void qemu_clock_init(QEMUClockType type)
 {
     QEMUClock *clock = qemu_clock_ptr(type);
@@ -326,11 +330,71 @@ static void qemu_clock_init(QEMUClockType type)
     main_loop_tlg.tl[type] = timerlist_new(type, NULL, NULL);
 }
 
+int64_t qemu_clock_get_ns(QEMUClockType type)
+{
+    int64_t now, last;
+    QEMUClock *clock = qemu_clock_ptr(type);
+
+    switch (type) {
+    case QEMU_CLOCK_REALTIME:
+        return get_clock();
+    default:
+    case QEMU_CLOCK_VIRTUAL:
+        if (use_icount) {
+            return cpu_get_icount();
+        } else {
+            return cpu_get_clock();
+        }
+    case QEMU_CLOCK_HOST:
+        now = get_clock_realtime();
+        last = clock->last;
+        clock->last = now;
+        if (now < last) {
+            notifier_list_notify(&clock->reset_notifiers, &now);
+        }
+        return now;
+    }
+}
+
+bool qemu_clock_has_timers(QEMUClockType type)
+{
+    return timerlist_has_timers(
+        main_loop_tlg.tl[type]);
+}
+
+bool qemu_clock_expired(QEMUClockType type)
+{
+    return timerlist_expired(
+        main_loop_tlg.tl[type]);
+}
+
 bool qemu_clock_use_for_deadline(QEMUClockType type)
 {
     return !(use_icount && (type == QEMU_CLOCK_VIRTUAL));
 }
 
+/* Calculate the soonest deadline across all timerlists attached
+ * to the clock. This is used for the icount timeout so we
+ * ignore whether or not the clock should be used in deadline
+ * calculations.
+ */
+int64_t qemu_clock_deadline_ns_all(QEMUClockType type)
+{
+    int64_t deadline = -1;
+    QEMUTimerList *timer_list;
+    QEMUClock *clock = qemu_clock_ptr(type);
+    QLIST_FOREACH(timer_list, &clock->timerlists, list) {
+        deadline = qemu_soonest_timeout(deadline,
+                                        timerlist_deadline_ns(timer_list));
+    }
+    return deadline;
+}
+
+QEMUTimerList *qemu_clock_get_main_loop_timerlist(QEMUClockType type)
+{
+    return main_loop_tlg.tl[type];
+}
+
 void qemu_clock_notify(QEMUClockType type)
 {
     QEMUTimerList *timer_list;
@@ -362,38 +426,34 @@ void qemu_clock_enable(QEMUClockType type, bool enabled)
     }
 }
 
-bool qemu_clock_has_timers(QEMUClockType type)
+void qemu_clock_register_reset_notifier(QEMUClockType type,
+                                        Notifier *notifier)
 {
-    return timerlist_has_timers(
-        main_loop_tlg.tl[type]);
+    QEMUClock *clock = qemu_clock_ptr(type);
+    notifier_list_add(&clock->reset_notifiers, notifier);
 }
 
-bool qemu_clock_expired(QEMUClockType type)
+void qemu_clock_unregister_reset_notifier(QEMUClockType type,
+                                          Notifier *notifier)
 {
-    return timerlist_expired(
-        main_loop_tlg.tl[type]);
+    notifier_remove(notifier);
 }
 
-/* Calculate the soonest deadline across all timerlists attached
- * to the clock. This is used for the icount timeout so we
- * ignore whether or not the clock should be used in deadline
- * calculations.
- */
-int64_t qemu_clock_deadline_ns_all(QEMUClockType type)
+bool qemu_clock_run_timers(QEMUClockType type)
 {
-    int64_t deadline = -1;
-    QEMUTimerList *timer_list;
-    QEMUClock *clock = qemu_clock_ptr(type);
-    QLIST_FOREACH(timer_list, &clock->timerlists, list) {
-        deadline = qemu_soonest_timeout(deadline,
-                                        timerlist_deadline_ns(timer_list));
-    }
-    return deadline;
+    return timerlist_run_timers(main_loop_tlg.tl[type]);
 }
 
-QEMUTimerList *qemu_clock_get_main_loop_timerlist(QEMUClockType type)
+bool qemu_clock_run_all_timers(void)
 {
-    return main_loop_tlg.tl[type];
+    bool progress = false;
+    QEMUClockType type;
+
+    for (type = 0; type < QEMU_CLOCK_MAX; type++) {
+        progress |= qemu_clock_run_timers(type);
+    }
+
+    return progress;
 }
 
 /* Transition function to convert a nanosecond timeout to ms
@@ -570,11 +630,6 @@ bool timer_expired(QEMUTimer *timer_head, int64_t current_time)
     return timer_expired_ns(timer_head, current_time * timer_head->scale);
 }
 
-bool qemu_clock_run_timers(QEMUClockType type)
-{
-    return timerlist_run_timers(main_loop_tlg.tl[type]);
-}
-
 void timerlistgroup_init(QEMUTimerListGroup *tlg,
                          QEMUTimerListNotifyCB *cb, void *opaque)
 {
@@ -616,45 +671,6 @@ int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg)
     return deadline;
 }
 
-int64_t qemu_clock_get_ns(QEMUClockType type)
-{
-    int64_t now, last;
-    QEMUClock *clock = qemu_clock_ptr(type);
-
-    switch (type) {
-    case QEMU_CLOCK_REALTIME:
-        return get_clock();
-    default:
-    case QEMU_CLOCK_VIRTUAL:
-        if (use_icount) {
-            return cpu_get_icount();
-        } else {
-            return cpu_get_clock();
-        }
-    case QEMU_CLOCK_HOST:
-        now = get_clock_realtime();
-        last = clock->last;
-        clock->last = now;
-        if (now < last) {
-            notifier_list_notify(&clock->reset_notifiers, &now);
-        }
-        return now;
-    }
-}
-
-void qemu_clock_register_reset_notifier(QEMUClockType type,
-                                        Notifier *notifier)
-{
-    QEMUClock *clock = qemu_clock_ptr(type);
-    notifier_list_add(&clock->reset_notifiers, notifier);
-}
-
-void qemu_clock_unregister_reset_notifier(QEMUClockType type,
-                                          Notifier *notifier)
-{
-    notifier_remove(notifier);
-}
-
 void init_clocks(void)
 {
     QEMUClockType type;
@@ -671,15 +687,3 @@ uint64_t timer_expire_time_ns(QEMUTimer *ts)
 {
     return timer_pending(ts) ? ts->expire_time : -1;
 }
-
-bool qemu_clock_run_all_timers(void)
-{
-    bool progress = false;
-    QEMUClockType type;
-
-    for (type = 0; type < QEMU_CLOCK_MAX; type++) {
-        progress |= qemu_clock_run_timers(type);
-    }
-
-    return progress;
-}
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 4/7 timer: move QEMUTimerListGroup function to be below QEMUClockType

In reply to Xuebing Wang
---
 qemu-timer.c |   86 ++++++++++++++++++++++++++++++----------------------------
 1 file changed, 45 insertions(+), 41 deletions(-)
qemu-timer.c +45 -41
index 471150c..6f13a76 100644
@@ -456,6 +456,51 @@ bool qemu_clock_run_all_timers(void)
     return progress;
 }
 
+/*
+ * QEMUTimerListGroup
+ */
+
+void timerlistgroup_init(QEMUTimerListGroup *tlg,
+                         QEMUTimerListNotifyCB *cb, void *opaque)
+{
+    QEMUClockType type;
+    for (type = 0; type < QEMU_CLOCK_MAX; type++) {
+        tlg->tl[type] = timerlist_new(type, cb, opaque);
+    }
+}
+
+void timerlistgroup_deinit(QEMUTimerListGroup *tlg)
+{
+    QEMUClockType type;
+    for (type = 0; type < QEMU_CLOCK_MAX; type++) {
+        timerlist_free(tlg->tl[type]);
+    }
+}
+
+bool timerlistgroup_run_timers(QEMUTimerListGroup *tlg)
+{
+    QEMUClockType type;
+    bool progress = false;
+    for (type = 0; type < QEMU_CLOCK_MAX; type++) {
+        progress |= timerlist_run_timers(tlg->tl[type]);
+    }
+    return progress;
+}
+
+int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg)
+{
+    int64_t deadline = -1;
+    QEMUClockType type;
+    for (type = 0; type < QEMU_CLOCK_MAX; type++) {
+        if (qemu_clock_use_for_deadline(tlg->tl[type]->clock->type)) {
+            deadline = qemu_soonest_timeout(deadline,
+                                            timerlist_deadline_ns(
+                                                tlg->tl[type]));
+        }
+    }
+    return deadline;
+}
+
 /* Transition function to convert a nanosecond timeout to ms
  * This is used where a system does not support ppoll
  */
@@ -630,47 +675,6 @@ bool timer_expired(QEMUTimer *timer_head, int64_t current_time)
     return timer_expired_ns(timer_head, current_time * timer_head->scale);
 }
 
-void timerlistgroup_init(QEMUTimerListGroup *tlg,
-                         QEMUTimerListNotifyCB *cb, void *opaque)
-{
-    QEMUClockType type;
-    for (type = 0; type < QEMU_CLOCK_MAX; type++) {
-        tlg->tl[type] = timerlist_new(type, cb, opaque);
-    }
-}
-
-void timerlistgroup_deinit(QEMUTimerListGroup *tlg)
-{
-    QEMUClockType type;
-    for (type = 0; type < QEMU_CLOCK_MAX; type++) {
-        timerlist_free(tlg->tl[type]);
-    }
-}
-
-bool timerlistgroup_run_timers(QEMUTimerListGroup *tlg)
-{
-    QEMUClockType type;
-    bool progress = false;
-    for (type = 0; type < QEMU_CLOCK_MAX; type++) {
-        progress |= timerlist_run_timers(tlg->tl[type]);
-    }
-    return progress;
-}
-
-int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg)
-{
-    int64_t deadline = -1;
-    QEMUClockType type;
-    for (type = 0; type < QEMU_CLOCK_MAX; type++) {
-        if (qemu_clock_use_for_deadline(tlg->tl[type]->clock->type)) {
-            deadline = qemu_soonest_timeout(deadline,
-                                            timerlist_deadline_ns(
-                                                tlg->tl[type]));
-        }
-    }
-    return deadline;
-}
-
 void init_clocks(void)
 {
     QEMUClockType type;
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 5/7 timer: move QEMUTimer related functions together

In reply to Xuebing Wang
---
 qemu-timer.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
qemu-timer.c +8 -5
index 6f13a76..c9801da 100644
@@ -548,6 +548,9 @@ int qemu_poll_ns(GPollFD *fds, guint nfds, int64_t timeout)
 #endif
 }
 
+/*
+ * QEMUTimer
+ */
 
 void timer_init(QEMUTimer *ts,
                 QEMUTimerList *timer_list, int scale,
@@ -675,6 +678,11 @@ bool timer_expired(QEMUTimer *timer_head, int64_t current_time)
     return timer_expired_ns(timer_head, current_time * timer_head->scale);
 }
 
+uint64_t timer_expire_time_ns(QEMUTimer *ts)
+{
+    return timer_pending(ts) ? ts->expire_time : -1;
+}
+
 void init_clocks(void)
 {
     QEMUClockType type;
@@ -686,8 +694,3 @@ void init_clocks(void)
     prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
 #endif
 }
-
-uint64_t timer_expire_time_ns(QEMUTimer *ts)
-{
-    return timer_pending(ts) ? ts->expire_time : -1;
-}
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH 6/7 timer: move general utility functions together

In reply to Xuebing Wang
---
 qemu-timer.c |   97 ++++++++++++++++++++++++++++++----------------------------
 1 file changed, 50 insertions(+), 47 deletions(-)
qemu-timer.c +50 -47
index c9801da..e592c14 100644
@@ -501,53 +501,6 @@ int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg)
     return deadline;
 }
 
-/* Transition function to convert a nanosecond timeout to ms
- * This is used where a system does not support ppoll
- */
-int qemu_timeout_ns_to_ms(int64_t ns)
-{
-    int64_t ms;
-    if (ns < 0) {
-        return -1;
-    }
-
-    if (!ns) {
-        return 0;
-    }
-
-    /* Always round up, because it's better to wait too long than to wait too
-     * little and effectively busy-wait
-     */
-    ms = (ns + SCALE_MS - 1) / SCALE_MS;
-
-    /* To avoid overflow problems, limit this to 2^31, i.e. approx 25 days */
-    if (ms > (int64_t) INT32_MAX) {
-        ms = INT32_MAX;
-    }
-
-    return (int) ms;
-}
-
-
-/* qemu implementation of g_poll which uses a nanosecond timeout but is
- * otherwise identical to g_poll
- */
-int qemu_poll_ns(GPollFD *fds, guint nfds, int64_t timeout)
-{
-#ifdef CONFIG_PPOLL
-    if (timeout < 0) {
-        return ppoll((struct pollfd *)fds, nfds, NULL, NULL);
-    } else {
-        struct timespec ts;
-        ts.tv_sec = timeout / 1000000000LL;
-        ts.tv_nsec = timeout % 1000000000LL;
-        return ppoll((struct pollfd *)fds, nfds, &ts, NULL);
-    }
-#else
-    return g_poll(fds, nfds, qemu_timeout_ns_to_ms(timeout));
-#endif
-}
-
 /*
  * QEMUTimer
  */
@@ -683,6 +636,56 @@ uint64_t timer_expire_time_ns(QEMUTimer *ts)
     return timer_pending(ts) ? ts->expire_time : -1;
 }
 
+/*
+ * General utility functions
+ */
+
+/* Transition function to convert a nanosecond timeout to ms
+ * This is used where a system does not support ppoll
+ */
+int qemu_timeout_ns_to_ms(int64_t ns)
+{
+    int64_t ms;
+    if (ns < 0) {
+        return -1;
+    }
+
+    if (!ns) {
+        return 0;
+    }
+
+    /* Always round up, because it's better to wait too long than to wait too
+     * little and effectively busy-wait
+     */
+    ms = (ns + SCALE_MS - 1) / SCALE_MS;
+
+    /* To avoid overflow problems, limit this to 2^31, i.e. approx 25 days */
+    if (ms > (int64_t) INT32_MAX) {
+        ms = INT32_MAX;
+    }
+
+    return (int) ms;
+}
+
+/* qemu implementation of g_poll which uses a nanosecond timeout but is
+ * otherwise identical to g_poll
+ */
+int qemu_poll_ns(GPollFD *fds, guint nfds, int64_t timeout)
+{
+#ifdef CONFIG_PPOLL
+    if (timeout < 0) {
+        return ppoll((struct pollfd *)fds, nfds, NULL, NULL);
+    } else {
+        struct timespec ts;
+        ts.tv_sec = timeout / 1000000000LL;
+        ts.tv_nsec = timeout % 1000000000LL;
+        return ppoll((struct pollfd *)fds, nfds, &ts, NULL);
+    }
+#else
+    return g_poll(fds, nfds, qemu_timeout_ns_to_ms(timeout));
+#endif
+}
+
 void init_clocks(void)
 {
     QEMUClockType type;
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 7/7 timer: clean unnecessary #include and use minimal required #include

In reply to Xuebing Wang
---
 qemu-timer.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
qemu-timer.c +3 -6
index e592c14..21aff82 100644
@@ -22,13 +22,10 @@
  * THE SOFTWARE.
  */
 
-#include "sysemu/sysemu.h"
-#include "monitor/monitor.h"
-#include "ui/console.h"
-
-#include "hw/hw.h"
-
+#include "qemu/thread.h" /* for qemu_event_init() etc */
+#include "qemu/main-loop.h" /* for qemu_notify_event() */
 #include "qemu/timer.h"
+
 #ifdef CONFIG_POSIX
 #include <pthread.h>
 #endif
Signature · 1 line
1.7.9.5
#8 lore raw
In reply to Xuebing Wang
Quoted 9 lines

This patchset includes below changes:
- put QEMUTimerList related functions together and make them private
- put QEMUClockType related functions together
- move QEMUTimerListGroup function to be below QEMUClockType
- put QEMUTimer related functions together
- put general utility functions together
- clean unnecessary #include and use minimal required #include

Quoted 8 lines

Xuebing Wang (7):
timer: move QEMUTimerList functions together
timer: make QEMUTimerList functions private (remove from APIs)
timer: move QEMUClockType related functions together
timer: move QEMUTimerListGroup function to be below QEMUClockType
timer: move QEMUTimer related functions together
timer: move general utility functions together
timer: clean unnecessary #include and use minimal required #include

I'm generally in favour of this patch set or something like it. It's nicely constrained to 2 include files. It appears to touch no code. And it appears to makes things tidier.

Stefan / Paolo? If you agree I will review in greater detail.

Signature · 1 line
Alex Bligh
#9 lore raw

Il 25/02/2014 17:25, Alex Bligh ha scritto:

Quoted 6 lines

I'm generally in favour of this patch set or something like it. It's nicely constrained to 2 include files. It appears to touch no code. And it appears to makes things tidier.

Stefan / Paolo? If you agree I will review in greater detail.

Sure, any help with reviews is welcome.

Paolo

Reviewed-by on the v1 series
#10 lore raw
In reply to Xuebing Wang
Quoted 39 lines · Xuebing Wang

There are 6 categories of APIs:
- QEMUClockType
- QEMUTimerList
- QEMUTimerListGroup
- QEMUTimer
- General utility functions
- Low level clock functions

Problems / solutions with previous API implementations:
1) Can not think of cases that we need QEMUTimerList APIs.
Reference: kernel_tree/Documentation/SubmittingPatches
-- Section "4) Don't over-design"
Purpose: simplify API
Solution: remove them from APIs
2) Implementations of some APIs are interwined
Purpose: put them together according to their categories, thus new
engineers are easy to understand them
Solution: put them together
3) Unnecessary header files are included
Purpose: simplify the included header files
Solution: only include the minimally required header file

This patchset includes below changes:
- put QEMUTimerList related functions together and make them private
- put QEMUClockType related functions together
- move QEMUTimerListGroup function to be below QEMUClockType
- put QEMUTimer related functions together
- put general utility functions together
- clean unnecessary #include and use minimal required #include

Xuebing Wang (7):
timer: move QEMUTimerList functions together
timer: make QEMUTimerList functions private (remove from APIs)
timer: move QEMUClockType related functions together
timer: move QEMUTimerListGroup function to be below QEMUClockType
timer: move QEMUTimer related functions together
timer: move general utility functions together
timer: clean unnecessary #include and use minimal required #include

Quoted 3 lines

include/qemu/timer.h | 94 --------
qemu-timer.c | 595 +++++++++++++++++++++++++++++---------------------

2 files changed, 341 insertions(+), 348 deletions(-)

As far as I can see, this patch set reorders qemu-timer.c in a more logical way, and removes some functions from timer.h that need not be exposed.

Therefore, this seems to me a good idea in principle, and:

on the lot, subject to the proviso I haven't compile tested them.

Signature · 1 line
Alex Bligh