diff options
Diffstat (limited to 'include/support')
-rw-r--r-- | include/support/android/locale_bionic.h | 4 | ||||
-rw-r--r-- | include/support/ibm/locale_mgmt_aix.h | 85 | ||||
-rw-r--r-- | include/support/ibm/xlocale.h | 57 | ||||
-rw-r--r-- | include/support/newlib/xlocale.h | 44 | ||||
-rw-r--r-- | include/support/solaris/xlocale.h | 20 | ||||
-rw-r--r-- | include/support/win32/locale_mgmt_win32.h | 33 | ||||
-rw-r--r-- | include/support/win32/locale_win32.h | 20 | ||||
-rw-r--r-- | include/support/xlocale/__nop_locale_mgmt.h | 52 | ||||
-rw-r--r-- | include/support/xlocale/__posix_l_fallback.h | 165 | ||||
-rw-r--r-- | include/support/xlocale/__strtonum_fallback.h | 67 | ||||
-rw-r--r-- | include/support/xlocale/xlocale.h | 194 |
11 files changed, 425 insertions, 316 deletions
diff --git a/include/support/android/locale_bionic.h b/include/support/android/locale_bionic.h index 3a020da67e6b..1365563ee481 100644 --- a/include/support/android/locale_bionic.h +++ b/include/support/android/locale_bionic.h @@ -24,8 +24,8 @@ extern "C" { } #endif -// Share implementation with Newlib -#include <support/xlocale/xlocale.h> +#include <support/xlocale/__posix_l_fallback.h> +#include <support/xlocale/__strtonum_fallback.h> #endif // defined(__ANDROID__) #endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H diff --git a/include/support/ibm/locale_mgmt_aix.h b/include/support/ibm/locale_mgmt_aix.h new file mode 100644 index 000000000000..e3b7a78c45a0 --- /dev/null +++ b/include/support/ibm/locale_mgmt_aix.h @@ -0,0 +1,85 @@ +// -*- C++ -*- +//===------------------- support/ibm/locale_mgmt_aix.h --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H +#define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H + +#if defined(_AIX) +#include "cstdlib" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_AIX71) +// AIX 7.1 and higher has these definitions. Definitions and stubs +// are provied here as a temporary workaround on AIX 6.1. + +#define LC_COLLATE_MASK 1 +#define LC_CTYPE_MASK 2 +#define LC_MESSAGES_MASK 4 +#define LC_MONETARY_MASK 8 +#define LC_NUMERIC_MASK 16 +#define LC_TIME_MASK 32 +#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \ + LC_MESSAGES_MASK | LC_MONETARY_MASK |\ + LC_NUMERIC_MASK | LC_TIME_MASK) + +typedef void* locale_t; + +// The following are stubs. They are not supported on AIX 6.1. +static inline +locale_t newlocale(int category_mask, const char *locale, locale_t base) +{ + _LC_locale_t *newloc, *loc; + if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL) + { + errno = EINVAL; + return (locale_t)0; + } + if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL) + { + errno = ENOMEM; + return (locale_t)0; + } + if (!base) + base = (_LC_locale_t *)__xopen_locale("C"); + memcpy(newloc, base, sizeof (_LC_locale_t)); + if (category_mask & LC_COLLATE_MASK) + newloc->lc_collate = loc->lc_collate; + if (category_mask & LC_CTYPE_MASK) + newloc->lc_ctype = loc->lc_ctype; + //if (category_mask & LC_MESSAGES_MASK) + // newloc->lc_messages = loc->lc_messages; + if (category_mask & LC_MONETARY_MASK) + newloc->lc_monetary = loc->lc_monetary; + if (category_mask & LC_TIME_MASK) + newloc->lc_time = loc->lc_time; + if (category_mask & LC_NUMERIC_MASK) + newloc->lc_numeric = loc->lc_numeric; + return (locale_t)newloc; +} +static inline +void freelocale(locale_t locobj) +{ + free(locobj); +} +static inline +locale_t uselocale(locale_t newloc) +{ + return (locale_t)0; +} +#endif // !defined(_AIX71) + +#ifdef __cplusplus +} +#endif +#endif // defined(_AIX) +#endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H diff --git a/include/support/ibm/xlocale.h b/include/support/ibm/xlocale.h index 8d99a5c7d34d..f39c0ba95d90 100644 --- a/include/support/ibm/xlocale.h +++ b/include/support/ibm/xlocale.h @@ -10,6 +10,7 @@ #ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H #define _LIBCPP_SUPPORT_IBM_XLOCALE_H +#include <support/ibm/locale_mgmt_aix.h> #if defined(_AIX) #include "cstdlib" @@ -21,62 +22,6 @@ extern "C" { #if !defined(_AIX71) // AIX 7.1 and higher has these definitions. Definitions and stubs // are provied here as a temporary workaround on AIX 6.1. - -#define LC_COLLATE_MASK 1 -#define LC_CTYPE_MASK 2 -#define LC_MESSAGES_MASK 4 -#define LC_MONETARY_MASK 8 -#define LC_NUMERIC_MASK 16 -#define LC_TIME_MASK 32 -#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \ - LC_MESSAGES_MASK | LC_MONETARY_MASK |\ - LC_NUMERIC_MASK | LC_TIME_MASK) - -typedef void* locale_t; - -// The following are stubs. They are not supported on AIX 6.1. -static inline -locale_t newlocale(int category_mask, const char *locale, locale_t base) -{ - _LC_locale_t *newloc, *loc; - if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL) - { - errno = EINVAL; - return (locale_t)0; - } - if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL) - { - errno = ENOMEM; - return (locale_t)0; - } - if (!base) - base = (_LC_locale_t *)__xopen_locale("C"); - memcpy(newloc, base, sizeof (_LC_locale_t)); - if (category_mask & LC_COLLATE_MASK) - newloc->lc_collate = loc->lc_collate; - if (category_mask & LC_CTYPE_MASK) - newloc->lc_ctype = loc->lc_ctype; - //if (category_mask & LC_MESSAGES_MASK) - // newloc->lc_messages = loc->lc_messages; - if (category_mask & LC_MONETARY_MASK) - newloc->lc_monetary = loc->lc_monetary; - if (category_mask & LC_TIME_MASK) - newloc->lc_time = loc->lc_time; - if (category_mask & LC_NUMERIC_MASK) - newloc->lc_numeric = loc->lc_numeric; - return (locale_t)newloc; -} -static inline -void freelocale(locale_t locobj) -{ - free(locobj); -} -static inline -locale_t uselocale(locale_t newloc) -{ - return (locale_t)0; -} - static inline int isalnum_l(int c, locale_t locale) { diff --git a/include/support/newlib/xlocale.h b/include/support/newlib/xlocale.h index d067cf85a3bc..4e4b23be8d6b 100644 --- a/include/support/newlib/xlocale.h +++ b/include/support/newlib/xlocale.h @@ -16,47 +16,9 @@ #include <clocale> #include <cwctype> #include <ctype.h> - -#ifdef __cplusplus -extern "C" { -#endif - -// Patch over newlib's lack of extended locale support -typedef void *locale_t; -static inline locale_t duplocale(locale_t) { - return NULL; -} - -static inline void freelocale(locale_t) { -} - -static inline locale_t newlocale(int, const char *, locale_t) { - return NULL; -} - -static inline locale_t uselocale(locale_t) { - return NULL; -} - -#define LC_COLLATE_MASK (1 << LC_COLLATE) -#define LC_CTYPE_MASK (1 << LC_CTYPE) -#define LC_MESSAGES_MASK (1 << LC_MESSAGES) -#define LC_MONETARY_MASK (1 << LC_MONETARY) -#define LC_NUMERIC_MASK (1 << LC_NUMERIC) -#define LC_TIME_MASK (1 << LC_TIME) -#define LC_ALL_MASK (LC_COLLATE_MASK|\ - LC_CTYPE_MASK|\ - LC_MONETARY_MASK|\ - LC_NUMERIC_MASK|\ - LC_TIME_MASK|\ - LC_MESSAGES_MASK) - -// Share implementation with Android's Bionic -#include <support/xlocale/xlocale.h> - -#ifdef __cplusplus -} // extern "C" -#endif +#include <support/xlocale/__nop_locale_mgmt.h> +#include <support/xlocale/__posix_l_fallback.h> +#include <support/xlocale/__strtonum_fallback.h> #endif // _NEWLIB_VERSION diff --git a/include/support/solaris/xlocale.h b/include/support/solaris/xlocale.h index 62b0d74a6d23..e20ef7a6e53b 100644 --- a/include/support/solaris/xlocale.h +++ b/include/support/solaris/xlocale.h @@ -44,11 +44,6 @@ long strtol_l(const char *__nptr, char **__endptr, return strtol(__nptr, __endptr, __base); } static inline -long double strtold_l(const char *__nptr, char **__endptr, - locale_t __loc) { - return strtold(__nptr, __endptr); -} -static inline unsigned long long strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) { return strtoull(__nptr, __endptr, __base); @@ -58,6 +53,21 @@ unsigned long strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) { return strtoul(__nptr, __endptr, __base); } +static inline +float strtof_l(const char *__nptr, char **__endptr, + locale_t __loc) { + return strtof(__nptr, __endptr); +} +static inline +double strtod_l(const char *__nptr, char **__endptr, + locale_t __loc) { + return strtod(__nptr, __endptr); +} +static inline +long double strtold_l(const char *__nptr, char **__endptr, + locale_t __loc) { + return strtold(__nptr, __endptr); +} #ifdef __cplusplus diff --git a/include/support/win32/locale_mgmt_win32.h b/include/support/win32/locale_mgmt_win32.h new file mode 100644 index 000000000000..b3316d62596f --- /dev/null +++ b/include/support/win32/locale_mgmt_win32.h @@ -0,0 +1,33 @@ +// -*- C++ -*- +//===----------------- support/win32/locale_mgmt_win32.h ------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H +#define _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H + +#include <xlocinfo.h> // _locale_t +#define locale_t _locale_t +#define LC_COLLATE_MASK _M_COLLATE +#define LC_CTYPE_MASK _M_CTYPE +#define LC_MONETARY_MASK _M_MONETARY +#define LC_NUMERIC_MASK _M_NUMERIC +#define LC_TIME_MASK _M_TIME +#define LC_MESSAGES_MASK _M_MESSAGES +#define LC_ALL_MASK ( LC_COLLATE_MASK \ + | LC_CTYPE_MASK \ + | LC_MESSAGES_MASK \ + | LC_MONETARY_MASK \ + | LC_NUMERIC_MASK \ + | LC_TIME_MASK ) +#define freelocale _free_locale +// FIXME: base currently unused. Needs manual work to construct the new locale +locale_t newlocale( int mask, const char * locale, locale_t base ); +locale_t uselocale( locale_t newloc ); + +#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_MGMT_WIN32_H diff --git a/include/support/win32/locale_win32.h b/include/support/win32/locale_win32.h index f728d234472f..7f3710ecc188 100644 --- a/include/support/win32/locale_win32.h +++ b/include/support/win32/locale_win32.h @@ -15,26 +15,10 @@ extern "C" unsigned short __declspec(dllimport) _ctype[]; #include "support/win32/support.h" +#include "support/win32/locale_mgmt_win32.h" #include <stdio.h> #include <memory> -#include <xlocinfo.h> // _locale_t -#define locale_t _locale_t -#define LC_COLLATE_MASK _M_COLLATE -#define LC_CTYPE_MASK _M_CTYPE -#define LC_MONETARY_MASK _M_MONETARY -#define LC_NUMERIC_MASK _M_NUMERIC -#define LC_TIME_MASK _M_TIME -#define LC_MESSAGES_MASK _M_MESSAGES -#define LC_ALL_MASK ( LC_COLLATE_MASK \ - | LC_CTYPE_MASK \ - | LC_MESSAGES_MASK \ - | LC_MONETARY_MASK \ - | LC_NUMERIC_MASK \ - | LC_TIME_MASK ) -#define freelocale _free_locale -// FIXME: base currently unused. Needs manual work to construct the new locale -locale_t newlocale( int mask, const char * locale, locale_t base ); -locale_t uselocale( locale_t newloc ); + lconv *localeconv_l( locale_t loc ); size_t mbrlen_l( const char *__restrict s, size_t n, mbstate_t *__restrict ps, locale_t loc); diff --git a/include/support/xlocale/__nop_locale_mgmt.h b/include/support/xlocale/__nop_locale_mgmt.h new file mode 100644 index 000000000000..0d3f23a2c969 --- /dev/null +++ b/include/support/xlocale/__nop_locale_mgmt.h @@ -0,0 +1,52 @@ +// -*- C++ -*- +//===------------ support/xlocale/__nop_locale_mgmt.h -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H +#define _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H + +#ifdef __cplusplus +extern "C" { +#endif + +// Patch over lack of extended locale support +typedef void *locale_t; +static inline locale_t duplocale(locale_t) { + return NULL; +} + +static inline void freelocale(locale_t) { +} + +static inline locale_t newlocale(int, const char *, locale_t) { + return NULL; +} + +static inline locale_t uselocale(locale_t) { + return NULL; +} + +#define LC_COLLATE_MASK (1 << LC_COLLATE) +#define LC_CTYPE_MASK (1 << LC_CTYPE) +#define LC_MESSAGES_MASK (1 << LC_MESSAGES) +#define LC_MONETARY_MASK (1 << LC_MONETARY) +#define LC_NUMERIC_MASK (1 << LC_NUMERIC) +#define LC_TIME_MASK (1 << LC_TIME) +#define LC_ALL_MASK (LC_COLLATE_MASK|\ + LC_CTYPE_MASK|\ + LC_MONETARY_MASK|\ + LC_NUMERIC_MASK|\ + LC_TIME_MASK|\ + LC_MESSAGES_MASK) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H diff --git a/include/support/xlocale/__posix_l_fallback.h b/include/support/xlocale/__posix_l_fallback.h new file mode 100644 index 000000000000..8bf9567ffc25 --- /dev/null +++ b/include/support/xlocale/__posix_l_fallback.h @@ -0,0 +1,165 @@ +// -*- C++ -*- +//===--------------- support/xlocale/__posix_l_fallback.h -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// These are reimplementations of some extended locale functions ( *_l ) that +// are normally part of POSIX. This shared implementation provides parts of the +// extended locale support for libc's that normally don't have any (like +// Android's bionic and Newlib). +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H +#define _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H + +#ifdef __cplusplus +extern "C" { +#endif + +inline _LIBCPP_ALWAYS_INLINE int isalnum_l(int c, locale_t) { + return ::isalnum(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isalpha_l(int c, locale_t) { + return ::isalpha(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isblank_l(int c, locale_t) { + return ::isblank(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iscntrl_l(int c, locale_t) { + return ::iscntrl(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isdigit_l(int c, locale_t) { + return ::isdigit(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isgraph_l(int c, locale_t) { + return ::isgraph(c); +} + +inline _LIBCPP_ALWAYS_INLINE int islower_l(int c, locale_t) { + return ::islower(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isprint_l(int c, locale_t) { + return ::isprint(c); +} + +inline _LIBCPP_ALWAYS_INLINE int ispunct_l(int c, locale_t) { + return ::ispunct(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isspace_l(int c, locale_t) { + return ::isspace(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isupper_l(int c, locale_t) { + return ::isupper(c); +} + +inline _LIBCPP_ALWAYS_INLINE int isxdigit_l(int c, locale_t) { + return ::isxdigit(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswalnum_l(wint_t c, locale_t) { + return ::iswalnum(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswalpha_l(wint_t c, locale_t) { + return ::iswalpha(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswblank_l(wint_t c, locale_t) { + return ::iswblank(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswcntrl_l(wint_t c, locale_t) { + return ::iswcntrl(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswdigit_l(wint_t c, locale_t) { + return ::iswdigit(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswgraph_l(wint_t c, locale_t) { + return ::iswgraph(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswlower_l(wint_t c, locale_t) { + return ::iswlower(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswprint_l(wint_t c, locale_t) { + return ::iswprint(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswpunct_l(wint_t c, locale_t) { + return ::iswpunct(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswspace_l(wint_t c, locale_t) { + return ::iswspace(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswupper_l(wint_t c, locale_t) { + return ::iswupper(c); +} + +inline _LIBCPP_ALWAYS_INLINE int iswxdigit_l(wint_t c, locale_t) { + return ::iswxdigit(c); +} + +inline _LIBCPP_ALWAYS_INLINE int toupper_l(int c, locale_t) { + return ::toupper(c); +} + +inline _LIBCPP_ALWAYS_INLINE int tolower_l(int c, locale_t) { + return ::tolower(c); +} + +inline _LIBCPP_ALWAYS_INLINE int towupper_l(int c, locale_t) { + return ::towupper(c); +} + +inline _LIBCPP_ALWAYS_INLINE int towlower_l(int c, locale_t) { + return ::towlower(c); +} + +inline _LIBCPP_ALWAYS_INLINE int strcoll_l(const char *s1, const char *s2, + locale_t) { + return ::strcoll(s1, s2); +} + +inline _LIBCPP_ALWAYS_INLINE size_t strxfrm_l(char *dest, const char *src, + size_t n, locale_t) { + return ::strxfrm(dest, src, n); +} + +inline _LIBCPP_ALWAYS_INLINE size_t strftime_l(char *s, size_t max, + const char *format, + const struct tm *tm, locale_t) { + return ::strftime(s, max, format, tm); +} + +inline _LIBCPP_ALWAYS_INLINE int wcscoll_l(const wchar_t *ws1, + const wchar_t *ws2, locale_t) { + return ::wcscoll(ws1, ws2); +} + +inline _LIBCPP_ALWAYS_INLINE size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, + size_t n, locale_t) { + return ::wcsxfrm(dest, src, n); +} + +#ifdef __cplusplus +} +#endif + +#endif // _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H diff --git a/include/support/xlocale/__strtonum_fallback.h b/include/support/xlocale/__strtonum_fallback.h new file mode 100644 index 000000000000..4ae3918b3d30 --- /dev/null +++ b/include/support/xlocale/__strtonum_fallback.h @@ -0,0 +1,67 @@ +// -*- C++ -*- +//===-------------- support/xlocale/__strtonum_fallback.h -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// These are reimplementations of some extended locale functions ( *_l ) that +// aren't part of POSIX. They are widely available though (GLIBC, BSD, maybe +// others). The unifying aspect in this case is that all of these functions +// convert strings to some numeric type. +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H +#define _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H + +#ifdef __cplusplus +extern "C" { +#endif + +inline _LIBCPP_ALWAYS_INLINE float strtof_l(const char *nptr, + char **endptr, locale_t) { + return ::strtof(nptr, endptr); +} + +inline _LIBCPP_ALWAYS_INLINE double strtod_l(const char *nptr, + char **endptr, locale_t) { + return ::strtod(nptr, endptr); +} + +inline _LIBCPP_ALWAYS_INLINE long double strtold_l(const char *nptr, + char **endptr, locale_t) { + return ::strtold(nptr, endptr); +} + +inline _LIBCPP_ALWAYS_INLINE long long +strtoll_l(const char *nptr, char **endptr, int base, locale_t) { + return ::strtoll(nptr, endptr, base); +} + +inline _LIBCPP_ALWAYS_INLINE unsigned long long +strtoull_l(const char *nptr, char **endptr, int base, locale_t) { + return ::strtoull(nptr, endptr, base); +} + +inline _LIBCPP_ALWAYS_INLINE long long +wcstoll_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) { + return ::wcstoll(nptr, endptr, base); +} + +inline _LIBCPP_ALWAYS_INLINE unsigned long long +wcstoull_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) { + return ::wcstoull(nptr, endptr, base); +} + +inline _LIBCPP_ALWAYS_INLINE long double wcstold_l(const wchar_t *nptr, + wchar_t **endptr, locale_t) { + return ::wcstold(nptr, endptr); +} + +#ifdef __cplusplus +} +#endif + +#endif // _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H diff --git a/include/support/xlocale/xlocale.h b/include/support/xlocale/xlocale.h index 99f710e8f44e..e69de29bb2d1 100644 --- a/include/support/xlocale/xlocale.h +++ b/include/support/xlocale/xlocale.h @@ -1,194 +0,0 @@ -// -*- C++ -*- -//===------------------- support/xlocale/xlocale.h ------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// This is a shared implementation of a shim to provide extended locale support -// on top of libc's that don't support it (like Android's bionic, and Newlib). -// -// The 'illusion' only works when the specified locale is "C" or "POSIX", but -// that's about as good as we can do without implementing full xlocale support -// in the underlying libc. -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H -#define _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H - -#ifdef __cplusplus -extern "C" { -#endif - -static inline int isalnum_l(int c, locale_t) { - return isalnum(c); -} - -static inline int isalpha_l(int c, locale_t) { - return isalpha(c); -} - -static inline int isblank_l(int c, locale_t) { - return isblank(c); -} - -static inline int iscntrl_l(int c, locale_t) { - return iscntrl(c); -} - -static inline int isdigit_l(int c, locale_t) { - return isdigit(c); -} - -static inline int isgraph_l(int c, locale_t) { - return isgraph(c); -} - -static inline int islower_l(int c, locale_t) { - return islower(c); -} - -static inline int isprint_l(int c, locale_t) { - return isprint(c); -} - -static inline int ispunct_l(int c, locale_t) { - return ispunct(c); -} - -static inline int isspace_l(int c, locale_t) { - return isspace(c); -} - -static inline int isupper_l(int c, locale_t) { - return isupper(c); -} - -static inline int isxdigit_l(int c, locale_t) { - return isxdigit(c); -} - -static inline int iswalnum_l(wint_t c, locale_t) { - return iswalnum(c); -} - -static inline int iswalpha_l(wint_t c, locale_t) { - return iswalpha(c); -} - -static inline int iswblank_l(wint_t c, locale_t) { - return iswblank(c); -} - -static inline int iswcntrl_l(wint_t c, locale_t) { - return iswcntrl(c); -} - -static inline int iswdigit_l(wint_t c, locale_t) { - return iswdigit(c); -} - -static inline int iswgraph_l(wint_t c, locale_t) { - return iswgraph(c); -} - -static inline int iswlower_l(wint_t c, locale_t) { - return iswlower(c); -} - -static inline int iswprint_l(wint_t c, locale_t) { - return iswprint(c); -} - -static inline int iswpunct_l(wint_t c, locale_t) { - return iswpunct(c); -} - -static inline int iswspace_l(wint_t c, locale_t) { - return iswspace(c); -} - -static inline int iswupper_l(wint_t c, locale_t) { - return iswupper(c); -} - -static inline int iswxdigit_l(wint_t c, locale_t) { - return iswxdigit(c); -} - -static inline int toupper_l(int c, locale_t) { - return toupper(c); -} - -static inline int tolower_l(int c, locale_t) { - return tolower(c); -} - -static inline int towupper_l(int c, locale_t) { - return towupper(c); -} - -static inline int towlower_l(int c, locale_t) { - return towlower(c); -} - -static inline int strcoll_l(const char *s1, const char *s2, locale_t) { - return strcoll(s1, s2); -} - -static inline size_t strxfrm_l(char *dest, const char *src, size_t n, - locale_t) { - return strxfrm(dest, src, n); -} - -static inline size_t strftime_l(char *s, size_t max, const char *format, - const struct tm *tm, locale_t) { - return strftime(s, max, format, tm); -} - -static inline int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t) { - return wcscoll(ws1, ws2); -} - -static inline size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n, - locale_t) { - return wcsxfrm(dest, src, n); -} - -static inline long double strtold_l(const char *nptr, char **endptr, locale_t) { - return strtold(nptr, endptr); -} - -static inline long long strtoll_l(const char *nptr, char **endptr, int base, - locale_t) { - return strtoll(nptr, endptr, base); -} - -static inline unsigned long long strtoull_l(const char *nptr, char **endptr, - int base, locale_t) { - return strtoull(nptr, endptr, base); -} - -static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr, - int base, locale_t) { - return wcstoll(nptr, endptr, base); -} - -static inline unsigned long long wcstoull_l(const wchar_t *nptr, - wchar_t **endptr, int base, - locale_t) { - return wcstoull(nptr, endptr, base); -} - -static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr, - locale_t) { - return wcstold(nptr, endptr); -} - -#ifdef __cplusplus -} -#endif - -#endif // _LIBCPP_SUPPORT_XLOCALE_XLOCALE_H |