CVS commit: src/external/bsd/libc++/dist/libcxxrt/src

2021-05-29 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun May 30 00:12:31 UTC 2021

Modified Files:
src/external/bsd/libc++/dist/libcxxrt/src: exception.cc
libelftc_dem_gnu3.c unwind-itanium.h

Log Message:
Merge 47661d00cd4d6cd728ae31b0bb29a49a6c06272a


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/bsd/libc++/dist/libcxxrt/src/exception.cc \
src/external/bsd/libc++/dist/libcxxrt/src/libelftc_dem_gnu3.c \
src/external/bsd/libc++/dist/libcxxrt/src/unwind-itanium.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/libc++/dist/libcxxrt/src

2021-05-29 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun May 30 00:12:31 UTC 2021

Modified Files:
src/external/bsd/libc++/dist/libcxxrt/src: exception.cc
libelftc_dem_gnu3.c unwind-itanium.h

Log Message:
Merge 47661d00cd4d6cd728ae31b0bb29a49a6c06272a


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/bsd/libc++/dist/libcxxrt/src/exception.cc \
src/external/bsd/libc++/dist/libcxxrt/src/libelftc_dem_gnu3.c \
src/external/bsd/libc++/dist/libcxxrt/src/unwind-itanium.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/libc++/dist/libcxxrt/src/exception.cc
diff -u src/external/bsd/libc++/dist/libcxxrt/src/exception.cc:1.2 src/external/bsd/libc++/dist/libcxxrt/src/exception.cc:1.3
--- src/external/bsd/libc++/dist/libcxxrt/src/exception.cc:1.2	Fri Jun 26 00:50:39 2015
+++ src/external/bsd/libc++/dist/libcxxrt/src/exception.cc	Sun May 30 00:12:31 2021
@@ -304,13 +304,17 @@ static pthread_key_t eh_key;
 static void exception_cleanup(_Unwind_Reason_Code reason, 
   struct _Unwind_Exception *ex)
 {
-	__cxa_free_exception(static_cast(ex));
+	// Exception layout:
+	// [__cxa_exception [_Unwind_Exception]] [exception object]
+	//
+	// __cxa_free_exception expects a pointer to the exception object
+	__cxa_free_exception(static_cast(ex + 1));
 }
 static void dependent_exception_cleanup(_Unwind_Reason_Code reason, 
   struct _Unwind_Exception *ex)
 {
 
-	__cxa_free_dependent_exception(static_cast(ex));
+	__cxa_free_dependent_exception(static_cast(ex + 1));
 }
 
 /**
@@ -340,7 +344,8 @@ static void thread_cleanup(void* thread_
 		if (info->foreign_exception_state != __cxa_thread_info::none)
 		{
 			_Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions);
-			e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
+			if (e->exception_cleanup)
+e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
 		}
 		else
 		{
@@ -516,7 +521,7 @@ static void emergency_malloc_free(char *
 			break;
 		}
 	}
-	assert(buffer > 0 &&
+	assert(buffer >= 0 &&
 	   "Trying to free something that is not an emergency buffer!");
 	// emergency_malloc() is expected to return 0-initialized data.  We don't
 	// zero the buffer when allocating it, because the static buffers will
@@ -556,7 +561,7 @@ static void free_exception(char *e)
 {
 	// If this allocation is within the address range of the emergency buffer,
 	// don't call free() because it was not allocated with malloc()
-	if ((e > emergency_buffer) &&
+	if ((e >= emergency_buffer) &&
 	(e < (emergency_buffer + sizeof(emergency_buffer
 	{
 		emergency_malloc_free(e);
@@ -854,6 +859,13 @@ extern "C" void __cxa_rethrow()
 
 	assert(ex->handlerCount > 0 && "Rethrowing uncaught exception!");
 
+	// `globals->uncaughtExceptions` was decremented by `__cxa_begin_catch`.
+	// It's normally incremented by `throw_exception`, but this path invokes
+	// `_Unwind_Resume_or_Rethrow` directly to rethrow the exception.
+	// This path is only reachable if we're rethrowing a C++ exception -
+	// foreign exceptions don't adjust any of this state.
+	globals->uncaughtExceptions++;
+
 	// ex->handlerCount will be decremented in __cxa_end_catch in enclosing
 	// catch block
 	
@@ -1199,11 +1211,13 @@ extern "C" void *__cxa_begin_catch(void 
 	// we see is a foreign exception then we won't have called it yet.
 	__cxa_thread_info *ti = thread_info();
 	__cxa_eh_globals *globals = >globals;
-	globals->uncaughtExceptions--;
 	_Unwind_Exception *exceptionObject = static_cast<_Unwind_Exception*>(e);
 
 	if (isCXXException(exceptionObject->exception_class))
 	{
+		// Only exceptions thrown with a C++ exception throwing function will
+		// increment this, so don't decrement it here.
+		globals->uncaughtExceptions--;
 		__cxa_exception *ex =  exceptionFromPointer(exceptionObject);
 
 		if (ex->handlerCount == 0)
@@ -1280,12 +1294,13 @@ extern "C" void __cxa_end_catch()
 	
 	if (ti->foreign_exception_state != __cxa_thread_info::none)
 	{
-		globals->caughtExceptions = 0;
 		if (ti->foreign_exception_state != __cxa_thread_info::rethrown)
 		{
 			_Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions);
-			e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
+			if (e->exception_cleanup)
+e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
 		}
+		globals->caughtExceptions = 0;
 		ti->foreign_exception_state = __cxa_thread_info::none;
 		return;
 	}
@@ -1339,6 +1354,14 @@ extern "C" std::type_info *__cxa_current
 }
 
 /**
+ * Cleanup, ensures that `__cxa_end_catch` is called to balance an explicit
+ * `__cxa_begin_catch` call.
+ */
+static void end_catch(char *)
+{
+	__cxa_end_catch();
+}
+/**
  * ABI function, called when an exception specification is violated.
  *
  * This function does not return.
@@ 

CVS commit: src/external/bsd/libc++/dist/libcxxrt/src

2017-08-01 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Aug  1 18:08:49 UTC 2017

Modified Files:
src/external/bsd/libc++/dist/libcxxrt/src: libelftc_dem_gnu3.c

Log Message:
Inline storage size in one place to avoid depending on DCE for removing
the USE_FORT=yes warning.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r1.2 \
src/external/bsd/libc++/dist/libcxxrt/src/libelftc_dem_gnu3.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/libc++/dist/libcxxrt/src

2017-08-01 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Aug  1 18:08:49 UTC 2017

Modified Files:
src/external/bsd/libc++/dist/libcxxrt/src: libelftc_dem_gnu3.c

Log Message:
Inline storage size in one place to avoid depending on DCE for removing
the USE_FORT=yes warning.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r1.2 \
src/external/bsd/libc++/dist/libcxxrt/src/libelftc_dem_gnu3.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/libc++/dist/libcxxrt/src/libelftc_dem_gnu3.c
diff -u src/external/bsd/libc++/dist/libcxxrt/src/libelftc_dem_gnu3.c:1.1.1.3 src/external/bsd/libc++/dist/libcxxrt/src/libelftc_dem_gnu3.c:1.2
--- src/external/bsd/libc++/dist/libcxxrt/src/libelftc_dem_gnu3.c:1.1.1.3	Fri Sep 11 11:19:59 2015
+++ src/external/bsd/libc++/dist/libcxxrt/src/libelftc_dem_gnu3.c	Tue Aug  1 18:08:48 2017
@@ -3624,7 +3624,7 @@ decode_fp_to_float80(const char *p, size
 #endif /* ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN */
 		}
 
