2 * Copyright (c) 2016-present, Facebook, Inc.
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
11 * Helper functions for fuzzing.
14 #ifndef FUZZ_HELPERS_H
15 #define FUZZ_HELPERS_H
29 #define MIN(a, b) ((a) < (b) ? (a) : (b))
30 #define MAX(a, b) ((a) > (b) ? (a) : (b))
32 #define FUZZ_QUOTE_IMPL(str) #str
33 #define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
36 * Asserts for fuzzing that are always enabled.
38 #define FUZZ_ASSERT_MSG(cond, msg) \
40 : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
41 __LINE__, FUZZ_QUOTE(cond), (msg)), \
43 #define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "");
44 #define FUZZ_ZASSERT(code) \
45 FUZZ_ASSERT_MSG(!ZSTD_isError(code), ZSTD_getErrorName(code))
48 #define FUZZ_STATIC static __inline __attribute__((unused))
49 #elif defined(__cplusplus) || \
50 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
51 #define FUZZ_STATIC static inline
52 #elif defined(_MSC_VER)
53 #define FUZZ_STATIC static __inline
55 #define FUZZ_STATIC static