Add strncmp as a function to strings.h. Also adds unit tests, and adds
strncmp as an entrypoint for all current platforms.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D106901
All fenv functions are also enabled for windows. Since two tests,
enabled_exceptions_test and feholdexcept_test are still failing on
windows, they have been disabled.
Reviewed By: aeubanks
Differential Revision: https://reviews.llvm.org/D106808
Included more math functions to Windows's entrypoints
and made a cmake option (-DLLVM_LIBC_MPFR_INSTALL_PATH)
where the user can specify the install path where the MPFR
library was built so it can be linked. The try_compile was
moved to LLVMLibCCheckMPFR.cmake, so the variable that is
set after this process can retain its value in other files
of the same parent file. A direct reason for this is for
LIBC_TESTS_CAN_USE_MPFR to be true when the user specifies
MPFR's path and retain its value even after leaving the file.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D106894
Incorporated the varied functions for nextafter and refactored
NextAfterTest.h to correctly define bitWidthOfType for both
Linux and Windows; by letting FloatProperties take care
of the directives' logic based on the platform being used.
This allows to successfully run nextafter's tests.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D106395
A README file with procedure for building/testing LLVM libc on Windows
has also been added.
Reviewed By: sivachandra, aeubanks
Differential Revision: https://reviews.llvm.org/D105231
Use expm1f(x) = exp(x) - 1 for |x| > ln(2).
For |x| <= ln(2), divide it into 3 subintervals: [-ln2, -1/8], [-1/8, 1/8], [1/8, ln2]
and use a degree-6 polynomial approximation generated by Sollya's fpminmax for each interval.
Errors < 1.5 ULPs when we use fma to evaluate the polynomials.
Differential Revision: https://reviews.llvm.org/D101134
They require clang-11 or above for building and hence had to be disabled
as the bots did not have clang-11 or higher. Bots have now been upgraded
so we can enable these functions now.
The implementations use the x86_64 FPU instructions. These instructions
are extremely slow compared to a polynomial based software
implementation. Also, their accuracy falls drastically once the input
goes beyond 2PI. To improve both the speed and accuracy, we will be
taking the following approach going forward:
1. As a follow up to this CL, we will implement a range reduction algorithm
which will expand the accuracy to the entire double precision range.
2. After that, we will replace the HW instructions with a polynomial
implementation to improve the run time.
After step 2, the implementations will be accurate, performant and target
architecture independent.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D102384
Current implementation defines LIBC_TARGET_MACHINE with the use of CMAKE_SYSTEM_PROCESSOR.
Unfortunately CMAKE_SYSTEM_PROCESSOR is OS dependent and can produce different results.
An evidence of this is the various matchers used to detect whether the architecture is x86.
This patch normalizes LIBC_TARGET_MACHINE and renames it LIBC_TARGET_ARCHITECTURE.
I've added many architectures but we may want to limit ourselves to x86 and ARM.
Differential Revision: https://reviews.llvm.org/D101524
[libc] Introduce asctime, asctime_r to LLVM libc
asctime and asctime_r share the same common code. They call asctime_internal
a static inline function.
asctime uses snprintf to return the string representation in a buffer.
It uses the following format (26 characters is the buffer size) as per
7.27.3.1 section in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2478.pdf.
The buf parameter for asctime_r shall point to a buffer of at least 26 bytes.
snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",...)
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D99686
The version of clang installed on the buildbot workers is not able to
compile them. However, the version of gcc installed is able to compile
them fine. So, this change disables them until we can find a way to
compile them using clang on the buildbot workers.
The current generic implementation of the fmaf function has been moved
to the FPUtil directory. This allows one use the fma operation from
implementations of other math functions like the trignometric functions
without depending on/requiring the fma/fmaf/fmal function targets. If
this pattern ends being convenient, we will switch all generic math
implementations to this pattern.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D100811
gmtime and gmtime_r share the same common code. They call gmtime_internal
a static inline function. Thus added only validation tests for gmtime_r.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D99046
This change doesn't handle TIMEZONE, tm_isdst and leap seconds.
Moved shared code between mktime and gmtime into time_utils.cpp.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D98467
This option will build LLVM libc as a full libc by itself. In this mode,
it is not expected that it will be mixed with other libcs. The
non-full-build mode will be the default LLVM libc build mode. In a future
where LLVM libc is complete enough, the full libc build will be made the
default mode.
Namely, implementations of fegetexceptfflag, fesetexceptflag,
fegetenv, fesetenv, feholdexcept and feupdateenv have been added.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D96935
Namely, these are the functions enabled: rint*, lrint*, llrint*, lround*,
llround*, nearbyint*. They were previously not enabled because they
required rounding mode and FP exception support. Now that rounding mode
and FP exception support is available for Aarch64, they can be enabled.
This change does not try to move the common parts of x86 and aarch64 and
build few abstractions over them. While this is possible, x86 story
needs a bit of cleanup, especially around manipulation of the mxcsr
register. Moreover, on x86 one can raise exceptions without performing
exception raising operations. So, all of this can be done in follow up
patches.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D94947
Use `memcpy` rather than copying bytes one by one, for there might be large
size structs to move.
Reviewed By: gchatelet, sivachandra
Differential Revision: https://reviews.llvm.org/D93195
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
The implementation is exactly the same as rint* as even rint does not
raise any floating point exceptions currently. [Note that the standards
do not specify that floating point exceptions must be raised - they
leave it up to the implementation to choose to raise FE_INEXACT when
rounding non-integral values.]
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D94112
A new function to MPFRWrapper has been added, which is used to set up
the unit tests.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D93007
Refactor src/math/hypotf.cpp and test/src/math/hypotf_test.cpp and reuse them for hypot and hypot_test
Differential Revision: https://reviews.llvm.org/D91831
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
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
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
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
The new code added is still very x86_64 specific. AArch64 support will
be added very soon and refactoring of the loader code will be done as
part of the patches adding it.
Reviewed By: asteinhauser
Differential Revision: https://reviews.llvm.org/D82700