[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [XEN] Can be built -std=gnu99 (except for .S files).



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 21f8c507da293d8c707071bafffeb2e9100f3922
# Parent  5c029fda79dca05de04b68a54a827f874aae087a
[XEN] Can be built -std=gnu99 (except for .S files).

Need to be careful with static initialisers:
 1. *_LOCK_UNLOCKED, CPU_MASK_* no longer include a cast
 2. Dynamic uses of the above are replaced by
    appropriate function invocations.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 Config.mk                                     |    2 ++
 xen/Rules.mk                                  |   10 ++++++++--
 xen/acm/acm_core.c                            |    2 +-
 xen/arch/ia64/Rules.mk                        |    2 --
 xen/arch/ia64/linux-xen/smpboot.c             |    3 ++-
 xen/arch/powerpc/Makefile                     |    2 +-
 xen/arch/x86/Makefile                         |    2 +-
 xen/arch/x86/io_apic.c                        |   11 ++++-------
 xen/arch/x86/irq.c                            |    2 +-
 xen/arch/x86/oprofile/xenoprof.c              |    2 +-
 xen/common/domain.c                           |    2 +-
 xen/common/page_alloc.c                       |    2 +-
 xen/common/schedule.c                         |    2 +-
 xen/drivers/char/console.c                    |    2 +-
 xen/drivers/char/serial.c                     |    4 ++--
 xen/include/asm-ia64/linux-xen/asm/spinlock.h |    8 ++++----
 xen/include/asm-powerpc/spinlock.h            |   12 ++++++------
 xen/include/asm-x86/spinlock.h                |    8 ++++----
 xen/include/xen/cpumask.h                     |    8 ++++----
 xen/include/xen/spinlock.h                    |    8 ++++----
 20 files changed, 49 insertions(+), 45 deletions(-)

diff -r 5c029fda79dc -r 21f8c507da29 Config.mk
--- a/Config.mk Wed Oct 18 14:36:20 2006 +0100
+++ b/Config.mk Wed Oct 18 14:46:48 2006 +0100
@@ -34,6 +34,8 @@ CFLAGS += -g
 CFLAGS += -g
 endif
 
+CFLAGS += -std=gnu99
+
 CFLAGS += -Wall -Wstrict-prototypes
 
 # -Wunused-value makes GCC 4.x too aggressive for my taste: ignoring the
diff -r 5c029fda79dc -r 21f8c507da29 xen/Rules.mk
--- a/xen/Rules.mk      Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/Rules.mk      Wed Oct 18 14:46:48 2006 +0100
@@ -63,8 +63,13 @@ AFLAGS-y               += -D__ASSEMBLY__
 AFLAGS-y               += -D__ASSEMBLY__
 
 ALL_OBJS := $(ALL_OBJS-y)
+
 CFLAGS   := $(strip $(CFLAGS) $(CFLAGS-y))
+
+# Most CFLAGS are safe for assembly files:
+#  -std=gnu{89,99} gets confused by #-prefixed end-of-line comments
 AFLAGS   := $(strip $(AFLAGS) $(AFLAGS-y))
+AFLAGS   += $(patsubst -std=gnu%,,$(CFLAGS))
 
 include Makefile
 
@@ -102,10 +107,11 @@ _clean_%/: FORCE
        $(CC) $(CFLAGS) -c $< -o $@
 
 %.o: %.S $(HDRS) Makefile
-       $(CC) $(CFLAGS) $(AFLAGS) -c $< -o $@
+       $(CC) $(AFLAGS) -c $< -o $@
 
 %.i: %.c $(HDRS) Makefile
        $(CPP) $(CFLAGS) $< -o $@
 
+# -std=gnu{89,99} gets confused by # as an end-of-line comment marker
 %.s: %.S $(HDRS) Makefile
-       $(CPP) $(CFLAGS) $(AFLAGS) $< -o $@
+       $(CPP) $(AFLAGS) $< -o $@
diff -r 5c029fda79dc -r 21f8c507da29 xen/acm/acm_core.c
--- a/xen/acm/acm_core.c        Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/acm/acm_core.c        Wed Oct 18 14:46:48 2006 +0100
@@ -60,7 +60,7 @@ struct acm_operations *acm_secondary_ops
 /* acm global binary policy (points to 'local' primary and secondary policies 
*/
 struct acm_binary_policy acm_bin_pol;
 /* acm binary policy lock */
-rwlock_t acm_bin_pol_rwlock = RW_LOCK_UNLOCKED;
+DEFINE_RWLOCK(acm_bin_pol_rwlock);
 
 /* until we have endian support in Xen, we discover it at runtime */
 u8 little_endian = 1;
diff -r 5c029fda79dc -r 21f8c507da29 xen/arch/ia64/Rules.mk
--- a/xen/arch/ia64/Rules.mk    Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/arch/ia64/Rules.mk    Wed Oct 18 14:46:48 2006 +0100
@@ -12,8 +12,6 @@ endif
 
 # Used only by linux/Makefile.
 AFLAGS_KERNEL  += -mconstant-gp -nostdinc $(CPPFLAGS)
-
-# Note: .S -> .o rule uses AFLAGS and CFLAGS.
 
 CFLAGS += -nostdinc -fno-builtin -fno-common -fno-strict-aliasing
 CFLAGS += -mconstant-gp
diff -r 5c029fda79dc -r 21f8c507da29 xen/arch/ia64/linux-xen/smpboot.c
--- a/xen/arch/ia64/linux-xen/smpboot.c Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/arch/ia64/linux-xen/smpboot.c Wed Oct 18 14:46:48 2006 +0100
@@ -650,7 +650,8 @@ clear_cpu_sibling_map(int cpu)
        for_each_cpu_mask(i, cpu_core_map[cpu])
                cpu_clear(cpu, cpu_core_map[i]);
 
-       cpu_sibling_map[cpu] = cpu_core_map[cpu] = CPU_MASK_NONE;
+       cpus_clear(cpu_sibling_map[cpu]);
+       cpus_clear(cpu_core_map[cpu]);
 }
 
 static void
