Index: include/__locale =================================================================== --- include/__locale +++ include/__locale @@ -19,7 +19,7 @@ #include #include #include -#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) +#if defined(_LIBCPP_WIN32API) # include #elif defined(_AIX) # include @@ -367,7 +367,7 @@ static const mask punct = _ISpunct; static const mask xdigit = _ISxdigit; static const mask blank = _ISblank; -#elif defined(_LIBCPP_MSVCRT) +#elif defined(_LIBCPP_WIN32API) typedef unsigned short mask; static const mask space = _SPACE; static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT; Index: include/locale =================================================================== --- include/locale +++ include/locale @@ -192,7 +192,8 @@ #endif #include #include -#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) +#include +#if defined(_LIBCPP_WIN32API) #include #elif defined(_NEWLIB_VERSION) // FIXME: replace all the uses of _NEWLIB_VERSION with __NEWLIB__ preceded by an Index: include/stdio.h =================================================================== --- include/stdio.h +++ include/stdio.h @@ -110,10 +110,12 @@ #ifdef __cplusplus // snprintf -#if defined(_LIBCPP_MSVCRT) +#if defined(_LIBCPP_WIN32API) extern "C" { -int vasprintf(char **sptr, const char *__restrict fmt, va_list ap); +#if defined(_LIBCPP_MSVCRT) int asprintf(char **sptr, const char *__restrict fmt, ...); +#endif +int vasprintf(char **sptr, const char *__restrict fmt, va_list ap); } #endif Index: include/support/win32/locale_win32.h =================================================================== --- include/support/win32/locale_win32.h +++ include/support/win32/locale_win32.h @@ -52,20 +52,21 @@ size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc); wint_t btowc_l( int c, locale_t loc ); int wctob_l( wint_t c, locale_t loc ); -inline _LIBCPP_ALWAYS_INLINE -decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ) -{ - return ___mb_cur_max_l_func(__l); -} + +decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ); // the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+ #define mbtowc_l _mbtowc_l #define strtoll_l _strtoi64_l #define strtoull_l _strtoui64_l -#define strtof_l _strtof_l #define strtod_l _strtod_l +#if defined(_LIBCPP_MSVCRT) +#define strtof_l _strtof_l #define strtold_l _strtold_l - +#else +float strtof_l(const char*, char**, locale_t); +long double strtold_l(const char*, char**, locale_t); +#endif inline _LIBCPP_INLINE_VISIBILITY int islower_l(int c, _locale_t loc) Index: include/wchar.h =================================================================== --- include/wchar.h +++ include/wchar.h @@ -166,7 +166,7 @@ } #endif -#if defined(__cplusplus) && defined(_LIBCPP_MSVCRT) +#if defined(__cplusplus) && defined(_LIBCPP_WIN32API) // Needed in MinGW as well extern "C" { size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src, size_t nmc, size_t len, mbstate_t *__restrict ps); Index: src/new.cpp =================================================================== --- src/new.cpp +++ src/new.cpp @@ -183,7 +183,7 @@ if (static_cast(alignment) < sizeof(void*)) alignment = std::align_val_t(sizeof(void*)); void* p; -#if defined(_LIBCPP_MSVCRT) +#if defined(_LIBCPP_WIN32API) while ((p = _aligned_malloc(size, static_cast(alignment))) == nullptr) #else while (::posix_memalign(&p, static_cast(alignment), size) != 0) @@ -256,7 +256,7 @@ operator delete(void* ptr, std::align_val_t) _NOEXCEPT { if (ptr) -#if defined(_LIBCPP_MSVCRT) +#if defined(_LIBCPP_WIN32API) ::_aligned_free(ptr); #else ::free(ptr); Index: src/support/win32/locale_win32.cpp =================================================================== --- src/support/win32/locale_win32.cpp +++ src/support/win32/locale_win32.cpp @@ -34,6 +34,18 @@ // uselocale returns the old locale_t return old_locale; } + +decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ) +{ +#if defined(_LIBCPP_MSVCRT) + return ___mb_cur_max_l_func(__l); +#else + __libcpp_locale_guard __current(__l); + return MB_CUR_MAX; +#endif +} + + lconv *localeconv_l( locale_t loc ) { __libcpp_locale_guard __current(loc); @@ -109,3 +121,15 @@ __libcpp_locale_guard __current(loc); return vasprintf( ret, format, ap ); } + +#ifndef _LIBCPP_MSVCRT +float strtof_l(const char* nptr, char** endptr, locale_t loc) { + __libcpp_locale_guard __current(loc); + return strtof(nptr, endptr); +} + +long double strtold_l(const char* nptr, char** endptr, locale_t loc) { + __libcpp_locale_guard __current(loc); + return strtold(nptr, endptr); +} +#endif Index: src/support/win32/support.cpp =================================================================== --- src/support/win32/support.cpp +++ src/support/win32/support.cpp @@ -16,7 +16,7 @@ #include // mbstate_t // Some of these functions aren't standard or if they conform, the name does not. - +#if defined(_LIBCPP_MSVCRT) int asprintf(char **sptr, const char *__restrict format, ...) { va_list ap; @@ -26,6 +26,7 @@ va_end(ap); return result; } +#endif // Like sprintf, but when return value >= 0 it returns // a pointer to a malloc'd string in *sptr. Index: src/system_error.cpp =================================================================== --- src/system_error.cpp +++ src/system_error.cpp @@ -65,7 +65,7 @@ string do_strerror_r(int ev); -#if defined(_LIBCPP_MSVCRT) +#if defined(_LIBCPP_WIN32API) string do_strerror_r(int ev) { char buffer[strerror_buff_size]; if (::strerror_s(buffer, strerror_buff_size, ev) == 0)