bcraig updated this revision to Diff 95520. bcraig added reviewers: jyknight, mclow.lists, EricWF. bcraig added a subscriber: cfe-commits.
https://reviews.llvm.org/D32147 Files: include/__bsd_locale_fallbacks.h include/__config Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -871,6 +871,10 @@ #endif #endif +#if defined(_NEWLIB_VERSION) +#define _LIBCPP_HAS_NO_ASPRINTF 1 +#endif + #ifdef __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 #endif Index: include/__bsd_locale_fallbacks.h =================================================================== --- include/__bsd_locale_fallbacks.h +++ include/__bsd_locale_fallbacks.h @@ -118,7 +118,26 @@ va_list __va; va_start(__va, __format); __locale_raii __current( uselocale(__l), uselocale ); +#if _LIBCPP_HAS_NO_ASPRINTF + va_list __va2; + va_copy(__va2, __va); + int __res = vsnprintf(0, 0, __format, __va2); + va_end(__va2); + if(__res < 0) + { + va_end(__va); + return __res; + } + *__s = (char *)malloc(__res+1); + if(*__s == 0) + { + va_end(__va); + return -1; + } + vsnprintf(*__s, __res+1, __format, __va); +#else int __res = vasprintf(__s, __format, __va); +#endif va_end(__va); return __res; }
Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -871,6 +871,10 @@ #endif #endif +#if defined(_NEWLIB_VERSION) +#define _LIBCPP_HAS_NO_ASPRINTF 1 +#endif + #ifdef __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 #endif Index: include/__bsd_locale_fallbacks.h =================================================================== --- include/__bsd_locale_fallbacks.h +++ include/__bsd_locale_fallbacks.h @@ -118,7 +118,26 @@ va_list __va; va_start(__va, __format); __locale_raii __current( uselocale(__l), uselocale ); +#if _LIBCPP_HAS_NO_ASPRINTF + va_list __va2; + va_copy(__va2, __va); + int __res = vsnprintf(0, 0, __format, __va2); + va_end(__va2); + if(__res < 0) + { + va_end(__va); + return __res; + } + *__s = (char *)malloc(__res+1); + if(*__s == 0) + { + va_end(__va); + return -1; + } + vsnprintf(*__s, __res+1, __format, __va); +#else int __res = vasprintf(__s, __format, __va); +#endif va_end(__va); return __res; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits