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>(&__llvm_libc::ceilf, &::ceilf, data, size); 74 SingleInputSingleOutputDiff<double>(&__llvm_libc::ceil, &::ceil, data, size); 75 SingleInputSingleOutputDiff<long double>(&__llvm_libc::ceill, &::ceill, data, 76 size); 77 78 SingleInputSingleOutputDiff<float>(&__llvm_libc::floorf, &::floorf, data, 79 size); 80 SingleInputSingleOutputDiff<double>(&__llvm_libc::floor, &::floor, data, 81 size); 82 SingleInputSingleOutputDiff<long double>(&__llvm_libc::floorl, &::floorl, 83 data, size); 84 85 SingleInputSingleOutputDiff<float>(&__llvm_libc::roundf, &::roundf, data, 86 size); 87 SingleInputSingleOutputDiff<double>(&__llvm_libc::round, &::round, data, 88 size); 89 SingleInputSingleOutputDiff<long double>(&__llvm_libc::roundl, &::roundl, 90 data, size); 91 92 SingleInputSingleOutputDiff<float>(&__llvm_libc::truncf, &::truncf, data, 93 size); 94 SingleInputSingleOutputDiff<double>(&__llvm_libc::trunc, &::trunc, data, 95 size); 96 SingleInputSingleOutputDiff<long double>(&__llvm_libc::truncl, &::truncl, 97 data, size); 98 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, 102 size); 103 104 TwoInputSingleOutputDiff<float, float>(&__llvm_libc::hypotf, &::hypotf, data, 105 size); 106 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); 113 114 TwoInputSingleOutputDiff<float, float>(&__llvm_libc::fdimf, &::fdimf, data, 115 size); 116 TwoInputSingleOutputDiff<double, double>(&__llvm_libc::fdim, &::fdim, data, 117 size); 118 TwoInputSingleOutputDiff<long double, long double>(&__llvm_libc::fdiml, 119 &::fdiml, data, size); 120 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, 124 size); 125 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); 132 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); 139 140 TwoInputSingleOutputDiff<float, int>(&__llvm_libc::ldexpf, &::ldexpf, data, 141 size); 142 TwoInputSingleOutputDiff<double, int>(&__llvm_libc::ldexp, &::ldexp, data, 143 size); 144 TwoInputSingleOutputDiff<long double, int>(&__llvm_libc::ldexpl, &::ldexpl, 145 data, size); 146 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); 150 151 return 0; 152 } 153