Makefile: add 'build=' option. bug.h: numeric {BUG,WARN}_ON

This commit is contained in:
2024-07-10 07:34:05 +02:00
parent 553dc6bd07
commit a48ebf9099
3 changed files with 93 additions and 22 deletions

View File

@@ -32,10 +32,17 @@
#include <stdbool.h>
#include <stdarg.h>
#ifndef BUG_ON
#define BUG_ON 0
#endif
#ifndef WARN_ON
#define WARN_ON 0
#endif
#include "likely.h"
#ifdef BUG_ON
#define bug_on(expr) do { \
#if (BUG_ON + 0 == 1)
#define bug_on(expr) do { \
if (unlikely(expr)) { \
fprintf(stderr, \
"** BUG IN %s[%s:%d]: assertion \"" #expr "\" failed.\n", \
@@ -47,7 +54,7 @@
#define bug_on(expr)
#endif
#ifdef WARN_ON
#if (WARN_ON + 0 == 1)
#define warn_on(expr) ({ \
int _ret = !!(expr); \
if (unlikely(_ret)) \