Skip to content

Commit 02c7be5

Browse files
authored
[libc++] Remove dead code from the locale base API and support code (#89070)
1 parent 40c1264 commit 02c7be5

File tree

10 files changed

+20
-114
lines changed

10 files changed

+20
-114
lines changed

libcxx/include/__locale_dir/locale_base_api.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,4 @@ except that locale_t is used instead of the current global locale.
9595
The variadic functions may be implemented as templates with a parameter pack instead of variadic functions.
9696
*/
9797

98-
/*
99-
// TODO: These symbols are never actually used, but defined by one or more implementations. They should be removed.
100-
long strtol_l(const char* str, char** str_end, locale_t);
101-
unsigned long strtoul_l(const char* str, char** str_end, locale_t);
102-
long long wcstoll_l(const wchar_t* str, wchar_t** str_end, int base, locale_t);
103-
unsigned long long wcstoull_l(const wchar_t* str, wchar_t** str_end, int base, locale_t);
104-
long double wcstold_l(const wchar_t* str, wchar_t** str_end, int base, locale_t);
105-
int sprintf_l(char* str, const char* format, locale_t, ...);
106-
int vsprintf_l(char* str, const char* format, locale_t, va_list);
107-
int vsnprintf_l(char* str, size_t size, const char* format, locale_t, va_list);
108-
int isblank_l(int ch, locale_t);
109-
110-
*/
111-
11298
#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H

libcxx/include/__locale_dir/locale_base_api/android.h

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,29 @@
1010
#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H
1111
#define _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H
1212

13-
#if defined(__BIONIC__)
13+
#include <stdlib.h>
1414

15-
# ifdef __cplusplus
15+
// FIXME: Is this actually required?
1616
extern "C" {
17-
# endif
18-
19-
# include <stdlib.h>
20-
# include <xlocale.h>
21-
22-
# ifdef __cplusplus
17+
#include <xlocale.h>
2318
}
24-
# endif
2519

26-
# if defined(__ANDROID__)
27-
28-
# include <android/api-level.h>
29-
# if __ANDROID_API__ < 21
30-
# include <__support/xlocale/__posix_l_fallback.h>
31-
# endif
20+
#include <android/api-level.h>
21+
#if __ANDROID_API__ < 21
22+
# include <__support/xlocale/__posix_l_fallback.h>
23+
#endif
3224

3325
// If we do not have this header, we are in a platform build rather than an NDK
3426
// build, which will always be at least as new as the ToT NDK, in which case we
3527
// don't need any of the inlines below since libc provides them.
36-
# if __has_include(<android/ndk-version.h>)
37-
# include <android/ndk-version.h>
28+
#if __has_include(<android/ndk-version.h>)
29+
# include <android/ndk-version.h>
3830
// In NDK versions later than 16, locale-aware functions are provided by
3931
// legacy_stdlib_inlines.h
40-
# if __NDK_MAJOR__ <= 16
41-
# if __ANDROID_API__ < 21
42-
# include <__support/xlocale/__strtonum_fallback.h>
43-
# elif __ANDROID_API__ < 26
32+
# if __NDK_MAJOR__ <= 16
33+
# if __ANDROID_API__ < 21
34+
# include <__support/xlocale/__strtonum_fallback.h>
35+
# elif __ANDROID_API__ < 26
4436

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

53-
inline _LIBCPP_HIDE_FROM_ABI long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
54-
return ::strtol(__nptr, __endptr, __base);
55-
}
56-
57-
# endif // __ANDROID_API__ < 26
45+
# endif // __ANDROID_API__ < 26
5846

59-
# endif // __NDK_MAJOR__ <= 16
60-
# endif // __has_include(<android/ndk-version.h>)
61-
# endif // defined(__ANDROID__)
47+
# endif // __NDK_MAJOR__ <= 16
48+
#endif // __has_include(<android/ndk-version.h>)
6249

63-
#endif // defined(__BIONIC__)
6450
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H

libcxx/include/__locale_dir/locale_base_api/fuchsia.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@
1010
#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H
1111
#define _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H
1212

13-
#if defined(__Fuchsia__)
14-
15-
# include <__support/xlocale/__posix_l_fallback.h>
16-
# include <__support/xlocale/__strtonum_fallback.h>
17-
# include <cstdlib>
18-
# include <cwchar>
19-
20-
#endif // defined(__Fuchsia__)
13+
#include <__support/xlocale/__posix_l_fallback.h>
14+
#include <__support/xlocale/__strtonum_fallback.h>
15+
#include <cstdlib>
16+
#include <cwchar>
2117

2218
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H

libcxx/include/__locale_dir/locale_base_api/ibm.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __en
5858
return ::strtoll(__nptr, __endptr, __base);
5959
}
6060

61-
inline _LIBCPP_HIDE_FROM_ABI long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
62-
__setAndRestore __newloc(locale);
63-
return ::strtol(__nptr, __endptr, __base);
64-
}
65-
6661
inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t locale) {
6762
__setAndRestore __newloc(locale);
6863
return ::strtod(__nptr, __endptr);
@@ -84,11 +79,6 @@ strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
8479
return ::strtoull(__nptr, __endptr, __base);
8580
}
8681

