Patchwork This patch is used to move some struct definition, like QEMUTimer, QEMUClock, from .c to .h.

login
register
mail settings
Submitter Wei Yang
Date Jan. 31, 2012, 6:56 a.m.
Message ID <1327992986-28168-1-git-send-email-weiyang@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/139140/
State New
Headers show

Comments

Wei Yang - Jan. 31, 2012, 6:56 a.m.
Tested on i386 platform.

Signed-off-by: Wei Yang<weiyang@linux.vnet.ibm.com>
---
 qemu-timer.c |   40 ----------------------------------------
 qemu-timer.h |   41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 40 deletions(-)
Blue Swirl - Feb. 4, 2012, 10:22 a.m.
On Tue, Jan 31, 2012 at 06:56, Wei Yang <weiyang@linux.vnet.ibm.com> wrote:
> Tested on i386 platform.
>
> Signed-off-by: Wei Yang<weiyang@linux.vnet.ibm.com>

Nack. Definitions should reside in files where they are used, only in
header files when they are used by multiple sources.

> ---
>  qemu-timer.c |   40 ----------------------------------------
>  qemu-timer.h |   41 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 41 insertions(+), 40 deletions(-)
>
> diff --git a/qemu-timer.c b/qemu-timer.c
> index cd026c6..2b5cc48 100644
> --- a/qemu-timer.c
> +++ b/qemu-timer.c
> @@ -46,46 +46,6 @@
>
>  #include "qemu-timer.h"
>
> -/***********************************************************/
> -/* timers */
> -
> -#define QEMU_CLOCK_REALTIME 0
> -#define QEMU_CLOCK_VIRTUAL  1
> -#define QEMU_CLOCK_HOST     2
> -
> -struct QEMUClock {
> -    int type;
> -    int enabled;
> -
> -    QEMUTimer *active_timers;
> -
> -    NotifierList reset_notifiers;
> -    int64_t last;
> -};
> -
> -struct QEMUTimer {
> -    QEMUClock *clock;
> -    int64_t expire_time;       /* in nanoseconds */
> -    int scale;
> -    QEMUTimerCB *cb;
> -    void *opaque;
> -    struct QEMUTimer *next;
> -};
> -
> -struct qemu_alarm_timer {
> -    char const *name;
> -    int (*start)(struct qemu_alarm_timer *t);
> -    void (*stop)(struct qemu_alarm_timer *t);
> -    void (*rearm)(struct qemu_alarm_timer *t, int64_t nearest_delta_ns);
> -#if defined(__linux__)
> -    int fd;
> -    timer_t timer;
> -#elif defined(_WIN32)
> -    HANDLE timer;
> -#endif
> -    char expired;
> -    char pending;
> -};
>
>  static struct qemu_alarm_timer *alarm_timer;
>
> diff --git a/qemu-timer.h b/qemu-timer.h
> index 67ca72e..5bf2fc7 100644
> --- a/qemu-timer.h
> +++ b/qemu-timer.h
> @@ -20,6 +20,47 @@
>  typedef struct QEMUClock QEMUClock;
>  typedef void QEMUTimerCB(void *opaque);
>
> +/***********************************************************/
> +/* timers */
> +
> +#define QEMU_CLOCK_REALTIME 0
> +#define QEMU_CLOCK_VIRTUAL  1
> +#define QEMU_CLOCK_HOST     2
> +
> +struct QEMUClock {
> +    int type;
> +    int enabled;
> +
> +    QEMUTimer *active_timers;
> +
> +    NotifierList reset_notifiers;
> +    int64_t last;
> +};
> +
> +struct QEMUTimer {
> +    QEMUClock *clock;
> +    int64_t expire_time;       /* in nanoseconds */
> +    int scale;
> +    QEMUTimerCB *cb;
> +    void *opaque;
> +    struct QEMUTimer *next;
> +};
> +
> +struct qemu_alarm_timer {
> +    char const *name;
> +    int (*start)(struct qemu_alarm_timer *t);
> +    void (*stop)(struct qemu_alarm_timer *t);
> +    void (*rearm)(struct qemu_alarm_timer *t, int64_t nearest_delta_ns);
> +#if defined(__linux__)
> +    int fd;
> +    timer_t timer;
> +#elif defined(_WIN32)
> +    HANDLE timer;
> +#endif
> +    char expired;
> +    char pending;
> +};
> +
>  /* The real time clock should be used only for stuff which does not
>    change the virtual machine state, as it is run even if the virtual
>    machine is stopped. The real time clock has a frequency of 1000
> --
> 1.7.4.1
>
>
Wei Yang - Feb. 6, 2012, 1:43 a.m.
On Sat, Feb 04, 2012 at 10:22:09AM +0000, Blue Swirl wrote:
>On Tue, Jan 31, 2012 at 06:56, Wei Yang <weiyang@linux.vnet.ibm.com> wrote:
>> Tested on i386 platform.
>>
>> Signed-off-by: Wei Yang<weiyang@linux.vnet.ibm.com>
>
>Nack. Definitions should reside in files where they are used, only in
>header files when they are used by multiple sources.
>
Thanks, I got the idea :-)
>> ---
>>  qemu-timer.c |   40 ----------------------------------------
>>  qemu-timer.h |   41 +++++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 41 insertions(+), 40 deletions(-)
>>
>> diff --git a/qemu-timer.c b/qemu-timer.c
>> index cd026c6..2b5cc48 100644
>> --- a/qemu-timer.c
>> +++ b/qemu-timer.c
>> @@ -46,46 +46,6 @@
>>
>>  #include "qemu-timer.h"
>>
>> -/***********************************************************/
>> -/* timers */
>> -
>> -#define QEMU_CLOCK_REALTIME 0
>> -#define QEMU_CLOCK_VIRTUAL  1
>> -#define QEMU_CLOCK_HOST     2
>> -
>> -struct QEMUClock {
>> -    int type;
>> -    int enabled;
>> -
>> -    QEMUTimer *active_timers;
>> -
>> -    NotifierList reset_notifiers;
>> -    int64_t last;
>> -};
>> -
>> -struct QEMUTimer {
>> -    QEMUClock *clock;
>> -    int64_t expire_time;       /* in nanoseconds */
>> -    int scale;
>> -    QEMUTimerCB *cb;
>> -    void *opaque;
>> -    struct QEMUTimer *next;
>> -};
>> -
>> -struct qemu_alarm_timer {
>> -    char const *name;
>> -    int (*start)(struct qemu_alarm_timer *t);
>> -    void (*stop)(struct qemu_alarm_timer *t);
>> -    void (*rearm)(struct qemu_alarm_timer *t, int64_t nearest_delta_ns);
>> -#if defined(__linux__)
>> -    int fd;
>> -    timer_t timer;
>> -#elif defined(_WIN32)
>> -    HANDLE timer;
>> -#endif
>> -    char expired;
>> -    char pending;
>> -};
>>
>>  static struct qemu_alarm_timer *alarm_timer;
>>
>> diff --git a/qemu-timer.h b/qemu-timer.h
>> index 67ca72e..5bf2fc7 100644
>> --- a/qemu-timer.h
>> +++ b/qemu-timer.h
>> @@ -20,6 +20,47 @@
>>  typedef struct QEMUClock QEMUClock;
>>  typedef void QEMUTimerCB(void *opaque);
>>
>> +/***********************************************************/
>> +/* timers */
>> +
>> +#define QEMU_CLOCK_REALTIME 0
>> +#define QEMU_CLOCK_VIRTUAL  1
>> +#define QEMU_CLOCK_HOST     2
>> +
>> +struct QEMUClock {
>> +    int type;
>> +    int enabled;
>> +
>> +    QEMUTimer *active_timers;
>> +
>> +    NotifierList reset_notifiers;
>> +    int64_t last;
>> +};
>> +
>> +struct QEMUTimer {
>> +    QEMUClock *clock;
>> +    int64_t expire_time;       /* in nanoseconds */
>> +    int scale;
>> +    QEMUTimerCB *cb;
>> +    void *opaque;
>> +    struct QEMUTimer *next;
>> +};
>> +
>> +struct qemu_alarm_timer {
>> +    char const *name;
>> +    int (*start)(struct qemu_alarm_timer *t);
>> +    void (*stop)(struct qemu_alarm_timer *t);
>> +    void (*rearm)(struct qemu_alarm_timer *t, int64_t nearest_delta_ns);
>> +#if defined(__linux__)
>> +    int fd;
>> +    timer_t timer;
>> +#elif defined(_WIN32)
>> +    HANDLE timer;
>> +#endif
>> +    char expired;
>> +    char pending;
>> +};
>> +
>>  /* The real time clock should be used only for stuff which does not
>>    change the virtual machine state, as it is run even if the virtual
>>    machine is stopped. The real time clock has a frequency of 1000
>> --
>> 1.7.4.1
>>
>>

Patch

diff --git a/qemu-timer.c b/qemu-timer.c
index cd026c6..2b5cc48 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -46,46 +46,6 @@ 
 
 #include "qemu-timer.h"
 
-/***********************************************************/
-/* timers */
-
-#define QEMU_CLOCK_REALTIME 0
-#define QEMU_CLOCK_VIRTUAL  1
-#define QEMU_CLOCK_HOST     2
-
-struct QEMUClock {
-    int type;
-    int enabled;
-
-    QEMUTimer *active_timers;
-
-    NotifierList reset_notifiers;
-    int64_t last;
-};
-
-struct QEMUTimer {
-    QEMUClock *clock;
-    int64_t expire_time;	/* in nanoseconds */
-    int scale;
-    QEMUTimerCB *cb;
-    void *opaque;
-    struct QEMUTimer *next;
-};
-
-struct qemu_alarm_timer {
-    char const *name;
-    int (*start)(struct qemu_alarm_timer *t);
-    void (*stop)(struct qemu_alarm_timer *t);
-    void (*rearm)(struct qemu_alarm_timer *t, int64_t nearest_delta_ns);
-#if defined(__linux__)
-    int fd;
-    timer_t timer;
-#elif defined(_WIN32)
-    HANDLE timer;
-#endif
-    char expired;
-    char pending;
-};
 
 static struct qemu_alarm_timer *alarm_timer;
 