-		memset(, 0, FLOAT_QUADRUPLE_BYTES);
+		memset(, 0, sizeof(f));
 
 #if ELFTC_BYTE_ORDER == ELFTC_BYTE_ORDER_LITTLE_ENDIAN
 		memcpy(, buf, FLOAT_EXTENED_BYTES);



CVS commit: src/external/bsd/libc++/dist/libcxxrt/src

2015-06-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Jun 26 00:50:39 UTC 2015

Modified Files:
src/external/bsd/libc++/dist/libcxxrt/src: exception.cc

Log Message:
Fix gcc revision check for __cxa_begin_catch() declaration.

Now it matches what was introduced in upstream commit e426f95.

Fixes PR lib/49990 (libc++ fails to compile with g++ 5.1)


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.4 -r1.2 \
src/external/bsd/libc++/dist/libcxxrt/src/exception.cc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/libc++/dist/libcxxrt/src/exception.cc
diff -u src/external/bsd/libc++/dist/libcxxrt/src/exception.cc:1.1.1.4 src/external/bsd/libc++/dist/libcxxrt/src/exception.cc:1.2
--- src/external/bsd/libc++/dist/libcxxrt/src/exception.cc:1.1.1.4	Thu May 15 23:56:01 2014
+++ src/external/bsd/libc++/dist/libcxxrt/src/exception.cc	Fri Jun 26 00:50:39 2015
@@ -673,7 +673,7 @@ static _Unwind_Reason_Code trace(struct 
  * If the failure happened by falling off the end of the stack without finding
  * a handler, prints a back trace before aborting.
  */
-#if __GNUC__  3  __GNUC_MINOR__  2
+#if __GNUC__  4 || (__GNUC__ == 4  __GNUC_MINOR__ = 4)
 extern C void *__cxa_begin_catch(void *e) throw();
 #else
 extern C void *__cxa_begin_catch(void *e);
@@ -1189,7 +1189,7 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_persona
  * pointer to the caught exception, which is either the adjusted pointer (for
  * C++ exceptions) of the unadjusted pointer (for foreign exceptions).
  */
-#if __GNUC__  3  __GNUC_MINOR__  2
+#if __GNUC__  4 || (__GNUC__ == 4  __GNUC_MINOR__ = 4)
 extern C void *__cxa_begin_catch(void *e) throw()
 #else
 extern C void *__cxa_begin_catch(void *e)



CVS commit: src/external/bsd/libc++/dist/libcxxrt/src

2015-06-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Jun 26 00:50:39 UTC 2015

Modified Files:
src/external/bsd/libc++/dist/libcxxrt/src: exception.cc

Log Message:
Fix gcc revision check for __cxa_begin_catch() declaration.

Now it matches what was introduced in upstream commit e426f95.

Fixes PR lib/49990 (libc++ fails to compile with g++ 5.1)


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.4 -r1.2 \
src/external/bsd/libc++/dist/libcxxrt/src/exception.cc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/bsd/libc++/dist/libcxxrt/src

2014-01-23 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jan 23 13:30:38 UTC 2014

Modified Files:
src/external/bsd/libc++/dist/libcxxrt/src: unwind-itanium.h

Log Message:
Force consistent alignemnt of _Unwind_Exception with libgcc_s.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/external/bsd/libc++/dist/libcxxrt/src/unwind-itanium.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/libc++/dist/libcxxrt/src/unwind-itanium.h
diff -u src/external/bsd/libc++/dist/libcxxrt/src/unwind-itanium.h:1.1.1.2 src/external/bsd/libc++/dist/libcxxrt/src/unwind-itanium.h:1.2
--- src/external/bsd/libc++/dist/libcxxrt/src/unwind-itanium.h:1.1.1.2	Wed Dec 25 20:19:47 2013
+++ src/external/bsd/libc++/dist/libcxxrt/src/unwind-itanium.h	Thu Jan 23 13:30:38 2014
@@ -80,7 +80,7 @@ struct _Unwind_Exception
 _Unwind_Exception_Cleanup_Fn exception_cleanup;
 unsigned long private_1;
 unsigned long private_2;
-  } ;
+  } __attribute__((__aligned__));
 
 extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
 extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,



CVS commit: src/external/bsd/libc++/dist/libcxxrt/src

2014-01-23 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jan 23 13:30:38 UTC 2014

Modified Files:
src/external/bsd/libc++/dist/libcxxrt/src: unwind-itanium.h

Log Message:
Force consistent alignemnt of _Unwind_Exception with libgcc_s.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/external/bsd/libc++/dist/libcxxrt/src/unwind-itanium.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.