Skip to content

Commit

Permalink
[libc++] Remove dead code from the locale base API and support code (l…
Browse files Browse the repository at this point in the history
  • Loading branch information
philnik777 committed Jul 6, 2024
1 parent 40c1264 commit 02c7be5
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 114 deletions.
14 changes: 0 additions & 14 deletions libcxx/include/__locale_dir/locale_base_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,4 @@ except that locale_t is used instead of the current global locale.
The variadic functions may be implemented as templates with a parameter pack instead of variadic functions.
*/

/*
// TODO: These symbols are never actually used, but defined by one or more implementations. They should be removed.
long strtol_l(const char* str, char** str_end, locale_t);
unsigned long strtoul_l(const char* str, char** str_end, locale_t);
long long wcstoll_l(const wchar_t* str, wchar_t** str_end, int base, locale_t);
unsigned long long wcstoull_l(const wchar_t* str, wchar_t** str_end, int base, locale_t);
long double wcstold_l(const wchar_t* str, wchar_t** str_end, int base, locale_t);
int sprintf_l(char* str, const char* format, locale_t, ...);
int vsprintf_l(char* str, const char* format, locale_t, va_list);
int vsnprintf_l(char* str, size_t size, const char* format, locale_t, va_list);
int isblank_l(int ch, locale_t);
*/

#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
46 changes: 16 additions & 30 deletions libcxx/include/__locale_dir/locale_base_api/android.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,29 @@
#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H
#define _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H

#if defined(__BIONIC__)
#include <stdlib.h>

# ifdef __cplusplus
// FIXME: Is this actually required?
extern "C" {
# endif

# include <stdlib.h>
# include <xlocale.h>

# ifdef __cplusplus
#include <xlocale.h>
}
# endif

# if defined(__ANDROID__)

# include <android/api-level.h>
# if __ANDROID_API__ < 21
# include <__support/xlocale/__posix_l_fallback.h>
# endif
#include <android/api-level.h>
#if __ANDROID_API__ < 21
# include <__support/xlocale/__posix_l_fallback.h>
#endif

// If we do not have this header, we are in a platform build rather than an NDK
// build, which will always be at least as new as the ToT NDK, in which case we
// don't need any of the inlines below since libc provides them.
# if __has_include(<android/ndk-version.h>)
# include <android/ndk-version.h>
#if __has_include(<android/ndk-version.h>)
# include <android/ndk-version.h>
// In NDK versions later than 16, locale-aware functions are provided by
// legacy_stdlib_inlines.h
# if __NDK_MAJOR__ <= 16
# if __ANDROID_API__ < 21
# include <__support/xlocale/__strtonum_fallback.h>
# elif __ANDROID_API__ < 26
# if __NDK_MAJOR__ <= 16
# if __ANDROID_API__ < 21
# include <__support/xlocale/__strtonum_fallback.h>
# elif __ANDROID_API__ < 26

inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) {
return ::strtof(__nptr, __endptr);
Expand All @@ -50,15 +42,9 @@ inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr
return ::strtod(__nptr, __endptr);
}

inline _LIBCPP_HIDE_FROM_ABI long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
return ::strtol(__nptr, __endptr, __base);
}

# endif // __ANDROID_API__ < 26
# endif // __ANDROID_API__ < 26

# endif // __NDK_MAJOR__ <= 16
# endif // __has_include(<android/ndk-version.h>)
# endif // defined(__ANDROID__)
# endif // __NDK_MAJOR__ <= 16
#endif // __has_include(<android/ndk-version.h>)

#endif // defined(__BIONIC__)
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H
12 changes: 4 additions & 8 deletions libcxx/include/__locale_dir/locale_base_api/fuchsia.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H
#define _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H

#if defined(__Fuchsia__)

# include <__support/xlocale/__posix_l_fallback.h>
# include <__support/xlocale/__strtonum_fallback.h>
# include <cstdlib>
# include <cwchar>

#endif // defined(__Fuchsia__)
#include <__support/xlocale/__posix_l_fallback.h>
#include <__support/xlocale/__strtonum_fallback.h>
#include <cstdlib>
#include <cwchar>

#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H
10 changes: 0 additions & 10 deletions libcxx/include/__locale_dir/locale_base_api/ibm.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __en
return ::strtoll(__nptr, __endptr, __base);
}

inline _LIBCPP_HIDE_FROM_ABI long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
__setAndRestore __newloc(locale);
return ::strtol(__nptr, __endptr, __base);
}

inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t locale) {
__setAndRestore __newloc(locale);
return ::strtod(__nptr, __endptr);
Expand All @@ -84,11 +79,6 @@ strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
return ::strtoull(__nptr, __endptr, __base);
}

inline _LIBCPP_HIDE_FROM_ABI unsigned long strtoul_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
__setAndRestore __newloc(locale);
return ::strtoul(__nptr, __endptr, __base);
}

inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {
const size_t buff_size = 256;
Expand Down
13 changes: 0 additions & 13 deletions libcxx/include/__locale_dir/locale_base_api/musl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,4 @@ inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, c
return ::strtoull(__nptr, __endptr, __base);
}

inline _LIBCPP_HIDE_FROM_ABI long long wcstoll_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
return ::wcstoll(__nptr, __endptr, __base);
}

inline _LIBCPP_HIDE_FROM_ABI unsigned long long
wcstoull_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
return ::wcstoull(__nptr, __endptr, __base);
}

inline _LIBCPP_HIDE_FROM_ABI long double wcstold_l(const wchar_t* __nptr, wchar_t** __endptr, locale_t) {
return ::wcstold(__nptr, __endptr);
}

#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H
10 changes: 0 additions & 10 deletions libcxx/include/__locale_dir/locale_base_api/newlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,4 @@
#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H
#define _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H

#if defined(_NEWLIB_VERSION)

# if !defined(__NEWLIB__) || __NEWLIB__ < 2 || __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
# include <__support/xlocale/__nop_locale_mgmt.h>
# include <__support/xlocale/__posix_l_fallback.h>
# include <__support/xlocale/__strtonum_fallback.h>
# endif

#endif // _NEWLIB_VERSION

#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H
8 changes: 0 additions & 8 deletions libcxx/include/__locale_dir/locale_base_api/openbsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,4 @@
#include <ctype.h>
#include <cwctype>

inline _LIBCPP_HIDE_FROM_ABI long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
return ::strtol(__nptr, __endptr, __base);
}

inline _LIBCPP_HIDE_FROM_ABI unsigned long strtoul_l(const char* __nptr, char** __endptr, int __base, locale_t) {
return ::strtoul(__nptr, __endptr, __base);
}

#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H
4 changes: 0 additions & 4 deletions libcxx/include/__locale_dir/locale_base_api/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,11 @@ _LIBCPP_EXPORTED_FROM_ABI size_t strftime_l(char* ret, size_t n, const char* for
# define strftime_l _strftime_l
#endif
#define sscanf_l(__s, __l, __f, ...) _sscanf_l(__s, __f, __l, __VA_ARGS__)
#define sprintf_l(__s, __l, __f, ...) _sprintf_l(__s, __f, __l, __VA_ARGS__)
#define vsprintf_l(__s, __l, __f, ...) _vsprintf_l(__s, __f, __l, __VA_ARGS__)
#define vsnprintf_l(__s, __n, __l, __f, ...) _vsnprintf_l(__s, __n, __f, __l, __VA_ARGS__)
_LIBCPP_EXPORTED_FROM_ABI int snprintf_l(char* __ret, size_t __n, locale_t __loc, const char* __format, ...);
_LIBCPP_EXPORTED_FROM_ABI int asprintf_l(char** __ret, locale_t __loc, const char* __format, ...);
_LIBCPP_EXPORTED_FROM_ABI int vasprintf_l(char** __ret, locale_t __loc, const char* __format, va_list __ap);

// not-so-pressing FIXME: use locale to determine blank characters
inline int isblank_l(int __c, locale_t /*loc*/) { return (__c == ' ' || __c == '\t'); }
inline int iswblank_l(wint_t __c, locale_t /*loc*/) { return (__c == L' ' || __c == L'\t'); }

#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H
2 changes: 0 additions & 2 deletions libcxx/include/__support/xlocale/__posix_l_fallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ inline _LIBCPP_HIDE_FROM_ABI int isalnum_l(int __c, locale_t) { return ::isalnum

inline _LIBCPP_HIDE_FROM_ABI int isalpha_l(int __c, locale_t) { return ::isalpha(__c); }

inline _LIBCPP_HIDE_FROM_ABI int isblank_l(int __c, locale_t) { return ::isblank(__c); }

inline _LIBCPP_HIDE_FROM_ABI int iscntrl_l(int __c, locale_t) { return ::iscntrl(__c); }

inline _LIBCPP_HIDE_FROM_ABI int isdigit_l(int __c, locale_t) { return ::isdigit(__c); }
Expand Down
15 changes: 0 additions & 15 deletions libcxx/include/__support/xlocale/__strtonum_fallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,4 @@ inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, c
return ::strtoull(__nptr, __endptr, __base);
}

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
inline _LIBCPP_HIDE_FROM_ABI long long wcstoll_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
return ::wcstoll(__nptr, __endptr, __base);
}

inline _LIBCPP_HIDE_FROM_ABI unsigned long long
wcstoull_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
return ::wcstoull(__nptr, __endptr, __base);
}

inline _LIBCPP_HIDE_FROM_ABI long double wcstold_l(const wchar_t* __nptr, wchar_t** __endptr, locale_t) {
return ::wcstold(__nptr, __endptr);
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS

#endif // _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H

0 comments on commit 02c7be5

Please sign in to comment.