diff --git a/qemu-timer.h b/qemu-timer.h
index 67ca72e..5bf2fc7 100644
--- a/qemu-timer.h
+++ b/qemu-timer.h
@@ -20,6 +20,47 @@ 
 typedef struct QEMUClock QEMUClock;
 typedef void QEMUTimerCB(void *opaque);
 
+/***********************************************************/
+/* timers */
+
+#define QEMU_CLOCK_REALTIME 0
+#define QEMU_CLOCK_VIRTUAL  1
+#define QEMU_CLOCK_HOST     2
+
+struct QEMUClock {
+    int type;
+    int enabled;
+
+    QEMUTimer *active_timers;
+
+    NotifierList reset_notifiers;
+    int64_t last;
+};
+
+struct QEMUTimer {
+    QEMUClock *clock;
+    int64_t expire_time;	/* in nanoseconds */
+    int scale;
+    QEMUTimerCB *cb;
+    void *opaque;
+    struct QEMUTimer *next;
+};
+
+struct qemu_alarm_timer {
+    char const *name;
+    int (*start)(struct qemu_alarm_timer *t);
+    void (*stop)(struct qemu_alarm_timer *t);
+    void (*rearm)(struct qemu_alarm_timer *t, int64_t nearest_delta_ns);
+#if defined(__linux__)
+    int fd;
+    timer_t timer;
+#elif defined(_WIN32)
+    HANDLE timer;
+#endif
+    char expired;
+    char pending;
+};
+
 /* The real time clock should be used only for stuff which does not
    change the virtual machine state, as it is run even if the virtual
    machine is stopped. The real time clock has a frequency of 1000