 +  return Math.ceil((bl * GHCJSBN_BITS) / 32);
 +}
 +
++#if GHCJSBN_BITS == 28
 +// 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");
-+}
++  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 << 28 - ws);
++}
++#else
++#error "ghcjsbn_index_b not implemented for current number of bits per limb";
++#endif
 +
 +// Bool -> BigNat -> Double
 +function h$ghcjsbn_toDouble_b(nonNeg, b) {

 
 -- | Compute next prime greater than @/n/@ probalistically.
 --
diff -X ../utils/updatePatches.excludes -Nru upstream/pkg/integer-gmp/src/GHC/Integer/Logarithms/Internals.hs boot/pkg/integer-gmp/src/GHC/Integer/Logarithms/Internals.hs
--- upstream/pkg/integer-gmp/src/GHC/Integer/Logarithms/Internals.hs	2019-06-15 23:41:11.000000000 +0200
+++ boot/pkg/integer-gmp/src/GHC/Integer/Logarithms/Internals.hs	2019-07-31 01:50:46.000000000 +0200
@@ -2,6 +2,11 @@
 {-# LANGUAGE MagicHash #-}
 {-# LANGUAGE UnboxedTuples #-}
 {-# LANGUAGE CPP #-}
+#ifdef ghcjs_HOST_OS
+{-# LANGUAGE JavaScriptFFI #-}
+{-# LANGUAGE UnliftedFFITypes #-}
+{-# LANGUAGE GHCForeignImportPrim #-}
+#endif
 
 {-# OPTIONS_HADDOCK hide #-}
 
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-06-15 23:41:11.000000000 +0200
+++ boot/pkg/integer-gmp/src/GHC/Integer/Logarithms.hs	2019-06-15 23:41:11.000000000 +0200

+error "no mkInteger implementation for specified GHCJSBN_BITS"
+#endif
+
+// BigNat -> Word -> Int (Ordering)
+function h$ghcjsbn_cmp_bw(b, w) {
+  ASSERTVALID_B(b, "cmp_bw");
