diff options
author | Moonchild <mcwerewolf@gmail.com> | 2018-05-27 17:54:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-27 17:54:50 +0200 |
commit | 7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2 (patch) | |
tree | 3c40aedae6cb2551066b406cec3559dc1a488baf /application/palemoon/app/nsBrowserApp.cpp | |
parent | a65c26ccf590103a07174d9722ef86bcaac877a6 (diff) | |
parent | 3c3c85983f96ed48fb6a2c16df712dd229c1f358 (diff) | |
download | UXP-7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2.tar UXP-7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2.tar.gz UXP-7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2.tar.lz UXP-7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2.tar.xz UXP-7840c750dbfd3f1b2ab3b4f0db561cafdc7dcfe2.zip |
Merge pull request #395 from trav90/buildsystem-work
Always build with SSE2 support & display an error if not available
Diffstat (limited to 'application/palemoon/app/nsBrowserApp.cpp')
-rw-r--r-- | application/palemoon/app/nsBrowserApp.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/application/palemoon/app/nsBrowserApp.cpp b/application/palemoon/app/nsBrowserApp.cpp index 8b0613528..c73b05d23 100644 --- a/application/palemoon/app/nsBrowserApp.cpp +++ b/application/palemoon/app/nsBrowserApp.cpp @@ -35,6 +35,51 @@ #include "mozilla/Telemetry.h" #include "mozilla/WindowsDllBlocklist.h" +#ifdef MOZ_LINUX_SSE2_STARTUP_ERROR +#include <cpuid.h> +#include "mozilla/Unused.h" + +static bool +IsSSE2Available() +{ + // The rest of the app has been compiled to assume that SSE2 is present + // unconditionally, so we can't use the normal copy of SSE.cpp here. + // Since SSE.cpp caches the results and we need them only transiently, + // instead of #including SSE.cpp here, let's just inline the specific check + // that's needed. + unsigned int level = 1u; + unsigned int eax, ebx, ecx, edx; + unsigned int bits = (1u<<26); + unsigned int max = __get_cpuid_max(0, nullptr); + if (level > max) { + return false; + } + __cpuid_count(level, 0, eax, ebx, ecx, edx); + return (edx & bits) == bits; +} + +static const char sSSE2Message[] = + "This browser version requires a processor with the SSE2 instruction " + "set extension.\n"; + +__attribute__((constructor)) +static void +SSE2Check() +{ + if (IsSSE2Available()) { + return; + } + // Using write() in order to avoid jemalloc-based buffering. Ignoring return + // values, since there isn't much we could do on failure and there is no + // point in trying to recover from errors. + MOZ_UNUSED(write(STDERR_FILENO, + sSSE2Message, + MOZ_ARRAY_LENGTH(sSSE2Message) - 1)); + // _exit() instead of exit() to avoid running the usual "at exit" code. + _exit(255); +} +#endif + #if !defined(MOZ_WIDGET_COCOA) && !defined(MOZ_WIDGET_ANDROID) #define MOZ_BROWSER_CAN_BE_CONTENTPROC #include "../../ipc/contentproc/plugin-container.cpp" |