From: Keir Fraser Date: Fri, 6 Apr 2007 09:10:45 +0000 (+0100) Subject: xen: Make bool_t an arch-dep definition, and define macros X-Git-Tag: 3.1.0-branched~78^2~2 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=14f8dcea987be144af468acc15ec5aba1e37f406;p=xen.git 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 --- diff --git a/xen/common/domain.c b/xen/common/domain.c index d94e65914f..b876984869 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -307,7 +307,7 @@ void domain_kill(struct domain *d) domain_pause(d); /* Already dying? Then bail. */ - if ( xchg(&d->is_dying, 1) ) + if ( test_and_set_bool(d->is_dying) ) { domain_unpause(d); return; @@ -453,7 +453,7 @@ void domain_pause_for_debugger(void) struct vcpu *v; atomic_inc(&d->pause_count); - if ( xchg(&d->is_paused_by_controller, 1) ) + if ( test_and_set_bool(d->is_paused_by_controller) ) domain_unpause(d); /* race-free atomic_dec(&d->pause_count) */ for_each_vcpu ( d, v ) @@ -553,13 +553,13 @@ void domain_unpause(struct domain *d) void domain_pause_by_systemcontroller(struct domain *d) { domain_pause(d); - if ( xchg(&d->is_paused_by_controller, 1) ) + if ( test_and_set_bool(d->is_paused_by_controller) ) domain_unpause(d); } void domain_unpause_by_systemcontroller(struct domain *d) { - if ( xchg(&d->is_paused_by_controller, 0) ) + if ( test_and_clear_bool(d->is_paused_by_controller) ) domain_unpause(d); } diff --git a/xen/include/asm-ia64/xentypes.h b/xen/include/asm-ia64/xentypes.h index d8bc8c0925..a482e0191e 100644 --- a/xen/include/asm-ia64/xentypes.h +++ b/xen/include/asm-ia64/xentypes.h @@ -5,6 +5,11 @@ typedef unsigned long ssize_t; typedef unsigned long size_t; typedef long long loff_t; + +typedef char bool_t; +#define test_and_set_bool(b) xchg(&(b), 1) +#define test_and_clear_bool(b) xchg(&(b), 0) + #endif /* !__ASSEMBLY__ */ #endif /* _ASM_IA64_XENTYPES_H */ diff --git a/xen/include/asm-powerpc/types.h b/xen/include/asm-powerpc/types.h index aab8d17e6d..5f6b4a6b0e 100644 --- a/xen/include/asm-powerpc/types.h +++ b/xen/include/asm-powerpc/types.h @@ -70,5 +70,9 @@ typedef u64 dma64_addr_t; typedef unsigned short xmem_bufctl_t; +typedef int bool_t; +#define test_and_set_bool(b) xchg(&(b), 1) +#define test_and_clear_bool(b) xchg(&(b), 0) + #endif /* __ASSEMBLY__ */ #endif diff --git a/xen/include/asm-x86/types.h b/xen/include/asm-x86/types.h index 1ebe5a16d9..fd2fd069b6 100644 --- a/xen/include/asm-x86/types.h +++ b/xen/include/asm-x86/types.h @@ -52,6 +52,10 @@ typedef unsigned long paddr_t; typedef unsigned long size_t; +typedef char bool_t; +#define test_and_set_bool(b) xchg(&(b), 1) +#define test_and_clear_bool(b) xchg(&(b), 0) + #endif /* __ASSEMBLY__ */ #if defined(__i386__) diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h index 7b1f3c0d84..fd89c98427 100644 --- a/xen/include/xen/types.h +++ b/xen/include/xen/types.h @@ -20,8 +20,6 @@ #define LONG_MIN (-LONG_MAX - 1) #define ULONG_MAX (~0UL) -typedef char bool_t; - /* bsd */ typedef unsigned char u_char; typedef unsigned short u_short;