mwrap.git  about / heads / tags
LD_PRELOAD malloc wrapper + line stats for Ruby
blob f4f4ac5cbc7d284ff34815d2b347c7b2125f2500 683 bytes (raw)
$ git show HEAD:ext/mwrap/check.h	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
#ifndef CHECK_H
#define CHECK_H
#include "gcc.h"
#include <stdlib.h>
#include <assert.h>
/*
 * standard assert may malloc, but NDEBUG behavior is standardized,
 * however Perl headers add some weirdness if we undef NDEBUG, so
 * keep NDEBUG defined and use MWRAP_NO_DEBUG
 */
#if defined(NDEBUG) && defined(MWRAP_NO_DEBUG)
#  define mwrap_assert(expr)
#  define CHECK(type, expect, expr) (void)(expr)
#else
#  define mwrap_assert(x) do { if (caa_unlikely(!(x))) abort(); } while (0)
#  define CHECK(type, expect, expr) do { \
	type checkvar = (expr); \
	mwrap_assert(checkvar==(expect)&& "BUG" && __FILE__ && __LINE__); \
	(void)checkvar; \
	} while (0)
#endif

#endif /* CHECK_H */

git clone https://80x24.org/mwrap.git