Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/common/include/asm linux: Make WARN_ONCE ac...



details:   https://anonhg.NetBSD.org/src/rev/034879393807
branches:  trunk
changeset: 1028848:034879393807
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 12:12:07 2021 +0000

description:
linux: Make WARN_ONCE actually happen only once.

diffstat:

 sys/external/bsd/common/include/asm/bug.h |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r 337db75152fd -r 034879393807 sys/external/bsd/common/include/asm/bug.h
--- a/sys/external/bsd/common/include/asm/bug.h Sun Dec 19 12:12:00 2021 +0000
+++ b/sys/external/bsd/common/include/asm/bug.h Sun Dec 19 12:12:07 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bug.h,v 1.3 2021/12/19 11:10:41 riastradh Exp $        */
+/*     $NetBSD: bug.h,v 1.4 2021/12/19 12:12:07 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -48,11 +48,19 @@
            : 0)
 
 #define        WARN_ONCE(CONDITION, FMT, ...)                                  \
-       WARN(CONDITION, FMT, ##__VA_ARGS__) /* XXX */
+({                                                                     \
+       static volatile unsigned __warn_once_done = 0;                  \
+       linux_warning((CONDITION)                                       \
+           ? (atomic_swap_uint(&__warn_once_done, 1) == 0              \
+               ? (printf("warning: %s:%d: " FMT, __FILE__, __LINE__,   \
+                       ##__VA_ARGS__), 1)                              \
+               : 1)                                                    \
+           : 0);                                                       \
+})
 
 #define        WARN_ON(CONDITION)      WARN(CONDITION, "%s\n", #CONDITION)
 #define        WARN_ON_SMP(CONDITION)  WARN_ON(CONDITION) /* XXX */
-#define        WARN_ON_ONCE(CONDITION) WARN_ON(CONDITION) /* XXX */
+#define        WARN_ON_ONCE(CONDITION) WARN_ONCE(CONDITION, "%s\n", #CONDITION)
 
 /* XXX Kludge to avoid GCC warning about statements without effect.  */
 static inline int



Home | Main Index | Thread Index | Old Index