summaryrefslogtreecommitdiffstats
path: root/libcxx/include/math.h
Commit message (Collapse)AuthorAgeFilesLines
* [libcxx] use __builtin_isnan in std::isnan.Ilya Tokar2019-11-151-0/+4
| | | | | | | | | | | | Summary: This allows std::isnan to be fully inlined, instead of generating calls. Reviewers: EricWF Reviewed By: EricWF Subscribers: christof, ldionne Differential Revision: https://reviews.llvm.org/D69806
* [libc++] Move __clamp_to_integral to <cmath>, and harden against min()/max() ↵Louis Dionne2019-09-041-34/+0
| | | | | | macros llvm-svn: 370900
* [libc++] Add `__truncating_cast` for safely casting float types to integersLouis Dionne2019-09-041-0/+34
| | | | | | | | | | | This is needed anytime we need to clamp an arbitrary floating point value to an integer type. Thanks to Eric Fiselier for the patch. Differential Revision: https://reviews.llvm.org/D66836 llvm-svn: 370891
* Apply new meta-programming traits throughout the library.Eric Fiselier2019-06-231-37/+37
| | | | | | The new meta-programming primitives are lower cost than the old versions. This patch removes those old versions and switches libc++ to use the new ones. llvm-svn: 364160
* Fix implementation of ::abs and std::abs LWG 2192.Eric Fiselier2019-04-231-9/+53
| | | | | | | | | | | | | | | | | | | Summary: All overloads of `::abs` and `std::abs` must be present in both `<cmath>` and `<cstdlib>`. This is problematic to implement because C defines `fabs` in `math.h` and `labs` in `stdlib.h`. This introduces a circular dependency between the two headers. This patch implements that requirement by moving `abs` into `math.h` and making `stdlib.h` include `math.h`. In order to get the underlying C declarations from the "real" `stdlib.h` inside our `math.h` we need some trickery. Specifically we need to make `stdlib.h` include next itself. Suggestions for a cleaner implementation are welcome. Reviewers: mclow.lists, ldionne Reviewed By: ldionne Subscribers: krytarowski, fedor.sergeev, dexonsmith, jdoerfert, jsji, libcxx-commits Differential Revision: https://reviews.llvm.org/D60097 llvm-svn: 359020
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by ↵Louis Dionne2018-07-111-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | _LIBCPP_INLINE_VISIBILITY Summary: We never actually mean to always inline a function -- all the uses of the macro I could find are actually attempts to control the visibility of symbols. This is better described by _LIBCPP_INLINE_VISIBILITY, which is actually always defined the same. This change is orthogonal to the decision of what we're actually going to do with _LIBCPP_INLINE_VISIBILITY -- it just simplifies things by having one canonical way of doing things. Note that this commit had originally been applied in r336369 and then reverted in r336382 because of unforeseen problems. Both of these problems have now been fixed. Reviewers: EricWF, mclow.lists Subscribers: christof, dexonsmith, erikvanderpoel Differential Revision: https://reviews.llvm.org/D48892 llvm-svn: 336866
* Revert "[libc++] Replace uses of _LIBCPP_ALWAYS_INLINE by ↵Louis Dionne2018-07-051-12/+12
| | | | | | | | | | | | | | | _LIBCPP_INLINE_VISIBILITY" This reverts commit r336369. The commit had two problems: 1. __pbump was marked as _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY instead of _LIBCPP_INLINE_VISIBILITY, which lead to two symbols being added in the dylib and the check-cxx-abilist failing. 2. The LLDB tests started failing because they undefine `_LIBCPP_INLINE_VISIBILITY`. I need to figure out why they do that and fix the tests before we can go forward with this change. llvm-svn: 336382
* [libc++] Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITYLouis Dionne2018-07-051-12/+12
| | | | | | | | | | | | | | | | | | | | Summary: We never actually mean to always inline a function -- all the uses of the macro I could find are actually attempts to control the visibility of symbols. This is better described by _LIBCPP_INLINE_VISIBILITY, which is actually always defined the same. This change is orthogonal to the decision of what we're actually going to do with _LIBCPP_INLINE_VISIBILITY -- it just simplifies things by having one canonical way of doing things. Reviewers: EricWF Subscribers: christof, llvm-commits, dexonsmith, erikvanderpoel, mclow.lists Differential Revision: https://reviews.llvm.org/D48892 llvm-svn: 336369
* Fix return type of isinf(double) and isnan(double) where possible.Richard Smith2018-05-011-0/+28
| | | | | | | | | | | When using an old version of glibc, a ::isinf(double) and ::isnan(double) function is provided, rather than just the macro required by C and C++. Displace this function using _LIBCPP_PREFERRED_OVERLOAD where possible. The only remaining case where we should get the wrong return type is now glibc + libc++ + a non-clang compiler. llvm-svn: 331241
* [libcxx] Do not include the C math.h header before __configMikhail Maltsev2018-02-221-10/+16
| | | | | | | | | | | | | | | | | | | | | | Summary: Certain C libraries require configuration macros defined in __config to provide the correct functionality for libc++. This patch ensures that the C header math.h is always included after the __config header. It also adds a Windows-specific #if guard for the case when the C math.h file is included the second time, as suggested by Marshall in https://reviews.llvm.org/rL323490. Fixes PR36382. Reviewers: mclow.lists, EricWF Reviewed By: mclow.lists Subscribers: cfe-commits, pcc, christof, rogfer01 Differential Revision: https://reviews.llvm.org/D43579 llvm-svn: 325760
* libcxx: Move #include_next <math.h> out of header guard in wrapper header.Peter Collingbourne2018-01-261-2/+10
| | | | | | | | | | | | | | | Code on Windows expects to be able to do: #define _USE_MATH_DEFINES #include <math.h> and receive the definitions of mathematical constants, even if <math.h> has previously been included. To support this scenario, re-include <math.h> every time the wrapper header is included. Differential Revision: https://reviews.llvm.org/D42403 llvm-svn: 323490
* cmath: Skip Libc for integral types in isinf, etc.Duncan P. N. Exon Smith2017-04-211-8/+81
| | | | | | | | | | | | | | | | | | | | | | | | For std::isinf, the standard requires effectively calling isinf as double from Libc for integral types. But integral types are never infinite; we don't need to call Libc to return false. Also short-circuit other functions where Libc won't have interesting answers: signbit, fpclassify, isfinite, isnan, and isnormal. I added correctness tests for integral types since we're no longer deferring to Libc. In review it was pointed out that in future revisions of the C++ standard we may add more types to std::is_arithmetic (e.g., std::is_fixed_point). I'll leave it to a future commit to hack this to allow using math functions on those. We'll need to change things like __libcpp_fpclassify anyway, so I'm not sure anything here would really be future-proof. https://reviews.llvm.org/D31561 rdar://problem/31361223 llvm-svn: 301060
* [libc++] Drop support for CRTs older than VS 2015Shoaib Meenai2017-04-071-41/+24
| | | | | | | | | | | LLVM dropped support for Visual Studio versions older than 2015 quite some time ago, so I consider it safe to drop libc++'s support for older CRTs. The CRT in Visual Studio 2015 provides a lot of previously missing functions, so targeting it requires less special casing. Differential Revision: https://reviews.llvm.org/D31798 llvm-svn: 299743
* math: add type promoting template definition on MSVCRTSaleem Abdulrasool2017-02-181-0/+20
| | | | | | | | When building with MSVCRT, we need to manually provide the type promoting overloads to allow the correct type deduced invocation for signbit(Int) and fpclassify(int). llvm-svn: 295559
* math: fix typo in macroSaleem Abdulrasool2017-02-171-2/+2
| | | | | | MAJOR was misspelt as NAJOR. Fix the spelling. llvm-svn: 295510
* math: correct the MSVCRT conditionSaleem Abdulrasool2017-02-161-2/+2
| | | | | | Fixes a number of tests in the testsuite on Windows. llvm-svn: 295330
* math: actually pull the declarations/overloads into stdSaleem Abdulrasool2017-02-131-0/+3
| | | | | | | The previous changes missed the change to include/cmath. These changes allow some of the rand.distribution tests to pass on Windows. llvm-svn: 294957
* math: follow up to SVN r294902Saleem Abdulrasool2017-02-121-26/+26
| | | | | | | | Pull in the math functions from ucrt 14+ after auditing the library. It seems that they are now complete for C99 math. Fixes more windows tests! llvm-svn: 294918
* math: pull more C functions from stdSaleem Abdulrasool2017-02-121-2/+2
| | | | | | | The newer ucrt version provides the gamma meth routines. Includede them when building the library. llvm-svn: 294902
* Fully qualify (preprend ::) calls to math functions from libcMehdi Amini2017-02-101-170/+170
| | | | | | | | | | | | | | | | | | | | | | Summary: This can cause a compile failure in cases like: double log(double); namespace foo { namespace log {} } using namespace foo; void bar(int i) { log((double)i); } Reviewers: EricWF, mclow.lists Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D29804 llvm-svn: 294696
* [libc++] Remove math_win32.hShoaib Meenai2016-09-241-4/+0
| | | | | | | | | Visual Studio 2013 and onward have all the required functions in their CRT headers, and we don't support older versions anymore. Differential Revision: https://reviews.llvm.org/D24879 llvm-svn: 282328
* Fix PR28506. Re-enable missing math.h C++11 decls on SunOS. Patch from ↵Eric Fiselier2016-08-151-29/+24
| | | | | | Michal Gorny. llvm-svn: 278716
* PR25118: move system_header pragma before uses of include_next to avoid ↵Richard Smith2015-10-091-1/+2
| | | | | | extension warnings for people finding libc++ headers via -I paths. llvm-svn: 249788
* Split <math.h> out of <cmath>.Richard Smith2015-10-081-0/+1418
llvm-svn: 249742
OpenPOWER on IntegriCloud