mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
include: move BUG_*() macros to separate header
Yet another step of uncluttering includes: move out the BUG_* macros into a separate header, which then is included as-needed. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Peter Hutterer
parent
a8bb924af1
commit
442aec2219
33
include/bug.h
Normal file
33
include/bug.h
Normal file
@@ -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 */
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user