diff options
author | trav90 <travawine@palemoon.org> | 2018-05-26 20:54:19 -0500 |
---|---|---|
committer | trav90 <travawine@palemoon.org> | 2018-05-27 08:55:43 -0500 |
commit | b9fc7c5eae61d168e677d96c1f1ad8a14cd1c3bd (patch) | |
tree | 253d6a1e6394b251d0fdd2c86697e1d042766690 /application/palemoon/app | |
parent | 3f215e15fb60f5b62b7f1cd3771ac7ecc9326d1a (diff) | |
download | UXP-b9fc7c5eae61d168e677d96c1f1ad8a14cd1c3bd.tar UXP-b9fc7c5eae61d168e677d96c1f1ad8a14cd1c3bd.tar.gz UXP-b9fc7c5eae61d168e677d96c1f1ad8a14cd1c3bd.tar.lz UXP-b9fc7c5eae61d168e677d96c1f1ad8a14cd1c3bd.tar.xz UXP-b9fc7c5eae61d168e677d96c1f1ad8a14cd1c3bd.zip |
Display an error on Linux in the absence of SSE2
Diffstat (limited to 'application/palemoon/app')
-rw-r--r-- | application/palemoon/app/Makefile.in | 8 | ||||
-rw-r--r-- | application/palemoon/app/moz.build | 3 | ||||
-rw-r--r-- | application/palemoon/app/nsBrowserApp.cpp | 45 |
3 files changed, 56 insertions, 0 deletions
diff --git a/application/palemoon/app/Makefile.in b/application/palemoon/app/Makefile.in index c0f01212c..12f28768a 100644 --- a/application/palemoon/app/Makefile.in +++ b/application/palemoon/app/Makefile.in @@ -33,6 +33,14 @@ NSDISTMODE = copy include $(topsrcdir)/config/config.mk +# If we are trying to show an error dialog about the lack of SSE2 support, +# make sure that code itself doesn't use SSE2. +ifdef MOZ_LINUX_SSE2_STARTUP_ERROR +CXXFLAGS := $(filter-out -march=% -msse2 -mfpmath=sse,$(CXXFLAGS)) +CXX := $(filter-out -march=% -msse2 -mfpmath=sse,$(CXX)) +CXXFLAGS += -mno-sse2 -mfpmath=387 +endif + ifeq ($(OS_ARCH),WINNT) # Rebuild firefox.exe if the manifest changes - it's included by splash.rc. # (this dependency should really be just for firefox.exe, not other targets) diff --git a/application/palemoon/app/moz.build b/application/palemoon/app/moz.build index 8b358b622..044c3e2d1 100644 --- a/application/palemoon/app/moz.build +++ b/application/palemoon/app/moz.build @@ -68,3 +68,6 @@ if CONFIG['MOZ_LINKER']: if CONFIG['HAVE_CLOCK_MONOTONIC']: OS_LIBS += CONFIG['REALTIME_LIBS'] + +if CONFIG['MOZ_LINUX_SSE2_STARTUP_ERROR']: + DEFINES['MOZ_LINUX_SSE2_STARTUP_ERROR'] = True 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" |