Skip to content

Commit

Permalink
Don't include config.h from serverassert.h
Browse files Browse the repository at this point in the history
Signed-off-by: Viktor Söderqvist <[email protected]>
  • Loading branch information
zuiderkwast committed Apr 30, 2024
1 parent b0d5a0f commit d60c276
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/serverassert.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,23 @@
#ifndef VALKEY_ASSERT_H
#define VALKEY_ASSERT_H

#include "config.h"
/* This is a drop-in replacement of assert. We use it even in code copied from
* other sources. To make these files usable outside of Valkey, it should be
* enough to replace this include with <assert.h>. Therefore, this file shoudn't
* have any dependencies to any other valkey code. */

#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
#define valkey_unreachable __builtin_unreachable
#else
#include <stdlib.h>
#define valkey_unreachable abort
#endif

#if __GNUC__ >= 3
#define likely(x) __builtin_expect(!!(x), 1)
#else
#define likely(x) (x)
#endif

#define assert(_e) (likely((_e))?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),valkey_unreachable()))
#define panic(...) _serverPanic(__FILE__,__LINE__,__VA_ARGS__),valkey_unreachable()
Expand Down

0 comments on commit d60c276

Please sign in to comment.