Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/libc++/dist/libcxxrt Import libcxxrt 47661d00cd...



details:   https://anonhg.NetBSD.org/src/rev/7f5f40885aab
branches:  trunk
changeset: 1021403:7f5f40885aab
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sun May 30 00:08:19 2021 +0000

description:
Import libcxxrt 47661d00cd4d6cd728ae31b0bb29a49a6c06272a

The repository moved to https://github.com/libcxxrt/libcxxrt in the mean
time, but keep it on the same branch as before. This primarily brings
C++14 support.

diffstat:

 external/bsd/libc++/dist/libcxxrt/src/memory.cc                   |   47 ++-
 external/bsd/libc++/dist/libcxxrt/src/typeinfo.cc                 |   10 +-
 external/bsd/libc++/dist/libcxxrt/src/unwind-arm.h                |   12 +-
 external/bsd/libc++/dist/libcxxrt/test/test.cc                    |    2 +
 external/bsd/libc++/dist/libcxxrt/test/test.h                     |    1 +
 external/bsd/libc++/dist/libcxxrt/test/test_demangle.cc           |   46 +++
 external/bsd/libc++/dist/libcxxrt/test/test_exception.cc          |  139 +++++++++-
 external/bsd/libc++/dist/libcxxrt/test/test_foreign_exceptions.cc |  125 ++++++++
 8 files changed, 353 insertions(+), 29 deletions(-)

diffs (truncated from 537 to 300 lines):

diff -r 276a01882d23 -r 7f5f40885aab external/bsd/libc++/dist/libcxxrt/src/memory.cc
--- a/external/bsd/libc++/dist/libcxxrt/src/memory.cc   Sat May 29 23:46:14 2021 +0000
+++ b/external/bsd/libc++/dist/libcxxrt/src/memory.cc   Sun May 30 00:08:19 2021 +0000
@@ -71,8 +71,17 @@
 }
 
 
+#if __cplusplus < 201103L
+#define NOEXCEPT throw()
+#define BADALLOC throw(std::bad_alloc)
+#else
+#define NOEXCEPT noexcept
+#define BADALLOC
+#endif
+
+
 __attribute__((weak))
