Skip to content

Commit 0791507

Browse files
committed
Merge all the BSD-like headers since they can't be reused on Windows
1 parent d8bc87a commit 0791507

File tree

9 files changed

+215
-300
lines changed

9 files changed

+215
-300
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,11 +503,8 @@ set(files
503503
__locale_dir/locale_base_api/win32.h
504504
__locale_dir/locale_guard.h
505505
__locale_dir/support/apple.h
506-
__locale_dir/support/characters/bsd_like.h
506+
__locale_dir/support/bsd_like.h
507507
__locale_dir/support/freebsd.h
508-
__locale_dir/support/management/bsd_like.h
509-
__locale_dir/support/other/bsd_like.h
510-
__locale_dir/support/strtonum/bsd_like.h
511508
__math/abs.h
512509
__math/copysign.h
513510
__math/error_functions.h

libcxx/include/__locale_dir/support/apple.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
# pragma GCC system_header
1616
#endif
1717

18-
#include <__locale_dir/support/management/bsd_like.h> // must come first since it defines __locale_t
19-
20-
#include <__locale_dir/support/characters/bsd_like.h>
21-
#include <__locale_dir/support/other/bsd_like.h>
22-
#include <__locale_dir/support/strtonum/bsd_like.h>
18+
#include <__locale_dir/support/bsd_like.h>
2319

2420
#endif // _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
//===-----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___LOCALE_DIR_SUPPORT_BSD_LIKE_H
10+
#define _LIBCPP___LOCALE_DIR_SUPPORT_BSD_LIKE_H
11+
12+
#include <__config>
13+
#include <__cstddef/size_t.h>
14+
#include <__std_mbstate_t.h>
15+
#include <__utility/forward.h>
16+
#include <clocale> // std::lconv
17+
#include <ctype.h>
18+
#include <stdlib.h>
19+
#include <string.h>
20+
#include <time.h>
21+
#if _LIBCPP_HAS_WIDE_CHARACTERS
22+
# include <wchar.h>
23+
# include <wctype.h>
24+
#endif
25+
26+
#include <xlocale.h>
27+
28+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29+
# pragma GCC system_header
30+
#endif
31+
32+
_LIBCPP_BEGIN_NAMESPACE_STD
33+
namespace __locale {
34+
35+
//
36+
// Locale management
37+
//
38+
using __locale_t = ::locale_t;
39+
40+
inline _LIBCPP_HIDE_FROM_ABI __locale_t __uselocale(__locale_t __loc) { return ::uselocale(__loc); }
41+
42+
inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __locale, __locale_t __base) {
43+
return ::newlocale(__category_mask, __locale, __base);
44+
}
45+
46+
inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { ::freelocale(__loc); }
47+
48+
inline _LIBCPP_HIDE_FROM_ABI lconv* __localeconv(__locale_t& __loc) { return ::localeconv_l(__loc); }
49+
50+
//
51+
// Strtonum functions
52+
//
53+
inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
54+
return ::strtof_l(__nptr, __endptr, __loc);
55+
}
56+
57+
inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) {
58+
return ::strtod_l(__nptr, __endptr, __loc);
59+
}
60+
61+
inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) {
62+
return ::strtold_l(__nptr, __endptr, __loc);
63+
}
64+
65+
inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
66+
return ::strtoll_l(__nptr, __endptr, __base, __loc);
67+
}
68+
69+
inline _LIBCPP_HIDE_FROM_ABI unsigned long long
70+
__strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
71+
return ::strtoull_l(__nptr, __endptr, __base, __loc);
72+
}
73+
74+
//
75+
// Character manipulation functions
76+
//
77+
inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t __loc) { return ::islower_l(__c, __loc); }
78+
79+
inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t __loc) { return ::isupper_l(__c, __loc); }
80+
81+
inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return ::isdigit_l(__c, __loc); }
82+
83+
inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return ::isxdigit_l(__c, __loc); }
84+
85+
inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return ::toupper_l(__c, __loc); }
86+
87+
inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t __loc) { return ::tolower_l(__c, __loc); }
88+
89+
inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) {
90+
return ::strcoll_l(__s1, __s2, __loc);
91+
}
92+
93+
inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t __loc) {
94+
return ::strxfrm_l(__dest, __src, __n, __loc);
95+
}
96+
97+
#if _LIBCPP_HAS_WIDE_CHARACTERS
98+
inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return ::iswspace_l(__c, __loc); }
99+
100+
inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return ::iswprint_l(__c, __loc); }
101+
102+
inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t __loc) { return ::iswcntrl_l(__c, __loc); }
103+
104+
inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __c, __locale_t __loc) { return ::iswupper_l(__c, __loc); }
105+
106+
inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __c, __locale_t __loc) { return ::iswlower_l(__c, __loc); }
107+
108+
inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __c, __locale_t __loc) { return ::iswalpha_l(__c, __loc); }
109+
110+
inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __c, __locale_t __loc) { return ::iswblank_l(__c, __loc); }
111+
112+
inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __c, __locale_t __loc) { return ::iswdigit_l(__c, __loc); }
113+
114+
inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __c, __locale_t __loc) { return ::iswpunct_l(__c, __loc); }
115+
116+
inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __c, __locale_t __loc) { return ::iswxdigit_l(__c, __loc); }
117+
118+
inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __c, __locale_t __loc) { return ::towupper_l(__c, __loc); }
119+
120+
inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __c, __locale_t __loc) { return ::towlower_l(__c, __loc); }
121+
122+
inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, const wchar_t* __ws2, __locale_t __loc) {
123+
return ::wcscoll_l(__ws1, __ws2, __loc);
124+
}
125+
126+
inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) {
127+
return ::wcsxfrm_l(__dest, __src, __n, __loc);
128+
}
129+
#endif // _LIBCPP_HAS_WIDE_CHARACTERS
130+
131+
inline _LIBCPP_HIDE_FROM_ABI size_t
132+
__strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) {
133+
return ::strftime_l(__s, __max, __format, __tm, __loc);
134+
}
135+
136+
//
137+
// Other functions
138+
//
139+
inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t __loc) { return MB_CUR_MAX_L(__loc); }
140+
141+
#if _LIBCPP_HAS_WIDE_CHARACTERS
142+
inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __c, __locale_t __loc) { return ::btowc_l(__c, __loc); }
143+
144+
inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __c, __locale_t __loc) { return ::wctob_l(__c, __loc); }
145+
146+
inline _LIBCPP_HIDE_FROM_ABI size_t
147+
__wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) {
148+
return ::wcsnrtombs_l(__dest, __src, __nwc, __len, __ps, __loc);
149+
}
150+
151+
inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __wc, mbstate_t* __ps, __locale_t __loc) {
152+
return ::wcrtomb_l(__s, __wc, __ps, __loc);
153+
}
154+
155+
inline _LIBCPP_HIDE_FROM_ABI size_t
156+
__mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) {
157+
return ::mbsnrtowcs_l(__dest, __src, __nms, __len, __ps, __loc);
158+
}
159+
160+
inline _LIBCPP_HIDE_FROM_ABI size_t
161+
__mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
162+
return ::mbrtowc_l(__pwc, __s, __n, __ps, __loc);
163+
}
164+
165+
inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) {
166+
return ::mbtowc_l(__pwc, __pmb, __max, __loc);
167+
}
168+
169+
inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
170+
return ::mbrlen_l(__s, __n, __ps, __loc);
171+
}
172+
173+
inline _LIBCPP_HIDE_FROM_ABI size_t
174+
__mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) {
175+
return ::mbsrtowcs_l(__dest, __src, __len, __ps, __loc);
176+
}
177+
#endif
178+
179+
_LIBCPP_DIAGNOSTIC_PUSH
180+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
181+
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates
182+
#ifdef _LIBCPP_COMPILER_CLANG_BASED
183+
# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)
184+
#else
185+
# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */
186+
#endif
187+
188+
template <class... _Args>
189+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf(
190+
char* __s, size_t __n, __locale_t __loc, const char* __format, _Args&&... __args) {
191+
return ::snprintf_l(__s, __n, __loc, __format, std::forward<_Args>(__args)...);
192+
}
193+
194+
template <class... _Args>
195+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(
196+
char** __s, __locale_t __loc, const char* __format, _Args&&... __args) {
197+
return ::asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...);
198+
}
199+
200+
template <class... _Args>
201+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf(
202+
const char* __s, __locale_t __loc, const char* __format, _Args&&... __args) {
203+
return ::sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...);
204+
}
205+
_LIBCPP_DIAGNOSTIC_POP
206+
#undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
207+
208+
} // namespace __locale
209+
_LIBCPP_END_NAMESPACE_STD
210+
211+
#endif // _LIBCPP___LOCALE_DIR_SUPPORT_BSD_LIKE_H

libcxx/include/__locale_dir/support/characters/bsd_like.h

Lines changed: 0 additions & 93 deletions
This file was deleted.

libcxx/include/__locale_dir/support/freebsd.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
# pragma GCC system_header
1616
#endif
1717

18-
#include <__locale_dir/support/management/bsd_like.h> // must come first since it defines __locale_t
19-
20-
#include <__locale_dir/support/characters/bsd_like.h>
21-
#include <__locale_dir/support/other/bsd_like.h>
22-
#include <__locale_dir/support/strtonum/bsd_like.h>
18+
#include <__locale_dir/support/bsd_like.h>
2319

2420
#endif // _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H

libcxx/include/__locale_dir/support/management/bsd_like.h

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)