Welcome! Log In Create A New Profile

Advanced

[njs] Introduced njs_assert() macro.

Dmitry Volyntsev
August 27, 2020 10:46AM
details: https://hg.nginx.org/njs/rev/fa50cc5b1128
branches:
changeset: 1509:fa50cc5b1128
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Thu Aug 27 14:43:23 2020 +0000
description:
Introduced njs_assert() macro.

diffstat:

src/njs_assert.h | 27 +++++++++++++++++++++++++++
src/njs_main.h | 1 +
2 files changed, 28 insertions(+), 0 deletions(-)

diffs (42 lines):

diff -r 6f561e3d947e -r fa50cc5b1128 src/njs_assert.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/njs_assert.h Thu Aug 27 14:43:23 2020 +0000
@@ -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 -r 6f561e3d947e -r fa50cc5b1128 src/njs_main.h
--- a/src/njs_main.h Thu Aug 27 14:43:22 2020 +0000
+++ b/src/njs_main.h Thu Aug 27 14:43:23 2020 +0000
@@ -36,6 +36,7 @@
#include <njs_chb.h>
#include <njs_utils.h>
#include <njs_sprintf.h>
+#include <njs_assert.h>

#include <njs_pcre.h>
#include <njs_regex.h>
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Introduced njs_assert() macro.

Dmitry Volyntsev 336 August 27, 2020 10:46AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 183
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready