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>
18 Index: b/libstdc++-v3/config/locale/generic/c_locale.h
19 ===================================================================
20 --- a/libstdc++-v3/config/locale/generic/c_locale.h
21 +++ b/libstdc++-v3/config/locale/generic/c_locale.h
23 __builtin_va_list __args;
24 __builtin_va_start(__args, __fmt);
26 -#ifdef _GLIBCXX_USE_C99
27 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
28 const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
30 const int __ret = __builtin_vsprintf(__out, __fmt, __args);
31 Index: b/libstdc++-v3/config/locale/gnu/c_locale.h
32 ===================================================================
33 --- a/libstdc++-v3/config/locale/gnu/c_locale.h
34 +++ b/libstdc++-v3/config/locale/gnu/c_locale.h
36 __builtin_va_list __args;
37 __builtin_va_start(__args, __fmt);
39 -#ifdef _GLIBCXX_USE_C99
40 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
41 const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
43 const int __ret = __builtin_vsprintf(__out, __fmt, __args);
44 Index: b/libstdc++-v3/include/bits/basic_string.h
45 ===================================================================
46 --- a/libstdc++-v3/include/bits/basic_string.h
47 +++ b/libstdc++-v3/include/bits/basic_string.h
49 _GLIBCXX_END_NAMESPACE_VERSION
52 -#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
53 +#if ((__cplusplus >= 201103L) && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)) \
54 && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
56 #include <ext/string_conversions.h>
57 Index: b/libstdc++-v3/include/bits/locale_facets.tcc
58 ===================================================================
59 --- a/libstdc++-v3/include/bits/locale_facets.tcc
60 +++ b/libstdc++-v3/include/bits/locale_facets.tcc
63 __num_base::_S_format_float(__io, __fbuf, __mod);
65 -#ifdef _GLIBCXX_USE_C99
66 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
67 // First try a buffer perhaps big enough (most probably sufficient
68 // for non-ios_base::fixed outputs)
69 int __cs_size = __max_digits * 3;
70 Index: b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
71 ===================================================================
72 --- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
73 +++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
76 const locale __loc = __io.getloc();
77 const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
78 -#ifdef _GLIBCXX_USE_C99
79 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
80 // First try a buffer perhaps big enough.
82 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
83 Index: b/libstdc++-v3/include/c_compatibility/math.h
84 ===================================================================
85 --- a/libstdc++-v3/include/c_compatibility/math.h
86 +++ b/libstdc++-v3/include/c_compatibility/math.h
92 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
93 using std::fpclassify;
96 Index: b/libstdc++-v3/include/c_compatibility/wchar.h
97 ===================================================================
98 --- a/libstdc++-v3/include/c_compatibility/wchar.h
99 +++ b/libstdc++-v3/include/c_compatibility/wchar.h
104 -#if _GLIBCXX_USE_C99
105 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
109 Index: b/libstdc++-v3/include/c_global/cstdlib
110 ===================================================================
111 --- a/libstdc++-v3/include/c_global/cstdlib
112 +++ b/libstdc++-v3/include/c_global/cstdlib
114 _GLIBCXX_END_NAMESPACE_VERSION
117 -#if _GLIBCXX_USE_C99
118 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
122 Index: b/libstdc++-v3/include/c_global/cwchar
123 ===================================================================
124 --- a/libstdc++-v3/include/c_global/cwchar
125 +++ b/libstdc++-v3/include/c_global/cwchar
127 _GLIBCXX_END_NAMESPACE_VERSION
130 -#if _GLIBCXX_USE_C99
131 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
139 -#if _GLIBCXX_USE_C99
140 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
144 Index: b/libstdc++-v3/include/c_std/cstdio
145 ===================================================================
146 --- a/libstdc++-v3/include/c_std/cstdio
147 +++ b/libstdc++-v3/include/c_std/cstdio
152 -#if _GLIBCXX_USE_C99
153 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
157 Index: b/libstdc++-v3/include/c_std/cstdlib
158 ===================================================================
159 --- a/libstdc++-v3/include/c_std/cstdlib
160 +++ b/libstdc++-v3/include/c_std/cstdlib
162 _GLIBCXX_END_NAMESPACE_VERSION
165 -#if _GLIBCXX_USE_C99
166 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
170 Index: b/libstdc++-v3/include/c_std/cwchar
171 ===================================================================
172 --- a/libstdc++-v3/include/c_std/cwchar
173 +++ b/libstdc++-v3/include/c_std/cwchar
175 _GLIBCXX_END_NAMESPACE_VERSION
178 -#if _GLIBCXX_USE_C99
179 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
183 Index: b/libstdc++-v3/include/ext/vstring.h
184 ===================================================================
185 --- a/libstdc++-v3/include/ext/vstring.h
186 +++ b/libstdc++-v3/include/ext/vstring.h
187 @@ -2680,7 +2680,7 @@
188 _GLIBCXX_END_NAMESPACE_VERSION
191 -#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99))
192 +#if ((__cplusplus >= 201103L) && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)))
194 #include <ext/string_conversions.h>
196 Index: b/libstdc++-v3/include/tr1/cstdio
197 ===================================================================
198 --- a/libstdc++-v3/include/tr1/cstdio
199 +++ b/libstdc++-v3/include/tr1/cstdio
204 -#if _GLIBCXX_USE_C99
205 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
207 namespace std _GLIBCXX_VISIBILITY(default)
209 Index: b/libstdc++-v3/include/tr1/cstdlib
210 ===================================================================
211 --- a/libstdc++-v3/include/tr1/cstdlib
212 +++ b/libstdc++-v3/include/tr1/cstdlib
217 -#if _GLIBCXX_USE_C99
218 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
220 namespace std _GLIBCXX_VISIBILITY(default)
222 Index: b/libstdc++-v3/include/tr1/cwchar
223 ===================================================================
224 --- a/libstdc++-v3/include/tr1/cwchar
225 +++ b/libstdc++-v3/include/tr1/cwchar
230 -#if _GLIBCXX_USE_C99
231 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
235 Index: b/libstdc++-v3/include/tr1/stdlib.h
236 ===================================================================
237 --- a/libstdc++-v3/include/tr1/stdlib.h
238 +++ b/libstdc++-v3/include/tr1/stdlib.h
243 -#if _GLIBCXX_USE_C99
244 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
246 using std::tr1::atoll;
247 using std::tr1::strtoll;
248 Index: b/libstdc++-v3/src/c++11/debug.cc
249 ===================================================================
250 --- a/libstdc++-v3/src/c++11/debug.cc
251 +++ b/libstdc++-v3/src/c++11/debug.cc
253 int __n __attribute__ ((__unused__)),
254 const char* __fmt, _Tp __s) const throw ()
256 -#ifdef _GLIBCXX_USE_C99
257 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
258 std::snprintf(__buf, __n, __fmt, __s);
260 std::sprintf(__buf, __fmt, __s);
261 Index: b/libstdc++-v3/include/c_global/cstdio
262 ===================================================================
263 --- a/libstdc++-v3/include/c_global/cstdio
264 +++ b/libstdc++-v3/include/c_global/cstdio
269 -#if _GLIBCXX_USE_C99
270 +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)