diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-06-14 21:19:42 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-06-14 21:19:42 -0700 |
commit | 0bf5420d380a56f8942249f29160c4f9c7a23957 (patch) | |
tree | 4492a51f5afd87fe117dd5463b52b1750c5707e2 | |
parent | e41a6bdf29755b9393dd1d58f03342e8f2a30ffc (diff) |
EMSCRIPTEN_KEEPALIVE
-rw-r--r-- | system/include/emscripten.h | 10 | ||||
-rwxr-xr-x | tests/runner.py | 7 |
2 files changed, 16 insertions, 1 deletions
diff --git a/system/include/emscripten.h b/system/include/emscripten.h index 70524835..e265e8fd 100644 --- a/system/include/emscripten.h +++ b/system/include/emscripten.h @@ -12,6 +12,16 @@ extern "C" { #endif /* + * Forces LLVM to not dead-code-eliminate a function. Note that + * closure may still eliminate it at the JS level, for which you + * should use EXPORTED_FUNCTIONS (see settings.js). + * + * Example usage: + * void EMSCRIPTEN_KEEPALIVE my_function() { .. } + */ +#define EMSCRIPTEN_KEEPALIVE __attribute__((used)) + +/* * Interface to the underlying JS engine. This function will * eval() the given script. */ diff --git a/tests/runner.py b/tests/runner.py index 77b648ec..c3f8cff7 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -2449,10 +2449,15 @@ m_divisor is 1091269979 #include <stdio.h> #include "emscripten.h" + extern "C" { + void EMSCRIPTEN_KEEPALIVE save_me_aimee() { printf("mann\n"); } + } + int main() { // EMSCRIPTEN_COMMENT("hello from the source"); emscripten_run_script("Module.print('hello world' + '!')"); printf("*%d*\n", emscripten_run_script_int("5*20")); + emscripten_run_script("_save_me_aimee()"); return 0; } ''' @@ -2463,7 +2468,7 @@ def process(filename): # TODO: restore this (see comment in emscripten.h) assert '// hello from the source' in src ''' - self.do_run(src, 'hello world!\n*100*', post_build=check) + self.do_run(src, 'hello world!\n*100*\nmann\n', post_build=check) def test_inlinejs(self): src = r''' |