summaryrefslogtreecommitdiff
path: root/src/pal/src/exception
diff options
context:
space:
mode:
authorFrederik Carlier <frederik.carlier@quamotion.mobi>2017-02-23 02:09:24 -0800
committerJan Vorlicek <janvorli@microsoft.com>2017-02-23 11:09:24 +0100
commit08581d8e9515ef1a348e7509785ea29195a9de37 (patch)
tree511e0204781ba1d70a45e6514db665de637136d7 /src/pal/src/exception
parent6af4182d058df3520103d81c3912899e8d29f884 (diff)
downloadcoreclr-08581d8e9515ef1a348e7509785ea29195a9de37.tar.gz
coreclr-08581d8e9515ef1a348e7509785ea29195a9de37.tar.bz2
coreclr-08581d8e9515ef1a348e7509785ea29195a9de37.zip
Android: workaround absence of getcontext/setcontext (#9725)
* Android: workaround absence of getcontext/setcontext use RtlCaptureContext and RtlRestoreContext
Diffstat (limited to 'src/pal/src/exception')
-rw-r--r--src/pal/src/exception/signal.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/pal/src/exception/signal.cpp b/src/pal/src/exception/signal.cpp
index d442afaf4c..ee7f7ce85f 100644
--- a/src/pal/src/exception/signal.cpp
+++ b/src/pal/src/exception/signal.cpp
@@ -47,6 +47,33 @@ SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do
#include "pal/context.h"
+#ifdef __ANDROID__
+// getcontext and setcontext are not available natively on Android
+int getcontext(ucontext_t *ucp)
+{
+ CONTEXT context;
+ RtlCaptureContext(&context);
+ CONTEXTToNativeContext(&context, ucp);
+
+ return 0;
+}
+
+int setcontext(const ucontext_t *ucp)
+{
+ CONTEXT context;
+ ULONG contextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT;
+
+#if defined(_AMD64_)
+ contextFlags |= CONTEXT_XSTATE;
+#endif
+
+ CONTEXTFromNativeContext(ucp, &context, contextFlags);
+ RtlRestoreContext(&context, NULL);
+
+ return 0;
+}
+#endif
+
using namespace CorUnix;
#ifdef SIGRTMIN