tools: add WARN_ON_ONCE
PATCH 80/114 tools: add WARN_ON_ONCE
From: Matthew Wilcox <[email protected]>
Subject: tools: add WARN_ON_ONCE
Patch series "Radix tree patches for 4.10", v3.
Mostly these are improvements; the only bug fixes in here relate to multiorder entries (which are unused in the 4.9 tree).
This patch (of 32):
The radix tree uses its own buggy WARN_ON_ONCE. Replace it with the definition from asm-generic/bug.h
Signed-off-by Matthew Wilcox <[email protected]>
Tested-by Kirill A. Shutemov <[email protected]>
Cc Konstantin Khlebnikov <[email protected]>
Cc Ross Zwisler <[email protected]>
Cc Matthew Wilcox <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
tools/include/asm/bug.h | 11 +++++++++++ tools/testing/radix-tree/Makefile | 2 +- tools/testing/radix-tree/linux/bug.h | 2 +- tools/testing/radix-tree/linux/types.h | 2 -- 4 files changed, 13 insertions(+), 4 deletions(-)
tools/include/asm/bug.h renamed from tools/include/asm/bug.h~tools-add-warn_on_once +11 -0
@@ -12,6 +12,17 @@unlikely (__ret_warn_on); \ }) +#define WARN_ON_ONCE (condition) ({ \ + static int __warned; \ + int __ret_warn_once = !!(condition); \ + \ + if (unlikely(__ret_warn_once && !__warned)) { \ + __warned = true; \ + WARN_ON(1); \ + } \ + unlikely(__ret_warn_once); \ +}) + #define WARN_ONCE(condition, format...) ({ \ static int __warned; \ int __ret_warn_once = !!(condition); \
tools/testing/radix-tree/Makefile renamed from tools/testing/radix-tree/Makefile~tools-add-warn_on_once +1 -1
@@ -1,5 +1,5 @@ -CFLAGS += -I. -g -O2 -Wall -D_LGPL_SOURCE +CFLAGS += -I. -I../../include -g -O2 -Wall -D_LGPL_SOURCE LDFLAGS += -lpthread -lurcu TARGETS = main OFILES = main.o radix-tree.o linux.o test.o tag_check.o find_next_bit.o \
tools/testing/radix-tree/linux/bug.h renamed from tools/testing/radix-tree/linux/bug.h~tools-add-warn_on_once +1 -1
@@ -1 +1 @@ -#define WARN_ON_ONCE (x) assert(x) +#include "asm/bug.h"
tools/testing/radix-tree/linux/types.h renamed from tools/testing/radix-tree/linux/types.h~tools-add-warn_on_once +0 -1
@@ -6,8 +6,6 @@#define __rcu#define __read_mostly -#define BITS_PER_LONG (sizeof(long) * 8)