summaryrefslogtreecommitdiffstats
path: root/libcxx/include/random
Commit message (Collapse)AuthorAgeFilesLines
* [libc++] Cleanup and enable multiple warnings.Eric Fiselier2019-12-121-0/+2
| | | | | | | | | | Too many warnings are being disabled too quickly. Warnings are important to keeping libc++ correct. This patch re-enables two warnings: -Wconstant-evaluated and -Wdeprecated-copy. In future, all warnings disabled for the test suite should require an attached bug. The bug should state the plan for re-enabling that warning, or a strong case why it should remain disabled.
* [libc++] Fix potential OOB in poisson_distributionLouis Dionne2019-11-071-21/+24
| | | | | See details in the original Chromium bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=994957
* [libc++] Explicitly cast in generate_canonicalLouis Dionne2019-08-201-1/+1
| | | | | | | | | | A new clang warning introduced in r367497 was complaining about the change in value. Thanks to Brian Cain for the patch. Differential Revision: https://reviews.llvm.org/D66422 llvm-svn: 369393
* [NFC][libcxx] Remove trailing whitespaceLouis Dionne2019-05-291-8/+8
| | | | | | It's incredibly annoying when trying to create diffs llvm-svn: 361981
* 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++] Use correct rand.eng.mers all-zeroes seed sequence fallbackHubert Tong2018-08-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Summary: When a seed sequence would lead to having no non-zero significant bits in the initial state of a `mersenne_twister_engine`, the fallback is to flip the most significant bit of the first value that appears in the textual representation of the initial state. rand.eng.mers describes this as setting the value to be 2 to the power of one less than w; the previous value encoded in the implementation, namely one less than "2 to the power of w", is replaced by the correct value in this patch. Reviewers: mclow.lists, EricWF, jasonliu Reviewed By: mclow.lists Subscribers: mclow.lists, jasonliu, EricWF, christof, ldionne, cfe-commits Differential Revision: https://reviews.llvm.org/D50736 llvm-svn: 339969
* Change an internal table of constants for the poisson distribution fromMarshall Clow2018-01-161-1/+1
| | | | | | | | | type 'result_type' to 'double'. The only thing that we ever do with these numbers is to promote them to 'double' and use them in a division. For small result_types, the values were getting truncated, skewing the results. Thanks to James Nagurne for the suggestion. llvm-svn: 322556
* Revert 313789 because gcc doesn't like itMarshall Clow2017-09-201-4/+4
| | | | llvm-svn: 313803
* Mark the __eval methods on independent_bits_engine (and ↵Marshall Clow2017-09-201-4/+4
| | | | | | __independent_bits_engine) as const, since they make no changes to the object. NFC. llvm-svn: 313789
* mark mersenne_twister_engine<>::seed(result_type __sd) with ↵Marshall Clow2017-09-111-0/+1
| | | | | | _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK to placate UBSAN. Fixes PR#34160 llvm-svn: 312932
* [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on WindowsEric Fiselier2017-05-311-2/+6
| | | | | | | | | | | | | | | | Summary: This patch improves how libc++ handles min/max macros within the headers. Previously libc++ would undef them and emit a warning. This patch changes libc++ to use `#pragma push_macro` to save the macro before undefining it, and `#pragma pop_macro` to restore the macros and the end of the header. Reviewers: mclow.lists, bcraig, compnerd, EricWF Reviewed By: EricWF Subscribers: cfe-commits, krytarowski Differential Revision: https://reviews.llvm.org/D33080 llvm-svn: 304357
* Remove uses of _UI because Windows is evil and tchar.h #define's itEric Fiselier2017-05-311-109/+109
| | | | llvm-svn: 304348
* Fix lgamma_r linking errors on Windows. It appears the normal lgamma ↵Eric Fiselier2017-05-061-4/+14
| | | | | | function is thread safe anyway llvm-svn: 302330
* Use lgamma_r instead of lgamma in binomial_distribution, because freakin' ↵Marshall Clow2017-05-041-4/+8
| | | | | | POSIX took a perfectly fine call and made it not thread safe. llvm-svn: 302168
* Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in the numeric tests and headersEric Fiselier2017-04-191-28/+28
| | | | llvm-svn: 300632
* [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VISEric Fiselier2017-01-041-48/+48
| | | | | | | | | | | | | The name _LIBCPP_TYPE_VIS_ONLY is no longer accurate because both _LIBCPP_TYPE_VIS and _LIBCPP_TYPE_VIS_ONLY expand to __attribute__((__type_visibility__)) with Clang. The only remaining difference is that _LIBCPP_TYPE_VIS_ONLY can be applied to templates whereas _LIBCPP_TYPE_VIS cannot (due to dllimport/dllexport not being allowed on templates). This patch renames _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS. llvm-svn: 291035
* fix sign comparison warningsEric Fiselier2016-12-241-1/+2
| | | | llvm-svn: 290469
* Cleanup: move visibility/linkage attributes to the first declaration.Evgeniy Stepanov2015-11-071-7/+8
| | | | | | | | | | | | This change moves visibility attributes from out-of-class method definitions to in-class declaration. This is needed for a switch to attribute((internal_linkage)) (see http://reviews.llvm.org/D13925) which can only appear on the first declaration. This change does not touch istream/ostream/streambuf. They are handled separately in http://reviews.llvm.org/D14409. llvm-svn: 252385
* Remove unused typedefs in random and regexEric Fiselier2015-07-181-5/+0
| | | | llvm-svn: 242628
* Add support for arc4random() to random_device.Ed Schouten2015-03-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Nuxi CloudABI (https://github.com/NuxiNL/cloudlibc) does not allow processes to access the global filesystem namespace. This breaks random_device, as it attempts to use /dev/{u,}random. This change adds support for arc4random(), which is present on CloudABI. In my opinion it would also make sense to use arc4random() on other operating systems, such as *BSD and Mac OS X, but I'd rather leave that to the maintainers of the respective platforms. Switching to arc4random() does change the ABI. This change also attempts to make some cleanups to the code. It adds a single #define for every random interface, instead of testing against operating systems explicitly. As discussed, also validate the token argument to be equal to "/dev/urandom" on all systems that only provide pseudo-random numbers. This should cause little to no breakage, as "/dev/urandom" is also the default argument value. Reviewed by: jfb Differential Revision: http://reviews.llvm.org/D8134 llvm-svn: 231764
* Get libc++ building on Sun Solaris. Patch from C Bergstrom.Eric Fiselier2015-01-231-2/+2
| | | | llvm-svn: 226947
* libc++: add NaCl and PNaCl support for std::random_deviceJF Bastien2014-12-011-2/+2
| | | | | | | | | | | | | | | | | Summary: The NaCl sandbox doesn't allow opening files under /dev, but it offers an API which provides the same capabilities. This is the same random device emulation that nacl_io performs for POSIX support, but nacl_io is an optional library so libc++ can't assume that device emulation will be performed. Note that NaCl only supports /dev/urandom, not /dev/random. This patch also cleans up some of the preprocessor #endif, and fixes the test for Win32 (it accepts any token, and would therefore never throw regardless of the token provided). Test Plan: ninja check-libcxx Reviewers: dschuff, mclow.lists, danalbert Subscribers: jfb, cfe-commits Differential Revision: http://reviews.llvm.org/D6442 llvm-svn: 223068
* Fix PR#20843: binomial_distribution<unsigned> is broken. Add test to ensure ↵Marshall Clow2014-09-171-1/+4
| | | | | | that signed and unsigned verstions produce the same sequence. llvm-svn: 217976
* Mark seed_seq default constructor and size() as noexcept. This is implied, ↵Marshall Clow2013-10-231-2/+2
| | | | | | but not required by LWG issue 2180 llvm-svn: 193227
* patch by Yaron: Uses rand_s() from stdlib.h (when building for Windows)Marshall Clow2013-10-091-0/+2
| | | | llvm-svn: 192325
* Xing Xue: port to IBM XLC++/AIX.Howard Hinnant2013-08-141-1/+1
| | | | llvm-svn: 188396
* Nico Rieck: this patch series fixes visibility issues on Windows as ↵Howard Hinnant2013-08-121-48/+48
| | | | | | explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>. llvm-svn: 188192
* move __save_flags from <random> to <ios> in preparation for reuse; no ↵Marshall Clow2013-07-091-27/+0
| | | | | | functionality change llvm-svn: 185968
* Neglected to remove a debugging comment from last commit.Howard Hinnant2013-05-211-1/+1
| | | | llvm-svn: 182422
* Fix a couple of bugs in linear_congruential_engine::seed. Regression test ↵Howard Hinnant2013-05-211-3/+3
| | | | | | added. llvm-svn: 182421
* No functionality change at this time. I've split _LIBCPP_VISIBLE up into ↵Howard Hinnant2013-03-061-49/+49
| | | | | | two flags: _LIBCPP_TYPE_VIS and _LIBCPP_FUNC_VIS. This is in preparation for taking advantage of clang's new __type_visibility__ attribute. llvm-svn: 176593
* Zhang Xiongpang: Add definitions for const data members. Fixes ↵Howard Hinnant2012-12-121-0/+122
| | | | | | http://llvm.org/bugs/show_bug.cgi?id=14585. llvm-svn: 170026
* Rename uses of _ and __ because these are getting stepped on by macros from ↵Howard Hinnant2012-10-301-48/+48
| | | | | | other system code. llvm-svn: 167038
* Dimitry Andric: many visibility fixes. Howard: Much appreciated. Can you ↵Howard Hinnant2012-09-141-3/+6
| | | | | | send me a patch to CREDITS.TXT? llvm-svn: 163862
* noexcept applied to <random>.Howard Hinnant2012-07-201-8/+8
| | | | llvm-svn: 160579
* Update <random> with constexpr support. Patch contributed by Jonathan Sauer.Howard Hinnant2012-04-021-86/+103
| | | | llvm-svn: 153896
* This is an initial commit of constexpr support as proposed by Richard Smith. ↵Howard Hinnant2012-04-021-2/+2
| | | | | | This by no means completes constexpr support. Indeed, it hardly scratches the surface. All it does is lay the foundation in <__config> and changes those few places in the library that are already using that foundation. llvm-svn: 153856
* Quash a whole bunch of warningsHoward Hinnant2011-12-011-10/+15
| | | | llvm-svn: 145624
* Further macro protection by replacing _[A-Z] with _[A-Z]pHoward Hinnant2011-11-291-291/+291
| | | | llvm-svn: 145410
* Add protection from min/max macrosHoward Hinnant2011-11-291-0/+2
| | | | llvm-svn: 145407
* Windows support by Ruben Van Boxem.Howard Hinnant2011-10-171-0/+2
| | | | llvm-svn: 142235
* Fix needle-in-haystack bug found by Walter BrownHoward Hinnant2011-08-151-1/+4
| | | | llvm-svn: 137617
* Fixed PR10574: http://llvm.org/bugs/show_bug.cgi?id=10574Howard Hinnant2011-08-121-0/+22
| | | | llvm-svn: 137522
* _STD -> _VSTD to avoid macro clash on windowsHoward Hinnant2011-06-301-66/+66
| | | | llvm-svn: 134190
* Think-o in poisson_distribution at mean == 10Howard Hinnant2011-04-141-1/+1
| | | | llvm-svn: 129520
* Fix bug in Sseq constraints found by Seth CantrellHoward Hinnant2011-04-111-12/+22
| | | | llvm-svn: 129285
* LWG 1522Howard Hinnant2010-11-181-4/+4
| | | | llvm-svn: 119710
* LWG 1439Howard Hinnant2010-11-181-31/+26
| | | | llvm-svn: 119703
* license changeHoward Hinnant2010-11-161-2/+2
| | | | llvm-svn: 119395
* Patch by Marshall Clow to make the assignment operators of ↵Howard Hinnant2010-10-131-1/+38
| | | | | | piecewise_constant_distribution and piecewise_linear_distribution exception safe. llvm-svn: 116404
OpenPOWER on IntegriCloud