Skip to content

New function emscripten_has_asyncify #9734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Current Trunk
- Only MEMFS is included by default, others (NODEFS, IDBFS, WORKERFS, PROXYFS)
must be linked in explicitly, using `-lnodefs.js`, `-lidbfs.js`',
`-lworkerfs.js`, `-lproxyfs.js`. See #9645
- New function emscripten_has_asyncify()

v1.39.0: 10/18/2019
-------------------
Expand Down
7 changes: 7 additions & 0 deletions site/source/docs/api_reference/emscripten.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,13 @@ Functions
:returns: The value of the specified setting. Note that for values other than an integer, a string is returned (cast the ``int`` return value to a ``char*``).
:rtype: int

.. c:function:: int emscripten_has_asyncify()

Returns whether pseudo-synchronous functions can be used.

:rtype: int
:returns: 1 if program was compiled with ASYNCIFY=1 or EMTERPRETER_ASYNC=1, 0 otherwise.


.. c:function:: void emscripten_debugger()

Expand Down
4 changes: 4 additions & 0 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -4258,6 +4258,10 @@ LibraryManager.library = {
return cache[fullname] = allocate(intArrayFromString(ret + ''), 'i8', ALLOC_NORMAL);
},

emscripten_has_asyncify: function() {
return {{{ ASYNCIFY || EMTERPRETIFY_ASYNC }}};
},

emscripten_debugger: function() {
debugger;
},
Expand Down
1 change: 1 addition & 0 deletions system/include/emscripten/emscripten.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ int emscripten_get_worker_queue_size(worker_handle worker);
// misc.

int emscripten_get_compiler_setting(const char *name);
int emscripten_has_asyncify();

void emscripten_debugger(void);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ _emscripten_gluOrtho2D
_emscripten_gluPerspective
_emscripten_gluProject
_emscripten_gluUnProject
_emscripten_has_asyncify
_emscripten_hide_mouse
_emscripten_html5_remove_all_event_listeners
_emscripten_idb_async_delete
Expand Down
16 changes: 16 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,22 @@ def test_emscripten_get_compiler_setting(self):
self.set_setting('RETAIN_COMPILER_SETTINGS', 1)
self.do_run(open(src).read(), open(output).read().replace('waka', shared.EMSCRIPTEN_VERSION))

@no_fastcomp('ASYNCIFY has been removed from fastcomp')
def test_emscripten_has_asyncify(self):
src = r'''
#include <stdio.h>
#include <emscripten.h>

int main() {
printf("%d\n", emscripten_has_asyncify());
return 0;
}
'''
self.set_setting('ASYNCIFY', 0)
self.do_run(src, '0')
self.set_setting('ASYNCIFY', 1)
self.do_run(src, '1')

# TODO: test only worked in non-fastcomp
def test_inlinejs(self):
self.skipTest('non-fastcomp is deprecated and fails in 3.5') # only supports EM_ASM
Expand Down
2 changes: 1 addition & 1 deletion tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -8113,7 +8113,7 @@ def test_metadce_hello(self, *args):
4, [], [], 8, 0, 0, 0), # noqa; totally empty!
# we don't metadce with linkable code! other modules may want stuff
# don't compare the # of functions in a main module, which changes a lot
'main_module_1': (['-O3', '-s', 'MAIN_MODULE=1'], 1600, [], [], 226403, None, 107, None), # noqa
'main_module_1': (['-O3', '-s', 'MAIN_MODULE=1'], 1601, [], [], 226403, None, 107, None), # noqa
'main_module_2': (['-O3', '-s', 'MAIN_MODULE=2'], 13, [], [], 10017, 13, 9, 20), # noqa
})
@no_wasm_backend()
Expand Down