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>(&__llvm_libc::ceilf
, &::ceilf
, data
, size
);
74 SingleInputSingleOutputDiff
<double>(&__llvm_libc::ceil
, &::ceil
, data
, size
);
75 SingleInputSingleOutputDiff
<long double>(&__llvm_libc::ceill
, &::ceill
, data
,
78 SingleInputSingleOutputDiff
<float>(&__llvm_libc::floorf
, &::floorf
, data
,
80 SingleInputSingleOutputDiff
<double>(&__llvm_libc::floor
, &::floor
, data
,
82 SingleInputSingleOutputDiff
<long double>(&__llvm_libc::floorl
, &::floorl
,
85 SingleInputSingleOutputDiff
<float>(&__llvm_libc::roundf
, &::roundf
, data
,
87 SingleInputSingleOutputDiff
<double>(&__llvm_libc::round
, &::round
, data
,
89 SingleInputSingleOutputDiff
<long double>(&__llvm_libc::roundl
, &::roundl
,
92 SingleInputSingleOutputDiff
<float>(&__llvm_libc::truncf
, &::truncf
, data
,
94 SingleInputSingleOutputDiff
<double>(&__llvm_libc::trunc
, &::trunc
, data
,
96 SingleInputSingleOutputDiff
<long double>(&__llvm_libc::truncl
, &::truncl
,
99 SingleInputSingleOutputDiff
<float>(&__llvm_libc::logbf
, &::logbf
, data
, size
);
100 SingleInputSingleOutputDiff
<double>(&__llvm_libc::logb
, &::logb
, data
, size
);
101 SingleInputSingleOutputDiff
<long double>(&__llvm_libc::logbl
, &::logbl
, data
,
104 TwoInputSingleOutputDiff
<float, float>(&__llvm_libc::hypotf
, &::hypotf
, data
,
107 TwoInputSingleOutputDiff
<float, float>(&__llvm_libc::remainderf
,
108 &::remainderf
, data
, size
);
109 TwoInputSingleOutputDiff
<double, double>(&__llvm_libc::remainder
,
110 &::remainder
, data
, size
);
111 TwoInputSingleOutputDiff
<long double, long double>(&__llvm_libc::remainderl
,
112 &::remainderl
, data
, size
);
114 TwoInputSingleOutputDiff
<float, float>(&__llvm_libc::fdimf
, &::fdimf
, data
,
116 TwoInputSingleOutputDiff
<double, double>(&__llvm_libc::fdim
, &::fdim
, data
,
118 TwoInputSingleOutputDiff
<long double, long double>(&__llvm_libc::fdiml
,
119 &::fdiml
, data
, size
);
121 SingleInputSingleOutputDiff
<float>(&__llvm_libc::sqrtf
, &::sqrtf
, data
, size
);
122 SingleInputSingleOutputDiff
<double>(&__llvm_libc::sqrt
, &::sqrt
, data
, size
);
123 SingleInputSingleOutputDiff
<long double>(&__llvm_libc::sqrtl
, &::sqrtl
, data
,
126 SingleInputSingleOutputWithSideEffectDiff
<float, int>(&__llvm_libc::frexpf
,
127 &::frexpf
, data
, size
);
128 SingleInputSingleOutputWithSideEffectDiff
<double, int>(&__llvm_libc::frexp
,
129 &::frexp
, data
, size
);
130 SingleInputSingleOutputWithSideEffectDiff
<long double, int>(
131 &__llvm_libc::frexpl
, &::frexpl
, data
, size
);
133 SingleInputSingleOutputWithSideEffectDiff
<float, float>(&__llvm_libc::modff
,
134 &::modff
, data
, size
);
135 SingleInputSingleOutputWithSideEffectDiff
<double, double>(
136 &__llvm_libc::modf
, &::modf
, data
, size
);
137 SingleInputSingleOutputWithSideEffectDiff
<long double, long double>(
138 &__llvm_libc::modfl
, &::modfl
, data
, size
);
140 TwoInputSingleOutputDiff
<float, int>(&__llvm_libc::ldexpf
, &::ldexpf
, data
,
142 TwoInputSingleOutputDiff
<double, int>(&__llvm_libc::ldexp
, &::ldexp
, data
,
144 TwoInputSingleOutputDiff
<long double, int>(&__llvm_libc::ldexpl
, &::ldexpl
,
147 RemQuoDiff
<float>(&__llvm_libc::remquof
, &::remquof
, data
, size
);
148 RemQuoDiff
<double>(&__llvm_libc::remquo
, &::remquo
, data
, size
);
149 RemQuoDiff
<long double>(&__llvm_libc::remquol
, &::remquol
, data
, size
);