 -install-includes: HsIntegerGmp.h ghc-gmp.h
 +install-includes: HsIntegerGmp.h
 diff -X ../utils/updatePatches.excludes -Nru upstream/pkg/integer-gmp/integer-gmp.cabal boot/pkg/integer-gmp/integer-gmp.cabal
---- upstream/pkg/integer-gmp/integer-gmp.cabal	2019-05-07 22:52:34.000000000 -0700
-+++ boot/pkg/integer-gmp/integer-gmp.cabal	2019-05-07 22:52:34.932871418 -0700
+--- upstream/pkg/integer-gmp/integer-gmp.cabal	2019-06-15 23:41:11.000000000 +0200
++++ boot/pkg/integer-gmp/integer-gmp.cabal	2019-06-15 23:41:11.000000000 +0200
 @@ -67,6 +67,9 @@
    c-sources:
      cbits/wrappers.c

 
 {-# OPTIONS_HADDOCK hide #-}
 
@@ -47,6 +52,13 @@
 -- First component of result is @log2 n@, second is @0#@ iff /n/ is a
 -- power of two.
 integerLog2IsPowerOf2# :: Integer -> (# Int#, Int# #)
+#if defined(ghcjs_HOST_OS)
+integerLog2IsPowerOf2# x = --
+  case js_integerLog2IsPowerOf2 (unsafeCoerce# x) of
+    y | isTrue# (y <# 0#) -> (# 0# -# y, 0# #)
+    y                     -> (# y      , 1# #)
+foreign import javascript unsafe "h$ghcjsbn_integerLog2IsPowerOf2($1)" js_integerLog2IsPowerOf2 :: Any -> Int#
+#else
 -- The power of 2 test is n&(n-1) == 0, thus powers of 2
 -- are indicated bythe second component being zero.
 integerLog2IsPowerOf2# (S# i#) = case int2Word# i# of
@@ -70,7 +82,7 @@
                 else case indexBigNat# bn i of
                         0## -> test (i -# 1#)
                         _   -> 1#
-
+#endif
 
 -- Assumption: Integer and Int# are strictly positive, Int# is less
 -- than logBase 2 of Integer, otherwise havoc ensues.
@@ -84,6 +96,10 @@
 -- 1# means we have a half-integer, round to even
 -- 2# means round up (away from zero)
 roundingMode# :: Integer -> Int# -> Int#
+#if defined(ghcjs_HOST_OS)
+roundingMode# x y = js_roundingMode (unsafeCoerce# x) y
+foreign import javascript unsafe "h$integer_roundingMode($1,$2)" js_roundingMode :: Any -> Int# -> Int#
+#else
 roundingMode# (S# i#) t =
     case int2Word# i# `and#` ((uncheckedShiftL# 2## t) `minusWord#` 1##) of
       k -> case uncheckedShiftL# 1## t of
@@ -116,3 +132,4 @@
                 else case indexBigNat# bn i of
                         0## -> test (i -# 1#)
                         _   -> 2#
+#endif
diff -X ../utils/updatePatches.excludes -Nru upstream/pkg/integer-gmp/src/GHC/Integer/Logarithms.hs boot/pkg/integer-gmp/src/GHC/Integer/Logarithms.hs
--- upstream/pkg/integer-gmp/src/GHC/Integer/Logarithms.hs	2019-05-07 22:52:34.000000000 -0700
+++ boot/pkg/integer-gmp/src/GHC/Integer/Logarithms.hs	2019-05-07 22:52:34.932871418 -0700
@@ -4,6 +4,9 @@
 {-# LANGUAGE UnliftedFFITypes #-}
 {-# LANGUAGE CPP #-}

+
+// extract a word from a BigNat
+function h$ghcjsbn_index_b(b, w) {
+  if(GHCJSBN_BITS === 28) {
+    var limb = (32 * w / 28)|0;
+    var l    = b[0];
+    var l1   = limb < l ? b[limb+1] : 0;
+    var l2   = (limb+1) < l ? b[limb+2] : 0;
+    var ws   = 4 * (w % 7);
+    return (l1 >>> ws) | (l2 << 24 - ws);
+  }
+  throw new Error("ghcjsbn_index_b not implemented for current number of bits per limb");
+}
+
+// Bool -> BigNat -> Double
