void-packages/srcpkgs/icecat/patches/musl-ucontext.patch

56 lines
1.4 KiB
Diff

Musl libc doesn't expose the ucontext_t internals, but
just an opaque struct __ucontext, thus disable code which
tries to access the members.
Define gettid(2) for musl libc as well.
--- tools/profiler/platform-linux.cc 2015-07-14 00:10:07.000000000 +0200
+++ tools/profiler/platform-linux.cc 2015-08-21 13:52:40.411391562 +0200
@@ -87,14 +87,13 @@
#define SIGNAL_SAVE_PROFILE SIGUSR2
-#if defined(__GLIBC__)
-// glibc doesn't implement gettid(2).
+// We need a definition of gettid(2), but neither glibc nor
+// musl libc provide a wrapper for it.
#include <sys/syscall.h>
pid_t gettid()
{
return (pid_t) syscall(SYS_gettid);
}
-#endif
/* static */ Thread::tid_t
Thread::GetCurrentId()
@@ -164,6 +163,7 @@
static void SetSampleContext(TickSample* sample, void* context)
{
+#if defined(__GLIBC__)
// Extracting the sample from the context is extremely machine dependent.
ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
mcontext_t& mcontext = ucontext->uc_mcontext;
@@ -196,6 +196,7 @@
// Implement this on MIPS.
UNIMPLEMENTED();
#endif
+#endif
}
#ifdef ANDROID
@@ -590,11 +594,13 @@
void TickSample::PopulateContext(void* aContext)
{
MOZ_ASSERT(aContext);
+#if defined(__GLIBC__)
ucontext_t* pContext = reinterpret_cast<ucontext_t*>(aContext);
if (!getcontext(pContext)) {
context = pContext;
SetSampleContext(this, aContext);
}
+#endif
}
// WARNING: Works with values up to 1 second