diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-21 22:40:55 +0100 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-21 22:40:55 +0100 |
| commit | 5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda (patch) | |
| tree | 1acdfa5220cd13b7be43a2a01368e80d306473ca /examples/redis-unstable/src/redisassert.h | |
| parent | c7ab12bba64d9c20ccd79b132dac475f7bc3923e (diff) | |
| download | crep-5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda.tar.gz | |
Add Redis source code for testing
Diffstat (limited to 'examples/redis-unstable/src/redisassert.h')
| -rw-r--r-- | examples/redis-unstable/src/redisassert.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/redis-unstable/src/redisassert.h b/examples/redis-unstable/src/redisassert.h new file mode 100644 index 0000000..4de8d5c --- /dev/null +++ b/examples/redis-unstable/src/redisassert.h @@ -0,0 +1,35 @@ +/* redisassert.h -- Drop in replacements assert.h that prints the stack trace + * in the Redis logs. + * + * This file should be included instead of "assert.h" inside libraries used by + * Redis that are using assertions, so instead of Redis disappearing with + * SIGABORT, we get the details and stack trace inside the log file. + * + * ---------------------------------------------------------------------------- + * + * Copyright (c) 2006-Present, Redis Ltd. + * All rights reserved. + * + * Licensed under your choice of (a) the Redis Source Available License 2.0 + * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the + * GNU Affero General Public License v3 (AGPLv3). + */ + +#ifndef __REDIS_ASSERT_H__ +#define __REDIS_ASSERT_H__ + +#include "config.h" + +#define assert(_e) (likely((_e))?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),redis_unreachable())) +#define panic(...) _serverPanic(__FILE__,__LINE__,__VA_ARGS__),redis_unreachable() + +void _serverAssert(const char *estr, const char *file, int line); +void _serverPanic(const char *file, int line, const char *msg, ...); + +#ifdef DEBUG_ASSERTIONS +#define debugAssert(_e) assert(_e) +#else +#define debugAssert(_e) ((void)0) +#endif + +#endif |
