diff options
author | Josh Meredith <joshmeredith2008@gmail.com> | 2023-05-08 14:51:54 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-05-16 13:59:22 -0400 |
commit | 5e3f9bb57680a40f6a9531e41dc2617c5f028e5c (patch) | |
tree | 9812a42d2ca88b9b8e59d298db71041216e1078f /rts/js/time.js | |
parent | 67330303714ab64751e538f318932a70c36392b6 (diff) | |
download | haskell-5e3f9bb57680a40f6a9531e41dc2617c5f028e5c.tar.gz |
JS: Implement h$clock_gettime in the JavaScript RTS (#23360)
Diffstat (limited to 'rts/js/time.js')
-rw-r--r-- | rts/js/time.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/rts/js/time.js b/rts/js/time.js new file mode 100644 index 0000000000..0ea6be1f54 --- /dev/null +++ b/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; } |