From 16e49cda09e180cd283e311392427ced5c7f2886 Mon Sep 17 00:00:00 2001 From: Luite Stegeman Date: Mon, 5 Aug 2024 12:06:17 +0200 Subject: [PATCH] make digest and foundation backwards compatible with GHC < 9.10 (#5) * make digest backwards compatible with GHC < 9.10 * make foundation compatible with GHC < 9.10 --- patches/digest-0.0.1.2.patch | 48 ++++++++++++++++----- patches/foundation-0.0.30.patch | 75 +++++++++++++++++++++++++-------- 2 files changed, 95 insertions(+), 28 deletions(-) diff --git a/patches/digest-0.0.1.2.patch b/patches/digest-0.0.1.2.patch index abb5559..17f4a54 100644 --- a/patches/digest-0.0.1.2.patch +++ b/patches/digest-0.0.1.2.patch @@ -1,8 +1,8 @@ -diff --git b/Test.hs a/Test.hs +diff --git a/Test.hs b/Test.hs new file mode 100644 -index 000000000..456818923 +index 0000000..d53608e --- /dev/null -+++ a/Test.hs ++++ b/Test.hs @@ -0,0 +1,5 @@ +import Data.Digest.CRC32 + @@ -10,7 +10,10 @@ index 000000000..456818923 +main = do + print $ crc32 [1,2,3,4,5] \ No newline at end of file -diff --git b/digest.cabal a/digest.cabal +diff --git a/digest.cabal b/digest.cabal +index eaea373..223bf21 100644 +--- a/digest.cabal ++++ b/digest.cabal @@ -45,3 +45,20 @@ library extra-libraries: z else @@ -32,22 +35,47 @@ diff --git b/digest.cabal a/digest.cabal + main-is: Test.hs + build-depends: digest -any + , base -diff --git b/jsbits/bindings.js a/jsbits/bindings.js +diff --git a/jsbits/bindings.js b/jsbits/bindings.js new file mode 100644 -index 000000000..783592c90 +index 0000000..35ea231 --- /dev/null -+++ a/jsbits/bindings.js -@@ -0,0 +1,13 @@ ++++ b/jsbits/bindings.js +@@ -0,0 +1,38 @@ ++// **** Start backwards compatibility **** ++ ++// These functions have been copied here from rts/js/mem.js (GHC 9.10+) ++// to provide compatibility with earlier versions of GHC. They should ++// be removed here when support for GHC earlier than 9.10 is dropped. ++ ++function h$digest$compat$withCBufferOnHeap(str_d, str_o, len, cont) { ++ var str = _malloc(len); ++ if(str_d !== null) h$digest$compat$copyToHeap(str_d, str_o, str, len); ++ var ret = cont(str); ++ _free(str); ++ return ret; ++} ++ ++function h$digest$compat$copyToHeap(buf_d, buf_o, tgt, len) { ++ if(len === 0) return; ++ var u8 = buf_d.u8; ++ for(var i=0;i