on 604f430 help sign in
streamly/jsbits/clock.js
31 lines 876 B history raw
1function h$clock_gettime_js(when, p_d, p_o) {
2 /* XXX: guess if we have to write 64 bit values:
4 alloca is often used and will give us 16 bytes
5 if timespec contains two 64 bit values
7 but we really should fix this by not having hsc2hs values
8 from the build system leak here
9 */
10 var is64 = p_d.i3.length == 4 && p_o == 0;
11 var o = p_o >> 2,
12 t = Date.now ? Date.now() : new Date().getTime(),
13 tf = Math.floor(t / 1000),
14 tn = 1000000 * (t - (1000 * tf));
15 if(is64) {
16 p_d.i3[o] = tf|0;
17 p_d.i3[o+1] = 0;
18 p_d.i3[o+2] = tn|0;
19 p_d.i3[o+3] = 0;
20 } else {
21 p_d.i3[o] = tf|0;
22 p_d.i3[o+1] = tn|0;
23 }
24 return 0;
26/* Hack! Supporting code for "clock" package
27 * "hspec" depends on clock.
28 */
29function h$hs_clock_darwin_gettime(when, p_d, p_o) {
30 h$clock_gettime_js(when, p_d, p_o);