[XEN] Can be built -std=gnu99 (except for .S files).
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 18 Oct 2006 13:46:48 +0000 (14:46 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 18 Oct 2006 13:46:48 +0000 (14:46 +0100)
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@xensource.com>
20 files changed:
Config.mk
xen/Rules.mk
xen/acm/acm_core.c
xen/arch/ia64/Rules.mk
xen/arch/ia64/linux-xen/smpboot.c
xen/arch/powerpc/Makefile
xen/arch/x86/Makefile
xen/arch/x86/io_apic.c
xen/arch/x86/irq.c
xen/arch/x86/oprofile/xenoprof.c
xen/common/domain.c
xen/common/page_alloc.c
xen/common/schedule.c
xen/drivers/char/console.c
xen/drivers/char/serial.c
xen/include/asm-ia64/linux-xen/asm/spinlock.h
xen/include/asm-powerpc/spinlock.h
xen/include/asm-x86/spinlock.h
xen/include/xen/cpumask.h
xen/include/xen/spinlock.h

index 4f1b1f7c1a81a25242a185ee17ba7e9acd0c0f47..e626a26283c031aea5b7d321a00e323d4d8e0949 100644 (file)
--- a/Config.mk
+++ b/Config.mk
@@ -34,6 +34,8 @@ else
 CFLAGS += -g
 endif
 
+CFLAGS += -std=gnu99
+
 CFLAGS += -Wall -Wstrict-prototypes
 
 # -Wunused-value makes GCC 4.x too aggressive for my taste: ignoring the
index b3ae01dfc26b2005078d8e296bcc89d953effa99..1522ba786bc19b32b7519b1b6117b9f2e0cc4426 100644 (file)
@@ -63,8 +63,13 @@ endif
 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 $@
index bafb177c3d6327f6b69896172b45de8bdbc7acfc..242b5c82f412c348d196762d14797c78125200b6 100644 (file)
@@ -60,7 +60,7 @@ struct acm_operations *acm_secondary_ops = NULL;
 /* 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;
index 3c8663c90be73fce2ce25c14836bd62f445102ce..944d8d018e00e25eaf781d54dd0e41be7e3bb830 100644 (file)
@@ -13,8 +13,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
 #CFLAGS  += -O3                # -O3 over-inlines making debugging tough!
index ac96fb8cc9cfe8b5cdd05554dafbdcac6f1bc6c6..4450ce926073f4a4ce98888ddeb2c5d63ec31195 100644 (file)
@@ -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
index 837364acc16a0a6aca4238dcf4dfa49aa0314bf4..5db65c2c7ccaa80a0e14a45ff7ed920fa731faaf 100644 (file)
@@ -141,7 +141,7 @@ asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c $(HDRS)
        $(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 $< $@
index e8b1dd02e88664172b24eed31c4db098e8f20cca..31f2793fb9086ddb8a2ace57803d2f7238a2319f 100644 (file)
@@ -69,7 +69,7 @@ asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c $(HDRS)
        $(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 $@ $<
index 9a86c040d03dea7f5db296e237aeb89c8fdf00cf..4b30851276eb6c7c6af4243eaee78d640bfea9ee 100644 (file)
@@ -269,13 +269,10 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
     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 */
index 4fa637ad01fc6af75de179fe7b4e4bee6839f733..4bad3ee23eb28110cd36427125e89184fd862d34 100644 (file)
@@ -450,7 +450,7 @@ int pirq_guest_bind(struct vcpu *v, int irq, int will_share)
         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;
index eca1f03d963685fcbbbcc8ed69d910f84a167160..f60656ba8cd9f05a7e63ac31af9dac8a4302f069 100644 (file)
@@ -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];
index 2dde26eb755db85ee032735d7c6aa1197c5dece6..f96becc578e696f65ad000d7a824d6af3c252c78 100644 (file)
@@ -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;
 
index 70aab2799b8043412ef109b4c81f4b5fb9b160b1..fbbe837780b89b44eb01ec558094e4414cb89560 100644 (file)
@@ -704,7 +704,7 @@ void free_domheap_pages(struct page_info *pg, unsigned int order)
     {
         /* 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;
     }
index b7ed65aa4c65a8a6f4d66a5458c056523abf5c52..fc2a927e2b849040e645cd4ea1069677a9997e09 100644 (file)
@@ -113,7 +113,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int processor)
     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);
index c3e17efe72574d79e8368a60bbd3772a8b7bd3a5..b43f8eafc790ba85e948111d2d9f4e61a9beabc8 100644 (file)
@@ -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();
 }
index 024de30ae9919384ef60fe2d31dd14fa6aba4d81..cd909a6cef3012d60ce0aa40bf1a9eb106a2da07 100644 (file)
@@ -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);
 }
index 1c2034c80d9d09054ab7a31d6d61f81013ac576c..129fbf5156f42e7997a1c638221911d98b042ca8 100644 (file)
@@ -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 RW_LOCK_UNLOCKED /*(rwlock_t)*/ { 0, 0 }
 
-#define rwlock_init(x)         do { *(x) = RW_LOCK_UNLOCKED; } while(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)
 
index f6574d6b768bc4b6503a0af8f2a0ac18b51e5bf5..e65e0f2bc0f319afcfe0c41a606142e3de814d86 100644 (file)
@@ -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_lock(spinlock_t *lock)
 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_lock(rwlock_t *lock)
 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)
index 1d864188dac1060e0448a2049c935d8d58874aa1..8c148e0240dce2eaa42c523d96b34074d40966ef 100644 (file)
@@ -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
index 997efb1d45a6262729f398247013f4b265818045..d9296201cb0ec5fa57526be25bb1fa2aa844e2f7 100644 (file)
@@ -239,14 +239,14 @@ static inline int __next_cpu(int n, const cpumask_t *srcp, int nbits)
 #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, const cpumask_t *srcp, int nbits)
 #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                                                      \
 } }
 
index 73184daad82336a349a5c2688ad31f872395da33..11f83119d4e5869bd38d652f9b6989ee44acc1b6 100644 (file)
 
 #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; } spinlock_t;
 
 #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)