diff -r 5c029fda79dc -r 21f8c507da29 xen/arch/powerpc/Makefile
--- a/xen/arch/powerpc/Makefile Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/arch/powerpc/Makefile Wed Oct 18 14:46:48 2006 +0100
@@ -141,7 +141,7 @@ asm-offsets.s: $(TARGET_SUBARCH)/asm-off
        $(CC) $(CFLAGS) -S -o $@ $<
 
 xen.lds: xen.lds.S $(HDRS)
-       $(CC) $(CFLAGS) -P -E $(AFLAGS) -o $@ $<
+       $(CC) -P -E $(AFLAGS) -o $@ $<
 
 dom0.bin: $(DOM0_IMAGE)
        cp $< $@
diff -r 5c029fda79dc -r 21f8c507da29 xen/arch/x86/Makefile
--- a/xen/arch/x86/Makefile     Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/arch/x86/Makefile     Wed Oct 18 14:46:48 2006 +0100
@@ -69,7 +69,7 @@ asm-offsets.s: $(TARGET_SUBARCH)/asm-off
        $(CC) $(CFLAGS) -S -o $@ $<
 
 xen.lds: $(TARGET_SUBARCH)/xen.lds.S $(HDRS)
-       $(CC) $(CFLAGS) -P -E -Ui386 $(AFLAGS) -o $@ $<
+       $(CC) -P -E -Ui386 $(AFLAGS) -o $@ $<
 
 boot/mkelf32: boot/mkelf32.c
        $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
