ia64/xen-unstable

changeset 14759:5a7eebbae5dc

xen: Make bool_t an arch-dep definition, and define macros
specifically for atomic test-and-modify operations on bool_t.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Fri Apr 06 10:10:45 2007 +0100 (2007-04-06)
parents a00c629f67be
children ba1911d8b5f7
files xen/common/domain.c xen/include/asm-ia64/xentypes.h xen/include/asm-powerpc/types.h xen/include/asm-x86/types.h xen/include/xen/types.h
line diff
     1.1 --- a/xen/common/domain.c	Thu Apr 05 18:47:04 2007 +0100
     1.2 +++ b/xen/common/domain.c	Fri Apr 06 10:10:45 2007 +0100
     1.3 @@ -307,7 +307,7 @@ void domain_kill(struct domain *d)
     1.4      domain_pause(d);
     1.5  
     1.6      /* Already dying? Then bail. */
     1.7 -    if ( xchg(&d->is_dying, 1) )
     1.8 +    if ( test_and_set_bool(d->is_dying) )
     1.9      {
    1.10          domain_unpause(d);
    1.11          return;
    1.12 @@ -453,7 +453,7 @@ void domain_pause_for_debugger(void)
    1.13      struct vcpu *v;
    1.14  
    1.15      atomic_inc(&d->pause_count);
    1.16 -    if ( xchg(&d->is_paused_by_controller, 1) )
    1.17 +    if ( test_and_set_bool(d->is_paused_by_controller) )
    1.18          domain_unpause(d); /* race-free atomic_dec(&d->pause_count) */
    1.19  
    1.20      for_each_vcpu ( d, v )
    1.21 @@ -553,13 +553,13 @@ void domain_unpause(struct domain *d)
    1.22  void domain_pause_by_systemcontroller(struct domain *d)
    1.23  {
    1.24      domain_pause(d);
    1.25 -    if ( xchg(&d->is_paused_by_controller, 1) )
    1.26 +    if ( test_and_set_bool(d->is_paused_by_controller) )
    1.27          domain_unpause(d);
    1.28  }
    1.29  
    1.30  void domain_unpause_by_systemcontroller(struct domain *d)
    1.31  {
    1.32 -    if ( xchg(&d->is_paused_by_controller, 0) )
    1.33 +    if ( test_and_clear_bool(d->is_paused_by_controller) )
    1.34          domain_unpause(d);
    1.35  }
    1.36  
     2.1 --- a/xen/include/asm-ia64/xentypes.h	Thu Apr 05 18:47:04 2007 +0100
     2.2 +++ b/xen/include/asm-ia64/xentypes.h	Fri Apr 06 10:10:45 2007 +0100
     2.3 @@ -5,6 +5,11 @@
     2.4  typedef unsigned long ssize_t;
     2.5  typedef unsigned long size_t;
     2.6  typedef long long loff_t;
     2.7 +
     2.8 +typedef char bool_t;
     2.9 +#define test_and_set_bool(b)   xchg(&(b), 1)
    2.10 +#define test_and_clear_bool(b) xchg(&(b), 0)
    2.11 +
    2.12  #endif /* !__ASSEMBLY__ */
    2.13  
    2.14  #endif /* _ASM_IA64_XENTYPES_H */
     3.1 --- a/xen/include/asm-powerpc/types.h	Thu Apr 05 18:47:04 2007 +0100
     3.2 +++ b/xen/include/asm-powerpc/types.h	Fri Apr 06 10:10:45 2007 +0100
     3.3 @@ -70,5 +70,9 @@ typedef u64 dma64_addr_t;
     3.4  
     3.5  typedef unsigned short xmem_bufctl_t;
     3.6  
     3.7 +typedef int bool_t;
     3.8 +#define test_and_set_bool(b)   xchg(&(b), 1)
     3.9 +#define test_and_clear_bool(b) xchg(&(b), 0)
    3.10 +
    3.11  #endif  /* __ASSEMBLY__ */
    3.12  #endif
     4.1 --- a/xen/include/asm-x86/types.h	Thu Apr 05 18:47:04 2007 +0100
     4.2 +++ b/xen/include/asm-x86/types.h	Fri Apr 06 10:10:45 2007 +0100
     4.3 @@ -52,6 +52,10 @@ typedef unsigned long paddr_t;
     4.4  
     4.5  typedef unsigned long size_t;
     4.6  
     4.7 +typedef char bool_t;
     4.8 +#define test_and_set_bool(b)   xchg(&(b), 1)
     4.9 +#define test_and_clear_bool(b) xchg(&(b), 0)
    4.10 +
    4.11  #endif /* __ASSEMBLY__ */
    4.12  
    4.13  #if defined(__i386__)
     5.1 --- a/xen/include/xen/types.h	Thu Apr 05 18:47:04 2007 +0100
     5.2 +++ b/xen/include/xen/types.h	Fri Apr 06 10:10:45 2007 +0100
     5.3 @@ -20,8 +20,6 @@
     5.4  #define LONG_MIN        (-LONG_MAX - 1)
     5.5  #define ULONG_MAX       (~0UL)
     5.6  
     5.7 -typedef char bool_t;
     5.8 -
     5.9  /* bsd */
    5.10  typedef unsigned char           u_char;
    5.11  typedef unsigned short          u_short;