diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -524,9 +524,6 @@ __support/musl/xlocale.h __support/newlib/xlocale.h __support/openbsd/xlocale.h - __support/solaris/floatingpoint.h - __support/solaris/wchar.h - __support/solaris/xlocale.h __support/win32/locale_win32.h __support/xlocale/__nop_locale_mgmt.h __support/xlocale/__posix_l_fallback.h diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -321,15 +321,6 @@ # define _LIBCPP_HAS_OPEN_WITH_WCHAR # endif // defined(_WIN32) -# ifdef __sun__ -# include -# ifdef _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else -# define _LIBCPP_BIG_ENDIAN -# endif -# endif // __sun__ - # if defined(_AIX) && !defined(__64BIT__) // The size of wchar is 2 byte on 32-bit mode on AIX. # define _LIBCPP_SHORT_WCHAR 1 @@ -374,7 +365,7 @@ // When this option is used, the token passed to `std::random_device`'s // constructor *must* be "/dev/urandom" -- anything else is an error. # if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ - defined(__DragonFly__) || defined(__sun__) + defined(__DragonFly__) # define _LIBCPP_USING_ARC4_RANDOM # elif defined(__wasi__) || defined(__EMSCRIPTEN__) # define _LIBCPP_USING_GETENTROPY @@ -695,8 +686,7 @@ # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) # endif // _LIBCPP_CXX03_LANG -# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \ - defined(__NetBSD__) +# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__) # define _LIBCPP_LOCALE__L_EXTENSIONS 1 # endif @@ -724,7 +714,7 @@ # define _LIBCPP_HAS_DEFAULTRUNELOCALE # endif -# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) +# if defined(__APPLE__) || defined(__FreeBSD__) # define _LIBCPP_WCTYPE_IS_MASK # endif @@ -881,7 +871,6 @@ defined(__linux__) || \ defined(__GNU__) || \ defined(__APPLE__) || \ - defined(__sun__) || \ defined(__MVS__) || \ defined(_AIX) || \ defined(__EMSCRIPTEN__) diff --git a/libcxx/include/__locale b/libcxx/include/__locale --- a/libcxx/include/__locale +++ b/libcxx/include/__locale @@ -28,9 +28,6 @@ # include <__support/ibm/xlocale.h> #elif defined(__ANDROID__) # include <__support/android/locale_bionic.h> -#elif defined(__sun__) -# include <__support/solaris/xlocale.h> -# include #elif defined(_NEWLIB_VERSION) # include <__support/newlib/xlocale.h> #elif defined(__OpenBSD__) @@ -482,7 +479,7 @@ static const mask blank = _CTYPE_B; static const mask __regex_word = 0x80; # endif -#elif defined(__sun__) || defined(_AIX) +#elif defined(_AIX) typedef unsigned int mask; static const mask space = _ISSPACE; static const mask print = _ISPRINT; @@ -494,11 +491,7 @@ static const mask punct = _ISPUNCT; static const mask xdigit = _ISXDIGIT; static const mask blank = _ISBLANK; -# if defined(_AIX) static const mask __regex_word = 0x8000; -# else - static const mask __regex_word = 0x80; -# endif #elif defined(_NEWLIB_VERSION) // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. typedef char mask; diff --git a/libcxx/include/math.h b/libcxx/include/math.h --- a/libcxx/include/math.h +++ b/libcxx/include/math.h @@ -538,10 +538,8 @@ // acos -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return ::acosf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return ::acosl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -550,10 +548,8 @@ // asin -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return ::asinf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return ::asinl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -562,10 +558,8 @@ // atan -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return ::atanf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return ::atanl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -574,10 +568,8 @@ // atan2 -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return ::atan2f(__y, __x);} inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {return ::atan2l(__y, __x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -597,10 +589,8 @@ // ceil -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return ::ceilf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return ::ceill(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -609,10 +599,8 @@ // cos -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return ::cosf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return ::cosl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -621,10 +609,8 @@ // cosh -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return ::coshf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return ::coshl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -633,10 +619,8 @@ // exp -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return ::expf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return ::expl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -645,10 +629,8 @@ // fabs -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return ::fabsf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return ::fabsl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -657,10 +639,8 @@ // floor -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return ::floorf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return ::floorl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -669,10 +649,8 @@ // fmod -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return ::fmodf(__x, __y);} inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT {return ::fmodl(__x, __y);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -692,10 +670,8 @@ // frexp -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return ::frexpf(__x, __e);} inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return ::frexpl(__x, __e);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -704,10 +680,8 @@ // ldexp -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return ::ldexpf(__x, __e);} inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return ::ldexpl(__x, __e);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -716,10 +690,8 @@ // log -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return ::logf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return ::logl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -728,10 +700,8 @@ // log10 -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return ::log10f(__x);} inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return ::log10l(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -740,17 +710,13 @@ // modf -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return ::modff(__x, __y);} inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT {return ::modfl(__x, __y);} -# endif // pow -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return ::powf(__x, __y);} inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {return ::powl(__x, __y);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -770,7 +736,6 @@ // sin -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return ::sinf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return ::sinl(__x);} #endif @@ -782,10 +747,8 @@ // sinh -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return ::sinhf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return ::sinhl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -794,10 +757,8 @@ // sqrt -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return ::sqrtf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return ::sqrtl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -806,10 +767,8 @@ // tan -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return ::tanf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return ::tanl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI @@ -818,10 +777,8 @@ // tanh -# if !defined(__sun__) inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return ::tanhf(__x);} inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return ::tanhl(__x);} -# endif template inline _LIBCPP_HIDE_FROM_ABI diff --git a/libcxx/include/stdlib.h b/libcxx/include/stdlib.h --- a/libcxx/include/stdlib.h +++ b/libcxx/include/stdlib.h @@ -109,16 +109,15 @@ #endif // MSVCRT already has the correct prototype in if __cplusplus is defined -#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) +#if !defined(_LIBCPP_MSVCRT) inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } -#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) +#endif // !defined(_LIBCPP_MSVCRT) -#if !defined(__sun__) inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT { return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h } @@ -131,7 +130,6 @@ abs(long double __lcpp_x) _NOEXCEPT { return __builtin_fabsl(__lcpp_x); } -#endif // !defined(__sun__) // div @@ -146,7 +144,7 @@ #endif // MSVCRT already has the correct prototype in if __cplusplus is defined -#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) +#if !defined(_LIBCPP_MSVCRT) inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); } @@ -156,7 +154,7 @@ return ::lldiv(__x, __y); } #endif -#endif // _LIBCPP_MSVCRT / __sun__ +#endif // _LIBCPP_MSVCRT } // extern "C++" #endif // __cplusplus diff --git a/libcxx/include/string.h b/libcxx/include/string.h --- a/libcxx/include/string.h +++ b/libcxx/include/string.h @@ -64,8 +64,7 @@ // MSVCRT, GNU libc and its derivates may already have the correct prototype in // . This macro can be defined by users if their C library provides // the right signature. -#if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \ - defined(__sun__) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) +#if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) #define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS #endif diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt --- a/libcxx/src/CMakeLists.txt +++ b/libcxx/src/CMakeLists.txt @@ -101,12 +101,6 @@ support/win32/thread_win32.cpp ) endif() -elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS") - list(APPEND LIBCXX_SOURCES - support/solaris/mbsnrtowcs.inc - support/solaris/wcsnrtombs.inc - support/solaris/xlocale.cpp - ) elseif(ZOS) list(APPEND LIBCXX_SOURCES support/ibm/mbsnrtowcs.cpp diff --git a/libcxx/src/include/config_elast.h b/libcxx/src/include/config_elast.h --- a/libcxx/src/include/config_elast.h +++ b/libcxx/src/include/config_elast.h @@ -35,8 +35,6 @@ #define _LIBCPP_ELAST 4095 #elif defined(__APPLE__) // No _LIBCPP_ELAST needed on Apple -#elif defined(__sun__) -#define _LIBCPP_ELAST ESTALE #elif defined(__MVS__) #define _LIBCPP_ELAST 1160 #elif defined(_LIBCPP_MSVCRT_LIKE) diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -6,12 +6,6 @@ // //===----------------------------------------------------------------------===// -// On Solaris, we need to define something to make the C99 parts of localeconv -// visible. -#ifdef __sun__ -#define _LCONV_C99 -#endif - #include <__utility/unreachable.h> #include #include @@ -1189,8 +1183,6 @@ return _C_ctype_tab_ + 1; #elif defined(__GLIBC__) return _LIBCPP_GET_C_LOCALE->__ctype_b; -#elif defined(__sun__) - return __ctype_mask; #elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) return __pctype_func(); #elif defined(__EMSCRIPTEN__) @@ -1411,10 +1403,8 @@ if (iswxdigit_l(ch, __l_)) *vec |= xdigit; #endif -#if !defined(__sun__) if (iswblank_l(ch, __l_)) *vec |= blank; -#endif } } return low; diff --git a/libcxx/src/random.cpp b/libcxx/src/random.cpp --- a/libcxx/src/random.cpp +++ b/libcxx/src/random.cpp @@ -17,10 +17,6 @@ #include #include -#if defined(__sun__) -# define rename solaris_headers_are_broken -#endif // defined(__sun__) - #include #include #include diff --git a/libcxx/src/support/solaris/README b/libcxx/src/support/solaris/README deleted file mode 100644 --- a/libcxx/src/support/solaris/README +++ /dev/null @@ -1,4 +0,0 @@ -This directory contains a partial implementation of the xlocale APIs for -Solaris. Some portions are lifted from FreeBSD libc, and so are covered by a -2-clause BSD license instead of the MIT/UUIC license that the rest of libc++ is -distributed under. diff --git a/libcxx/src/support/solaris/mbsnrtowcs.inc b/libcxx/src/support/solaris/mbsnrtowcs.inc deleted file mode 100644 --- a/libcxx/src/support/solaris/mbsnrtowcs.inc +++ /dev/null @@ -1,76 +0,0 @@ - - -/*- - * As noted in the source, some portions of this implementation are copied from - * FreeBSD libc. These are covered by the following copyright: - * - * Copyright (c) 2002-2004 Tim J. Robbins. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -size_t -mbsnrtowcs_l(wchar_t * __restrict dst, const char ** __restrict src, - size_t nms, size_t len, mbstate_t * __restrict ps, locale_t loc) -{ - const char *s; - size_t nchr; - wchar_t wc; - size_t nb; - FIX_LOCALE(loc); - - s = *src; - nchr = 0; - - if (dst == NULL) { - for (;;) { - if ((nb = mbrtowc_l(&wc, s, nms, ps, loc)) == (size_t)-1) - /* Invalid sequence - mbrtowc() sets errno. */ - return ((size_t)-1); - else if (nb == 0 || nb == (size_t)-2) - return (nchr); - s += nb; - nms -= nb; - nchr++; - } - /*NOTREACHED*/ - } - - while (len-- > 0) { - if ((nb = mbrtowc_l(dst, s, nms, ps, loc)) == (size_t)-1) { - *src = s; - return ((size_t)-1); - } else if (nb == (size_t)-2) { - *src = s + nms; - return (nchr); - } else if (nb == 0) { - *src = NULL; - return (nchr); - } - s += nb; - nms -= nb; - nchr++; - dst++; - } - *src = s; - return (nchr); -} diff --git a/libcxx/src/support/solaris/wcsnrtombs.inc b/libcxx/src/support/solaris/wcsnrtombs.inc deleted file mode 100644 --- a/libcxx/src/support/solaris/wcsnrtombs.inc +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * Copyright (c) 2002-2004 Tim J. Robbins. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - -size_t -wcsnrtombs_l(char * __restrict dst, const wchar_t ** __restrict src, - size_t nwc, size_t len, mbstate_t * __restrict ps, locale_t loc) -{ - FIX_LOCALE(loc); - mbstate_t mbsbak; - char buf[MB_CUR_MAX_L(loc)]; - const wchar_t *s; - size_t nbytes; - size_t nb; - - s = *src; - nbytes = 0; - - if (dst == NULL) { - while (nwc-- > 0) { - if ((nb = wcrtomb_l(buf, *s, ps, loc)) == (size_t)-1) - /* Invalid character - wcrtomb() sets errno. */ - return ((size_t)-1); - else if (*s == L'\0') - return (nbytes + nb - 1); - s++; - nbytes += nb; - } - return (nbytes); - } - - while (len > 0 && nwc-- > 0) { - if (len > (size_t)MB_CUR_MAX_L(loc)) { - /* Enough space to translate in-place. */ - if ((nb = wcrtomb_l(dst, *s, ps, loc)) == (size_t)-1) { - *src = s; - return ((size_t)-1); - } - } else { - /* - * May not be enough space; use temp. buffer. - * - * We need to save a copy of the conversion state - * here so we can restore it if the multibyte - * character is too long for the buffer. - */ - mbsbak = *ps; - if ((nb = wcrtomb_l(buf, *s, ps, loc)) == (size_t)-1) { - *src = s; - return ((size_t)-1); - } - if (nb > (int)len) { - /* MB sequence for character won't fit. */ - *ps = mbsbak; - break; - } - memcpy(dst, buf, nb); - } - if (*s == L'\0') { - *src = NULL; - return (nbytes + nb - 1); - } - s++; - dst += nb; - len -= nb; - nbytes += nb; - } - *src = s; - return (nbytes); -} diff --git a/libcxx/src/support/solaris/xlocale.cpp b/libcxx/src/support/solaris/xlocale.cpp deleted file mode 100644 --- a/libcxx/src/support/solaris/xlocale.cpp +++ /dev/null @@ -1,68 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifdef __sun__ - -#include "__support/solaris/xlocale.h" -#include -#include -#include - -extern "C" { - -int isxdigit_l(int __c, locale_t __l) { - return isxdigit(__c); -} - -int iswxdigit_l(wint_t __c, locale_t __l) { - return isxdigit(__c); -} - -// FIXME: This disregards the locale, which is Very Wrong -#define vsnprintf_l(__s, __n, __l, __format, __va) \ - vsnprintf(__s, __n, __format, __va) - -int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) -{ - va_list __va; - va_start(__va, __format); - int __res = vsnprintf_l(__s, __n , __l, __format, __va); - va_end(__va); - return __res; -} - -int asprintf_l(char **__s, locale_t __l, const char *__format, ...) { - va_list __va; - va_start(__va, __format); - // FIXME: - int __res = vasprintf(__s, __format, __va); - va_end(__va); - return __res; -} - -int sscanf_l(const char *__s, locale_t __l, const char *__format, ...) { - va_list __va; - va_start(__va, __format); - // FIXME: - int __res = vsscanf(__s, __format, __va); - va_end(__va); - return __res; -} - -size_t mbrtowc_l(wchar_t *__pwc, const char *__pmb, - size_t __max, mbstate_t *__ps, locale_t __loc) { - return mbrtowc(__pwc, __pmb, __max, __ps); -} - -struct lconv *localeconv_l(locale_t __l) { - return localeconv(); -} - -}; - -#endif // __sun__