aboutsummaryrefslogtreecommitdiff
path: root/src/library.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-04-22 07:53:31 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-04-22 07:53:31 -0700
commitc37042e3f9d65062d9464d782eeec3bc3efd6f42 (patch)
treeeb3f3ef6f8d7be559cf32d0ff5f7e8916ba5d295 /src/library.js
parent887ce3dde89410d012a708c3ec454f679b2e5b1e (diff)
work towards QUANTUM_SIZE=1 (unused)
Diffstat (limited to 'src/library.js')
-rw-r--r--src/library.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js
index 7653d446..c7fe551b 100644
--- a/src/library.js
+++ b/src/library.js
@@ -87,7 +87,7 @@ var Library = {
} else {
ret = {{{ makeGetValue(0, 'argIndex', 'i32') }}};
}
- argIndex += type === 'l'.charCodeAt(0) ? 8 : 4; // XXX hardcoded native sizes
+ argIndex += {{{ QUANTUM_SIZE === 1 ? 1 : "type === 'l'.charCodeAt(0) ? 8 : 4" }}};
}
return ret;
}
@@ -463,7 +463,11 @@ var Library = {
fstat: function(stream, ptr) {
var info = _STDIO.streams[stream];
if (!info) return -1;
- {{{ makeSetValue('ptr', '$struct_stat___FLATTENER[9]', 'info.data.length', 'i32') }}} // st_size. XXX: hardcoded index 9 into the structure.
+ try {
+ {{{ makeSetValue('ptr', '$struct_stat___FLATTENER[9]', 'info.data.length', 'i32') }}} // st_size. XXX: hardcoded index 9 into the structure.
+ } catch(e) {
+ {{{ makeSetValue('ptr', '9', 'info.data.length', 'i32') }}} // no FLATTENER
+ }
// TODO: other fields
return 0;
},
@@ -592,6 +596,9 @@ var Library = {
// string.h
memcpy: function (dest, src, num, idunno) {
+#if ASSERTIONS
+ assert(num % 1 === 0, 'memcpy given ' + num + ' bytes to copy. Problem with QUANTUM_SIZE=1 corrections perhaps?');
+#endif
var curr;
for (var i = 0; i < num; i++) {
// TODO: optimize for the typed arrays case