summaryrefslogtreecommitdiffstats
path: root/libcxx/include/support
Commit message (Collapse)AuthorAgeFilesLines
* [libcxx] [Windows] Store the lconv struct returned from localeconv in locale_tMartin Storsjö2020-02-041-4/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes using non-default locales, which currently can crash when e.g. formatting numbers. Within the localeconv_l function, the per-thread locale is temporarily changed with __libcpp_locale_guard, then localeconv() is called, returning an lconv * struct pointer. When localeconv_l returns, the __libcpp_locale_guard dtor restores the per-thread locale back to the original. This invalidates the contents of the earlier returned lconv struct, and all C strings that are pointed to within it are also invalidated. Thus, to have an actually working localeconv_l function, the function needs to allocate some sort of storage for the returned contents, that stays valid for as long as the caller needs to use the returned struct. Extend the libcxx/win32 specific locale_t class with storage for a deep copy of a lconv struct, and change localeconv_l to take a reference to the locale_t, to allow it to store the returned lconv struct there. This works fine for libcxx itself, but wouldn't necessarily be right for a caller that uses libcxx's localeconv_l function. This fixes around 11 of libcxx's currently failing tests on windows. Differential Revision: https://reviews.llvm.org/D69505 (cherry picked from commit 7db4f2c6945a24a7d81dad3362700353e2ec369e)
* [libcxx] [Windows] Make a more proper implementation of strftime_l for mingw ↵Martin Storsjö2020-01-141-1/+2
| | | | | | | | | | | | | | | | with msvcrt.dll This also makes this function consistent with the rest of the libc++ provided fallbacks. The locale support in msvcrt.dll is very limited anyway; it can only be configured processwide, not per thread, and it only seems to support the locales "C" and "" (the user set locale), so it's hard to make any meaningful automatic test for it. But manually tested, this change does make time formatting locale code in libc++ output times in the user requested format, when using locale "". Differential Revision: https://reviews.llvm.org/D69554
* [libcxx] Omit unneeded locale fallbacks on Android 21+Shoaib Meenai2019-11-251-0/+2
| | | | | | | Android API level 21 and above have all these functions available, so we don't need to include our fallback definitions. Differential Revision: https://reviews.llvm.org/D69983
* [NFC] Strip trailing whitespace from libc++Louis Dionne2019-10-232-4/+4
|
* [libc++] Remove empty header xlocale/xlocale.hLouis Dionne2019-03-111-0/+0
| | | | | | | | | | | | | | Summary: I can't think of a reason for shipping this empty header. If there is a reason to do so, then hopefully this review can uncover it. Reviewers: mclow.lists, EricWF Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D59137 llvm-svn: 355829
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1916-64/+48
| | | | | | | | | | | | | | | | | | 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
* Fix Shadowing warning on WindowsEric Fiselier2018-10-011-2/+2
| | | | llvm-svn: 343439
* [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4Jordan Rupprecht2018-07-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4 r338122 changed the linkage of some methods which revealed an existing ODR violation, e.g.: projects/libcxx/include/support/xlocale/__posix_l_fallback.h:83:38: error: 'internal_linkage' attribute does not appear on the first declaration of 'iswcntrl_l' inline _LIBCPP_INLINE_VISIBILITY int iswcntrl_l(wint_t c, locale_t) { ^ lib/include/wctype.h:55:12: note: previous definition is here extern int iswcntrl_l (wint_t, locale_t); These were added to newlib in 2.4 [1] [2], so move them to the already existing include guard. [1] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=238455adfab4f8070ac65400aac22bb8a9e502fc [2] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=8493c1631643fada62384768408852bc0fa6ff44 Reviewers: ldionne, rsmith, EricWF Subscribers: christof, cfe-commits Differential Revision: https://reviews.llvm.org/D49927 llvm-svn: 338157
* [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by ↵Louis Dionne2018-07-113-57/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | _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-053-57/+57
| | | | | | | | | | | | | | | _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-053-57/+57
| | | | | | | | | | | | | | | | | | | | 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
* [Win32] Overload ==, != for locale_t and long longPirama Arumuga Nainar2018-07-021-0/+8
| | | | | | | | | | | | | | | | Summary: _is_chartype_l (needed for isxdigit_l) in MinGW compares locale_t and NULL. NULL is 'long long' for 64-bit, and this results in ambiguous overloads when compiled with Clang. Define a concrete overload for the operators to fix the ambiguity. Reviewers: mstorsjo, EricWF, srhines, danalbert Subscribers: christof, cfe-commits, ldionne Differential Revision: https://reviews.llvm.org/D48749 llvm-svn: 336141
* Condition usage of locale stdlib functions on Android API versionPeter Collingbourne2018-05-161-7/+8
| | | | | | | | | | | | Some *_l functions were not available in some versions of Bionic. This CL checks that the NDK version supports the functions, and if not, falls back on the corresponding functions that don't take a locale. Patch by Tom Anderson! Differential Revision: https://reviews.llvm.org/D46558 llvm-svn: 332543
* support: add missing locale stubs for android L, MSaleem Abdulrasool2018-04-131-0/+37
| | | | | | | | | The strto* family was introduced in android O (API Level 26). However, the support headers were adjusted to indicate that all locale aware functions were added in L. Provide stubs for the locale aware strto* family until O. llvm-svn: 330045
* Stop using __strtonum_fallback on Android.Dan Albert2018-02-071-1/+0
| | | | | | | Fallback implementations are now provided by bionic when necessary, which these may conflict with. llvm-svn: 324534
* Allow to set locale on Windows.Martin Storsjo2017-11-231-2/+67
| | | | | | | | | | | | | | | Fix the problem PR31516 with setting locale on Windows by wrapping _locale_t with a pointer-like class. Reduces 74 test failures in std/localization test suite to 47 test failures (on llvm clang, Visual Studio 2015). Number of test failures doesn't depend on the platform (x86 or x64). Patch by Andrey Khalyavin. Differential Revision: https://reviews.llvm.org/D40181 llvm-svn: 318902
* Remove a broken win32 locale function redirectionMartin Storsjo2017-11-211-1/+0
| | | | | | | | | | | | | | | | One can't replace vsscanf(_l) with a sscanf(_l) that doesn't take a va_list. This has been untouched since it was added in SVN r140728, so apparently it hasn't been used since. One reason for this mistake originally might have been that there was no _vsscanf_l until MSVC 2015. Since it's unused, just remove this define. Differential Revision: https://reviews.llvm.org/D40323 llvm-svn: 318810
* Redirect strftime_l to the locale-ignorant strftime on mingwMartin Storsjo2017-09-061-0/+4
| | | | | | | | | | | | | | | _strftime_l is only available in the numbered msvcrt versions (starting from msvcr80.dll). In the default configuration, mingw targets the unversioned msvcrt.dll - and there, _strftime_l is not available (not even on windows 10). If __MSVCRT_VERSION__ is set to a higher value (indicating a non-default target and wanting to link to msvcrXX.dll), use the correct function. Differential Revision: https://reviews.llvm.org/D37468 llvm-svn: 312617
* PR32476: __nop_locale_mgmt.h not needed with newlib 2.5+James Y Knight2017-06-141-0/+3
| | | | | | | | | | | | | | | | | | | | Newlib 2.5 added the locale management functions, so it should not include __nop_local_mgmt.h. This change adds proper guard around that include statement. For newlib 2.4, some releases contain these functions and some don't, and they all have the same version numbers. This patch will work properly with the initial "2.4.0" release which does not include these functions and require __nop_local_mgmt.h. This has been tested against newlib 2.2 and 2.5, and also sanity checks against other different version numbers. Patch by Martin J. O'Riordan and Walter Lee Differential Revision: https://reviews.llvm.org/D32146 llvm-svn: 305394
* Fix Libc++ build with MinGW64Eric Fiselier2017-05-311-7/+8
| | | | | | | | | | | | | | Summary: This patch corrects the build errors I encountered when building on MinGW64. Reviewers: mati865, rnk, compnerd, smeenai, bcraig Reviewed By: mati865, smeenai Subscribers: martell, chapuni, cfe-commits Differential Revision: https://reviews.llvm.org/D33082 llvm-svn: 304360
* Don't interfere with the __builtin_foo namespace under MSVCEric Fiselier2017-05-101-156/+0
| | | | | | | | | This patch follows up on feedback received in the review for D32988. Specifically that libc++ should not mess with the __builtin namespace, and that libc++ should use __popcnt to implement __pop_count under MSVC. llvm-svn: 302731
* [libc++] Refactor Windows support headers.Eric Fiselier2017-05-104-88/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch refactors and tries to remove as much of the Windows support headers as possible. This is needed because they currently introduce super weird include cycles and dependencies between STL and libc headers. The changes in this patch are: * remove `support/win32/support.h` completely. The required parts have either been moved into `support/win32/msvc_support.h` (for `MSVC` only helpers not needed by Clang), or directly into their respective `foo.h` headers. * Combine `locale_win32.h` and `locale_mgmt_win32.h` into a single headers, this header should only be included within `__locale` or `locale` to avoid include cycles. * Remove the unneeded parts of `limits_win32.h` and re-name it to `limits_msvc_win32.h` since it's only needed by Clang. I've tested this patch using Clang on Windows, but I suspect it might technically regress our non-existent support for MSVC. Is somebody able to double check? This refactor is needed to support upcoming fixes to `<locale>` on Windows. Reviewers: bcraig, rmaprath, compnerd, EricWF Reviewed By: EricWF Subscribers: majnemer, cfe-commits Differential Revision: https://reviews.llvm.org/D32988 llvm-svn: 302727
* Fix DLL import/export on Win32 locale helpersEric Fiselier2017-05-081-3/+4
| | | | llvm-svn: 302391
* [libcxx] Direct support for FuchsiaPetr Hosek2017-04-131-0/+23
| | | | | | | | | | | Fuchsia's libc was forked from musl, but has evolved sufficiently since then so it no longer makes sense to pretend it's musl. This change implements direct support for Fuchsia rather than piggybacking on musl support. Differential Revision: https://reviews.llvm.org/D31970 llvm-svn: 300261
* [libc++] Drop support for CRTs older than VS 2015Shoaib Meenai2017-04-072-15/+0
| | | | | | | | | | | 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
* Add _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] macros.Eric Fiselier2017-01-061-2/+2
| | | | | | | | | | | | This patch refactors the compiler detection done in `__config` by creating a set of `_LIBCPP_COMPILER_<TYPE>` macros. The goal of this patch is to make it easier to detect what compiler is being used outside of `__config`. Additionally this patch removes workarounds for GCC in `__bit_reference`. I tested GCC 4.8 and 4.9 without the workaround and neither seemed to need it anymore. llvm-svn: 291286
* Refactor bitscan64 checkSaleem Abdulrasool2017-01-041-3/+2
| | | | | | | | Introduce a `_LIBCPP_HAS_BITSCAN64` macro to specify if the 64-bit variant of the bitscan family of APIs is available. This avoids duplicating the check in the support header. llvm-svn: 290924
* clean up use of _WIN32Saleem Abdulrasool2017-01-031-8/+6
| | | | | | | | | Replace the use of _WIN32 in libc++. Replace most use with a C runtime check _LIBCPP_MSVCRT or the new _LIBCPP_WIN32 to indicate that we are using the Win32 API. Use a new _LIBCPP_WCHAR_IS_UCS2 to indicate that we are on an environment that has a short wchar_t. llvm-svn: 290910
* locale: update ctype access for MSVC CRT 14+Saleem Abdulrasool2017-01-021-1/+5
| | | | | | | | | | | Visual C++ 14 and newer split msvcrt into msvcrt and ucrt with flavours of the ucrt for different environments. This changed the access to the ctype table by introducing the `__pctype_func` and `__pwctype_func` accessors. Use this rather than directly accessing `_ctype` which allows us to be safer in threaded situations by going through the libc locking. llvm-svn: 290823
* [libc++] Add missing locale aliasesShoaib Meenai2016-09-291-2/+3
| | | | | | | | | Add underscore aliases for strtof_l and strtod_l. _strtold_l exists in VS 2013 and above, so fix that definition as a drive-by fix. Differential Revision: https://reviews.llvm.org/D25059 llvm-svn: 282681
* [libc++] Remove math_win32.hShoaib Meenai2016-09-241-117/+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 signatures of fallback tow(upper|lower)_l.Dan Albert2016-09-191-2/+2
| | | | | | | | | | | | | | Summary: These functions take and return wint_t, not int: http://pubs.opengroup.org/onlinepubs/9699919799/functions/towupper.html Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24743 llvm-svn: 281936
* Replace __ANDROID__ with __BIONIC__.Dan Albert2016-09-191-2/+2
| | | | | | | | | | | | | | | Summary: None of these checks are specific to Android devices. If libc++ was used with Bionic on a normal Linux system these checks would still be needed. Reviewers: mclow.lists, EricWF Subscribers: compnerd, tberghammer, danalbert, srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D24690 llvm-svn: 281921
* [libc++] Avoid <memory> include in locale_win32.hShoaib Meenai2016-09-151-5/+1
| | | | | | | | | | | | | | | | | | | | | | | When `_LIBCPP_NO_EXCEPTIONS` is defined, we end up with compile errors when targeting MSVCRT: * Code includes `<new>` * `<new>` includes `<cstdlib>` in order to get `abort` * `<cstdlib>` includes `<stdlib.h>`, _before_ the `using ::abort` * `<stdlib.h>` includes `locale_win32.h` * `locale_win32.h` includes `<memory>` * `<memory>` includes `<stdexcept>` * `<stdexcept>` includes `<cstdlib` for `abort`, but that inclusion gets (correctly) ignored because of header guards * `<stdexcept>` references `_VSTD::abort`, which isn't declared The easiest solution is to make `locale_win32.h` not include `<memory>`, by removing the use of `unique_ptr` and manually restoring the locale instead. Differential Revision: https://reviews.llvm.org/D24374 llvm-svn: 281641
* support: clean up MSVC supportSaleem Abdulrasool2016-09-081-20/+2
| | | | | | | | | | | Visual Studio 2013 (CRT version 12) added support for many C99 long long and long double functions. Visual Studio 2015 (CRT version 14) increased C99 and C11 compliance further. Since we don't support Visual Studio versions older than 2013, we can considerably clean up the support header. Patch by Shoaib Meenai! llvm-svn: 280988
* Implement LWG issue 1169. num_get not fully compatible with strto*Eric Fiselier2016-06-192-5/+26
| | | | | | | | | | | Use strtof and strtod for floats and doubles respectively instead of always using strtold. The other parts of the change are already implemented in libc++. This patch also has a drive by fix to wbuffer_convert::underflow() which prevents it from calling memmove(buff, null, 0). llvm-svn: 273106
* Reorganize locale extension fallbacks. NFCIBen Craig2016-05-205-207/+225
| | | | | | | | | | | | | | | | | | | | | | | The various _l locale extension functions originate from very different places. Some come from POSIX, some are BSD extensions, and some are shared BSD and GLIBC extensions. This patch tries to group the local extension reimplementations by source. This should make it easier to make libcxx work with POSIX compliant C libraries that lack these extensions. The fallback locale functions are also useful on their own for other lightweight platforms. Putting these fallback implementations in support/xlocale should enable code sharing. I have no access to a newlib system or an android system to build and test with. I _do_ have access to a system without any of the _l locale extensions though, and I was able to ensure that the new __posix_l_fallback.h and __strtonum_fallback.h didn't have any massive problems. http://reviews.llvm.org/D17416 llvm-svn: 270213
* Split locale management out of locale_win32. NFCIBen Craig2016-03-092-18/+35
| | | | | | | | | | | | | | | | | | For the locale refactor, the locale management functions (newlocale, freelocale, uselocale) are needed in a separate header from the various _l functions. This is because some platforms implement the _l functions in terms of a locale switcher RAII helper, and the locale switcher RAII helper needs the locale management functions. This patch helps pave the way by getting all the functions in the right files, so that later diffs aren't completely horrible. Unfortunately, the Windows, Cygwin, and MinGW builds seemed to have bit-rotted, so I wasn't able to test this completely. I don't think I made things any worse than they already are though. http://reviews.llvm.org/D17419 llvm-svn: 263020
* Split locale management out of newlib/xlocale.h. NFCIBen Craig2016-02-182-30/+53
| | | | | | | | | | | | | | | | | | | | | | | This is one part of many of a locale refactor. See http://reviews.llvm.org/D17146 for an idea of where this is going. For the locale refactor, the locale management functions (newlocale, freelocale, uselocale) are needed in a separate header from the various _l functions. This is because some platforms implement the _l functions in terms of a locale switcher RAII helper, and the locale switcher RAII helper needs the locale management functions. This patch helps pave the way by getting all the functions in the right files, so that later diffs aren't completely horrible. The "do-nothing" / "nop" locale functions are also useful on their own for other lightweight platforms. Putting these nop implementations in support/xlocale should enable code sharing. Unfortunately, I have no access to a newlib system to build and test with, so this change has been made blind. Reviewed: http://reviews.llvm.org/D17382 llvm-svn: 261231
* Split locale management out of ibm/xlocale.h. NFCIBen Craig2016-02-182-56/+86
| | | | | | | | | | | | | | | | | | | | This is one part of many of a locale refactor. See http://reviews.llvm.org/D17146 for an idea of where this is going. For the locale refactor, the locale management functions (newlocale, freelocale, uselocale) are needed in a separate header from the various _l functions. This is because some platforms implement the _l functions in terms of a locale switcher RAII helper, and the locale switcher RAII helper needs the locale management functions. This patch helps pave the way by getting all the functions in the right files, so that later diffs aren't completely horrible. Unfortunately, I have no access to an AIX machine to build with, so this change has been made blind. Also, the original author (Xing Xue) does not appear to have a Phabricator account. Reviewed: http://reviews.llvm.org/D17380 llvm-svn: 261230
* Add initial support for the MUSL C library.Vasileios Kalintiris2015-11-091-0/+58
| | | | | | | | | | | | | | | | | | | Summary: This patch adds the LIBCXX_LIBC_IS_MUSL cmake option to allow the building of libcxx with the Musl C library. The option is necessary as Musl does not provide any predefined macro in order to test for its presence, like GLIBC. Most of the changes specify the correct path to choose through the various #if/#else constructs in the locale code. Depends on D13407. Reviewers: mclow.lists, jroelofs, EricWF Subscribers: jfb, tberghammer, danalbert, srhines, cfe-commits Differential Revision: http://reviews.llvm.org/D13673 llvm-svn: 252457
* cmath: account for MSVCRT 12.0 changesSaleem Abdulrasool2015-02-281-1/+3
| | | | | | | | | | | | | | MSVCRT 12.0 introduces better compatibility for C99. This includes a number of math routines that were previously undefined. Use the crtversion.h header to detect the version of MSVCRT being targeted and avoid re-declaring the variables. Since copysign has been introduced in MSVCRT, importing the definition via using makes it difficult to provide overloads (due to minor differences between throw () and noexcept. Avoid defining the overloads on newer MSVCRT targets. llvm-svn: 230867
* Get libc++ building on Sun Solaris. Patch from C Bergstrom.Eric Fiselier2015-01-231-93/+3
| | | | llvm-svn: 226947
* Fixes to get libc++ building on sun solaris. Patch from C Bergstrom.Eric Fiselier2014-11-251-0/+2
| | | | llvm-svn: 222794
* Fix win32 support header for mingw32.Dan Albert2014-10-061-0/+3
| | | | | | These functions are defined as static in the mingw32 headers. llvm-svn: 219140
* Support newlib as libc++'s C library [locale part]Jonathan Roelofs2014-09-193-165/+261
| | | | | | http://reviews.llvm.org/D5385 llvm-svn: 218144
* Add support for BIONIC C library (Android). Patch from Dan AlbertMarshall Clow2014-07-101-0/+192
| | | | llvm-svn: 212724
* Add license headers to a bunch of libc++ files that were missing them. No ↵Marshall Clow2014-01-163-0/+27
| | | | | | functionality change. Fixes 18291. Thanks to Nico for the bug report and the patch. llvm-svn: 199400
* 80 cols fixes.Yaron Keren2014-01-041-99/+123
| | | | llvm-svn: 198482
* Implement the functions: clz, clzl, clzll, ctz, ctzl, and ctzllYaron Keren2014-01-041-27/+88
| | | | | | | | for libcxx when compiled with Visual C++ on Win32 and Win64. clang and gcc (MinGW) compilers provide these implementations themselves. llvm-svn: 198481
OpenPOWER on IntegriCloud