850-libstdcxx-uclibc-c99.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. [Gustavo: update for 4.9.3]
  15. diff -Nura gcc-4.9.3.orig/libstdc++-v3/config/locale/generic/c_locale.h gcc-4.9.3/libstdc++-v3/config/locale/generic/c_locale.h
  16. --- gcc-4.9.3.orig/libstdc++-v3/config/locale/generic/c_locale.h 2014-01-02 19:30:10.000000000 -0300
  17. +++ gcc-4.9.3/libstdc++-v3/config/locale/generic/c_locale.h 2015-06-27 06:46:04.420022179 -0300
  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. diff -Nura gcc-4.9.3.orig/libstdc++-v3/config/locale/gnu/c_locale.h gcc-4.9.3/libstdc++-v3/config/locale/gnu/c_locale.h
  27. --- gcc-4.9.3.orig/libstdc++-v3/config/locale/gnu/c_locale.h 2014-01-02 19:30:10.000000000 -0300
  28. +++ gcc-4.9.3/libstdc++-v3/config/locale/gnu/c_locale.h 2015-06-27 06:46:04.465023743 -0300
  29. @@ -88,7 +88,7 @@
  30. __builtin_va_list __args;
  31. __builtin_va_start(__args, __fmt);
  32. -#ifdef _GLIBCXX_USE_C99
  33. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  34. const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
  35. #else
  36. const int __ret = __builtin_vsprintf(__out, __fmt, __args);
  37. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/bits/basic_string.h gcc-4.9.3/libstdc++-v3/include/bits/basic_string.h
  38. --- gcc-4.9.3.orig/libstdc++-v3/include/bits/basic_string.h 2015-05-28 13:27:46.000000000 -0300
  39. +++ gcc-4.9.3/libstdc++-v3/include/bits/basic_string.h 2015-06-27 06:49:04.741284648 -0300
  40. @@ -2844,7 +2844,7 @@
  41. _GLIBCXX_END_NAMESPACE_VERSION
  42. } // namespace
  43. -#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
  44. +#if __cplusplus >= 201103L && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__))
  45. #include <ext/string_conversions.h>
  46. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/bits/locale_facets_nonio.tcc gcc-4.9.3/libstdc++-v3/include/bits/locale_facets_nonio.tcc
  47. --- gcc-4.9.3.orig/libstdc++-v3/include/bits/locale_facets_nonio.tcc 2014-01-02 19:30:10.000000000 -0300
  48. +++ gcc-4.9.3/libstdc++-v3/include/bits/locale_facets_nonio.tcc 2015-06-27 06:46:04.466023777 -0300
  49. @@ -572,7 +572,7 @@
  50. {
  51. const locale __loc = __io.getloc();
  52. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  53. -#ifdef _GLIBCXX_USE_C99
  54. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  55. // First try a buffer perhaps big enough.
  56. int __cs_size = 64;
  57. char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
  58. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/bits/locale_facets.tcc gcc-4.9.3/libstdc++-v3/include/bits/locale_facets.tcc
  59. --- gcc-4.9.3.orig/libstdc++-v3/include/bits/locale_facets.tcc 2014-01-02 19:30:10.000000000 -0300
  60. +++ gcc-4.9.3/libstdc++-v3/include/bits/locale_facets.tcc 2015-06-27 06:46:04.466023777 -0300
  61. @@ -987,7 +987,7 @@
  62. char __fbuf[16];
  63. __num_base::_S_format_float(__io, __fbuf, __mod);
  64. -#ifdef _GLIBCXX_USE_C99
  65. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  66. // First try a buffer perhaps big enough (most probably sufficient
  67. // for non-ios_base::fixed outputs)
  68. int __cs_size = __max_digits * 3;
  69. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/c_compatibility/math.h gcc-4.9.3/libstdc++-v3/include/c_compatibility/math.h
  70. --- gcc-4.9.3.orig/libstdc++-v3/include/c_compatibility/math.h 2014-01-02 19:30:10.000000000 -0300
  71. +++ gcc-4.9.3/libstdc++-v3/include/c_compatibility/math.h 2015-06-27 06:46:04.466023777 -0300
  72. @@ -56,7 +56,7 @@
  73. using std::floor;
  74. using std::fmod;
  75. -#if _GLIBCXX_USE_C99
  76. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  77. using std::fpclassify;
  78. using std::isfinite;
  79. using std::isinf;
  80. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/c_compatibility/wchar.h gcc-4.9.3/libstdc++-v3/include/c_compatibility/wchar.h
  81. --- gcc-4.9.3.orig/libstdc++-v3/include/c_compatibility/wchar.h 2014-01-02 19:30:10.000000000 -0300
  82. +++ gcc-4.9.3/libstdc++-v3/include/c_compatibility/wchar.h 2015-06-27 06:46:04.466023777 -0300
  83. @@ -103,7 +103,7 @@
  84. using std::wmemset;
  85. using std::wcsftime;
  86. -#if _GLIBCXX_USE_C99
  87. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  88. using std::wcstold;
  89. using std::wcstoll;
  90. using std::wcstoull;
  91. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/c_global/cstdio gcc-4.9.3/libstdc++-v3/include/c_global/cstdio
  92. --- gcc-4.9.3.orig/libstdc++-v3/include/c_global/cstdio 2014-01-23 18:17:15.000000000 -0300
  93. +++ gcc-4.9.3/libstdc++-v3/include/c_global/cstdio 2015-06-27 06:46:04.481024298 -0300
  94. @@ -146,7 +146,7 @@
  95. using ::vsprintf;
  96. } // namespace
  97. -#if _GLIBCXX_USE_C99
  98. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  99. #undef snprintf
  100. #undef vfscanf
  101. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/c_global/cstdlib gcc-4.9.3/libstdc++-v3/include/c_global/cstdlib
  102. --- gcc-4.9.3.orig/libstdc++-v3/include/c_global/cstdlib 2014-01-02 19:30:10.000000000 -0300
  103. +++ gcc-4.9.3/libstdc++-v3/include/c_global/cstdlib 2015-06-27 06:46:04.466023777 -0300
  104. @@ -182,7 +182,7 @@
  105. _GLIBCXX_END_NAMESPACE_VERSION
  106. } // namespace
  107. -#if _GLIBCXX_USE_C99
  108. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  109. #undef _Exit
  110. #undef llabs
  111. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/c_global/cwchar gcc-4.9.3/libstdc++-v3/include/c_global/cwchar
  112. --- gcc-4.9.3.orig/libstdc++-v3/include/c_global/cwchar 2014-01-02 19:30:10.000000000 -0300
  113. +++ gcc-4.9.3/libstdc++-v3/include/c_global/cwchar 2015-06-27 06:46:04.466023777 -0300
  114. @@ -232,7 +232,7 @@
  115. _GLIBCXX_END_NAMESPACE_VERSION
  116. } // namespace
  117. -#if _GLIBCXX_USE_C99
  118. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  119. #undef wcstold
  120. #undef wcstoll
  121. @@ -289,7 +289,7 @@
  122. using std::vwscanf;
  123. #endif
  124. -#if _GLIBCXX_USE_C99
  125. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  126. using std::wcstold;
  127. using std::wcstoll;
  128. using std::wcstoull;
  129. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/c_std/cstdio gcc-4.9.3/libstdc++-v3/include/c_std/cstdio
  130. --- gcc-4.9.3.orig/libstdc++-v3/include/c_std/cstdio 2014-01-02 19:30:10.000000000 -0300
  131. +++ gcc-4.9.3/libstdc++-v3/include/c_std/cstdio 2015-06-27 06:46:04.480024263 -0300
  132. @@ -144,7 +144,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. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/c_std/cstdlib gcc-4.9.3/libstdc++-v3/include/c_std/cstdlib
  140. --- gcc-4.9.3.orig/libstdc++-v3/include/c_std/cstdlib 2014-01-02 19:30:10.000000000 -0300
  141. +++ gcc-4.9.3/libstdc++-v3/include/c_std/cstdlib 2015-06-27 06:46:04.480024263 -0300
  142. @@ -180,7 +180,7 @@
  143. _GLIBCXX_END_NAMESPACE_VERSION
  144. } // namespace
  145. -#if _GLIBCXX_USE_C99
  146. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  147. #undef _Exit
  148. #undef llabs
  149. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/c_std/cwchar gcc-4.9.3/libstdc++-v3/include/c_std/cwchar
  150. --- gcc-4.9.3.orig/libstdc++-v3/include/c_std/cwchar 2014-01-02 19:30:10.000000000 -0300
  151. +++ gcc-4.9.3/libstdc++-v3/include/c_std/cwchar 2015-06-27 06:46:04.480024263 -0300
  152. @@ -228,7 +228,7 @@
  153. _GLIBCXX_END_NAMESPACE_VERSION
  154. } // namespace
  155. -#if _GLIBCXX_USE_C99
  156. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  157. #undef wcstold
  158. #undef wcstoll
  159. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/ext/vstring.h gcc-4.9.3/libstdc++-v3/include/ext/vstring.h
  160. --- gcc-4.9.3.orig/libstdc++-v3/include/ext/vstring.h 2014-01-02 19:30:10.000000000 -0300
  161. +++ gcc-4.9.3/libstdc++-v3/include/ext/vstring.h 2015-06-27 06:46:04.480024263 -0300
  162. @@ -2680,7 +2680,7 @@
  163. _GLIBCXX_END_NAMESPACE_VERSION
  164. } // namespace
  165. -#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99))
  166. +#if ((__cplusplus >= 201103L) && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)))
  167. #include <ext/string_conversions.h>
  168. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/tr1/cstdio gcc-4.9.3/libstdc++-v3/include/tr1/cstdio
  169. --- gcc-4.9.3.orig/libstdc++-v3/include/tr1/cstdio 2014-01-02 19:30:10.000000000 -0300
  170. +++ gcc-4.9.3/libstdc++-v3/include/tr1/cstdio 2015-06-27 06:46:04.480024263 -0300
  171. @@ -33,7 +33,7 @@
  172. #include <cstdio>
  173. -#if _GLIBCXX_USE_C99
  174. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  175. namespace std _GLIBCXX_VISIBILITY(default)
  176. {
  177. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/tr1/cstdlib gcc-4.9.3/libstdc++-v3/include/tr1/cstdlib
  178. --- gcc-4.9.3.orig/libstdc++-v3/include/tr1/cstdlib 2014-01-02 19:30:10.000000000 -0300
  179. +++ gcc-4.9.3/libstdc++-v3/include/tr1/cstdlib 2015-06-27 06:46:04.480024263 -0300
  180. @@ -35,7 +35,7 @@
  181. #if _GLIBCXX_HOSTED
  182. -#if _GLIBCXX_USE_C99
  183. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  184. namespace std _GLIBCXX_VISIBILITY(default)
  185. {
  186. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/tr1/cwchar gcc-4.9.3/libstdc++-v3/include/tr1/cwchar
  187. --- gcc-4.9.3.orig/libstdc++-v3/include/tr1/cwchar 2014-01-02 19:30:10.000000000 -0300
  188. +++ gcc-4.9.3/libstdc++-v3/include/tr1/cwchar 2015-06-27 06:46:04.480024263 -0300
  189. @@ -52,7 +52,7 @@
  190. using std::vwscanf;
  191. #endif
  192. -#if _GLIBCXX_USE_C99
  193. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  194. using std::wcstold;
  195. using std::wcstoll;
  196. using std::wcstoull;
  197. diff -Nura gcc-4.9.3.orig/libstdc++-v3/include/tr1/stdlib.h gcc-4.9.3/libstdc++-v3/include/tr1/stdlib.h
  198. --- gcc-4.9.3.orig/libstdc++-v3/include/tr1/stdlib.h 2014-01-02 19:30:10.000000000 -0300
  199. +++ gcc-4.9.3/libstdc++-v3/include/tr1/stdlib.h 2015-06-27 06:46:04.481024298 -0300
  200. @@ -33,7 +33,7 @@
  201. #if _GLIBCXX_HOSTED
  202. -#if _GLIBCXX_USE_C99
  203. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  204. using std::tr1::atoll;
  205. using std::tr1::strtoll;
  206. diff -Nura gcc-4.9.3.orig/libstdc++-v3/src/c++11/debug.cc gcc-4.9.3/libstdc++-v3/src/c++11/debug.cc
  207. --- gcc-4.9.3.orig/libstdc++-v3/src/c++11/debug.cc 2014-01-02 19:30:10.000000000 -0300
  208. +++ gcc-4.9.3/libstdc++-v3/src/c++11/debug.cc 2015-06-27 06:46:04.481024298 -0300
  209. @@ -788,7 +788,7 @@
  210. int __n __attribute__ ((__unused__)),
  211. const char* __fmt, _Tp __s) const throw ()
  212. {
  213. -#ifdef _GLIBCXX_USE_C99
  214. +#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
  215. std::snprintf(__buf, __n, __fmt, __s);
  216. #else
  217. std::sprintf(__buf, __fmt, __s);