[Git][ghc/ghc][master] JS: Implement h$clock_gettime in the JavaScript RTS (#23360)

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue May 16 17:59:38 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
5e3f9bb5 by Josh Meredith at 2023-05-16T13:59:22-04:00
JS: Implement h$clock_gettime in the JavaScript RTS (#23360)

- - - - -


3 changed files:

- libraries/base/tests/Concurrent/all.T
- + rts/js/time.js
- rts/rts.cabal.in


Changes:

=====================================
libraries/base/tests/Concurrent/all.T
=====================================
@@ -1,3 +1,3 @@
 test('Chan002', [extra_run_opts('100'), fragile(22836)], compile_and_run, [''])
 test('Chan003',      extra_run_opts('200'), compile_and_run, [''])
-test('ThreadDelay001', js_broken(22374), compile_and_run, [''])
+test('ThreadDelay001', normal, compile_and_run, [''])


=====================================
rts/js/time.js
=====================================
@@ -0,0 +1,20 @@
+function h$clock_gettime(when, p_d, p_o) {
+  var is64 = p_d.i3.length == 4 && p_o == 0;
+  var o  = p_o >> 2;
+  var t  = Date.now ? Date.now() : new Date().getTime();
+  var tf = Math.floor(t / 1000);
+  var tn = 1000000 * (t - (1000 * tf));
+
+  if (is64) {
+    p_d.i3[o]   = tf|0;
+    p_d.i3[o+1] = 0;
+    p_d.i3[o+2] = tn|0;
+    p_d.i3[o+3] = 0;
+  } else {
+    p_d.i3[o]   = tf|0;
+    p_d.i3[o+1] = tn|0;
+  }
+  return 0;
+}
+
+function h$CLOCK_REALTIME() { return 0; }


=====================================
rts/rts.cabal.in
=====================================
@@ -112,6 +112,7 @@ library
         js/verify.js
         js/weak.js
         js/globals.js
+        js/time.js
 
       install-includes: HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h
                         ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e3f9bb57680a40f6a9531e41dc2617c5f028e5c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e3f9bb57680a40f6a9531e41dc2617c5f028e5c
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230516/b07c7acb/attachment-0001.html>


More information about the ghc-commits mailing list