Skip to content

Commit

Permalink
https://patchwork.ozlabs.org/patch/995203/#2045049
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
pevik committed Dec 5, 2018
1 parent c3b6763 commit 643bcee
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
19 changes: 19 additions & 0 deletions include/tst_common.h
Expand Up @@ -65,4 +65,23 @@
ERET; \
})

#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)

#if GCC_VERSION >= 40300
# define BUILD_BUG_ON_MSG(cond, msg) \
compiletime_assert(!(cond), msg, tst_brk_detect_)
# define compiletime_assert(condition, msg, funcname_) \
do { \
void funcname_(void) __attribute__((error(msg))); \
if (!(condition)) \
funcname_(); \
} while (0)
#else
# define BUILD_BUG_ON_MSG(cond, msg) BUILD_BUG_ON(cond)
# define BUILD_BUG_ON(cond) \
do { ((void)sizeof(char[1 - 2 * !!(cond)])); } while (0)
#endif

#endif /* TST_COMMON_H__ */
6 changes: 5 additions & 1 deletion include/tst_test.h
Expand Up @@ -70,7 +70,11 @@ void tst_brk_(const char *file, const int lineno, int ttype,
__attribute__ ((format (printf, 4, 5)));

#define tst_brk(ttype, arg_fmt, ...) \
tst_brk_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__)
({ \
BUILD_BUG_ON_MSG(!((ttype) & (TBROK | TCONF | TFAIL)), \
"tst_brk(): invalid type, please use TBROK/TCONF/TFAIL"); \
tst_brk_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__);\
})

/* flush stderr and stdout */
void tst_flush(void);
Expand Down

0 comments on commit 643bcee

Please sign in to comment.