Commit 81ca0296 authored by Matt Mackall's avatar Matt Mackall Committed by Linus Torvalds

[PATCH] move duplicate BUG and WARN_ON bits to asm-generic

This moves duplicate BUG, PAGE_BUG, BUG_ON, and WARN_ON code to asm-generic
and makes them slightly more consistent.  This cleanup is also preparatory
work for making BUG and WARN verbosity configurable.
Signed-off-by: default avatarMatt Mackall <mpm@selenic.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 74dcabc2
...@@ -9,15 +9,7 @@ ...@@ -9,15 +9,7 @@
__asm__ __volatile__("call_pal %0 # bugchk\n\t"".long %1\n\t.8byte %2" \ __asm__ __volatile__("call_pal %0 # bugchk\n\t"".long %1\n\t.8byte %2" \
: : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__)) : : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__))
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) #define HAVE_ARCH_BUG
#include <asm-generic/bug.h>
#define PAGE_BUG(page) BUG()
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
...@@ -8,23 +8,15 @@ extern volatile void __bug(const char *file, int line, void *data); ...@@ -8,23 +8,15 @@ extern volatile void __bug(const char *file, int line, void *data);
/* give file/line information */ /* give file/line information */
#define BUG() __bug(__FILE__, __LINE__, NULL) #define BUG() __bug(__FILE__, __LINE__, NULL)
#define PAGE_BUG(page) __bug(__FILE__, __LINE__, page)
#else #else
/* these just cause an oops */ /* this just causes an oops */
#define BUG() (*(int *)0 = 0) #define BUG() (*(int *)0 = 0)
#define PAGE_BUG(page) (*(int *)0 = 0)
#endif #endif
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) #define HAVE_ARCH_BUG
#include <asm-generic/bug.h>
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
...@@ -5,26 +5,13 @@ ...@@ -5,26 +5,13 @@
#ifdef CONFIG_DEBUG_BUGVERBOSE #ifdef CONFIG_DEBUG_BUGVERBOSE
extern volatile void __bug(const char *file, int line, void *data); extern volatile void __bug(const char *file, int line, void *data);
/* give file/line information */ /* give file/line information */
#define BUG() __bug(__FILE__, __LINE__, NULL) #define BUG() __bug(__FILE__, __LINE__, NULL)
#define PAGE_BUG(page) __bug(__FILE__, __LINE__, page)
#else #else
/* these just cause an oops */
#define BUG() (*(int *)0 = 0) #define BUG() (*(int *)0 = 0)
#define PAGE_BUG(page) (*(int *)0 = 0)
#endif #endif
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) #define HAVE_ARCH_BUG
#include <asm-generic/bug.h>
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
#ifndef _CRIS_BUG_H #ifndef _CRIS_BUG_H
#define _CRIS_BUG_H #define _CRIS_BUG_H
#include <asm-generic/bug.h>
#define BUG() do { \
printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
} while (0)
#define PAGE_BUG(page) do { \
BUG(); \
} while (0)
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
#ifndef _ASM_GENERIC_BUG_H
#define _ASM_GENERIC_BUG_H
#include <linux/compiler.h>
#include <linux/config.h>
#ifndef HAVE_ARCH_BUG
#define BUG() do { \
printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
panic("BUG!"); \
} while (0)
#endif
#ifndef HAVE_ARCH_PAGE_BUG
#define PAGE_BUG(page) do { \
printk("page BUG for page at %p\n", page); \
BUG(); \
} while (0)
#endif
#ifndef HAVE_ARCH_BUG_ON
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
#endif
#ifndef HAVE_ARCH_WARN_ON
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif
#endif
#ifndef _H8300_BUG_H #ifndef _H8300_BUG_H
#define _H8300_BUG_H #define _H8300_BUG_H
#include <asm-generic/bug.h>
#define BUG() do { \
printk("%s(%d): kernel BUG!\n", __FILE__, __LINE__); \
} while (0)
#define PAGE_BUG(page) do { \
BUG(); \
} while (0)
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
...@@ -19,17 +19,7 @@ ...@@ -19,17 +19,7 @@
#define BUG() __asm__ __volatile__("ud2\n") #define BUG() __asm__ __volatile__("ud2\n")
#endif #endif
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) #define HAVE_ARCH_BUG
#include <asm-generic/bug.h>
#define PAGE_BUG(page) do { \
BUG(); \
} while (0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
...@@ -8,15 +8,8 @@ ...@@ -8,15 +8,8 @@
#endif #endif
#define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0) #define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0)
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) /* should this BUG should be made generic? */
#define HAVE_ARCH_BUG
#define PAGE_BUG(page) do { BUG(); } while (0) #include <asm-generic/bug.h>
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
...@@ -21,20 +21,7 @@ ...@@ -21,20 +21,7 @@
} while (0) } while (0)
#endif #endif
#define BUG_ON(condition) do { \ #define HAVE_ARCH_BUG
if (unlikely((condition)!=0)) \ #include <asm-generic/bug.h>
BUG(); \
} while(0)
#define PAGE_BUG(page) do { \
BUG(); \
} while (0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
#ifndef _M68KNOMMU_BUG_H #ifndef _M68KNOMMU_BUG_H
#define _M68KNOMMU_BUG_H #define _M68KNOMMU_BUG_H
#include <asm-generic/bug.h>
#define BUG() do { \
printk("%s(%d): kernel BUG!\n", __FILE__, __LINE__); \
} while (0)
#define BUG_ON(condition) do { \
if (unlikely((condition)!=0)) \
BUG(); \
} while(0)
#define PAGE_BUG(page) do { \
BUG(); \
} while (0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
...@@ -7,14 +7,8 @@ ...@@ -7,14 +7,8 @@
do { \ do { \
__asm__ __volatile__("break %0" : : "i" (BRK_BUG)); \ __asm__ __volatile__("break %0" : : "i" (BRK_BUG)); \
} while (0) } while (0)
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
#define PAGE_BUG(page) do { BUG(); } while (0)
#define WARN_ON(condition) do { \ #define HAVE_ARCH_BUG
if (unlikely((condition)!=0)) { \ #include <asm-generic/bug.h>
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
#ifndef _PARISC_BUG_H #ifndef _PARISC_BUG_H
#define _PARISC_BUG_H #define _PARISC_BUG_H
#include <asm-generic/bug.h>
/*
* Tell the user there is some problem.
*/
#define BUG() do { \
extern void dump_stack(void); \
printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
dump_stack(); \
} while (0)
#define BUG_ON(condition) do { \
if (unlikely((condition)!=0)) \
BUG(); \
} while(0)
#define PAGE_BUG(page) do { \
BUG(); \
} while (0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
...@@ -35,8 +35,6 @@ struct bug_entry { ...@@ -35,8 +35,6 @@ struct bug_entry {
} \ } \
} while (0) } while (0)
#define PAGE_BUG(page) BUG()
#define WARN_ON(x) do { \ #define WARN_ON(x) do { \
if (!__builtin_constant_p(x) || (x)) { \ if (!__builtin_constant_p(x) || (x)) { \
__asm__ __volatile__( \ __asm__ __volatile__( \
...@@ -49,4 +47,9 @@ struct bug_entry { ...@@ -49,4 +47,9 @@ struct bug_entry {
} \ } \
} while (0) } while (0)
#define HAVE_ARCH_BUG
#define HAVE_ARCH_BUG_ON
#define HAVE_ARCH_WARN_ON
#include <asm-generic/bug.h>
#endif #endif
...@@ -43,8 +43,6 @@ struct bug_entry { ...@@ -43,8 +43,6 @@ struct bug_entry {
"i" (__FUNCTION__)); \ "i" (__FUNCTION__)); \
} while (0) } while (0)
#define PAGE_BUG(page) do { BUG(); } while (0)
#define WARN_ON(x) do { \ #define WARN_ON(x) do { \
__asm__ __volatile__( \ __asm__ __volatile__( \
"1: tdnei %0,0\n" \ "1: tdnei %0,0\n" \
...@@ -56,4 +54,10 @@ struct bug_entry { ...@@ -56,4 +54,10 @@ struct bug_entry {
} while (0) } while (0)
#endif #endif
#define HAVE_ARCH_BUG
#define HAVE_ARCH_BUG_ON
#define HAVE_ARCH_WARN_ON
#include <asm-generic/bug.h>
#endif #endif
...@@ -6,22 +6,9 @@ ...@@ -6,22 +6,9 @@
#define BUG() do { \ #define BUG() do { \
printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \ printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
__asm__ __volatile__(".long 0"); \ __asm__ __volatile__(".long 0"); \
} while (0)
#define BUG_ON(condition) do { \
if (unlikely((condition)!=0)) \
BUG(); \
} while(0)
#define PAGE_BUG(page) do { \
BUG(); \
} while (0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0) } while (0)
#define HAVE_ARCH_BUG
#include <asm-generic/bug.h>
#endif #endif
...@@ -11,20 +11,7 @@ ...@@ -11,20 +11,7 @@
asm volatile("nop"); \ asm volatile("nop"); \
} while (0) } while (0)
#define BUG_ON(condition) do { \ #define HAVE_ARCH_BUG
if (unlikely((condition)!=0)) \ #include <asm-generic/bug.h>
BUG(); \
} while(0)
#define PAGE_BUG(page) do { \
BUG(); \
} while (0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
...@@ -25,20 +25,7 @@ extern void do_BUG(const char *file, int line); ...@@ -25,20 +25,7 @@ extern void do_BUG(const char *file, int line);
#define BUG() __bug_trap() #define BUG() __bug_trap()
#endif #endif
#define BUG_ON(condition) do { \ #define HAVE_ARCH_BUG
if (unlikely((condition)!=0)) \ #include <asm-generic/bug.h>
BUG(); \
} while(0)
#define PAGE_BUG(page) do { \
BUG(); \
} while (0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
/* $Id$ */
#ifndef _SPARC64_BUG_H #ifndef _SPARC64_BUG_H
#define _SPARC64_BUG_H #define _SPARC64_BUG_H
...@@ -15,20 +13,7 @@ extern void do_BUG(const char *file, int line); ...@@ -15,20 +13,7 @@ extern void do_BUG(const char *file, int line);
#define BUG() __builtin_trap() #define BUG() __builtin_trap()
#endif #endif
#define BUG_ON(condition) do { \ #define HAVE_ARCH_BUG
if (unlikely((condition)!=0)) \ #include <asm-generic/bug.h>
BUG(); \
} while(0)
#define PAGE_BUG(page) do { \
BUG(); \
} while (0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
#ifndef __UM_BUG_H #ifndef __UM_BUG_H
#define __UM_BUG_H #define __UM_BUG_H
#include <asm-generic/bug.h>
#ifndef __ASSEMBLY__
#define BUG() do { \
panic("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
} while (0)
#define BUG_ON(condition) do { \
if (unlikely((condition)!=0)) \
BUG(); \
} while(0)
#define PAGE_BUG(page) do { \
BUG(); \
} while (0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
extern int foo;
#endif
#endif #endif
...@@ -16,15 +16,7 @@ ...@@ -16,15 +16,7 @@
extern void __bug (void) __attribute__ ((noreturn)); extern void __bug (void) __attribute__ ((noreturn));
#define BUG() __bug() #define BUG() __bug()
#define PAGE_BUG(page) __bug() #define HAVE_ARCH_BUG
#include <asm-generic/bug.h>
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif /* __V850_BUG_H__ */ #endif /* __V850_BUG_H__ */
...@@ -6,27 +6,20 @@ ...@@ -6,27 +6,20 @@
/* /*
* Tell the user there is some problem. The exception handler decodes * Tell the user there is some problem. The exception handler decodes
* this frame. * this frame.
*/ */
struct bug_frame { struct bug_frame {
unsigned char ud2[2]; unsigned char ud2[2];
/* should use 32bit offset instead, but the assembler doesn't /* should use 32bit offset instead, but the assembler doesn't
like it */ like it */
char *filename; char *filename;
unsigned short line; unsigned short line;
} __attribute__((packed)); } __attribute__((packed));
#define HAVE_ARCH_BUG
#define BUG() \ #define BUG() \
asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \ asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \
"i"(__LINE__), "i" (__stringify(KBUILD_BASENAME))) "i"(__LINE__), "i" (__stringify(KBUILD_BASENAME)))
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
#define PAGE_BUG(page) BUG()
void out_of_line_bug(void); void out_of_line_bug(void);
#include <asm-generic/bug.h>
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
dump_stack(); \
} \
} while (0)
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment