Skip to content

Commit a6058e3

Browse files
committed
[libc++] Remove dead code from the locale base API and support code
1 parent fa61f06 commit a6058e3

File tree

12 files changed

+70
-219
lines changed

12 files changed

+70
-219
lines changed

libcxx/include/__config

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,10 +796,6 @@ typedef __char32_t char32_t;
796796
# endif
797797
# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
798798

799-
// This macro provides a HIDE_FROM_ABI equivalent that can be applied to extern
800-
// "C" function, as those lack mangling.
801-
# define _LIBCPP_HIDE_FROM_ABI_C _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
802-
803799
# ifdef _LIBCPP_BUILDING_LIBRARY
804800
# if _LIBCPP_ABI_VERSION > 1
805801
# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI

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: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,63 +10,41 @@
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
25-
26-
# if defined(__ANDROID__)
2719

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
44-
45-
# if defined(__cplusplus)
46-
extern "C" {
47-
# endif
32+
# if __NDK_MAJOR__ <= 16
33+
# if __ANDROID_API__ < 21
34+
# include <__support/xlocale/__strtonum_fallback.h>
35+
# elif __ANDROID_API__ < 26
4836

49-
inline _LIBCPP_HIDE_FROM_ABI_C float strtof_l(const char* __nptr, char** __endptr, locale_t) {
37+
inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) {
5038
return ::strtof(__nptr, __endptr);
5139
}
5240

53-
inline _LIBCPP_HIDE_FROM_ABI_C double strtod_l(const char* __nptr, char** __endptr, locale_t) {
41+
inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t) {
5442
return ::strtod(__nptr, __endptr);
5543
}
5644

57-
inline _LIBCPP_HIDE_FROM_ABI_C long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
58-
return ::strtol(__nptr, __endptr, __base);
59-
}
60-
61-
# if defined(__cplusplus)
62-
}
63-
# endif
64-
65-
# endif // __ANDROID_API__ < 26
45+
# endif // __ANDROID_API__ < 26
6646

67-
# endif // __NDK_MAJOR__ <= 16
68-
# endif // __has_include(<android/ndk-version.h>)
69-
# endif // defined(__ANDROID__)
47+
# endif // __NDK_MAJOR__ <= 16
48+
#endif // __has_include(<android/ndk-version.h>)
7049

71-
#endif // defined(__BIONIC__)
7250
#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 & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121
#include "cstdlib"
2222

23-
#ifdef __cplusplus
24-
extern "C" {
25-
#endif
26-
2723
#if defined(__MVS__)
2824
# include <wctype.h>
2925
// POSIX routines
@@ -62,11 +58,6 @@ inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __en
6258
return ::strtoll(__nptr, __endptr, __base);
6359
}
6460

65-
inline _LIBCPP_HIDE_FROM_ABI long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
66-
__setAndRestore __newloc(locale);
67-
return ::strtol(__nptr, __endptr, __base);
68-
}
69-
7061
inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t locale) {
7162
__setAndRestore __newloc(locale);
7263
return ::strtod(__nptr, __endptr);
@@ -88,11 +79,6 @@ strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
8879
return ::strtoull(__nptr, __endptr, __base);
8980
}
9081

91-
inline _LIBCPP_HIDE_FROM_ABI unsigned long strtoul_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
92-
__setAndRestore __newloc(locale);
93-
return ::strtoul(__nptr, __endptr, __base);
94-
}
95-
9682
inline _LIBCPP_HIDE_FROM_ABI int vasprintf(char** strp, const char* fmt, va_list ap) {
9783
const size_t buff_size = 256;
9884
if ((*strp = (char*)malloc(buff_size)) == NULL) {
@@ -118,7 +104,4 @@ inline _LIBCPP_HIDE_FROM_ABI int vasprintf(char** strp, const char* fmt, va_list
118104
return str_size;
119105
}
120106

121-
#ifdef __cplusplus
122-
}
123-
#endif
124107
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H

libcxx/include/__locale_dir/locale_base_api/musl.h

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,12 @@
2020
#include <cstdlib>
2121
#include <cwchar>
2222

23-
#ifdef __cplusplus
24-
extern "C" {
25-
#endif
26-
27-
inline _LIBCPP_HIDE_FROM_ABI_C long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) {
23+
inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) {
2824
return ::strtoll(__nptr, __endptr, __base);
2925
}
3026

31-
inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long
32-
strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) {
27+
inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) {
3328
return ::strtoull(__nptr, __endptr, __base);
3429
}
3530

36-
inline _LIBCPP_HIDE_FROM_ABI_C long long wcstoll_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
37-
return ::wcstoll(__nptr, __endptr, __base);
38-
}
39-
40-
inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long
41-
wcstoull_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
42-
return ::wcstoull(__nptr, __endptr, __base);
43-
}
44-
45-
inline _LIBCPP_HIDE_FROM_ABI_C long double wcstold_l(const wchar_t* __nptr, wchar_t** __endptr, locale_t) {
46-
return ::wcstold(__nptr, __endptr);
47-
}
48-
49-
#ifdef __cplusplus
50-
}
51-
#endif
52-
5331
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H

libcxx/include/__locale_dir/locale_base_api/newlib.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@
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
12+
#if !defined(__NEWLIB__) || __NEWLIB__ < 2 || __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
13+
# include <__support/xlocale/__nop_locale_mgmt.h>
14+
# include <__support/xlocale/__posix_l_fallback.h>
15+
# include <__support/xlocale/__strtonum_fallback.h>
16+
#endif
2117

2218
#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H

libcxx/include/__locale_dir/locale_base_api/openbsd.h

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

19-
#ifdef __cplusplus
20-
extern "C" {
21-
#endif
22-
23-
inline _LIBCPP_HIDE_FROM_ABI_C long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
24-
return ::strtol(__nptr, __endptr, __base);
25-
}
26-
27-
inline _LIBCPP_HIDE_FROM_ABI_C unsigned long strtoul_l(const char* __nptr, char** __endptr, int __base, locale_t) {
28-
return ::strtoul(__nptr, __endptr, __base);
29-
}
30-
31-
#ifdef __cplusplus
32-
}
33-
#endif
34-
3519
#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/__nop_locale_mgmt.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,16 @@
1212

1313
#include <__config>
1414

15-
#ifdef __cplusplus
16-
extern "C" {
17-
#endif
18-
1915
// Patch over lack of extended locale support
2016
typedef void* locale_t;
2117

22-
inline _LIBCPP_HIDE_FROM_ABI_C locale_t duplocale(locale_t) { return NULL; }
18+
inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return NULL; }
2319

24-
inline _LIBCPP_HIDE_FROM_ABI_C void freelocale(locale_t) {}
20+
inline _LIBCPP_HIDE_FROM_ABI void freelocale(locale_t) {}
2521

26-
inline _LIBCPP_HIDE_FROM_ABI_C locale_t newlocale(int, const char*, locale_t) { return NULL; }
22+
inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return NULL; }
2723

28-
inline _LIBCPP_HIDE_FROM_ABI_C locale_t uselocale(locale_t) { return NULL; }
24+
inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return NULL; }
2925

3026
#define LC_COLLATE_MASK (1 << LC_COLLATE)
3127
#define LC_CTYPE_MASK (1 << LC_CTYPE)
@@ -36,8 +32,4 @@ inline _LIBCPP_HIDE_FROM_ABI_C locale_t uselocale(locale_t) { return NULL; }
3632
#define LC_ALL_MASK \
3733
(LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK | LC_MESSAGES_MASK)
3834

39-
#ifdef __cplusplus
40-
} // extern "C"
41-
#endif
42-
4335
#endif // _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H

0 commit comments

Comments
 (0)