libstdcxx-uclibc-c99.patch 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. Allow C99-depending features of libstdc++ with uClibc
  2. The libstdc++ code is fairly restrictive on how it checks for C99
  3. compatibility: it requires *complete* C99 support to enable certain
  4. features. For example, uClibc provides a good number of C99 features,
  5. but not C99 complex number support. For this reason, libstdc++
  6. completely disables many the standard C++ methods that can in fact
  7. work because uClibc provides the necessary functions.
  8. This patch is similar and highly inspired from
  9. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58393, but implemented in
  10. a way that doesn't involve changing the configure.ac script, as
  11. autoreconfiguring gcc is complicated. It simply relies on the fact
  12. that uClibc defines the __UCLIBC__ definition.
  13. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  14. Index: b/libstdc++-v3/config/locale/generic/c_locale.h
  15. ===================================================================
  16. --- a/libstdc++-v3/config/locale/generic/c_locale.h
  17. +++ b/libstdc++-v3/config/locale/generic/c_locale.h
  18. @@ -70,7 +70,7 @@
  19. __builtin_va_list __args;
  20. __builtin_va_start(__args, __fmt);
  21. -#ifdef _GLIBCXX_USE_C99
  22. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  23. const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
  24. #else
  25. const int __ret = __builtin_vsprintf(__out, __fmt, __args);
  26. Index: b/libstdc++-v3/config/locale/gnu/c_locale.h
  27. ===================================================================
  28. --- a/libstdc++-v3/config/locale/gnu/c_locale.h
  29. +++ b/libstdc++-v3/config/locale/gnu/c_locale.h
  30. @@ -88,7 +88,7 @@
  31. __builtin_va_list __args;
  32. __builtin_va_start(__args, __fmt);
  33. -#ifdef _GLIBCXX_USE_C99
  34. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  35. const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
  36. #else
  37. const int __ret = __builtin_vsprintf(__out, __fmt, __args);
  38. Index: b/libstdc++-v3/include/bits/basic_string.h
  39. ===================================================================
  40. --- a/libstdc++-v3/include/bits/basic_string.h
  41. +++ b/libstdc++-v3/include/bits/basic_string.h
  42. @@ -2809,7 +2809,7 @@
  43. _GLIBCXX_END_NAMESPACE_VERSION
  44. } // namespace
  45. -#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
  46. +#if ((__cplusplus >= 201103L) && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)) \
  47. && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
  48. #include <ext/string_conversions.h>
  49. Index: b/libstdc++-v3/include/bits/locale_facets.tcc
  50. ===================================================================
  51. --- a/libstdc++-v3/include/bits/locale_facets.tcc
  52. +++ b/libstdc++-v3/include/bits/locale_facets.tcc
  53. @@ -987,7 +987,7 @@
  54. char __fbuf[16];
  55. __num_base::_S_format_float(__io, __fbuf, __mod);
  56. -#ifdef _GLIBCXX_USE_C99
  57. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  58. // First try a buffer perhaps big enough (most probably sufficient
  59. // for non-ios_base::fixed outputs)
  60. int __cs_size = __max_digits * 3;
  61. Index: b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
  62. ===================================================================
  63. --- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
  64. +++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
  65. @@ -572,7 +572,7 @@
  66. {
  67. const locale __loc = __io.getloc();
  68. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  69. -#ifdef _GLIBCXX_USE_C99
  70. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  71. // First try a buffer perhaps big enough.
  72. int __cs_size = 64;
  73. char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
  74. Index: b/libstdc++-v3/include/c_compatibility/math.h
  75. ===================================================================
  76. --- a/libstdc++-v3/include/c_compatibility/math.h
  77. +++ b/libstdc++-v3/include/c_compatibility/math.h
  78. @@ -56,7 +56,7 @@
  79. using std::floor;
  80. using std::fmod;
  81. -#if _GLIBCXX_USE_C99
  82. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  83. using std::fpclassify;
  84. using std::isfinite;
  85. using std::isinf;
  86. Index: b/libstdc++-v3/include/c_compatibility/wchar.h
  87. ===================================================================
  88. --- a/libstdc++-v3/include/c_compatibility/wchar.h
  89. +++ b/libstdc++-v3/include/c_compatibility/wchar.h
  90. @@ -103,7 +103,7 @@
  91. using std::wmemset;
  92. using std::wcsftime;
  93. -#if _GLIBCXX_USE_C99
  94. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  95. using std::wcstold;
  96. using std::wcstoll;
  97. using std::wcstoull;
  98. Index: b/libstdc++-v3/include/c_global/cstdlib
  99. ===================================================================
  100. --- a/libstdc++-v3/include/c_global/cstdlib
  101. +++ b/libstdc++-v3/include/c_global/cstdlib
  102. @@ -182,7 +182,7 @@
  103. _GLIBCXX_END_NAMESPACE_VERSION
  104. } // namespace
  105. -#if _GLIBCXX_USE_C99
  106. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  107. #undef _Exit
  108. #undef llabs
  109. Index: b/libstdc++-v3/include/c_global/cwchar
  110. ===================================================================
  111. --- a/libstdc++-v3/include/c_global/cwchar
  112. +++ b/libstdc++-v3/include/c_global/cwchar
  113. @@ -232,7 +232,7 @@
  114. _GLIBCXX_END_NAMESPACE_VERSION
  115. } // namespace
  116. -#if _GLIBCXX_USE_C99
  117. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  118. #undef wcstold
  119. #undef wcstoll
  120. @@ -289,7 +289,7 @@
  121. using std::vwscanf;
  122. #endif
  123. -#if _GLIBCXX_USE_C99
  124. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  125. using std::wcstold;
  126. using std::wcstoll;
  127. using std::wcstoull;
  128. Index: b/libstdc++-v3/include/c_std/cstdio
  129. ===================================================================
  130. --- a/libstdc++-v3/include/c_std/cstdio
  131. +++ b/libstdc++-v3/include/c_std/cstdio
  132. @@ -139,7 +139,7 @@
  133. using ::vsprintf;
  134. } // namespace std
  135. -#if _GLIBCXX_USE_C99
  136. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  137. #undef snprintf
  138. #undef vfscanf
  139. Index: b/libstdc++-v3/include/c_std/cstdlib
  140. ===================================================================
  141. --- a/libstdc++-v3/include/c_std/cstdlib
  142. +++ b/libstdc++-v3/include/c_std/cstdlib
  143. @@ -180,7 +180,7 @@
  144. _GLIBCXX_END_NAMESPACE_VERSION
  145. } // namespace
  146. -#if _GLIBCXX_USE_C99
  147. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  148. #undef _Exit
  149. #undef llabs
  150. Index: b/libstdc++-v3/include/c_std/cwchar
  151. ===================================================================
  152. --- a/libstdc++-v3/include/c_std/cwchar
  153. +++ b/libstdc++-v3/include/c_std/cwchar
  154. @@ -228,7 +228,7 @@
  155. _GLIBCXX_END_NAMESPACE_VERSION
  156. } // namespace
  157. -#if _GLIBCXX_USE_C99
  158. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  159. #undef wcstold
  160. #undef wcstoll
  161. Index: b/libstdc++-v3/include/ext/vstring.h
  162. ===================================================================
  163. --- a/libstdc++-v3/include/ext/vstring.h
  164. +++ b/libstdc++-v3/include/ext/vstring.h
  165. @@ -2571,7 +2571,7 @@
  166. _GLIBCXX_END_NAMESPACE_VERSION
  167. } // namespace
  168. -#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99))
  169. +#if ((__cplusplus >= 201103L) && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)))
  170. #include <ext/string_conversions.h>
  171. Index: b/libstdc++-v3/include/tr1/cstdio
  172. ===================================================================
  173. --- a/libstdc++-v3/include/tr1/cstdio
  174. +++ b/libstdc++-v3/include/tr1/cstdio
  175. @@ -33,7 +33,7 @@
  176. #include <cstdio>
  177. -#if _GLIBCXX_USE_C99
  178. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  179. namespace std _GLIBCXX_VISIBILITY(default)
  180. {
  181. Index: b/libstdc++-v3/include/tr1/cstdlib
  182. ===================================================================
  183. --- a/libstdc++-v3/include/tr1/cstdlib
  184. +++ b/libstdc++-v3/include/tr1/cstdlib
  185. @@ -35,7 +35,7 @@
  186. #if _GLIBCXX_HOSTED
  187. -#if _GLIBCXX_USE_C99
  188. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  189. namespace std _GLIBCXX_VISIBILITY(default)
  190. {
  191. Index: b/libstdc++-v3/include/tr1/cwchar
  192. ===================================================================
  193. --- a/libstdc++-v3/include/tr1/cwchar
  194. +++ b/libstdc++-v3/include/tr1/cwchar
  195. @@ -52,7 +52,7 @@
  196. using std::vwscanf;
  197. #endif
  198. -#if _GLIBCXX_USE_C99
  199. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  200. using std::wcstold;
  201. using std::wcstoll;
  202. using std::wcstoull;
  203. Index: b/libstdc++-v3/include/tr1/stdlib.h
  204. ===================================================================
  205. --- a/libstdc++-v3/include/tr1/stdlib.h
  206. +++ b/libstdc++-v3/include/tr1/stdlib.h
  207. @@ -33,7 +33,7 @@
  208. #if _GLIBCXX_HOSTED
  209. -#if _GLIBCXX_USE_C99
  210. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  211. using std::tr1::atoll;
  212. using std::tr1::strtoll;
  213. Index: b/libstdc++-v3/src/c++11/debug.cc
  214. ===================================================================
  215. --- a/libstdc++-v3/src/c++11/debug.cc
  216. +++ b/libstdc++-v3/src/c++11/debug.cc
  217. @@ -787,7 +787,7 @@
  218. int __n __attribute__ ((__unused__)),
  219. const char* __fmt, _Tp __s) const throw ()
  220. {
  221. -#ifdef _GLIBCXX_USE_C99
  222. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  223. std::snprintf(__buf, __n, __fmt, __s);
  224. #else
  225. std::sprintf(__buf, __fmt, __s);
  226. Index: b/libstdc++-v3/include/c_global/cstdio
  227. ===================================================================
  228. --- a/libstdc++-v3/include/c_global/cstdio
  229. +++ b/libstdc++-v3/include/c_global/cstdio
  230. @@ -139,7 +139,7 @@
  231. using ::vsprintf;
  232. } // namespace
  233. -#if _GLIBCXX_USE_C99
  234. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  235. #undef snprintf
  236. #undef vfscanf