1 | //===-- ldexp_differential_fuzz.cpp ---------------------------------------===// |
2 | // |
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 |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | /// |
9 | /// Differential fuzz test for llvm-libc ldexp implementation. |
10 | /// |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #include "fuzzing/math/RemQuoDiff.h" |
14 | #include "fuzzing/math/SingleInputSingleOutputDiff.h" |
15 | #include "fuzzing/math/TwoInputSingleOutputDiff.h" |
16 | |
17 | #include "src/math/ceil.h" |
18 | #include "src/math/ceilf.h" |
19 | #include "src/math/ceill.h" |
20 | |
21 | #include "src/math/fdim.h" |
22 | #include "src/math/fdimf.h" |
23 | #include "src/math/fdiml.h" |
24 | |
25 | #include "src/math/floor.h" |
26 | #include "src/math/floorf.h" |
27 | #include "src/math/floorl.h" |
28 | |
29 | #include "src/math/frexp.h" |
30 | #include "src/math/frexpf.h" |
31 | #include "src/math/frexpl.h" |
32 | |
33 | #include "src/math/hypotf.h" |
34 | |
35 | #include "src/math/ldexp.h" |
36 | #include "src/math/ldexpf.h" |
37 | #include "src/math/ldexpl.h" |
38 | |
39 | #include "src/math/logb.h" |
40 | #include "src/math/logbf.h" |
41 | #include "src/math/logbl.h" |
42 | |
43 | #include "src/math/modf.h" |
44 | #include "src/math/modff.h" |
45 | #include "src/math/modfl.h" |
46 | |
47 | #include "src/math/remainder.h" |
48 | #include "src/math/remainderf.h" |
49 | #include "src/math/remainderl.h" |
50 | |
51 | #include "src/math/remquo.h" |
52 | #include "src/math/remquof.h" |
53 | #include "src/math/remquol.h" |
54 | |
55 | #include "src/math/round.h" |
56 | #include "src/math/roundf.h" |
57 | #include "src/math/roundl.h" |
58 | |
59 | #include "src/math/sqrt.h" |
60 | #include "src/math/sqrtf.h" |
61 | #include "src/math/sqrtl.h" |
62 | |
63 | #include "src/math/trunc.h" |
64 | #include "src/math/truncf.h" |
65 | #include "src/math/truncl.h" |
66 | |
67 | #include <math.h> |
68 | #include <stddef.h> |
69 | #include <stdint.h> |
70 | |
71 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
72 | |
73 | SingleInputSingleOutputDiff<float>(func1: &LIBC_NAMESPACE::ceilf, func2: &::ceilf, data, |
74 | size); |
75 | SingleInputSingleOutputDiff<double>(func1: &LIBC_NAMESPACE::ceil, func2: &::ceil, data, |
76 | size); |
77 | SingleInputSingleOutputDiff<long double>(func1: &LIBC_NAMESPACE::ceill, func2: &::ceill, |
78 | data, size); |
79 | |
80 | SingleInputSingleOutputDiff<float>(func1: &LIBC_NAMESPACE::floorf, func2: &::floorf, data, |
81 | size); |
82 | SingleInputSingleOutputDiff<double>(func1: &LIBC_NAMESPACE::floor, func2: &::floor, data, |
83 | size); |
84 | SingleInputSingleOutputDiff<long double>(func1: &LIBC_NAMESPACE::floorl, func2: &::floorl, |
85 | data, size); |
86 | |
87 | SingleInputSingleOutputDiff<float>(func1: &LIBC_NAMESPACE::roundf, func2: &::roundf, data, |
88 | size); |
89 | SingleInputSingleOutputDiff<double>(func1: &LIBC_NAMESPACE::round, func2: &::round, data, |
90 | size); |
91 | SingleInputSingleOutputDiff<long double>(func1: &LIBC_NAMESPACE::roundl, func2: &::roundl, |
92 | data, size); |
93 | |
94 | SingleInputSingleOutputDiff<float>(func1: &LIBC_NAMESPACE::truncf, func2: &::truncf, data, |
95 | size); |
96 | SingleInputSingleOutputDiff<double>(func1: &LIBC_NAMESPACE::trunc, func2: &::trunc, data, |
97 | size); |
98 | SingleInputSingleOutputDiff<long double>(func1: &LIBC_NAMESPACE::truncl, func2: &::truncl, |
99 | data, size); |
100 | |
101 | SingleInputSingleOutputDiff<float>(func1: &LIBC_NAMESPACE::logbf, func2: &::logbf, data, |
102 | size); |
103 | SingleInputSingleOutputDiff<double>(func1: &LIBC_NAMESPACE::logb, func2: &::logb, data, |
104 | size); |
105 | SingleInputSingleOutputDiff<long double>(func1: &LIBC_NAMESPACE::logbl, func2: &::logbl, |
106 | data, size); |
107 | |
108 | TwoInputSingleOutputDiff<float, float>(func1: &LIBC_NAMESPACE::hypotf, func2: &::hypotf, |
109 | data, size); |
110 | |
111 | TwoInputSingleOutputDiff<float, float>(func1: &LIBC_NAMESPACE::remainderf, |
112 | func2: &::remainderf, data, size); |
113 | TwoInputSingleOutputDiff<double, double>(func1: &LIBC_NAMESPACE::remainder, |
114 | func2: &::remainder, data, size); |
115 | TwoInputSingleOutputDiff<long double, long double>( |
116 | func1: &LIBC_NAMESPACE::remainderl, func2: &::remainderl, data, size); |
117 | |
118 | TwoInputSingleOutputDiff<float, float>(func1: &LIBC_NAMESPACE::fdimf, func2: &::fdimf, data, |
119 | size); |
120 | TwoInputSingleOutputDiff<double, double>(func1: &LIBC_NAMESPACE::fdim, func2: &::fdim, data, |
121 | size); |
122 | TwoInputSingleOutputDiff<long double, long double>(func1: &LIBC_NAMESPACE::fdiml, |
123 | func2: &::fdiml, data, size); |
124 | |
125 | SingleInputSingleOutputDiff<float>(func1: &LIBC_NAMESPACE::sqrtf, func2: &::sqrtf, data, |
126 | size); |
127 | SingleInputSingleOutputDiff<double>(func1: &LIBC_NAMESPACE::sqrt, func2: &::sqrt, data, |
128 | size); |
129 | SingleInputSingleOutputDiff<long double>(func1: &LIBC_NAMESPACE::sqrtl, func2: &::sqrtl, |
130 | data, size); |
131 | |
132 | SingleInputSingleOutputWithSideEffectDiff<float, int>(func1: &LIBC_NAMESPACE::frexpf, |
133 | func2: &::frexpf, data, size); |
134 | SingleInputSingleOutputWithSideEffectDiff<double, int>(func1: &LIBC_NAMESPACE::frexp, |
135 | func2: &::frexp, data, size); |
136 | SingleInputSingleOutputWithSideEffectDiff<long double, int>( |
137 | func1: &LIBC_NAMESPACE::frexpl, func2: &::frexpl, data, size); |
138 | |
139 | SingleInputSingleOutputWithSideEffectDiff<float, float>( |
140 | func1: &LIBC_NAMESPACE::modff, func2: &::modff, data, size); |
141 | SingleInputSingleOutputWithSideEffectDiff<double, double>( |
142 | func1: &LIBC_NAMESPACE::modf, func2: &::modf, data, size); |
143 | SingleInputSingleOutputWithSideEffectDiff<long double, long double>( |
144 | func1: &LIBC_NAMESPACE::modfl, func2: &::modfl, data, size); |
145 | |
146 | TwoInputSingleOutputDiff<float, int>(func1: &LIBC_NAMESPACE::ldexpf, func2: &::ldexpf, data, |
147 | size); |
148 | TwoInputSingleOutputDiff<double, int>(func1: &LIBC_NAMESPACE::ldexp, func2: &::ldexp, data, |
149 | size); |
150 | TwoInputSingleOutputDiff<long double, int>(func1: &LIBC_NAMESPACE::ldexpl, func2: &::ldexpl, |
151 | data, size); |
152 | |
153 | RemQuoDiff<float>(func1: &LIBC_NAMESPACE::remquof, func2: &::remquof, data, size); |
154 | RemQuoDiff<double>(func1: &LIBC_NAMESPACE::remquo, func2: &::remquo, data, size); |
155 | RemQuoDiff<long double>(func1: &LIBC_NAMESPACE::remquol, func2: &::remquol, data, size); |
156 | |
157 | return 0; |
158 | } |
159 | |