31 Commits

Author SHA1 Message Date
sribee8
da30197f1c
[libc] Fuzz tests for fsqrt, f16sqrt, and hypot (#150489)
Added fuzz tests for f16sqrt, fsqrt, and hypot

---------

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-25 17:15:26 +00:00
sribee8
16b4fb50dd
[libc] cbrt fuzz test (#150063)
Implemented fuzz test for cbrt

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-22 21:31:12 +00:00
sribee8
82451d0b13
[libc] Updated exp fuzz tests (#148912)
Fuzz tests were previously in the wrong format, updated them to correct
format.

---------

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-16 11:36:17 -07:00
sribee8
037d34815e
[libc] Updated fuzz tests for trig functions (#148891)
Fuzz tests were set up incorrectly so updated trig functions to match
the correct format.

---------

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-16 17:57:47 +00:00
sribee8
ba95df17ec
[libc] sqrt and log functions fuzz tests (#148006)
added fuzz tests for sqrt and log functions

---------

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-15 20:04:06 +00:00
sribee8
1f97c9432d
[libc] exp fuzz tests (#148086)
Created fuzz tests for exp functions

---------

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-14 16:36:24 +00:00
sribee8
425ed22b2e
[libc] asin fuzz testing (#147786)
Added fuzz test for asin

---------

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-10 16:28:57 +00:00
sribee8
a9d8843d71
[libc] Fuzz tests for acos and atan (#147843)
created fuzz tests for acos and atan

---------

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-10 16:28:29 +00:00
sribee8
81614e5b90
[libc] sincos fuzz test (#147855)
Created fuzz test for sincos

---------

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-10 16:26:26 +00:00
Chuvak
3709c2d15a
[libc] Fix wrong name in Compare.h (#117223)
Fix for some mistakes in source code found using PVS Studio.

Inspired by: https://pvs-studio.com/en/blog/posts/cpp/1188/

Fixed:
- [Bug 5](https://pvs-studio.com/en/blog/posts/cpp/1188/#IDF23EA2CEAB)
2024-11-21 18:29:08 -05:00
RoseZhang03
2d95dee0c0
[libc] math fuzzing MPFR include statement (#102358)
Updated the include statement for MPFR
2024-08-07 21:12:40 +00:00
RoseZhang03
0142bd6b15
[libc] created tan function fuzzer (#101570)
Also edited file header formatting on sin_fuz and cos_fuzz
2024-08-01 23:19:47 +00:00
RoseZhang03
b45d36299e
[libc] added cos function fuzzing test (#101556) 2024-08-01 21:59:55 +00:00
Michael Jones
3497211d80
[libc] Fix math fuzzers (#101529)
Fix minor typos that accumulated while the math fuzzers were disabled.
2024-08-01 10:40:11 -07:00
RoseZhang03
90065da6d5
[libc] created fuzz test for sin function (#101411)
Verifies that sin function output is correct by comparing with MPFR
output. NaN and inf are not tested (as our output will vary compared to
MPFR), and signed zeroes are already tested in unit tests.
2024-08-01 17:31:04 +00:00
lntue
dfdef2cbf7
[libc] Fix the remaining isnan and isinf in tests. (#100969)
Fixes https://github.com/llvm/llvm-project/issues/100964
2024-07-28 21:37:01 -07:00
lntue
5748ad84e5
[libc] Add proxy header math_macros.h. (#87598)
Context: https://github.com/llvm/llvm-project/pull/87017

- Add proxy header `libc/hdr/math_macros.h` that will:
  - include `<math.h>` in overlay mode,
- include `"include/llvm-libc-macros/math-macros.h"` in full build mode.
- Its corresponding CMake target `libc.hdr.math_macros` will only depend
on `libc.include.math` and `libc.include.llvm-libc-macros.math_macros`
in full build mode.
- Replace all `#include "include/llvm-libc-macros/math-macros.h"` with
`#include "hdr/math_macros.h"`.
- Add dependency to `libc.hdr.math_macros` CMake target when using
`add_fp_unittest`.
- Update the remaining dependency.
- Update bazel overlay: add `libc:hdr_math_macros` target, and replacing
all dependency on `libc:llvm_libc_macros_math_macros` with
`libc:hdr_math_macros`.
2024-04-05 18:21:16 -04:00
Michael Jones
5d56b34807
[libc] Remove direct math.h includes (#85324)
Reland of #84991

A downstream overlay mode user ran into issues with the isnan macro not
working in our sources with a specific libc configuration. This patch
replaces the last direct includes of math.h with our internal
math_macros.h, along with the necessary build system changes.
2024-03-18 14:19:33 -07:00
Guillaume Chatelet
b6bc9d72f6
[libc] Mass replace enclosing namespace (#67032)
This is step 4 of
https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
2023-09-26 11:45:04 +02:00
Michael Jones
f1990feb35 [libc] add fuzz target for strtointeger functions
The string to integer conversion functions are well suited to
differential fuzzing, and this patch adds a target to enable just that.
It also fixes a bug in the fuzzing comparison logic and changes atoi
slightly to match the behavior described in the C standard.

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D140178
2022-12-20 10:48:34 -08:00
Michael Jones
9ac66f0650 [libc][cmake] split fputil into individual targets
The libc.src.__support.FPUtil.fputil target encompassed many unrelated
files, and provided a lot of hidden dependencies. This patch splits out
all of these files into component parts and cleans up the cmake files
that used them. It does not touch any source files for simplicity, but
there may be changes made to them in future patches.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D132980
2022-08-31 10:44:52 -07:00
Guillaume Chatelet
f72261508a [libc][NFC] Use STL case for type_traits
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion. Starting with the type_traits header.

Differential Revision: https://reviews.llvm.org/D130727
2022-07-29 09:57:03 +00:00
Michael Jones
bf0ded805a [libc][NFC] split standalone_cpp into single headers
Previously, the entire support/CPP folder was in one header library,
which meant that a lot of headers were included where they shouldn't be.
This patch splits each header into its own target, as well as adjusting
each place they were included to only include what is used.

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D121237
2022-03-08 11:56:08 -08:00
Michael Jones
1c92911e9e [libc] apply new lint rules
This patch applies the lint rules described in the previous patch. There
was also a significant amount of effort put into manually fixing things,
since all of the templated functions, or structs defined in /spec, were
not updated and had to be handled manually.

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D114302
2021-12-07 10:49:47 -08:00
Siva Chandra Reddy
d9bbad277c [libc][Obvious][NFC] A bunch of cosmetic cleanup.
* Added missing header guards.
* Fixed license header format in a few files.
* Renamed files to more suitable names.
2021-11-19 17:02:55 +00:00
Siva Chandra Reddy
f362aea42d [libc][NFC] Move utils/CPP to src/__support/CPP.
The idea is to move all pieces related to the actual libc sources to the
"src" directory. This allows downstream users to ship and build just the
"src" directory.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D112653
2021-10-28 15:50:00 +00:00
Michael Jones
c120edc7b3 [libc][nfc] move ctype_utils and FPUtils to __support
Some ctype functions are called from other libc functions (e.g. isspace
is used in atoi). By moving ctype_utils.h to __support it becomes easier
to include just the implementations of these functions. For these
reasons the implementation for isspace was moved into
ctype_utils as well.

FPUtils was moved to simplify the build order, and to clarify which
files are a part of the actual libc.

Many files were modified to accomodate these changes, mostly changing
the #include paths.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D107600
2021-08-06 17:29:41 +00:00
Siva Chandra Reddy
6666e0d7a2 [libc] Make FPBits a union.
This helps us avoid the uncomfortable reinterpret-casts. Avoiding the
reinterpret casts prevents us from tripping the sanitizers as well.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D100360
2021-04-13 09:21:35 -07:00
Siva Chandra Reddy
7f7b0dc4e1 [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
2021-01-05 22:32:39 -08:00
Siva Chandra Reddy
4766a86cf2 [libc] Combine all math differential fuzzers into one target.
Also added diffing of a few more math functions. Combining the diff check
for all of these functions helps us meet the OSS fuzz bar of a minimum of
100 program edges.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D91817
2020-11-20 07:46:15 -08:00
Siva Chandra Reddy
892ed1f150 [libc] Add differential fuzzers for ldexp and remquo.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D91763
2020-11-19 08:32:05 -08:00