-void* operator new(size_t size)
+void* operator new(size_t size) BADALLOC
 {
        if (0 == size)
        {
@@ -97,7 +106,7 @@
 }
 
 __attribute__((weak))
-void* operator new(size_t size, const std::nothrow_t &) throw()
+void* operator new(size_t size, const std::nothrow_t &) NOEXCEPT
 {
        try {
                return :: operator new(size);
@@ -110,27 +119,21 @@
 
 
 __attribute__((weak))
-void operator delete(void * ptr)
-#if __cplusplus < 201000L
-throw()
-#endif
+void operator delete(void * ptr) NOEXCEPT
 {
        free(ptr);
 }
 
 
 __attribute__((weak))
-void * operator new[](size_t size)
-#if __cplusplus < 201000L
-throw(std::bad_alloc)
-#endif
+void * operator new[](size_t size) BADALLOC
 {
        return ::operator new(size);
 }
 
 
 __attribute__((weak))
-void * operator new[](size_t size, const std::nothrow_t &) throw()
+void * operator new[](size_t size, const std::nothrow_t &) NOEXCEPT
 {
        try {
                return ::operator new[](size);
@@ -143,12 +146,26 @@
 
 
 __attribute__((weak))
-void operator delete[](void * ptr)
-#if __cplusplus < 201000L
-throw()
-#endif
+void operator delete[](void * ptr) NOEXCEPT
+{
+       ::operator delete(ptr);
+}
+
+// C++14 additional delete operators
+
+#if __cplusplus >= 201402L
+
+__attribute__((weak))
+void operator delete(void * ptr, size_t) NOEXCEPT
 {
        ::operator delete(ptr);
 }
 
 
+__attribute__((weak))
+void operator delete[](void * ptr, size_t) NOEXCEPT
+{
+       ::operator delete(ptr);
+}
+
+#endif
diff -r 276a01882d23 -r 7f5f40885aab external/bsd/libc++/dist/libcxxrt/src/typeinfo.cc
--- a/external/bsd/libc++/dist/libcxxrt/src/typeinfo.cc Sat May 29 23:46:14 2021 +0000
+++ b/external/bsd/libc++/dist/libcxxrt/src/typeinfo.cc Sun May 30 00:08:19 2021 +0000
@@ -86,15 +86,7 @@
        if (NULL != demangled)
        {
                size_t len = strlen(demangled);
-               if (buf == NULL)
-               {
-                       if (n)
-                       {
-                               *n = len;
-                       }
-                       return demangled;
-               }
-               if (*n < len+1)
+               if (!buf || (*n < len+1))
                {
                        buf = static_cast<char*>(realloc(buf, len+1));
                }
diff -r 276a01882d23 -r 7f5f40885aab external/bsd/libc++/dist/libcxxrt/src/unwind-arm.h
--- a/external/bsd/libc++/dist/libcxxrt/src/unwind-arm.h        Sat May 29 23:46:14 2021 +0000
+++ b/external/bsd/libc++/dist/libcxxrt/src/unwind-arm.h        Sun May 30 00:08:19 2021 +0000
@@ -20,15 +20,19 @@
  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */ 
 
+/* For uint32_t and uint64_t */
+#include <stdint.h>
+
 /**
  * ARM-specific unwind definitions.  These are taken from the ARM EHABI
  * specification.
  */
  typedef enum
 {
+       _URC_NO_REASON = 0,
        _URC_OK = 0,                /* operation completed successfully */
        _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
-    _URC_END_OF_STACK = 5,
+       _URC_END_OF_STACK = 5,
        _URC_HANDLER_FOUND = 6,
        _URC_INSTALL_CONTEXT = 7,
        _URC_CONTINUE_UNWIND = 8,
@@ -41,10 +45,12 @@
 static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME  = 0;
 static const _Unwind_State _US_UNWIND_FRAME_STARTING = 1;
 static const _Unwind_State _US_UNWIND_FRAME_RESUME   = 2;
+static const _Unwind_State _US_ACTION_MASK           = 3;
 #else // GCC fails at knowing what a constant expression is
 #      define _US_VIRTUAL_UNWIND_FRAME  0
 #      define _US_UNWIND_FRAME_STARTING 1
-#      define _US_UNWIND_FRAME_RESUME 2
+#      define _US_UNWIND_FRAME_RESUME   2
+#      define _US_ACTION_MASK           3
 #endif
 
 typedef struct _Unwind_Context _Unwind_Context;
@@ -89,7 +95,7 @@
        } pr_cache;
        /** Force alignment of next item to 8-byte boundary */
        long long int :0;
-};
+} __attribute__((__aligned__(8)));
 
 /* Unwinding functions */
 _Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *ucbp);
diff -r 276a01882d23 -r 7f5f40885aab external/bsd/libc++/dist/libcxxrt/test/test.cc
--- a/external/bsd/libc++/dist/libcxxrt/test/test.cc    Sat May 29 23:46:14 2021 +0000
+++ b/external/bsd/libc++/dist/libcxxrt/test/test.cc    Sun May 30 00:08:19 2021 +0000
@@ -35,6 +35,7 @@
 void test_type_info(void);
 void test_exceptions();
 void test_guards(void);
+void test_demangle(void);
 int main(int argc, char **argv)
 {
        int ch;
@@ -52,5 +53,6 @@
        test_type_info();
        test_guards();
        test_exceptions();
+       test_demangle();
        return 0;
 }
diff -r 276a01882d23 -r 7f5f40885aab external/bsd/libc++/dist/libcxxrt/test/test.h
--- a/external/bsd/libc++/dist/libcxxrt/test/test.h     Sat May 29 23:46:14 2021 +0000
+++ b/external/bsd/libc++/dist/libcxxrt/test/test.h     Sun May 30 00:08:19 2021 +0000
@@ -2,3 +2,4 @@
 void log_test(bool predicate, const char *file, int line, const char *message);
 
 #define TEST(p, m) log_test(p, __FILE__, __LINE__, m)
+#define TEST_LOC(p, m, file, line) log_test(p, file, line, m)
diff -r 276a01882d23 -r 7f5f40885aab external/bsd/libc++/dist/libcxxrt/test/test_demangle.cc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/libc++/dist/libcxxrt/test/test_demangle.cc   Sun May 30 00:08:19 2021 +0000
@@ -0,0 +1,46 @@
+#include "test.h"
+#include <cxxabi.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <list>
+
+template <typename T> void test(const char* expected, int line) {
+       const char *mangled = typeid(T).name();
+       int status = 0;
+       using abi::__cxa_demangle;
+       char* demangled = __cxa_demangle(mangled, 0, 0, &status);
+       printf("mangled='%s' demangled='%s', status=%d\n", mangled, demangled,
+           status);
+       free(demangled);
+       TEST_LOC(status == 0, "should be able to demangle", __FILE__, line);
+       TEST_LOC(demangled != 0, "should be able to demangle", __FILE__, line);
+       if (!demangled) {
+               /* Don't dereference NULL in strcmp() */
+               return;
+       }
+       TEST_LOC(strcmp(expected, demangled) == 0, "should be able to demangle",
+           __FILE__, line);
+       TEST_LOC(strcmp(mangled, demangled) != 0, "should be able to demangle",
+           __FILE__, line);
+}
+
+
+namespace N {
+template<typename T, int U>
+class Templated {
+       virtual ~Templated() {};
+};
+}
+
+void test_demangle(void)
+{
+       using namespace N;
+       test<int>("int", __LINE__);
+       test<char[4]>("char [4]", __LINE__);
+       test<char[]>("char []", __LINE__);
+       test<Templated<Templated<long, 7>, 8> >(
+           "N::Templated<N::Templated<long, 7>, 8>", __LINE__);
+       test<Templated<void(long), -1> >(
+           "N::Templated<void (long), -1>", __LINE__);
+}
diff -r 276a01882d23 -r 7f5f40885aab external/bsd/libc++/dist/libcxxrt/test/test_exception.cc
--- a/external/bsd/libc++/dist/libcxxrt/test/test_exception.cc  Sat May 29 23:46:14 2021 +0000
+++ b/external/bsd/libc++/dist/libcxxrt/test/test_exception.cc  Sun May 30 00:08:19 2021 +0000
@@ -1,4 +1,5 @@
 #include "test.h"
+#include "unwind.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -7,12 +8,12 @@
 
 #define fprintf(...)
 
-void log(void* ignored)
+void log_cleanup(void* ignored)
 {
        //printf("Cleanup called on %s\n", *(char**)ignored);
 }
 #define CLEANUP\
-       __attribute__((cleanup(log))) __attribute__((unused))\
+       __attribute__((cleanup(log_cleanup))) __attribute__((unused))\
                const char *f = __func__;
 
 /**
@@ -191,6 +192,136 @@
        throw 0;
 }
 
+struct uncaught_exception_checker
+{
+       uncaught_exception_checker(bool uncaught) : m_uncaught(uncaught) {}
+       ~uncaught_exception_checker() {
+               if (std::uncaught_exception())
+                       TEST(m_uncaught, "At least one uncaught exception is in flight");
+               else
+                       TEST(!m_uncaught, "No uncaught exceptions are in flight");
+       }
+       bool m_uncaught;
+};
+
+void test_rethrown_uncaught_exception()
+{
+       uncaught_exception_checker outer(false);
+       try
+       {
+               try
+               {
+                       throw 42;
+               }
+               catch (int)
+               {
+                       uncaught_exception_checker inner(true);
+                       throw;
+               }
+       }
+       catch (...) {}
+}
+
+static void exception_cleanup(_Unwind_Reason_Code, struct _Unwind_Exception *ex)
+{
+       delete ex;
+}
+
+void test_rethrown_uncaught_foreign_exception()



Home | Main Index | Thread Index | Old Index