From 19cc8a5eb2e6fa9e3012d32b7e19d9ebedf39d73 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Tue, 26 Feb 2013 17:08:43 +0400 Subject: [PATCH] Move BUG_ONs to include/bug.h We will need futexes to use in PIE code but futex.h uses BUG_ON helper, so to diet inclusions move BUG_ONs code to include/bug.h. Signed-off-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- include/bug.h | 30 ++++++++++++++++++++++++++++++ include/util.h | 31 +------------------------------ 2 files changed, 31 insertions(+), 30 deletions(-) create mode 100644 include/bug.h diff --git a/include/bug.h b/include/bug.h new file mode 100644 index 000000000..4475a09ce --- /dev/null +++ b/include/bug.h @@ -0,0 +1,30 @@ +#ifndef __CR_BUG_H__ +#define __CR_BUG_H__ + +#include + +#include "log.h" + +#ifndef BUG_ON_HANDLER + +#ifdef CR_NOGLIBC +# define __raise() +#else +# define __raise() raise(SIGABRT) +#endif + +# define BUG_ON_HANDLER(condition) \ + do { \ + if ((condition)) { \ + pr_err("BUG at %s:%d\n", __FILE__, __LINE__); \ + __raise(); \ + *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__; \ + } \ + } while (0) + +#endif /* BUG_ON_HANDLER */ + +#define BUG_ON(condition) BUG_ON_HANDLER((condition)) +#define BUG() BUG_ON(true) + +#endif /* __CR_BUG_H__ */ diff --git a/include/util.h b/include/util.h index 66238451f..53542e51d 100644 --- a/include/util.h +++ b/include/util.h @@ -14,6 +14,7 @@ #include "compiler.h" #include "asm/types.h" +#include "bug.h" #include "log.h" #include "protobuf/vma.pb-c.h" @@ -31,36 +32,6 @@ #define MEGA(size) PREF_SHIFT_OP(K, <<, size) #define GIGA(size) PREF_SHIFT_OP(K, <<, size) -#ifndef BUG_ON_HANDLER - -#ifdef CR_NOGLIBC - -#define BUG_ON_HANDLER(condition) \ - do { \ - if ((condition)) { \ - pr_err("BUG at %s:%d\n", __FILE__, __LINE__); \ - *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__; \ - } \ - } while (0) - -#else /* CR_NOGLIBC */ - -# define BUG_ON_HANDLER(condition) \ - do { \ - if ((condition)) { \ - pr_err("BUG at %s:%d\n", __FILE__, __LINE__); \ - raise(SIGABRT); \ - *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__; \ - } \ - } while (0) - -#endif /* CR_NOGLIBC */ - -#endif /* BUG_ON_HANDLER */ - -#define BUG_ON(condition) BUG_ON_HANDLER((condition)) -#define BUG() BUG_ON(true) - /* * Write buffer @ptr of @size bytes into @fd file * Returns