Index: config/locale/dragonfly/c_locale.cc =================================================================== RCS file: /cvsroot/src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.cc,v retrieving revision 1.1.1.8 diff -p -u -r1.1.1.8 c_locale.cc --- config/locale/dragonfly/c_locale.cc 10 Apr 2021 22:10:12 -0000 1.1.1.8 +++ config/locale/dragonfly/c_locale.cc 24 Apr 2021 04:41:48 -0000 @@ -28,13 +28,17 @@ // Written by Benjamin Kosnik // Modified for DragonFly by John Marino +// Modified for NetBSD by Christos Zoulas and +// matthew green #include #include #include #include #include +#ifndef __NetBSD__ #include +#endif namespace std _GLIBCXX_VISIBILITY(default) { @@ -189,6 +193,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const char* const* const locale::_S_categories = __gnu_cxx::category_names; +#ifdef __NetBSD__ + int + __convert_from_v(const __c_locale& __cloc, char* __out, + const int __size __attribute__ ((__unused__)), + const char* __fmt, ...) + { + __builtin_va_list __args; + __builtin_va_start(__args, __fmt); + + const int __ret = vsnprintf_l(__out, __size, (struct _locale *)__cloc, + __fmt, __args); + + __builtin_va_end(__args); + + return __ret; + } +#endif + _GLIBCXX_END_NAMESPACE_VERSION } // namespace Index: config/locale/dragonfly/c_locale.h =================================================================== RCS file: /cvsroot/src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.h,v retrieving revision 1.1.1.7 diff -p -u -r1.1.1.7 c_locale.h --- config/locale/dragonfly/c_locale.h 10 Apr 2021 22:10:12 -0000 1.1.1.7 +++ config/locale/dragonfly/c_locale.h 24 Apr 2021 04:41:48 -0000 @@ -33,6 +33,8 @@ // Written by Benjamin Kosnik // Modified for DragonFly by John Marino +// Modified for NetBSD by Christos Zoulas and +// matthew green #ifndef _GLIBCXX_CXX_LOCALE_H #define _GLIBCXX_CXX_LOCALE_H 1 @@ -40,7 +42,11 @@ #pragma GCC system_header #include +#ifndef __NetBSD__ #include +#else +#include +#endif #define _GLIBCXX_NUM_CATEGORIES 0 @@ -50,6 +56,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef int* __c_locale; +#ifndef __NetBSD__ // Convert numeric value of type double and long double to string and // return length of string. If vsnprintf is available use it, otherwise // fall back to the unsafe vsprintf which, in general, can be dangerous @@ -75,6 +82,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION uselocale((locale_t)__old); return __ret; } +#else + // NetBSD backend requires vasprintf_l() which may not be visible in + // all complation environments (eg, _XOPEN_SOURCE=600) so the backend + // lives in the library code, instead of this header. + int + __convert_from_v(const __c_locale& __cloc, char* __out, + const int __size __attribute__ ((__unused__)), + const char* __fmt, ...); +#endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace