diff --git a/Xext/sync.c b/Xext/sync.c index fd2ceb042..37436b829 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -60,6 +60,7 @@ PERFORMANCE OF THIS SOFTWARE. #include #include "scrnintstr.h" #include "os.h" +#include "bug.h" #include "extnsionst.h" #include "dixstruct.h" #include "pixmapstr.h" diff --git a/Xi/exevents.c b/Xi/exevents.c index e16171468..cff5a2ae5 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -89,6 +89,8 @@ SOFTWARE. #include #include #include + +#include "bug.h" #include "windowstr.h" #include "miscstruct.h" #include "region.h" diff --git a/Xi/xibarriers.c b/Xi/xibarriers.c index 1926762ad..7261964cb 100644 --- a/Xi/xibarriers.c +++ b/Xi/xibarriers.c @@ -45,6 +45,7 @@ #include #endif +#include "bug.h" #include "xibarriers.h" #include "scrnintstr.h" #include "cursorstr.h" diff --git a/dix/cursor.c b/dix/cursor.c index a9ad34467..4405e8d55 100644 --- a/dix/cursor.c +++ b/dix/cursor.c @@ -50,6 +50,8 @@ SOFTWARE. #include #include + +#include "bug.h" #include "servermd.h" #include "scrnintstr.h" #include "dixstruct.h" diff --git a/dix/devices.c b/dix/devices.c index 84a6406d1..3b9791361 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -53,6 +53,7 @@ SOFTWARE. #include "resource.h" #include #include +#include "bug.h" #include "windowstr.h" #include "inputstr.h" #include "scrnintstr.h" diff --git a/dix/enterleave.c b/dix/enterleave.c index c1e6ac600..223182aac 100644 --- a/dix/enterleave.c +++ b/dix/enterleave.c @@ -32,6 +32,8 @@ #include #include #include + +#include "bug.h" #include "inputstr.h" #include "windowstr.h" #include "scrnintstr.h" diff --git a/dix/events.c b/dix/events.c index 2a5c2683a..3e504e1c3 100644 --- a/dix/events.c +++ b/dix/events.c @@ -106,6 +106,8 @@ Equipment Corporation. #endif #include + +#include "bug.h" #include "misc.h" #include "resource.h" #include diff --git a/dix/gestures.c b/dix/gestures.c index 43672ace5..d95909ea6 100644 --- a/dix/gestures.c +++ b/dix/gestures.c @@ -38,6 +38,7 @@ #include "eventconvert.h" #include "windowstr.h" #include "mi.h" +#include "bug.h" #define GESTURE_HISTORY_SIZE 100 diff --git a/dix/getevents.c b/dix/getevents.c index c39ef3371..40b303a0b 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -37,6 +37,7 @@ #include #include +#include "bug.h" #include "misc.h" #include "resource.h" #include "inputstr.h" diff --git a/dix/grabs.c b/dix/grabs.c index 53ba1d6b9..ed3721363 100644 --- a/dix/grabs.c +++ b/dix/grabs.c @@ -62,6 +62,7 @@ SOFTWARE. #include "exglobals.h" #include "inpututils.h" #include "client.h" +#include "bug.h" #define BITMASK(i) (((Mask)1) << ((i) & 31)) #define MASKIDX(i) ((i) >> 5) diff --git a/dix/inpututils.c b/dix/inpututils.c index 9026f651b..2c77ecf04 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -27,6 +27,7 @@ #include "dix-config.h" #endif +#include "bug.h" #include "exevents.h" #include "exglobals.h" #include "misc.h" diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index 632971ed9..ded8ca13b 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -31,6 +31,7 @@ #include #include #include +#include "bug.h" #include diff --git a/dix/touch.c b/dix/touch.c index d0d286f80..235596e99 100644 --- a/dix/touch.c +++ b/dix/touch.c @@ -39,6 +39,7 @@ #include "eventconvert.h" #include "windowstr.h" #include "mi.h" +#include "bug.h" #define TOUCH_HISTORY_SIZE 100 diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c index 078e7c2d3..f3ce3d291 100644 --- a/hw/xwayland/xwayland-input.c +++ b/hw/xwayland/xwayland-input.c @@ -29,6 +29,7 @@ #include #include +#include "bug.h" #include #include #include diff --git a/include/bug.h b/include/bug.h new file mode 100644 index 000000000..5988dd576 --- /dev/null +++ b/include/bug.h @@ -0,0 +1,33 @@ +#ifndef _XSERVER_OS_BUG_H +#define _XSERVER_OS_BUG_H + +#include "os.h" + +/* Don't use this directly, use BUG_WARN or BUG_WARN_MSG instead */ +#define __BUG_WARN_MSG(cond, with_msg, ...) \ + do { if (cond) { \ + ErrorFSigSafe("BUG: triggered 'if (" #cond ")'\n"); \ + ErrorFSigSafe("BUG: %s:%u in %s()\n", \ + __FILE__, __LINE__, __func__); \ + if (with_msg) ErrorFSigSafe(__VA_ARGS__); \ + xorg_backtrace(); \ + } } while(0) + +#define BUG_WARN_MSG(cond, ...) \ + __BUG_WARN_MSG(cond, 1, __VA_ARGS__) + +#define BUG_WARN(cond) __BUG_WARN_MSG(cond, 0, NULL) + +#define BUG_RETURN(cond) \ + do { if (cond) { __BUG_WARN_MSG(cond, 0, NULL); return; } } while(0) + +#define BUG_RETURN_MSG(cond, ...) \ + do { if (cond) { __BUG_WARN_MSG(cond, 1, __VA_ARGS__); return; } } while(0) + +#define BUG_RETURN_VAL(cond, val) \ + do { if (cond) { __BUG_WARN_MSG(cond, 0, NULL); return (val); } } while(0) + +#define BUG_RETURN_VAL_MSG(cond, val, ...) \ + do { if (cond) { __BUG_WARN_MSG(cond, 1, __VA_ARGS__); return (val); } } while(0) + +#endif /* _XSERVER_OS_BUG_H */ diff --git a/include/misc.h b/include/misc.h index 4b632098b..50efaba3c 100644 --- a/include/misc.h +++ b/include/misc.h @@ -416,31 +416,4 @@ typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */ extern _X_EXPORT unsigned long globalSerialNumber; extern _X_EXPORT unsigned long serverGeneration; -/* Don't use this directly, use BUG_WARN or BUG_WARN_MSG instead */ -#define __BUG_WARN_MSG(cond, with_msg, ...) \ - do { if (cond) { \ - ErrorFSigSafe("BUG: triggered 'if (" #cond ")'\n"); \ - ErrorFSigSafe("BUG: %s:%u in %s()\n", \ - __FILE__, __LINE__, __func__); \ - if (with_msg) ErrorFSigSafe(__VA_ARGS__); \ - xorg_backtrace(); \ - } } while(0) - -#define BUG_WARN_MSG(cond, ...) \ - __BUG_WARN_MSG(cond, 1, __VA_ARGS__) - -#define BUG_WARN(cond) __BUG_WARN_MSG(cond, 0, NULL) - -#define BUG_RETURN(cond) \ - do { if (cond) { __BUG_WARN_MSG(cond, 0, NULL); return; } } while(0) - -#define BUG_RETURN_MSG(cond, ...) \ - do { if (cond) { __BUG_WARN_MSG(cond, 1, __VA_ARGS__); return; } } while(0) - -#define BUG_RETURN_VAL(cond, val) \ - do { if (cond) { __BUG_WARN_MSG(cond, 0, NULL); return (val); } } while(0) - -#define BUG_RETURN_VAL_MSG(cond, val, ...) \ - do { if (cond) { __BUG_WARN_MSG(cond, 1, __VA_ARGS__); return (val); } } while(0) - #endif /* MISC_H */ diff --git a/mi/mieq.c b/mi/mieq.c index c98d46862..e15d9edab 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -39,6 +39,8 @@ in this Software without prior written authorization from The Open Group. #include #include #include + +#include "bug.h" #include "misc.h" #include "windowstr.h" #include "pixmapstr.h" diff --git a/miext/shadow/c2p_core.h b/miext/shadow/c2p_core.h index 5b9ea066c..c1f9050a3 100644 --- a/miext/shadow/c2p_core.h +++ b/miext/shadow/c2p_core.h @@ -32,6 +32,8 @@ * Basic transpose step */ +#include "bug.h" + static inline void _transp(CARD32 d[], unsigned int i1, unsigned int i2, unsigned int shift, CARD32 mask) { diff --git a/os/io.c b/os/io.c index 841a0ee40..0d3c3119c 100644 --- a/os/io.c +++ b/os/io.c @@ -72,6 +72,8 @@ SOFTWARE. #endif #include #include + +#include "bug.h" #include "os.h" #include "osdep.h" #include "opaque.h" diff --git a/os/log.c b/os/log.c index e15823046..dff6d68de 100644 --- a/os/log.c +++ b/os/log.c @@ -89,6 +89,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #include "input.h" #include "opaque.h" +#include "bug.h" #ifdef WIN32 #include diff --git a/os/utils.c b/os/utils.c index 1620442c1..98f532d89 100644 --- a/os/utils.c +++ b/os/utils.c @@ -82,6 +82,7 @@ __stdcall unsigned long GetTickCount(void); #include "dixfont.h" #include #include "osdep.h" +#include "bug.h" #include "extension.h" #include #ifndef WIN32 diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index be66d2af9..bc6ef4e56 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -49,6 +49,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "xkbgeom.h" #include #include "xkbfile.h" +#include "bug.h" #define CREATE_ATOM(s) MakeAtom(s,sizeof(s)-1,1)