This introduces mktime to LLVM libc, based on C99/C2X/Single Unix Spec.
Co-authored-by: Jeff Bailey <jeffbailey@google.com>
This change doesn't handle TIMEZONE, tm_isdst and leap seconds. It returns -1 for invalid dates. I have verified the return results for all the possible dates with glibc's mktime.
TODO:
+ Handle leap seconds.
+ Handle out of range time and date values that don't overflow or underflow.
+ Implement the following suggestion Siva - As we start accumulating the seconds, we should be able to check if the next amount of seconds to be added can lead to an overflow. If it does, return the overflow value. If not keep accumulating. The benefit is that, we don't have to validate every input, and also do not need the special cases for sizeof(time_t) == 4.
+ Handle timezone and update of tm_isdst
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D91551
This switches all of the files in src/string, src/math, and
test/src/math from using relative paths (e.g. `#include “include/string.h”`)
to global paths (e.g. `#include <string.h>`) to make bringing up those
functions on other platforms, such as fuchsia, easier.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D91394
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
The rounding behavior of NormalFloat to float format has been changed
to round to nearest. Also, a bug in NormalFloat to subnormal number
conversion has been fixed.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D91591
This is mostly changing stringref to std::string, outs() to cout,
and small supporting changes. This will make running unit tests possible
on systems that are only grabbing the libc part of llvm.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D91568
This is acheived by making the RunContext a state variable of the test
classes.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D90805
This corrects WrapperGen generating incorrect wrappers for functions
that take no arguments. Previously it would generate a wrapper with a
single argument of type `void`.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D90800
Rename the files containing the `__errno_location` function
to `__errno_location.h/cpp` to match the other files and move
the `llvmlibc_errno` macro to its own file.
Split assert.h into `__assert_fail.h` (contains the function prototype)
and assert.h (contains the assert macro).
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D90653
Also moved most of the common type definitions from libc/spec/stdc.td
to libc/spec/spec.td so that they can be used to list functions in llvm_libc_ext.td.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D89436
The function listings in api.td are removed. The same lists are now deduced using the information
in entrypoints.txt.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D89267
This patch adds memory function size distributions sampled from different applications running in production.
This will be used to benchmark and compare memory functions implementations.
Differential Revision: https://reviews.llvm.org/D89401
This revision removes dependencies that exist between different string functions. This allows for the libc user to use a specific function X of this library without also depending on Y and Z.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D87421
The implementation is not fully standards compliant in the sense that
errno is not set on error, and floating point exceptions are not raised.
Subnormal range and normal range are tested separately in the tests.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D86666
This applies the same fix that D84748 did for macro definitions.
Appropriate include path is now automatically set for all libraries
which link against gtest targets, which avoids the need to set
include_directories in various parts of the project.
Differential Revision: https://reviews.llvm.org/D86616