[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [v2 1/6] Port WARN_ON_ONCE() from Linux
Port WARN_ON_ONCE macro from Linux. Signed-off-by: Sameer Goel <sameer.goel@xxxxxxxxxx> Acked-by: Julien Grall <julien.grall@xxxxxxxxxx> --- xen/arch/arm/xen.lds.S | 1 + xen/arch/x86/xen.lds.S | 1 + xen/include/xen/lib.h | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S index 245a0e0e85..2f211be22f 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -94,6 +94,7 @@ SECTIONS __end_schedulers_array = .; *(.data.rel) *(.data.rel.*) + *(.data.unlikely) CONSTRUCTORS } :text diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 70afedd31d..11b2a93eb1 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -270,6 +270,7 @@ SECTIONS *(.data) *(.data.rel) *(.data.rel.*) + *(.data.unlikely) CONSTRUCTORS } :text diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 1d9771340c..b8442a292e 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -11,6 +11,19 @@ #define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0) #define WARN_ON(p) do { if (unlikely(p)) WARN(); } while (0) +#define WARN_ON_ONCE(p) \ +({ \ + static bool __section(".data.unlikely") warned; \ + bool ret_warn_once = !!(p); \ + \ + if ( unlikely(ret_warn_once && !warned) ) \ + { \ + warned = true; \ + WARN(); \ + } \ + unlikely(ret_warn_once); \ +}) + #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) /* Force a compilation error if condition is true */ #define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); }) -- 2.17.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |