aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormax99x <max99x@gmail.com>2011-08-06 06:30:27 +0300
committermax99x <max99x@gmail.com>2011-08-06 06:30:27 +0300
commit869dd298eb0a61b882688cb9e79c4df729b64a54 (patch)
tree1888ecea09519da7779ace0780d89a245aa9e658
parentb90a6c482d50772c37ced79dd86c8c005e1f71d5 (diff)
Replaced "new Date.getTime()" with "Date.now()";
Added a note about shared lib static allocations.
-rw-r--r--src/jsifier.js2
-rw-r--r--src/library.js20
2 files changed, 12 insertions, 10 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 016c7df6..c6f73d50 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -212,6 +212,8 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
});
constant = '[' + constant.join(', ') + ']';
}
+ // NOTE: This is the only place that could potentially create static
+ // allocations in a shared library.
constant = makePointer(constant, null, BUILD_AS_SHARED_LIB ? 'ALLOC_NORMAL' : 'ALLOC_STATIC', item.type);
var js = item.ident + '=' + constant + ';';
diff --git a/src/library.js b/src/library.js
index 4b447194..4d7e95b3 100644
--- a/src/library.js
+++ b/src/library.js
@@ -31,7 +31,7 @@ LibraryManager.library = {
write: false,
isFolder: true,
isDevice: false,
- timestamp: new Date().getTime(),
+ timestamp: Date.now(),
inodeNumber: 1,
contents: {}
},
@@ -182,7 +182,7 @@ LibraryManager.library = {
parent.contents[name] = {
read: canRead === undefined ? true : canRead,
write: canWrite === undefined ? false : canWrite,
- timestamp: new Date().getTime(),
+ timestamp: Date.now(),
inodeNumber: FS.nextInode++
};
for (var key in properties) {
@@ -556,7 +556,7 @@ LibraryManager.library = {
time = {{{ makeGetValue('times', 'offset', 'i32') }}}
time *= 1000;
} else {
- time = new Date().getTime();
+ time = Date.now();
}
var file = FS.findObject(Pointer_stringify(path));
if (file === null) return -1;
@@ -768,7 +768,7 @@ LibraryManager.library = {
if (obj === null) return -1;
obj.read = mode & 0x100; // S_IRUSR.
obj.write = mode & 0x80; // S_IWUSR.
- obj.timestamp = new Date().getTime();
+ obj.timestamp = Date.now();
return 0;
},
fchmod__deps: ['$FS', '__setErrNo', '$ERRNO_CODES', 'chmod'],
@@ -1105,7 +1105,7 @@ LibraryManager.library = {
if (typeof path !== 'string') path = Pointer_stringify(path);
var target = FS.findObject(path, dontResolveLastLink);
if (target === null) return -1;
- target.timestamp = new Date().getTime();
+ target.timestamp = Date.now();
return 0;
},
chroot__deps: ['__setErrNo', '$ERRNO_CODES'],
@@ -1273,7 +1273,7 @@ LibraryManager.library = {
var contents = target.contents;
if (length < contents.length) contents.length = length;
else while (length > contents.length) contents.push(0);
- target.timestamp = new Date().getTime();
+ target.timestamp = Date.now();
return 0;
}
}
@@ -1621,7 +1621,7 @@ LibraryManager.library = {
for (var i = 0; i < nbyte; i++) {
contents[offset + i] = {{{ makeGetValue('buf', 'i', 'i8') }}};
}
- stream.object.timestamp = new Date().getTime();
+ stream.object.timestamp = Date.now();
return i;
}
},
@@ -1650,7 +1650,7 @@ LibraryManager.library = {
return -1;
}
}
- stream.object.timestamp = new Date().getTime();
+ stream.object.timestamp = Date.now();
return i;
} else {
___setErrNo(ERRNO_CODES.ENXIO);
@@ -1902,8 +1902,8 @@ LibraryManager.library = {
// http://pubs.opengroup.org/onlinepubs/000095399/functions/usleep.html
// We're single-threaded, so use a busy loop. Super-ugly.
var msec = useconds / 1000;
- var start = new Date().getTime();
- while (new Date().getTime() - start < msec) {
+ var start = Date.now();
+ while (Date.now() - start < msec) {
// Do nothing.
}
return 0;