1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* Additional definitions and implementation for fuzzing code */
9 #ifndef mozilla_Fuzzing_h
10 #define mozilla_Fuzzing_h
12 #ifdef FUZZING_SNAPSHOT
13 # include "mozilla/fuzzing/NyxWrapper.h"
16 # include "mozilla/fuzzing/Nyx.h"
17 # include "mozilla/ScopeExit.h"
19 # define MOZ_FUZZING_NYX_RELEASE(id) \
20 if (mozilla::fuzzing::Nyx::instance().is_enabled(id)) { \
21 mozilla::fuzzing::Nyx::instance().release(); \
24 # define MOZ_FUZZING_NYX_GUARD(id) \
25 auto nyxGuard = mozilla::MakeScopeExit([&] { \
26 if (mozilla::fuzzing::Nyx::instance().is_enabled(id)) { \
27 mozilla::fuzzing::Nyx::instance().release(); \
32 # define MOZ_FUZZING_HANDLE_CRASH_EVENT2(aType, aReason) \
34 nyx_handle_event(aType, __FILE__, __LINE__, aReason); \
37 # define MOZ_FUZZING_HANDLE_CRASH_EVENT4(aType, aFilename, aLine, aReason) \
39 nyx_handle_event(aType, aFilename, aLine, aReason); \
43 # define MOZ_FUZZING_NYX_RELEASE(id)
44 # define MOZ_FUZZING_NYX_GUARD(id)
45 # define MOZ_FUZZING_HANDLE_CRASH_EVENT2(aType, aReason) \
48 # define MOZ_FUZZING_HANDLE_CRASH_EVENT4(aType, aFilename, aLine, aReason) \
53 #endif /* mozilla_Fuzzing_h */