summaryrefslogtreecommitdiff
path: root/libc/fuzzing/math/nextafter_differential_fuzz.cpp
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@google.com>2021-01-03 22:33:48 -0800
committerSiva Chandra Reddy <sivachandra@google.com>2021-01-05 22:32:39 -0800
commit7f7b0dc4e15fac5f91f8f6dcc7f91c9025f41ae0 (patch)
treed4b5b63690e551bb5f8e81e56270aa5b43f3c3d7 /libc/fuzzing/math/nextafter_differential_fuzz.cpp
parent993d8ac5cb935b78fb136c25a7e4bae18852f429 (diff)
[libc] Add implementations of nextafter[f|l] functions.
A differential fuzzer for these functions has also been added. Along the way, a small correction has been done to the normal/subnormal limits of x86 long double values. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D94109
Diffstat (limited to 'libc/fuzzing/math/nextafter_differential_fuzz.cpp')
-rw-r--r--libc/fuzzing/math/nextafter_differential_fuzz.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/libc/fuzzing/math/nextafter_differential_fuzz.cpp b/libc/fuzzing/math/nextafter_differential_fuzz.cpp
new file mode 100644
index 000000000000..f4a7891df2aa
--- /dev/null
+++ b/libc/fuzzing/math/nextafter_differential_fuzz.cpp
@@ -0,0 +1,26 @@
+//===-- nextafter_differential_fuzz.cpp
+//---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// Differential fuzz test for llvm-libc nextafter implementation.
+///
+//===----------------------------------------------------------------------===//
+
+#include "fuzzing/math/TwoInputSingleOutputDiff.h"
+
+#include "src/math/nextafter.h"
+#include "src/math/nextafterf.h"
+#include "src/math/nextafterl.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ TwoInputSingleOutputDiff<float, float>(&__llvm_libc::nextafterf,
+ &::nextafterf, data, size);
+ TwoInputSingleOutputDiff<double, double>(&__llvm_libc::nextafter,
+ &::nextafter, data, size);
+ return 0;
+}