aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-10-03 19:59:05 +0200
committerAlon Zakai <alonzakai@gmail.com>2011-10-03 19:59:05 +0200
commita9f082c2d60417730d11d2c0dc9da7e6e5ed2e00 (patch)
treebaf6d9b2d17814be17d45f90d09b74f47ebb9248 /src
parent95420a111d0ba2154ce9953b2506f7e402b97d7b (diff)
fix test_time
Diffstat (limited to 'src')
-rw-r--r--src/compiler.js2
-rw-r--r--src/library.js33
2 files changed, 19 insertions, 16 deletions
diff --git a/src/compiler.js b/src/compiler.js
index 9bf81ba4..1639d4e7 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -79,5 +79,7 @@ raw = null;
// Do it
+//dprint(JSON.stringify(C_DEFINES));
+
JSify(analyzer(intertyper(lines)));
diff --git a/src/library.js b/src/library.js
index 3387a326..9b48a1a2 100644
--- a/src/library.js
+++ b/src/library.js
@@ -4584,8 +4584,8 @@ LibraryManager.library = {
// ==========================================================================
clock: function() {
- if (_clock.start === undefined) _clock.start = new Date();
- return (Date.now() - _clock.start.getTime()) * 1000;
+ if (_clock.start === undefined) _clock.start = Date.now();
+ return Math.floor((Date.now() - _clock.start) * ({{{ cDefine('CLOCKS_PER_SEC') }}}/1000));
},
time: function(ptr) {
@@ -4663,8 +4663,8 @@ LibraryManager.library = {
timegm__deps: ['mktime'],
timegm: function(tmPtr) {
_tzset();
- var offset = {{{ makeGetValue('_timezone', 0, 'i32') }}};
- var daylight = {{{ makeGetValue('_daylight', 0, 'i32') }}};
+ var offset = {{{ makeGetValue('__timezone', 0, 'i32') }}};
+ var daylight = {{{ makeGetValue('__daylight', 0, 'i32') }}};
daylight = (daylight == 1) ? 60 * 60 : 0;
var ret = _mktime(tmPtr) + offset - daylight;
return ret;
@@ -4742,29 +4742,30 @@ LibraryManager.library = {
},
// TODO: Initialize these to defaults on startup from system settings.
- tzname: null,
- daylight: null,
- timezone: null,
- tzset__deps: ['malloc', 'tzname', 'daylight', 'timezone'],
+ // Note: glibc has one fewer underscore for all of these. Also used in other related functions (timegm)
+ _tzname: null,
+ _daylight: null,
+ _timezone: null,
+ tzset__deps: ['_tzname', '_daylight', '_timezone'],
tzset: function() {
// TODO: Use (malleable) environment variables instead of system settings.
- if (_tzname !== null) return;
+ if (__tzname) return; // glibc does not need the double __
- _timezone = _malloc(QUANTUM_SIZE);
- {{{ makeSetValue('_timezone', '0', '-(new Date()).getTimezoneOffset() * 60', 'i32') }}}
+ __timezone = _malloc(QUANTUM_SIZE);
+ {{{ makeSetValue('__timezone', '0', '-(new Date()).getTimezoneOffset() * 60', 'i32') }}}
- _daylight = _malloc(QUANTUM_SIZE);
+ __daylight = _malloc(QUANTUM_SIZE);
var winter = new Date(2000, 0, 1);
var summer = new Date(2000, 6, 1);
- {{{ makeSetValue('_daylight', '0', 'Number(winter.getTimezoneOffset() != summer.getTimezoneOffset())', 'i32') }}}
+ {{{ makeSetValue('__daylight', '0', 'Number(winter.getTimezoneOffset() != summer.getTimezoneOffset())', 'i32') }}}
var winterName = winter.toString().match(/\(([A-Z]+)\)/)[1];
var summerName = summer.toString().match(/\(([A-Z]+)\)/)[1];
var winterNamePtr = allocate(intArrayFromString(winterName), 'i8', ALLOC_NORMAL);
var summerNamePtr = allocate(intArrayFromString(summerName), 'i8', ALLOC_NORMAL);
- _tzname = _malloc(2 * QUANTUM_SIZE);
- {{{ makeSetValue('_tzname', '0', 'winterNamePtr', 'i32') }}}
- {{{ makeSetValue('_tzname', QUANTUM_SIZE, 'summerNamePtr', 'i32') }}}
+ __tzname = _malloc(2 * QUANTUM_SIZE); // glibc does not need the double __
+ {{{ makeSetValue('__tzname', '0', 'winterNamePtr', 'i32') }}}
+ {{{ makeSetValue('__tzname', QUANTUM_SIZE, 'summerNamePtr', 'i32') }}}
},
stime__deps: ['$ERRNO_CODES', '__setErrNo'],