| 1 |
#ifndef CONTRIB_FUZZ_FUZZUTIL_H |
| 2 |
#define CONTRIB_FUZZ_FUZZUTIL_H |
| 3 |
#include <iostream> |
| 4 |
#include <memory> |
| 5 |
#include <stdint.h> |
| 6 |
|
| 7 |
/* Try and use std::optional, but failing that assume we'll have a |
| 8 |
* workable https://abseil.io/ install on the include path to get |
| 9 |
* their backport of std::optional. */ |
| 10 |
#ifdef __has_include |
| 11 |
#if __has_include(<optional>) && __cplusplus >= 201703L |
| 12 |
#include <optional> |
| 13 |
#define CONTRIB_FUZZ_HAVE_STD_OPTIONAL |
| 14 |
#endif |
| 15 |
#endif |
| 16 |
#ifdef CONTRIB_FUZZ_HAVE_STD_OPTIONAL |
| 17 |
namespace contrib |
| 18 |
{ |
| 19 |
using std::nullopt; |
| 20 |
using std::optional; |
| 21 |
} /* namespace contrib */ |
| 22 |
#else |
| 23 |
#include "third_party/absl/types/optional.h" |
| 24 |
namespace contrib |
| 25 |
{ |
| 26 |
using absl::nullopt; |
| 27 |
using absl::optional; |
| 28 |
} /* namespace contrib */ |
| 29 |
#endif |
| 30 |
|
| 31 |
/* set DEBUG to 1 for a few debugging prints, or 2 for a lot */ |
| 32 |
#define DEBUG 0 |
| 33 |
#define LOG(level) \ |
| 34 |
if (level <= DEBUG) \ |
| 35 |
std::cout |
| 36 |
|
| 37 |
#endif /* CONTRIB_FUZZ_FUZZUTIL_H */ |