Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly ...



details:   https://anonhg.NetBSD.org/src/rev/6a42a2623a70
branches:  trunk
changeset: 961893:6a42a2623a70
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Apr 24 21:17:40 2021 +0000

description:
move the NetBSD version of:

   __convert_from_v(const __c_locale& __cloc, char* __out,
                    const int __size __attribute__ ((__unused__)),
                    const char* __fmt, ...)

from the .h file into the .cc file.

NetBSD version relies upon vasprintf_l() being defined and compile
contexts such as _XOPEN_SOURCE=600 or _POSIX_C_SOURCE < 200809 may
not provide the definition of it, cause compile time issues for
3rdparty applications in c++locale.h.  This ensure that all the
required definitions are present when this code is compiled.

diffstat:

 external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.cc |  20 +++++++++
 external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.h  |  22 +++++----
 2 files changed, 33 insertions(+), 9 deletions(-)

diffs (98 lines):

diff -r 3dd970837ec2 -r 6a42a2623a70 external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.cc
--- a/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.cc   Sat Apr 24 20:34:34 2021 +0000
+++ b/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.cc   Sat Apr 24 21:17:40 2021 +0000
@@ -28,6 +28,8 @@
 
 // Written by Benjamin Kosnik <bkoz%redhat.com@localhost>
 // Modified for DragonFly by John Marino <gnugcc%marino.st@localhost>
+// Modified for NetBSD by Christos Zoulas <christos%zoulas.com@localhost> and
+// matthew green <mrg%eterna.com.au@localhost>
 
 #include <cstdlib>
 #include <locale>
@@ -191,6 +193,24 @@
 
   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
 
diff -r 3dd970837ec2 -r 6a42a2623a70 external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.h
--- a/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.h    Sat Apr 24 20:34:34 2021 +0000
+++ b/external/gpl3/gcc/dist/libstdc++-v3/config/locale/dragonfly/c_locale.h    Sat Apr 24 21:17:40 2021 +0000
@@ -33,6 +33,8 @@
 
 // Written by Benjamin Kosnik <bkoz%redhat.com@localhost>
 // Modified for DragonFly by John Marino <gnugcc%marino.st@localhost>
+// Modified for NetBSD by Christos Zoulas <christos%zoulas.com@localhost> and
+// matthew green <mrg%eterna.com.au@localhost>
 
 #ifndef _GLIBCXX_CXX_LOCALE_H
 #define _GLIBCXX_CXX_LOCALE_H 1
@@ -54,6 +56,7 @@
 
   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
@@ -63,30 +66,31 @@
                   const int __size __attribute__ ((__unused__)),
                   const char* __fmt, ...)
   {
-#ifndef __NetBSD__
     __c_locale __old = (__c_locale)uselocale((locale_t)__cloc);
-#endif
 
     __builtin_va_list __args;
     __builtin_va_start(__args, __fmt);
 
-#ifndef __NetBSD__
 #if _GLIBCXX_USE_C99_STDIO
     const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
 #else
     const int __ret = __builtin_vsprintf(__out, __fmt, __args);
 #endif
 
-    uselocale((locale_t)__old);
-#else
-    const int __ret = vsnprintf_l(__out, __size, (locale_t)__cloc, __fmt,
-       __args);
-#endif
-
     __builtin_va_end(__args);
 
+    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



Home | Main Index | Thread Index | Old Index