1 //===-- ldexp_differential_fuzz.cpp ---------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 /// Differential fuzz test for llvm-libc ldexp implementation.
11 //===----------------------------------------------------------------------===//
13 #include "fuzzing/math/RemQuoDiff.h"
14 #include "fuzzing/math/SingleInputSingleOutputDiff.h"
15 #include "fuzzing/math/TwoInputSingleOutputDiff.h"
17 #include "src/math/ceil.h"
18 #include "src/math/ceilf.h"
19 #include "src/math/ceill.h"
21 #include "src/math/fdim.h"
22 #include "src/math/fdimf.h"
23 #include "src/math/fdiml.h"
25 #include "src/math/floor.h"
26 #include "src/math/floorf.h"
27 #include "src/math/floorl.h"
29 #include "src/math/frexp.h"
30 #include "src/math/frexpf.h"
31 #include "src/math/frexpl.h"
33 #include "src/math/hypotf.h"
35 #include "src/math/ldexp.h"
36 #include "src/math/ldexpf.h"
37 #include "src/math/ldexpl.h"
39 #include "src/math/logb.h"
40 #include "src/math/logbf.h"
41 #include "src/math/logbl.h"
43 #include "src/math/modf.h"
44 #include "src/math/modff.h"
45 #include "src/math/modfl.h"
47 #include "src/math/remainder.h"
48 #include "src/math/remainderf.h"
49 #include "src/math/remainderl.h"
51 #include "src/math/remquo.h"
52 #include "src/math/remquof.h"
53 #include "src/math/remquol.h"
55 #include "src/math/round.h"
56 #include "src/math/roundf.h"
57 #include "src/math/roundl.h"
59 #include "src/math/sqrt.h"
60 #include "src/math/sqrtf.h"
61 #include "src/math/sqrtl.h"
63 #include "src/math/trunc.h"
64 #include "src/math/truncf.h"
65 #include "src/math/truncl.h"
71 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data
, size_t size
) {
73 SingleInputSingleOutputDiff
<float>(&LIBC_NAMESPACE::ceilf
, &::ceilf
, data
,
75 SingleInputSingleOutputDiff
<double>(&LIBC_NAMESPACE::ceil
, &::ceil
, data
,
77 SingleInputSingleOutputDiff
<long double>(&LIBC_NAMESPACE::ceill
, &::ceill
,
80 SingleInputSingleOutputDiff
<float>(&LIBC_NAMESPACE::floorf
, &::floorf
, data
,
82 SingleInputSingleOutputDiff
<double>(&LIBC_NAMESPACE::floor
, &::floor
, data
,
84 SingleInputSingleOutputDiff
<long double>(&LIBC_NAMESPACE::floorl
, &::floorl
,
87 SingleInputSingleOutputDiff
<float>(&LIBC_NAMESPACE::roundf
, &::roundf
, data
,
89 SingleInputSingleOutputDiff
<double>(&LIBC_NAMESPACE::round
, &::round
, data
,
91 SingleInputSingleOutputDiff
<long double>(&LIBC_NAMESPACE::roundl
, &::roundl
,
94 SingleInputSingleOutputDiff
<float>(&LIBC_NAMESPACE::truncf
, &::truncf
, data
,
96 SingleInputSingleOutputDiff
<double>(&LIBC_NAMESPACE::trunc
, &::trunc
, data
,
98 SingleInputSingleOutputDiff
<long double>(&LIBC_NAMESPACE::truncl
, &::truncl
,
101 SingleInputSingleOutputDiff
<float>(&LIBC_NAMESPACE::logbf
, &::logbf
, data
,
103 SingleInputSingleOutputDiff
<double>(&LIBC_NAMESPACE::logb
, &::logb
, data
,
105 SingleInputSingleOutputDiff
<long double>(&LIBC_NAMESPACE::logbl
, &::logbl
,
108 TwoInputSingleOutputDiff
<float, float>(&LIBC_NAMESPACE::hypotf
, &::hypotf
,
111 TwoInputSingleOutputDiff
<float, float>(&LIBC_NAMESPACE::remainderf
,
112 &::remainderf
, data
, size
);
113 TwoInputSingleOutputDiff
<double, double>(&LIBC_NAMESPACE::remainder
,
114 &::remainder
, data
, size
);
115 TwoInputSingleOutputDiff
<long double, long double>(
116 &LIBC_NAMESPACE::remainderl
, &::remainderl
, data
, size
);
118 TwoInputSingleOutputDiff
<float, float>(&LIBC_NAMESPACE::fdimf
, &::fdimf
, data
,
120 TwoInputSingleOutputDiff
<double, double>(&LIBC_NAMESPACE::fdim
, &::fdim
, data
,
122 TwoInputSingleOutputDiff
<long double, long double>(&LIBC_NAMESPACE::fdiml
,
123 &::fdiml
, data
, size
);
125 SingleInputSingleOutputDiff
<float>(&LIBC_NAMESPACE::sqrtf
, &::sqrtf
, data
,
127 SingleInputSingleOutputDiff
<double>(&LIBC_NAMESPACE::sqrt
, &::sqrt
, data
,
129 SingleInputSingleOutputDiff
<long double>(&LIBC_NAMESPACE::sqrtl
, &::sqrtl
,
132 SingleInputSingleOutputWithSideEffectDiff
<float, int>(&LIBC_NAMESPACE::frexpf
,
133 &::frexpf
, data
, size
);
134 SingleInputSingleOutputWithSideEffectDiff
<double, int>(&LIBC_NAMESPACE::frexp
,
135 &::frexp
, data
, size
);
136 SingleInputSingleOutputWithSideEffectDiff
<long double, int>(
137 &LIBC_NAMESPACE::frexpl
, &::frexpl
, data
, size
);
139 SingleInputSingleOutputWithSideEffectDiff
<float, float>(
140 &LIBC_NAMESPACE::modff
, &::modff
, data
, size
);
141 SingleInputSingleOutputWithSideEffectDiff
<double, double>(
142 &LIBC_NAMESPACE::modf
, &::modf
, data
, size
);
143 SingleInputSingleOutputWithSideEffectDiff
<long double, long double>(
144 &LIBC_NAMESPACE::modfl
, &::modfl
, data
, size
);
146 TwoInputSingleOutputDiff
<float, int>(&LIBC_NAMESPACE::ldexpf
, &::ldexpf
, data
,
148 TwoInputSingleOutputDiff
<double, int>(&LIBC_NAMESPACE::ldexp
, &::ldexp
, data
,
150 TwoInputSingleOutputDiff
<long double, int>(&LIBC_NAMESPACE::ldexpl
, &::ldexpl
,
153 RemQuoDiff
<float>(&LIBC_NAMESPACE::remquof
, &::remquof
, data
, size
);
154 RemQuoDiff
<double>(&LIBC_NAMESPACE::remquo
, &::remquo
, data
, size
);
155 RemQuoDiff
<long double>(&LIBC_NAMESPACE::remquol
, &::remquol
, data
, size
);