87-
inline _LIBCPP_HIDE_FROM_ABI unsigned long strtoul_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
88-
__setAndRestore __newloc(locale);
89-
return ::strtoul(__nptr, __endptr, __base);
90-
}
91-
9282
inline _LIBCPP_HIDE_FROM_ABI
9383
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {
9484
const size_t buff_size = 256;

libcxx/include/__locale_dir/locale_base_api/musl.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,4 @@ inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, c
2828
return ::strtoull(__nptr, __endptr, __base);
2929
}
3030

31-
inline _LIBCPP_HIDE_FROM_ABI long long wcstoll_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
32-
return ::wcstoll(__nptr, __endptr, __base);
33-
}
34-
35-
inline _LIBCPP_HIDE_FROM_ABI unsigned long long
36-
wcstoull_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
37-
return ::wcstoull(__nptr, __endptr, __base);
38-
}
39-
40-
inline _LIBCPP_HIDE_FROM_ABI long double wcstold_l(const wchar_t* __nptr, wchar_t** __endptr, locale_t) {
41-
return ::wcstold(__nptr, __endptr);
42-
}
43-
4431
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H

libcxx/include/__locale_dir/locale_base_api/newlib.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,4 @@
99
#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H
1010
#define _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H
1111

12-
#if defined(_NEWLIB_VERSION)
13-
14-
# if !defined(__NEWLIB__) || __NEWLIB__ < 2 || __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
15-
# include <__support/xlocale/__nop_locale_mgmt.h>
16-
# include <__support/xlocale/__posix_l_fallback.h>
17-
# include <__support/xlocale/__strtonum_fallback.h>
18-
# endif
19-
20-
#endif // _NEWLIB_VERSION
21-
2212
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H

libcxx/include/__locale_dir/locale_base_api/openbsd.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,4 @@
1616
#include <ctype.h>
1717
#include <cwctype>
1818

19-
inline _LIBCPP_HIDE_FROM_ABI long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
20-
return ::strtol(__nptr, __endptr, __base);
21-
}
22-
23-
inline _LIBCPP_HIDE_FROM_ABI unsigned long strtoul_l(const char* __nptr, char** __endptr, int __base, locale_t) {
24-
return ::strtoul(__nptr, __endptr, __base);
25-
}
26-
2719
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H

libcxx/include/__locale_dir/locale_base_api/win32.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,11 @@ _LIBCPP_EXPORTED_FROM_ABI size_t strftime_l(char* ret, size_t n, const char* for
225225
# define strftime_l _strftime_l
226226
#endif
227227
#define sscanf_l(__s, __l, __f, ...) _sscanf_l(__s, __f, __l, __VA_ARGS__)
228-
#define sprintf_l(__s, __l, __f, ...) _sprintf_l(__s, __f, __l, __VA_ARGS__)
229-
#define vsprintf_l(__s, __l, __f, ...) _vsprintf_l(__s, __f, __l, __VA_ARGS__)
230-
#define vsnprintf_l(__s, __n, __l, __f, ...) _vsnprintf_l(__s, __n, __f, __l, __VA_ARGS__)
231228
_LIBCPP_EXPORTED_FROM_ABI int snprintf_l(char* __ret, size_t __n, locale_t __loc, const char* __format, ...);
232229
_LIBCPP_EXPORTED_FROM_ABI int asprintf_l(char** __ret, locale_t __loc, const char* __format, ...);
233230
_LIBCPP_EXPORTED_FROM_ABI int vasprintf_l(char** __ret, locale_t __loc, const char* __format, va_list __ap);
234231

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

239235
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H

libcxx/include/__support/xlocale/__posix_l_fallback.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ inline _LIBCPP_HIDE_FROM_ABI int isalnum_l(int __c, locale_t) { return ::isalnum
2929

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

32-
inline _LIBCPP_HIDE_FROM_ABI int isblank_l(int __c, locale_t) { return ::isblank(__c); }
33-
3432
inline _LIBCPP_HIDE_FROM_ABI int iscntrl_l(int __c, locale_t) { return ::iscntrl(__c); }
3533

3634
inline _LIBCPP_HIDE_FROM_ABI int isdigit_l(int __c, locale_t) { return ::isdigit(__c); }

libcxx/include/__support/xlocale/__strtonum_fallback.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,4 @@ inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, c
4242
return ::strtoull(__nptr, __endptr, __base);
4343
}
4444

45-
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
46-
inline _LIBCPP_HIDE_FROM_ABI long long wcstoll_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
47-
return ::wcstoll(__nptr, __endptr, __base);
48-
}
49-
50-
inline _LIBCPP_HIDE_FROM_ABI unsigned long long
51-
wcstoull_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
52-
return ::wcstoull(__nptr, __endptr, __base);
53-
}
54-
55-
inline _LIBCPP_HIDE_FROM_ABI long double wcstold_l(const wchar_t* __nptr, wchar_t** __endptr, locale_t) {
56-
return ::wcstold(__nptr, __endptr);
57-
}
58-
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
59-
6045
#endif // _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H

0 commit comments

Comments
 (0)