Support compiling pdfium with emscripten.
Bug: chromium:804907
Change-Id: I3562653fbc26d669d1e0a99894a69da032a0349e
Reviewed-on: https://pdfium-review.googlesource.com/23810
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/third_party/base/numerics/safe_math_impl.h b/third_party/base/numerics/safe_math_impl.h
index 4bcc671..61f18d2 100644
--- a/third_party/base/numerics/safe_math_impl.h
+++ b/third_party/base/numerics/safe_math_impl.h
@@ -44,7 +44,11 @@
};
// Probe for builtin math overflow support on Clang and version check on GCC.
-#if defined(__has_builtin)
+#if defined(EMSCRIPTEN)
+// Emscripten Clang reports that it has the builtins, it may be lowered to an
+// instruction that is unsupported in asm.js
+#define USE_OVERFLOW_BUILTINS (0)
+#elif defined(__has_builtin)
#define USE_OVERFLOW_BUILTINS (__has_builtin(__builtin_add_overflow))
#elif defined(__GNUC__)
#define USE_OVERFLOW_BUILTINS (__GNUC__ >= 5)