1 Allow C99-depending features of libstdc++ with uClibc
3 The libstdc++ code is fairly restrictive on how it checks for C99
4 compatibility: it requires *complete* C99 support to enable certain
5 features. For example, uClibc provides a good number of C99 features,
6 but not C99 complex number support. For this reason, libstdc++
7 completely disables many the standard C++ methods that can in fact
8 work because uClibc provides the necessary functions.
10 This patch is similar and highly inspired from
11 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58393, but implemented in
12 a way that doesn't involve changing the configure.ac script, as
13 autoreconfiguring gcc is complicated. It simply relies on the fact
14 that uClibc defines the __UCLIBC__ definition.
16 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
17 [Gustavo: update for 4.9.3]
19 Index: b/libstdc++-v3/config/locale/generic/c_locale.h
20 ===================================================================
21 --- a/libstdc++-v3/config/locale/generic/c_locale.h
22 +++ b/libstdc++-v3/config/locale/generic/c_locale.h
24 __builtin_va_list __args;
25 __builtin_va_start(__args, __fmt);
27 -#ifdef _GLIBCXX_USE_C99
28 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
29 const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
31 const int __ret = __builtin_vsprintf(__out, __fmt, __args);
32 Index: b/libstdc++-v3/config/locale/gnu/c_locale.h
33 ===================================================================
34 --- a/libstdc++-v3/config/locale/gnu/c_locale.h
35 +++ b/libstdc++-v3/config/locale/gnu/c_locale.h
37 __builtin_va_list __args;
38 __builtin_va_start(__args, __fmt);
40 -#ifdef _GLIBCXX_USE_C99
41 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
42 const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
44 const int __ret = __builtin_vsprintf(__out, __fmt, __args);
45 Index: b/libstdc++-v3/include/bits/basic_string.h
46 ===================================================================
47 --- a/libstdc++-v3/include/bits/basic_string.h
48 +++ b/libstdc++-v3/include/bits/basic_string.h
50 _GLIBCXX_END_NAMESPACE_VERSION
53 -#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
54 +#if __cplusplus >= 201103L && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__))
56 #include <ext/string_conversions.h>
58 Index: b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
59 ===================================================================
60 --- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
61 +++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
64 const locale __loc = __io.getloc();
65 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
66 -#ifdef _GLIBCXX_USE_C99
67 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
68 // First try a buffer perhaps big enough.
70 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
71 Index: b/libstdc++-v3/include/bits/locale_facets.tcc
72 ===================================================================
73 --- a/libstdc++-v3/include/bits/locale_facets.tcc
74 +++ b/libstdc++-v3/include/bits/locale_facets.tcc
77 __num_base::_S_format_float(__io, __fbuf, __mod);
79 -#ifdef _GLIBCXX_USE_C99
80 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
81 // First try a buffer perhaps big enough (most probably sufficient
82 // for non-ios_base::fixed outputs)
83 int __cs_size = __max_digits * 3;
84 Index: b/libstdc++-v3/include/c_compatibility/math.h
85 ===================================================================
86 --- a/libstdc++-v3/include/c_compatibility/math.h
87 +++ b/libstdc++-v3/include/c_compatibility/math.h
93 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
94 using std::fpclassify;
97 Index: b/libstdc++-v3/include/c_compatibility/wchar.h
98 ===================================================================
99 --- a/libstdc++-v3/include/c_compatibility/wchar.h
100 +++ b/libstdc++-v3/include/c_compatibility/wchar.h
105 -#if _GLIBCXX_USE_C99
106 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
110 Index: b/libstdc++-v3/include/c_global/cstdio
111 ===================================================================
112 --- a/libstdc++-v3/include/c_global/cstdio
113 +++ b/libstdc++-v3/include/c_global/cstdio
118 -#if _GLIBCXX_USE_C99
119 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
123 Index: b/libstdc++-v3/include/c_global/cstdlib
124 ===================================================================
125 --- a/libstdc++-v3/include/c_global/cstdlib
126 +++ b/libstdc++-v3/include/c_global/cstdlib
128 _GLIBCXX_END_NAMESPACE_VERSION
131 -#if _GLIBCXX_USE_C99
132 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
136 Index: b/libstdc++-v3/include/c_global/cwchar
137 ===================================================================
138 --- a/libstdc++-v3/include/c_global/cwchar
139 +++ b/libstdc++-v3/include/c_global/cwchar
141 _GLIBCXX_END_NAMESPACE_VERSION
144 -#if _GLIBCXX_USE_C99
145 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
153 -#if _GLIBCXX_USE_C99
154 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
158 Index: b/libstdc++-v3/include/c_std/cstdio
159 ===================================================================
160 --- a/libstdc++-v3/include/c_std/cstdio
161 +++ b/libstdc++-v3/include/c_std/cstdio
166 -#if _GLIBCXX_USE_C99
167 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
171 Index: b/libstdc++-v3/include/c_std/cstdlib
172 ===================================================================
173 --- a/libstdc++-v3/include/c_std/cstdlib
174 +++ b/libstdc++-v3/include/c_std/cstdlib
176 _GLIBCXX_END_NAMESPACE_VERSION
179 -#if _GLIBCXX_USE_C99
180 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
184 Index: b/libstdc++-v3/include/c_std/cwchar
185 ===================================================================
186 --- a/libstdc++-v3/include/c_std/cwchar
187 +++ b/libstdc++-v3/include/c_std/cwchar
189 _GLIBCXX_END_NAMESPACE_VERSION
192 -#if _GLIBCXX_USE_C99
193 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
197 Index: b/libstdc++-v3/include/ext/vstring.h
198 ===================================================================
199 --- a/libstdc++-v3/include/ext/vstring.h
200 +++ b/libstdc++-v3/include/ext/vstring.h
201 @@ -2680,7 +2680,7 @@
202 _GLIBCXX_END_NAMESPACE_VERSION
205 -#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99))
206 +#if ((__cplusplus >= 201103L) && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)))
208 #include <ext/string_conversions.h>
210 Index: b/libstdc++-v3/include/tr1/cstdio
211 ===================================================================
212 --- a/libstdc++-v3/include/tr1/cstdio
213 +++ b/libstdc++-v3/include/tr1/cstdio
218 -#if _GLIBCXX_USE_C99
219 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
221 namespace std _GLIBCXX_VISIBILITY(default)
223 Index: b/libstdc++-v3/include/tr1/cstdlib
224 ===================================================================
225 --- a/libstdc++-v3/include/tr1/cstdlib
226 +++ b/libstdc++-v3/include/tr1/cstdlib
231 -#if _GLIBCXX_USE_C99
232 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
234 namespace std _GLIBCXX_VISIBILITY(default)
236 Index: b/libstdc++-v3/include/tr1/cwchar
237 ===================================================================
238 --- a/libstdc++-v3/include/tr1/cwchar
239 +++ b/libstdc++-v3/include/tr1/cwchar
244 -#if _GLIBCXX_USE_C99
245 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
249 Index: b/libstdc++-v3/include/tr1/stdlib.h
250 ===================================================================
251 --- a/libstdc++-v3/include/tr1/stdlib.h
252 +++ b/libstdc++-v3/include/tr1/stdlib.h
257 -#if _GLIBCXX_USE_C99
258 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
260 using std::tr1::atoll;
261 using std::tr1::strtoll;
262 Index: b/libstdc++-v3/src/c++11/debug.cc
263 ===================================================================
264 --- a/libstdc++-v3/src/c++11/debug.cc
265 +++ b/libstdc++-v3/src/c++11/debug.cc
267 int __n __attribute__ ((__unused__)),
268 const char* __fmt, _Tp __s) const throw ()
270 -#ifdef _GLIBCXX_USE_C99
271 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
272 std::snprintf(__buf, __n, __fmt, __s);
274 std::sprintf(__buf, __fmt, __s);