aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library.js22
-rw-r--r--tests/runner.py6
2 files changed, 11 insertions, 17 deletions
diff --git a/src/library.js b/src/library.js
index 685f839a..2f5290cd 100644
--- a/src/library.js
+++ b/src/library.js
@@ -210,19 +210,9 @@ var Library = {
var currArg = getNextArg(false, argSize);
// Truncate to requested size.
argSize = argSize || 4;
- var limit = undefined;
- if (argSize == 4) {
- limit = 0xFFFFFFFF;
- } else if (argSize == 2) {
- limit = 0xFFFF;
- } else if (argSize == 1) {
- limit = 0xFF;
- }
- if (limit !== undefined) {
- currArg = currArg & limit;
- if (!signed && currArg < 0 || signed && currArg > (limit - 1) / 2) {
- currArg = ~(limit - currArg);
- }
+ if (argSize <= 4) {
+ var limit = Math.pow(256, argSize) - 1;
+ currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
}
// Format the number.
var currAbsArg = Math.abs(currArg);
@@ -795,8 +785,12 @@ var Library = {
var info = STDIO.streams[stream];
if (!info) return -1;
try {
+ {{{ makeSetValue('ptr', '$struct_stat___FLATTENER[0]', '1', 'i32') }}} // st_dev. XXX: hardcoded index 0 into the structure.
+ {{{ makeSetValue('ptr', '$struct_stat___FLATTENER[15]', 'stream', 'i32') }}} // st_ino. XXX: hardcoded index 15 into the structure.
{{{ makeSetValue('ptr', '$struct_stat___FLATTENER[9]', 'info.data.length', 'i32') }}} // st_size. XXX: hardcoded index 9 into the structure.
} catch(e) {
+ {{{ makeSetValue('ptr', '0', '1', 'i32') }}}
+ {{{ makeSetValue('ptr', '15', 'stream', 'i32') }}}
{{{ makeSetValue('ptr', '9', 'info.data.length', 'i32') }}} // no FLATTENER
}
// TODO: other fields
@@ -1501,7 +1495,6 @@ var Library = {
dlopen: function(filename, flag) {
// TODO: Add support for LD_LIBRARY_PATH.
filename = Pointer_stringify(filename);
- filename += '.js';
if (DLFCN_DATA.loadedLibNames[filename]) {
// Already loaded; increment ref count and return.
@@ -1615,6 +1608,7 @@ var Library = {
// XXX we only handle _SC_PAGE_SIZE/PAGESIZE for now, 30 on linux, 29 on OS X... be careful here!
switch(name_) {
case 29: case 30: return PAGE_SIZE;
+ case 2: return 1000000; // _SC_CLK_TCK
default: throw 'unknown sysconf param: ' + name_;
}
},
diff --git a/tests/runner.py b/tests/runner.py
index fdf15d44..52b575ca 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1821,7 +1821,7 @@ if 'benchmark' not in sys.argv:
filename = os.path.join(dirname, 'liblib.cpp')
BUILD_AS_SHARED_LIB = 1
self.build(lib_src, dirname, filename)
- shutil.move(filename + '.o.js', os.path.join(dirname, 'liblib.so.js'))
+ shutil.move(filename + '.o.js', os.path.join(dirname, 'liblib.so'))
src = '''
#include <cstdio>
@@ -1866,7 +1866,7 @@ if 'benchmark' not in sys.argv:
BUILD_AS_SHARED_LIB = 1
EXPORTED_FUNCTIONS = ['__Z7get_cmpv']
self.build(lib_src, dirname, filename)
- shutil.move(filename + '.o.js', os.path.join(dirname, 'liblib.so.js'))
+ shutil.move(filename + '.o.js', os.path.join(dirname, 'liblib.so'))
src = '''
#include <stdio.h>
@@ -1956,7 +1956,7 @@ if 'benchmark' not in sys.argv:
EXPORTED_FUNCTIONS = ['__Z4funciPFvvE']
EXPORTED_GLOBALS = ['_global']
self.build(lib_src, dirname, filename)
- shutil.move(filename + '.o.js', os.path.join(dirname, 'liblib.so.js'))
+ shutil.move(filename + '.o.js', os.path.join(dirname, 'liblib.so'))
src = '''
#include <stdio.h>