summaryrefslogtreecommitdiffstats
path: root/libcxx/include/support/win32
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
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-192-8/+6
| | | | | | | | | | | | | | | | | | 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
* [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
* 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
* 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
* [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
* [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
* 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
* 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
* 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
* 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
* This patch implements snprintf_l function in a way similar to the other Yaron Keren2013-11-181-1/+1
| | | | | | | | | | | functions in src/support/win32/locale_win32.cpp and locale_win32.h, calling upon vsnprintf for which there is a MingW correct alternative. Note! __USE_MINGW_ANSI_STDIO is not modified in this patch. In order to use the __mingw version it must be defined before including the MingW headers. llvm-svn: 195044
* Windows.h is not required.Yaron Keren2013-11-151-1/+0
| | | | llvm-svn: 194870
* Yaron Keren: Add missing comment.Howard Hinnant2013-10-061-1/+1
| | | | llvm-svn: 192068
* G M: Changes all references to "x inline" to "inline x" where x = ↵Howard Hinnant2013-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | _libcpp_always_inline or _libcpp_inline_visibility macros. The patch touches these files: locale array deque new string utility vector __bit_reference __split_buffer locale_win32.h There is no intended functionality change and it is expected that reversing the position of the inline keyword with regard to the other keywords does not change the meaning of anything, least not for apple/Linux etc. It is intended to make libcxx more consistent with itself and to prevent the 1000 or so "inline.cpp(3) : warning C4141: 'inline' : used more than once" warnings that MS's cl.exe compiler emits without this patch, i.e. if inline is not the first keyword before a function name etc. Prefer "inline [other inline related keyword]" over "[other related keyword] inline". After this patch, libcxx should be consistent to this pattern. llvm-svn: 191987
* G M: Restore the ability for libcxx to compile again on mingw 64.Howard Hinnant2013-09-174-21/+28
| | | | llvm-svn: 190837
* Nico Rieck: Currently _MSC_VER and _WIN32 are used to guard code which isHoward Hinnant2013-08-013-8/+8
| | | | | | | | | | | | | | | | | | | | | | MSVC-specific, MSVCRT-specific, or Windows-specific. Because Clang can also define _MSC_VER, and MSVCRT is not necessarily the only C runtime, these macros should not be used interchangeably. This patch divides all Windows-related bits into the aforementioned categories. Two new macros are introduced: - _LIBCPP_MSVC: Defined when compiling with MSVC. Detected using _MSC_VER, excluding Clang. - _LIBCPP_MSVCRT: Defined when using the Microsoft CRT. This is the default when _WIN32 is defined. This leaves _WIN32 for code using the Windows API. This also corrects the spelling of _LIBCP_HAS_IS_BASE_OF to _LIBCPP_HAS_IS_BASE_OF. Nico, please prepare a patch for CREDITS.TXT, thanks. llvm-svn: 187593
* Glen: This patch gets the string conversion functions working on Windows. ↵Howard Hinnant2013-05-161-9/+8
| | | | | | It also refactors repetitive code in string.cpp do greatly reduce the repetitiveness, increasing maintainability. llvm-svn: 182026
* Ruben Van Boxem: Turn islower_l and isupper_l into functions (instead of ↵Howard Hinnant2013-04-121-2/+15
| | | | | | macros) on Windows only to quell a warning during libc++ building. llvm-svn: 179408
* Add missing newlines at EOF.Bob Wilson2012-02-202-2/+2
| | | | llvm-svn: 150965
* Fix http://llvm.org/bugs/show_bug.cgi?id=11428. Fix provided by Alberto ↵Howard Hinnant2011-12-021-5/+5
| | | | | | Ganesh Barbati llvm-svn: 145698
* Jean-Daniel: __builtin_popcountll support for WindowsHoward Hinnant2011-12-021-3/+26
| | | | llvm-svn: 145684
* Windows port work by Ruben Van BoxemHoward Hinnant2011-10-273-7/+123
| | | | llvm-svn: 143105
* More windows port work by Ruben Van BoxemHoward Hinnant2011-10-222-15/+85
| | | | llvm-svn: 142732
* Windows port work by Ruben Van BoxemHoward Hinnant2011-10-201-0/+73
| | | | llvm-svn: 142578
* Windows port work by Ruben Van BoxemHoward Hinnant2011-09-291-4/+4
| | | | llvm-svn: 140805
* Windows patch work by Ruben Van BoxemHoward Hinnant2011-09-291-0/+5
| | | | llvm-svn: 140781
* Work on Windows port by Ruben Van BoxemHoward Hinnant2011-09-282-34/+75
| | | | llvm-svn: 140728
* Work on Windows port by Ruben Van BoxemHoward Hinnant2011-09-232-4/+47
| | | | llvm-svn: 140384
* Partial Windows port by Ruben Van BoxemHoward Hinnant2011-09-222-0/+52
llvm-svn: 140328
OpenPOWER on IntegriCloud