diff -r 5c029fda79dc -r 21f8c507da29 xen/arch/x86/io_apic.c
--- a/xen/arch/x86/io_apic.c    Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/arch/x86/io_apic.c    Wed Oct 18 14:46:48 2006 +0100
@@ -269,13 +269,10 @@ static void set_ioapic_affinity_irq(unsi
     int pin;
     struct irq_pin_list *entry = irq_2_pin + irq;
     unsigned int apicid_value;
-    cpumask_t tmp;
-       
-    cpus_and(tmp, cpumask, cpu_online_map);
-    if (cpus_empty(tmp))
-        tmp = TARGET_CPUS;
-
-    cpus_and(cpumask, tmp, CPU_MASK_ALL);
+
+    cpus_and(cpumask, cpumask, cpu_online_map);
+    if (cpus_empty(cpumask))
+        cpumask = TARGET_CPUS;
 
     apicid_value = cpu_mask_to_apicid(cpumask);
     /* Prepare to do the io_apic_write */
diff -r 5c029fda79dc -r 21f8c507da29 xen/arch/x86/irq.c
--- a/xen/arch/x86/irq.c        Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/arch/x86/irq.c        Wed Oct 18 14:46:48 2006 +0100
@@ -450,7 +450,7 @@ int pirq_guest_bind(struct vcpu *v, int 
         action->in_flight   = 0;
         action->shareable   = will_share;
         action->ack_type    = pirq_acktype(irq);
-        action->cpu_eoi_map = CPU_MASK_NONE;
+        cpus_clear(action->cpu_eoi_map);
 
         desc->depth = 0;
         desc->status |= IRQ_GUEST;
diff -r 5c029fda79dc -r 21f8c507da29 xen/arch/x86/oprofile/xenoprof.c
--- a/xen/arch/x86/oprofile/xenoprof.c  Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/arch/x86/oprofile/xenoprof.c  Wed Oct 18 14:46:48 2006 +0100
@@ -14,7 +14,7 @@
 #define MAX_OPROF_SHARED_PAGES 32
 
 /* Lock protecting the following global state */
-static spinlock_t xenoprof_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(xenoprof_lock);
 
 struct domain *active_domains[MAX_OPROF_DOMAINS];
 int active_ready[MAX_OPROF_DOMAINS];
diff -r 5c029fda79dc -r 21f8c507da29 xen/common/domain.c
--- a/xen/common/domain.c       Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/common/domain.c       Wed Oct 18 14:46:48 2006 +0100
@@ -27,7 +27,7 @@
 #include <public/vcpu.h>
 
 /* Both these structures are protected by the domlist_lock. */
-rwlock_t domlist_lock = RW_LOCK_UNLOCKED;
+DEFINE_RWLOCK(domlist_lock);
 struct domain *domain_hash[DOMAIN_HASH_SIZE];
 struct domain *domain_list;
 
diff -r 5c029fda79dc -r 21f8c507da29 xen/common/page_alloc.c
--- a/xen/common/page_alloc.c   Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/common/page_alloc.c   Wed Oct 18 14:46:48 2006 +0100
@@ -704,7 +704,7 @@ void free_domheap_pages(struct page_info
     {
         /* Freeing anonymous domain-heap pages. */
         for ( i = 0; i < (1 << order); i++ )
-            pg[i].u.free.cpumask = CPU_MASK_NONE;
+            cpus_clear(pg[i].u.free.cpumask);
         free_heap_pages(pfn_dom_zone_type(page_to_mfn(pg)), pg, order);
         drop_dom_ref = 0;
     }
diff -r 5c029fda79dc -r 21f8c507da29 xen/common/schedule.c
--- a/xen/common/schedule.c     Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/common/schedule.c     Wed Oct 18 14:46:48 2006 +0100
@@ -113,7 +113,7 @@ int sched_init_vcpu(struct vcpu *v, unsi
     if ( is_idle_domain(d) || ((d->domain_id == 0) && opt_dom0_vcpus_pin) )
         v->cpu_affinity = cpumask_of_cpu(processor);
     else
-        v->cpu_affinity = CPU_MASK_ALL;
+        cpus_setall(v->cpu_affinity);
 
     /* Initialise the per-domain timers. */
     init_timer(&v->timer, vcpu_timer_fn, v, v->processor);
diff -r 5c029fda79dc -r 21f8c507da29 xen/drivers/char/console.c
--- a/xen/drivers/char/console.c        Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/drivers/char/console.c        Wed Oct 18 14:46:48 2006 +0100
@@ -418,7 +418,7 @@ void console_endboot(void)
 
 void console_force_unlock(void)
 {
-    console_lock = SPIN_LOCK_UNLOCKED;
+    spin_lock_init(&console_lock);
     serial_force_unlock(sercon_handle);
     console_start_sync();
 }
diff -r 5c029fda79dc -r 21f8c507da29 xen/drivers/char/serial.c
--- a/xen/drivers/char/serial.c Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/drivers/char/serial.c Wed Oct 18 14:46:48 2006 +0100
@@ -295,8 +295,8 @@ void serial_force_unlock(int handle)
     if ( handle == -1 )
         return;
 
-    port->rx_lock = SPIN_LOCK_UNLOCKED;
-    port->tx_lock = SPIN_LOCK_UNLOCKED;
+    spin_lock_init(&port->rx_lock);
+    spin_lock_init(&port->tx_lock);
 
     serial_start_sync(handle);
 }
diff -r 5c029fda79dc -r 21f8c507da29 
xen/include/asm-ia64/linux-xen/asm/spinlock.h
--- a/xen/include/asm-ia64/linux-xen/asm/spinlock.h     Wed Oct 18 14:36:20 
2006 +0100
+++ b/xen/include/asm-ia64/linux-xen/asm/spinlock.h     Wed Oct 18 14:46:48 
2006 +0100
@@ -33,7 +33,7 @@ typedef struct {
 #endif
 } spinlock_t;
 
-#define SPIN_LOCK_UNLOCKED                     (spinlock_t) { 0 }
+#define SPIN_LOCK_UNLOCKED                     /*(spinlock_t)*/ { 0 }
 #define spin_lock_init(x)                      ((x)->lock = 0)
 
 #ifdef ASM_SUPPORTED
@@ -136,9 +136,9 @@ typedef struct {
        unsigned int break_lock;
 #endif
 } rwlock_t;
-#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 }
-
-#define rwlock_init(x)         do { *(x) = RW_LOCK_UNLOCKED; } while(0)
+#define RW_LOCK_UNLOCKED /*(rwlock_t)*/ { 0, 0 }
+
+#define rwlock_init(x)         do { *(x) = (rwlock_t) RW_LOCK_UNLOCKED; } 
while(0)
 #define read_can_lock(rw)      (*(volatile int *)(rw) >= 0)
 #define write_can_lock(rw)     (*(volatile int *)(rw) == 0)
 
diff -r 5c029fda79dc -r 21f8c507da29 xen/include/asm-powerpc/spinlock.h
--- a/xen/include/asm-powerpc/spinlock.h        Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/include/asm-powerpc/spinlock.h        Wed Oct 18 14:46:48 2006 +0100
@@ -81,10 +81,10 @@ typedef union {
 
 #define __UNLOCKED (0U)
 #define __LOCKED (~__UNLOCKED)
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { __UNLOCKED }
+#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { __UNLOCKED }
 static inline void spin_lock_init(spinlock_t *lock)
 {
-    *lock = SPIN_LOCK_UNLOCKED;
+    *lock = (spinlock_t) SPIN_LOCK_UNLOCKED;
 }
 
 static inline int spin_is_locked(spinlock_t *lock)
@@ -103,7 +103,7 @@ static inline void _raw_spin_unlock(spin
 static inline void _raw_spin_unlock(spinlock_t *lock)
 {
     sync_before_release();
-    *lock = SPIN_LOCK_UNLOCKED;
+    *lock = (spinlock_t) SPIN_LOCK_UNLOCKED;
 }
 
 static inline int _raw_spin_trylock(spinlock_t *lock)
@@ -121,10 +121,10 @@ typedef struct {
     volatile unsigned int lock;
 } rwlock_t;
 
-#define RW_LOCK_UNLOCKED (rwlock_t) { __UNLOCKED }
+#define RW_LOCK_UNLOCKED /*(rwlock_t)*/ { __UNLOCKED }
 static inline void rwlock_init(rwlock_t *lock)
 {
-    *lock = RW_LOCK_UNLOCKED;
+    *lock = (rwlock_t) RW_LOCK_UNLOCKED;
 }
 
 static inline void _raw_read_lock(rwlock_t *lock)
@@ -152,7 +152,7 @@ static inline void _raw_write_unlock(rwl
 static inline void _raw_write_unlock(rwlock_t *lock)
 {
     sync_before_release();
-    *lock = RW_LOCK_UNLOCKED;
+    *lock = (rwlock_t) RW_LOCK_UNLOCKED;
 }
 
 static inline void _raw_read_unlock(rwlock_t *lock)
diff -r 5c029fda79dc -r 21f8c507da29 xen/include/asm-x86/spinlock.h
--- a/xen/include/asm-x86/spinlock.h    Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/include/asm-x86/spinlock.h    Wed Oct 18 14:46:48 2006 +0100
@@ -12,9 +12,9 @@ typedef struct {
     u8 recurse_cnt;
 } spinlock_t;
 
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { 1, -1, 0 }
+#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { 1, -1, 0 }
 
-#define spin_lock_init(x)      do { *(x) = SPIN_LOCK_UNLOCKED; } while(0)
+#define spin_lock_init(x)      do { *(x) = (spinlock_t) SPIN_LOCK_UNLOCKED; } 
while(0)
 #define spin_is_locked(x)      (*(volatile char *)(&(x)->lock) <= 0)
 
 static inline void _raw_spin_lock(spinlock_t *lock)
@@ -89,9 +89,9 @@ typedef struct {
     volatile unsigned int lock;
 } rwlock_t;
 
-#define RW_LOCK_UNLOCKED (rwlock_t) { RW_LOCK_BIAS }
+#define RW_LOCK_UNLOCKED /*(rwlock_t)*/ { RW_LOCK_BIAS }
 
-#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
+#define rwlock_init(x) do { *(x) = (rwlock_t) RW_LOCK_UNLOCKED; } while(0)
 
 /*
  * On x86, we implement read-write locks as a 32-bit counter
diff -r 5c029fda79dc -r 21f8c507da29 xen/include/xen/cpumask.h
--- a/xen/include/xen/cpumask.h Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/include/xen/cpumask.h Wed Oct 18 14:46:48 2006 +0100
@@ -239,14 +239,14 @@ static inline int __next_cpu(int n, cons
 #if NR_CPUS <= BITS_PER_LONG
 
 #define CPU_MASK_ALL                                                   \
-(cpumask_t) { {                                                                
\
+/*(cpumask_t)*/ { {                                                    \
        [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD                 \
 } }
 
 #else
 
 #define CPU_MASK_ALL                                                   \
-(cpumask_t) { {                                                                
\
+/*(cpumask_t)*/ { {                                                    \
        [0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL,                        \
        [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD                 \
 } }
@@ -254,12 +254,12 @@ static inline int __next_cpu(int n, cons
 #endif
 
 #define CPU_MASK_NONE                                                  \
-(cpumask_t) { {                                                                
\
+/*(cpumask_t)*/ { {                                                    \
        [0 ... BITS_TO_LONGS(NR_CPUS)-1] =  0UL                         \
 } }
 
 #define CPU_MASK_CPU0                                                  \
-(cpumask_t) { {                                                                
\
+/*(cpumask_t)*/ { {                                                    \
        [0] =  1UL                                                      \
 } }
 
diff -r 5c029fda79dc -r 21f8c507da29 xen/include/xen/spinlock.h
--- a/xen/include/xen/spinlock.h        Wed Oct 18 14:36:20 2006 +0100
+++ b/xen/include/xen/spinlock.h        Wed Oct 18 14:46:48 2006 +0100
@@ -42,10 +42,10 @@
 
 #if (__GNUC__ > 2)
 typedef struct { } spinlock_t;
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { }
+#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { }
 #else
 typedef struct { int gcc_is_buggy; } spinlock_t;
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 }
+#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { 0 }
 #endif
 
 #define spin_lock_init(lock)             do { } while(0)
@@ -58,10 +58,10 @@ typedef struct { int gcc_is_buggy; } spi
 
 #if (__GNUC__ > 2)
 typedef struct { } rwlock_t;
-#define RW_LOCK_UNLOCKED (rwlock_t) { }
+#define RW_LOCK_UNLOCKED /*(rwlock_t)*/ { }
 #else
 typedef struct { int gcc_is_buggy; } rwlock_t;
-#define RW_LOCK_UNLOCKED (rwlock_t) { 0 }
+#define RW_LOCK_UNLOCKED /*(rwlock_t)*/ { 0 }
 #endif
 
 #define rwlock_init(lock)            do { } while(0)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.