diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-09-24 23:26:59 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-09-24 23:26:59 -0700 |
commit | 008137390b13414957e832a609ea269500507651 (patch) | |
tree | 02519710084941714affaa6082bfb38c0a9d9c2d /src | |
parent | a24892cf4378138d67e56e37d053c5a574befdf8 (diff) |
emscripten.py option to expose header #defines to library. fixes fcntl
Diffstat (limited to 'src')
-rw-r--r-- | src/library.js | 28 | ||||
-rw-r--r-- | src/parseTools.js | 4 | ||||
-rw-r--r-- | src/settings.js | 3 |
3 files changed, 20 insertions, 15 deletions
diff --git a/src/library.js b/src/library.js index a0f41a35..d9ca93cf 100644 --- a/src/library.js +++ b/src/library.js @@ -971,7 +971,7 @@ LibraryManager.library = { } var stream = FS.streams[fildes]; switch (cmd) { - case 0: // F_DUPFD. + case {{{ C_DEFINES['F_DUPFD'] }}}: var arg = {{{ makeGetValue('varargs', 0, 'i32') }}}; if (arg < 0) { ___setErrNo(ERRNO_CODES.EINVAL); @@ -984,10 +984,10 @@ LibraryManager.library = { if (arg in FS.streams) arg = FS.streams.length; FS.streams[arg] = newStream; return arg; - case 1: // F_GETFD. - case 2: // F_SETFD. + case {{{ C_DEFINES['F_GETFD'] }}}: + case {{{ C_DEFINES['F_SETFD'] }}}: return 0; // FD_CLOEXEC makes no sense for a single process. - case 3: // F_GETFL. + case {{{ C_DEFINES['F_GETFL'] }}}: var flags = 0; if (stream.isRead && stream.isWrite) flags = 0x2; // O_RDWR. else if (!stream.isRead && stream.isWrite) flags = 0x1; // O_WRONLY. @@ -995,26 +995,26 @@ LibraryManager.library = { if (stream.isAppend) flags |= 0x400; // O_APPEND. // Synchronization and blocking flags are irrelevant to us. return flags; - case 4: // F_SETFL. + case {{{ C_DEFINES['F_SETFL'] }}}: var arg = {{{ makeGetValue('varargs', 0, 'i32') }}}; stream.isAppend = Boolean(arg | 0x400); // O_APPEND. // Synchronization and blocking flags are irrelevant to us. return 0; - case 5: // F_GETLK. - case 12: // F_GETLK64. + case {{{ C_DEFINES['F_GETLK'] }}}: + case {{{ C_DEFINES['F_GETLK64'] }}}: var arg = {{{ makeGetValue('varargs', 0, 'i32') }}}; var offset = ___flock_struct_layout.l_type; // We're always unlocked. - {{{ makeSetValue('arg', 'offset', '2', 'i16') }}} // F_UNLCK. + {{{ makeSetValue('arg', 'offset', C_DEFINES['F_UNLCK'], 'i16') }}} return 0; - case 6: // F_SETLK. - case 7: // F_SETLKW. - case 13: // F_SETLK64. - case 14: // F_SETLKW64. + case {{{ C_DEFINES['F_SETLK'] }}}: + case {{{ C_DEFINES['F_SETLKW'] }}}: + case {{{ C_DEFINES['F_SETLK64'] }}}: + case {{{ C_DEFINES['F_SETLKW64'] }}}: // Pretend that the locking is successful. return 0; - case 8: // F_SETOWN. - case 9: // F_GETOWN. + case {{{ C_DEFINES['F_SETOWN'] }}}: + case {{{ C_DEFINES['F_GETOWN'] }}}: // These are for sockets. We don't have them implemented (yet?). ___setErrNo(ERRNO_CODES.EINVAL); return -1; diff --git a/src/parseTools.js b/src/parseTools.js index ab67cbf7..7d62b34d 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -6,7 +6,9 @@ function processMacros(text) { return text.replace(/{{{[^}]+}}}/g, function(str) { str = str.substr(3, str.length-6); - return eval(str).toString(); + var ret = eval(str); + if (ret !== undefined) ret = ret.toString(); + return ret; }); } diff --git a/src/settings.js b/src/settings.js index ed4fcd05..392263df 100644 --- a/src/settings.js +++ b/src/settings.js @@ -123,6 +123,9 @@ INCLUDE_FULL_LIBRARY = 0; // Whether to include the whole library rather than ju // dynamically loading modules that make use of runtime // library functions that are not used in the main module. +C_DEFINES = {}; // A set of defines, for example generated from your header files. + // This lets the emscripten libc see the right values + SHOW_LABELS = 0; // Show labels in the generated code BUILD_AS_SHARED_LIB = 0; // Whether to build the code as a shared library, which |