From: Dmitry Volyntsev Date: Thu, 27 Aug 2020 14:43:23 +0000 (+0000) Subject: Introduced njs_assert() macro. X-Git-Tag: 0.4.4~22 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=5ef77c04aa6f92cbb88512b77981a37d3c07ed96;p=njs.git Introduced njs_assert() macro. --- diff --git a/src/njs_assert.h b/src/njs_assert.h new file mode 100644 index 00000000..55583caf --- /dev/null +++ b/src/njs_assert.h @@ -0,0 +1,27 @@ + +/* + * Copyright (C) Dmitry Volyntsev + * Copyright (C) NGINX, Inc. + */ + +#ifndef _NJS_ASSERT_H_INCLUDED_ +#define _NJS_ASSERT_H_INCLUDED_ + +#if (NJS_DEBUG) + +#define njs_assert(condition) \ + do { \ + if (!(condition)) { \ + njs_stderror("Assertion \"%s\" failed at %s:%d\n", #condition, \ + __FILE__, __LINE__); \ + abort(); \ + } \ + } while (0) + +#else + +#define njs_assert(condition) (void) (condition) + +#endif + +#endif /* _NJS_ASSERT_H_INCLUDED_ */ diff --git a/src/njs_main.h b/src/njs_main.h index f59791d4..9884d2b1 100644 --- a/src/njs_main.h +++ b/src/njs_main.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include