|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [v3 1/6] Define WARN_ON_ONCE() macro to mirror Linux functionality
Define WARN_ON_ONCE() macro to mirror Linux functionality.
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..1ef714110a 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.cold)
CONSTRUCTORS
} :text
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 70afedd31d..51d9da2482 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.cold)
CONSTRUCTORS
} :text
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 1d9771340c..2bdaf6d60d 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.cold") 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.1
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |