ia64/xen-unstable

changeset 11872:21f8c507da29

[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@xensource.com>
author kfraser@localhost.localdomain
date Wed Oct 18 14:46:48 2006 +0100 (2006-10-18)
parents 5c029fda79dc
children bd6d4a499e47
files 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
line diff
     1.1 --- a/Config.mk	Wed Oct 18 14:36:20 2006 +0100
     1.2 +++ b/Config.mk	Wed Oct 18 14:46:48 2006 +0100
     1.3 @@ -34,6 +34,8 @@ else
     1.4  CFLAGS += -g
     1.5  endif
     1.6  
     1.7 +CFLAGS += -std=gnu99
     1.8 +
     1.9  CFLAGS += -Wall -Wstrict-prototypes
    1.10  
    1.11  # -Wunused-value makes GCC 4.x too aggressive for my taste: ignoring the
     2.1 --- a/xen/Rules.mk	Wed Oct 18 14:36:20 2006 +0100
     2.2 +++ b/xen/Rules.mk	Wed Oct 18 14:46:48 2006 +0100
     2.3 @@ -63,8 +63,13 @@ endif
     2.4  AFLAGS-y               += -D__ASSEMBLY__
     2.5  
     2.6  ALL_OBJS := $(ALL_OBJS-y)
     2.7 +
     2.8  CFLAGS   := $(strip $(CFLAGS) $(CFLAGS-y))
     2.9 +
    2.10 +# Most CFLAGS are safe for assembly files:
    2.11 +#  -std=gnu{89,99} gets confused by #-prefixed end-of-line comments
    2.12  AFLAGS   := $(strip $(AFLAGS) $(AFLAGS-y))
    2.13 +AFLAGS   += $(patsubst -std=gnu%,,$(CFLAGS))
    2.14  
    2.15  include Makefile
    2.16  
    2.17 @@ -102,10 +107,11 @@ clean:: $(addprefix _clean_, $(subdir-al
    2.18  	$(CC) $(CFLAGS) -c $< -o $@
    2.19  
    2.20  %.o: %.S $(HDRS) Makefile
    2.21 -	$(CC) $(CFLAGS) $(AFLAGS) -c $< -o $@
    2.22 +	$(CC) $(AFLAGS) -c $< -o $@
    2.23  
    2.24  %.i: %.c $(HDRS) Makefile
    2.25  	$(CPP) $(CFLAGS) $< -o $@
    2.26  
    2.27 +# -std=gnu{89,99} gets confused by # as an end-of-line comment marker
    2.28  %.s: %.S $(HDRS) Makefile
    2.29 -	$(CPP) $(CFLAGS) $(AFLAGS) $< -o $@
    2.30 +	$(CPP) $(AFLAGS) $< -o $@
     3.1 --- a/xen/acm/acm_core.c	Wed Oct 18 14:36:20 2006 +0100
     3.2 +++ b/xen/acm/acm_core.c	Wed Oct 18 14:46:48 2006 +0100
     3.3 @@ -60,7 +60,7 @@ struct acm_operations *acm_secondary_ops
     3.4  /* acm global binary policy (points to 'local' primary and secondary policies */
     3.5  struct acm_binary_policy acm_bin_pol;
     3.6  /* acm binary policy lock */
     3.7 -rwlock_t acm_bin_pol_rwlock = RW_LOCK_UNLOCKED;
     3.8 +DEFINE_RWLOCK(acm_bin_pol_rwlock);
     3.9  
    3.10  /* until we have endian support in Xen, we discover it at runtime */
    3.11  u8 little_endian = 1;
     4.1 --- a/xen/arch/ia64/Rules.mk	Wed Oct 18 14:36:20 2006 +0100
     4.2 +++ b/xen/arch/ia64/Rules.mk	Wed Oct 18 14:46:48 2006 +0100
     4.3 @@ -13,8 +13,6 @@ endif
     4.4  # Used only by linux/Makefile.
     4.5  AFLAGS_KERNEL  += -mconstant-gp -nostdinc $(CPPFLAGS)
     4.6  
     4.7 -# Note: .S -> .o rule uses AFLAGS and CFLAGS.
     4.8 -
     4.9  CFLAGS	+= -nostdinc -fno-builtin -fno-common -fno-strict-aliasing
    4.10  CFLAGS	+= -mconstant-gp
    4.11  #CFLAGS  += -O3		# -O3 over-inlines making debugging tough!
     5.1 --- a/xen/arch/ia64/linux-xen/smpboot.c	Wed Oct 18 14:36:20 2006 +0100
     5.2 +++ b/xen/arch/ia64/linux-xen/smpboot.c	Wed Oct 18 14:46:48 2006 +0100
     5.3 @@ -650,7 +650,8 @@ clear_cpu_sibling_map(int cpu)
     5.4  	for_each_cpu_mask(i, cpu_core_map[cpu])
     5.5  		cpu_clear(cpu, cpu_core_map[i]);
     5.6  
     5.7 -	cpu_sibling_map[cpu] = cpu_core_map[cpu] = CPU_MASK_NONE;
     5.8 +	cpus_clear(cpu_sibling_map[cpu]);
     5.9 +	cpus_clear(cpu_core_map[cpu]);
    5.10  }
    5.11  
    5.12  static void
     6.1 --- a/xen/arch/powerpc/Makefile	Wed Oct 18 14:36:20 2006 +0100
     6.2 +++ b/xen/arch/powerpc/Makefile	Wed Oct 18 14:46:48 2006 +0100
     6.3 @@ -141,7 +141,7 @@ asm-offsets.s: $(TARGET_SUBARCH)/asm-off
     6.4  	$(CC) $(CFLAGS) -S -o $@ $<
     6.5  
     6.6  xen.lds: xen.lds.S $(HDRS)
     6.7 -	$(CC) $(CFLAGS) -P -E $(AFLAGS) -o $@ $<
     6.8 +	$(CC) -P -E $(AFLAGS) -o $@ $<
     6.9  
    6.10  dom0.bin: $(DOM0_IMAGE)
    6.11  	cp $< $@
     7.1 --- a/xen/arch/x86/Makefile	Wed Oct 18 14:36:20 2006 +0100
     7.2 +++ b/xen/arch/x86/Makefile	Wed Oct 18 14:46:48 2006 +0100
     7.3 @@ -69,7 +69,7 @@ asm-offsets.s: $(TARGET_SUBARCH)/asm-off
     7.4  	$(CC) $(CFLAGS) -S -o $@ $<
     7.5  
     7.6  xen.lds: $(TARGET_SUBARCH)/xen.lds.S $(HDRS)
     7.7 -	$(CC) $(CFLAGS) -P -E -Ui386 $(AFLAGS) -o $@ $<
     7.8 +	$(CC) -P -E -Ui386 $(AFLAGS) -o $@ $<
     7.9  
    7.10  boot/mkelf32: boot/mkelf32.c
    7.11  	$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
     8.1 --- a/xen/arch/x86/io_apic.c	Wed Oct 18 14:36:20 2006 +0100
     8.2 +++ b/xen/arch/x86/io_apic.c	Wed Oct 18 14:46:48 2006 +0100
     8.3 @@ -269,13 +269,10 @@ static void set_ioapic_affinity_irq(unsi
     8.4      int pin;
     8.5      struct irq_pin_list *entry = irq_2_pin + irq;
     8.6      unsigned int apicid_value;
     8.7 -    cpumask_t tmp;
     8.8 -	
     8.9 -    cpus_and(tmp, cpumask, cpu_online_map);
    8.10 -    if (cpus_empty(tmp))
    8.11 -        tmp = TARGET_CPUS;
    8.12  
    8.13 -    cpus_and(cpumask, tmp, CPU_MASK_ALL);
    8.14 +    cpus_and(cpumask, cpumask, cpu_online_map);
    8.15 +    if (cpus_empty(cpumask))
    8.16 +        cpumask = TARGET_CPUS;
    8.17  
    8.18      apicid_value = cpu_mask_to_apicid(cpumask);
    8.19      /* Prepare to do the io_apic_write */
     9.1 --- a/xen/arch/x86/irq.c	Wed Oct 18 14:36:20 2006 +0100
     9.2 +++ b/xen/arch/x86/irq.c	Wed Oct 18 14:46:48 2006 +0100
     9.3 @@ -450,7 +450,7 @@ int pirq_guest_bind(struct vcpu *v, int 
     9.4          action->in_flight   = 0;
     9.5          action->shareable   = will_share;
     9.6          action->ack_type    = pirq_acktype(irq);
     9.7 -        action->cpu_eoi_map = CPU_MASK_NONE;
     9.8 +        cpus_clear(action->cpu_eoi_map);
     9.9  
    9.10          desc->depth = 0;
    9.11          desc->status |= IRQ_GUEST;
    10.1 --- a/xen/arch/x86/oprofile/xenoprof.c	Wed Oct 18 14:36:20 2006 +0100
    10.2 +++ b/xen/arch/x86/oprofile/xenoprof.c	Wed Oct 18 14:46:48 2006 +0100
    10.3 @@ -14,7 +14,7 @@
    10.4  #define MAX_OPROF_SHARED_PAGES 32
    10.5  
    10.6  /* Lock protecting the following global state */
    10.7 -static spinlock_t xenoprof_lock = SPIN_LOCK_UNLOCKED;
    10.8 +static DEFINE_SPINLOCK(xenoprof_lock);
    10.9  
   10.10  struct domain *active_domains[MAX_OPROF_DOMAINS];
   10.11  int active_ready[MAX_OPROF_DOMAINS];
    11.1 --- a/xen/common/domain.c	Wed Oct 18 14:36:20 2006 +0100
    11.2 +++ b/xen/common/domain.c	Wed Oct 18 14:46:48 2006 +0100
    11.3 @@ -27,7 +27,7 @@
    11.4  #include <public/vcpu.h>
    11.5  
    11.6  /* Both these structures are protected by the domlist_lock. */
    11.7 -rwlock_t domlist_lock = RW_LOCK_UNLOCKED;
    11.8 +DEFINE_RWLOCK(domlist_lock);
    11.9  struct domain *domain_hash[DOMAIN_HASH_SIZE];
   11.10  struct domain *domain_list;
   11.11  
    12.1 --- a/xen/common/page_alloc.c	Wed Oct 18 14:36:20 2006 +0100
    12.2 +++ b/xen/common/page_alloc.c	Wed Oct 18 14:46:48 2006 +0100
    12.3 @@ -704,7 +704,7 @@ void free_domheap_pages(struct page_info
    12.4      {
    12.5          /* Freeing anonymous domain-heap pages. */
    12.6          for ( i = 0; i < (1 << order); i++ )
    12.7 -            pg[i].u.free.cpumask = CPU_MASK_NONE;
    12.8 +            cpus_clear(pg[i].u.free.cpumask);
    12.9          free_heap_pages(pfn_dom_zone_type(page_to_mfn(pg)), pg, order);
   12.10          drop_dom_ref = 0;
   12.11      }
    13.1 --- a/xen/common/schedule.c	Wed Oct 18 14:36:20 2006 +0100
    13.2 +++ b/xen/common/schedule.c	Wed Oct 18 14:46:48 2006 +0100
    13.3 @@ -113,7 +113,7 @@ int sched_init_vcpu(struct vcpu *v, unsi
    13.4      if ( is_idle_domain(d) || ((d->domain_id == 0) && opt_dom0_vcpus_pin) )
    13.5          v->cpu_affinity = cpumask_of_cpu(processor);
    13.6      else
    13.7 -        v->cpu_affinity = CPU_MASK_ALL;
    13.8 +        cpus_setall(v->cpu_affinity);
    13.9  
   13.10      /* Initialise the per-domain timers. */
   13.11      init_timer(&v->timer, vcpu_timer_fn, v, v->processor);
    14.1 --- a/xen/drivers/char/console.c	Wed Oct 18 14:36:20 2006 +0100
    14.2 +++ b/xen/drivers/char/console.c	Wed Oct 18 14:46:48 2006 +0100
    14.3 @@ -418,7 +418,7 @@ void console_endboot(void)
    14.4  
    14.5  void console_force_unlock(void)
    14.6  {
    14.7 -    console_lock = SPIN_LOCK_UNLOCKED;
    14.8 +    spin_lock_init(&console_lock);
    14.9      serial_force_unlock(sercon_handle);
   14.10      console_start_sync();
   14.11  }
    15.1 --- a/xen/drivers/char/serial.c	Wed Oct 18 14:36:20 2006 +0100
    15.2 +++ b/xen/drivers/char/serial.c	Wed Oct 18 14:46:48 2006 +0100
    15.3 @@ -295,8 +295,8 @@ void serial_force_unlock(int handle)
    15.4      if ( handle == -1 )
    15.5          return;
    15.6  
    15.7 -    port->rx_lock = SPIN_LOCK_UNLOCKED;
    15.8 -    port->tx_lock = SPIN_LOCK_UNLOCKED;
    15.9 +    spin_lock_init(&port->rx_lock);
   15.10 +    spin_lock_init(&port->tx_lock);
   15.11  
   15.12      serial_start_sync(handle);
   15.13  }
    16.1 --- a/xen/include/asm-ia64/linux-xen/asm/spinlock.h	Wed Oct 18 14:36:20 2006 +0100
    16.2 +++ b/xen/include/asm-ia64/linux-xen/asm/spinlock.h	Wed Oct 18 14:46:48 2006 +0100
    16.3 @@ -33,7 +33,7 @@ typedef struct {
    16.4  #endif
    16.5  } spinlock_t;
    16.6  
    16.7 -#define SPIN_LOCK_UNLOCKED			(spinlock_t) { 0 }
    16.8 +#define SPIN_LOCK_UNLOCKED			/*(spinlock_t)*/ { 0 }
    16.9  #define spin_lock_init(x)			((x)->lock = 0)
   16.10  
   16.11  #ifdef ASM_SUPPORTED
   16.12 @@ -136,9 +136,9 @@ typedef struct {
   16.13  	unsigned int break_lock;
   16.14  #endif
   16.15  } rwlock_t;
   16.16 -#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 }
   16.17 +#define RW_LOCK_UNLOCKED /*(rwlock_t)*/ { 0, 0 }
   16.18  
   16.19 -#define rwlock_init(x)		do { *(x) = RW_LOCK_UNLOCKED; } while(0)
   16.20 +#define rwlock_init(x)		do { *(x) = (rwlock_t) RW_LOCK_UNLOCKED; } while(0)
   16.21  #define read_can_lock(rw)	(*(volatile int *)(rw) >= 0)
   16.22  #define write_can_lock(rw)	(*(volatile int *)(rw) == 0)
   16.23  
    17.1 --- a/xen/include/asm-powerpc/spinlock.h	Wed Oct 18 14:36:20 2006 +0100
    17.2 +++ b/xen/include/asm-powerpc/spinlock.h	Wed Oct 18 14:46:48 2006 +0100
    17.3 @@ -81,10 +81,10 @@ typedef union {
    17.4  
    17.5  #define __UNLOCKED (0U)
    17.6  #define __LOCKED (~__UNLOCKED)
    17.7 -#define SPIN_LOCK_UNLOCKED (spinlock_t) { __UNLOCKED }
    17.8 +#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { __UNLOCKED }
    17.9  static inline void spin_lock_init(spinlock_t *lock)
   17.10  {
   17.11 -    *lock = SPIN_LOCK_UNLOCKED;
   17.12 +    *lock = (spinlock_t) SPIN_LOCK_UNLOCKED;
   17.13  }
   17.14  
   17.15  static inline int spin_is_locked(spinlock_t *lock)
   17.16 @@ -103,7 +103,7 @@ static inline void _raw_spin_lock(spinlo
   17.17  static inline void _raw_spin_unlock(spinlock_t *lock)
   17.18  {
   17.19      sync_before_release();
   17.20 -    *lock = SPIN_LOCK_UNLOCKED;
   17.21 +    *lock = (spinlock_t) SPIN_LOCK_UNLOCKED;
   17.22  }
   17.23  
   17.24  static inline int _raw_spin_trylock(spinlock_t *lock)
   17.25 @@ -121,10 +121,10 @@ typedef struct {
   17.26      volatile unsigned int lock;
   17.27  } rwlock_t;
   17.28  
   17.29 -#define RW_LOCK_UNLOCKED (rwlock_t) { __UNLOCKED }
   17.30 +#define RW_LOCK_UNLOCKED /*(rwlock_t)*/ { __UNLOCKED }
   17.31  static inline void rwlock_init(rwlock_t *lock)
   17.32  {
   17.33 -    *lock = RW_LOCK_UNLOCKED;
   17.34 +    *lock = (rwlock_t) RW_LOCK_UNLOCKED;
   17.35  }
   17.36  
   17.37  static inline void _raw_read_lock(rwlock_t *lock)
   17.38 @@ -152,7 +152,7 @@ static inline void _raw_write_lock(rwloc
   17.39  static inline void _raw_write_unlock(rwlock_t *lock)
   17.40  {
   17.41      sync_before_release();
   17.42 -    *lock = RW_LOCK_UNLOCKED;
   17.43 +    *lock = (rwlock_t) RW_LOCK_UNLOCKED;
   17.44  }
   17.45  
   17.46  static inline void _raw_read_unlock(rwlock_t *lock)
    18.1 --- a/xen/include/asm-x86/spinlock.h	Wed Oct 18 14:36:20 2006 +0100
    18.2 +++ b/xen/include/asm-x86/spinlock.h	Wed Oct 18 14:46:48 2006 +0100
    18.3 @@ -12,9 +12,9 @@ typedef struct {
    18.4      u8 recurse_cnt;
    18.5  } spinlock_t;
    18.6  
    18.7 -#define SPIN_LOCK_UNLOCKED (spinlock_t) { 1, -1, 0 }
    18.8 +#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { 1, -1, 0 }
    18.9  
   18.10 -#define spin_lock_init(x)	do { *(x) = SPIN_LOCK_UNLOCKED; } while(0)
   18.11 +#define spin_lock_init(x)	do { *(x) = (spinlock_t) SPIN_LOCK_UNLOCKED; } while(0)
   18.12  #define spin_is_locked(x)	(*(volatile char *)(&(x)->lock) <= 0)
   18.13  
   18.14  static inline void _raw_spin_lock(spinlock_t *lock)
   18.15 @@ -89,9 +89,9 @@ typedef struct {
   18.16      volatile unsigned int lock;
   18.17  } rwlock_t;
   18.18  
   18.19 -#define RW_LOCK_UNLOCKED (rwlock_t) { RW_LOCK_BIAS }
   18.20 +#define RW_LOCK_UNLOCKED /*(rwlock_t)*/ { RW_LOCK_BIAS }
   18.21  
   18.22 -#define rwlock_init(x)	do { *(x) = RW_LOCK_UNLOCKED; } while(0)
   18.23 +#define rwlock_init(x)	do { *(x) = (rwlock_t) RW_LOCK_UNLOCKED; } while(0)
   18.24  
   18.25  /*
   18.26   * On x86, we implement read-write locks as a 32-bit counter
    19.1 --- a/xen/include/xen/cpumask.h	Wed Oct 18 14:36:20 2006 +0100
    19.2 +++ b/xen/include/xen/cpumask.h	Wed Oct 18 14:46:48 2006 +0100
    19.3 @@ -239,14 +239,14 @@ static inline int __next_cpu(int n, cons
    19.4  #if NR_CPUS <= BITS_PER_LONG
    19.5  
    19.6  #define CPU_MASK_ALL							\
    19.7 -(cpumask_t) { {								\
    19.8 +/*(cpumask_t)*/ { {							\
    19.9  	[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD			\
   19.10  } }
   19.11  
   19.12  #else
   19.13  
   19.14  #define CPU_MASK_ALL							\
   19.15 -(cpumask_t) { {								\
   19.16 +/*(cpumask_t)*/ { {							\
   19.17  	[0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL,			\
   19.18  	[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD			\
   19.19  } }
   19.20 @@ -254,12 +254,12 @@ static inline int __next_cpu(int n, cons
   19.21  #endif
   19.22  
   19.23  #define CPU_MASK_NONE							\
   19.24 -(cpumask_t) { {								\
   19.25 +/*(cpumask_t)*/ { {							\
   19.26  	[0 ... BITS_TO_LONGS(NR_CPUS)-1] =  0UL				\
   19.27  } }
   19.28  
   19.29  #define CPU_MASK_CPU0							\
   19.30 -(cpumask_t) { {								\
   19.31 +/*(cpumask_t)*/ { {							\
   19.32  	[0] =  1UL							\
   19.33  } }
   19.34  
    20.1 --- a/xen/include/xen/spinlock.h	Wed Oct 18 14:36:20 2006 +0100
    20.2 +++ b/xen/include/xen/spinlock.h	Wed Oct 18 14:46:48 2006 +0100
    20.3 @@ -42,10 +42,10 @@
    20.4  
    20.5  #if (__GNUC__ > 2)
    20.6  typedef struct { } spinlock_t;
    20.7 -#define SPIN_LOCK_UNLOCKED (spinlock_t) { }
    20.8 +#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { }
    20.9  #else
   20.10  typedef struct { int gcc_is_buggy; } spinlock_t;
   20.11 -#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 }
   20.12 +#define SPIN_LOCK_UNLOCKED /*(spinlock_t)*/ { 0 }
   20.13  #endif
   20.14  
   20.15  #define spin_lock_init(lock)             do { } while(0)
   20.16 @@ -58,10 +58,10 @@ typedef struct { int gcc_is_buggy; } spi
   20.17  
   20.18  #if (__GNUC__ > 2)
   20.19  typedef struct { } rwlock_t;
   20.20 -#define RW_LOCK_UNLOCKED (rwlock_t) { }
   20.21 +#define RW_LOCK_UNLOCKED /*(rwlock_t)*/ { }
   20.22  #else
   20.23  typedef struct { int gcc_is_buggy; } rwlock_t;
   20.24 -#define RW_LOCK_UNLOCKED (rwlock_t) { 0 }
   20.25 +#define RW_LOCK_UNLOCKED /*(rwlock_t)*/ { 0 }
   20.26  #endif
   20.27  
   20.28  #define rwlock_init(lock)            do { } while(0)