diff options
-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; } |