diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-01-27 20:12:46 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-01-27 20:12:46 -0800 |
commit | 87758abf9f56473b5da6945a5d7e020e2ead1bd5 (patch) | |
tree | ca665cc9ffac156b8eb46b7bc0b2b80bc82d600c | |
parent | dd8ef8c71cb8b1429c86ce95ffaced67daab2c96 (diff) |
EM_ASM_ variants that return a value but receive no inputs; fixes #2070
-rw-r--r-- | system/include/emscripten/emscripten.h | 6 | ||||
-rw-r--r-- | tests/core/test_inlinejs3.in | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/system/include/emscripten/emscripten.h b/system/include/emscripten/emscripten.h index fb456d67..2fc82f50 100644 --- a/system/include/emscripten/emscripten.h +++ b/system/include/emscripten/emscripten.h @@ -50,10 +50,14 @@ extern "C" { * return $0 + $1; * }, calc(), otherCalc()); * - * Note the {,} + * Note the { and }. If you just want to receive an output value + * (int or double) but *not* to pass any values, you can use + * EM_ASM_INT_V and EM_ASM_DOUBLE_V respectively. */ #define EM_ASM_INT(code, ...) emscripten_asm_const_int(#code, __VA_ARGS__) #define EM_ASM_DOUBLE(code, ...) emscripten_asm_const_double(#code, __VA_ARGS__) +#define EM_ASM_INT_V(code) emscripten_asm_const_int(#code) +#define EM_ASM_DOUBLE_V(code) emscripten_asm_const_double(#code) /* * Forces LLVM to not dead-code-eliminate a function. Note that diff --git a/tests/core/test_inlinejs3.in b/tests/core/test_inlinejs3.in index e21ed041..9ddd5907 100644 --- a/tests/core/test_inlinejs3.in +++ b/tests/core/test_inlinejs3.in @@ -15,6 +15,9 @@ int main(int argc, char **argv) { }, i, double(i) / 12); } + EM_ASM_INT({ globalVar = $0 }, sum); // no outputs, just input + sum = 0; + sum = EM_ASM_INT_V({ return globalVar }); // no inputs, just output printf("sum: %d\n", sum); return 0; } |