llvm-capstone/libcxx/include/support
Martin Storsjö 7db4f2c694 [libcxx] [Windows] Store the lconv struct returned from localeconv in locale_t
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
2020-01-29 22:37:11 +02:00
..
android [libcxx] Omit unneeded locale fallbacks on Android 21+ 2019-11-25 11:06:08 -08:00
fuchsia
ibm [NFC] Strip trailing whitespace from libc++ 2019-10-23 11:19:19 -07:00
musl
newlib
solaris [NFC] Strip trailing whitespace from libc++ 2019-10-23 11:19:19 -07:00
win32 [libcxx] [Windows] Store the lconv struct returned from localeconv in locale_t 2020-01-29 22:37:11 +02:00
xlocale [libc++] Remove empty header xlocale/xlocale.h 2019-03-11 15:41:51 +00:00