diff options
author | stephan <stephan@noemail.net> | 2023-01-02 20:07:30 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2023-01-02 20:07:30 +0000 |
commit | b1cc895c920a2f5985ce1b5f0d7fb1012c5b097f (patch) | |
tree | 2afd95eec78e4c8908065d34321e72942082158b /ext/wasm/api | |
parent | a347927d60c70686c995bd453bd3ca7b1e3f24c8 (diff) | |
download | sqlite-b1cc895c920a2f5985ce1b5f0d7fb1012c5b097f.tar.gz sqlite-b1cc895c920a2f5985ce1b5f0d7fb1012c5b097f.zip |
Another reformulation of SQLITE_WASM_DEALLOC to attempt to work around a Safari-specific quirk reported in [forum:5489305f601b8c3f|forum post 5489305f601b8c3f].
FossilOrigin-Name: ae0196d86ee8ca424b5ef5a43c32988f4ab5131ea146669bc1467e31a2384901
Diffstat (limited to 'ext/wasm/api')
-rw-r--r-- | ext/wasm/api/sqlite3-api-glue.js | 3 | ||||
-rw-r--r-- | ext/wasm/api/sqlite3-wasm.c | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js index e88694fa3..239af7c9a 100644 --- a/ext/wasm/api/sqlite3-api-glue.js +++ b/ext/wasm/api/sqlite3-api-glue.js @@ -809,6 +809,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ capi[e[0]] = e[1]; } } + /* Exporting SQLITE_WASM_DEALLOC via the wasm.ctype entries fails + in Safari. One final thing to try: */ + capi.SQLITE_WASM_DEALLOC = wasm.exports.sqlite3_wasm_ptr_to_sqlite3_free(); if(wasm.exports[sqlite3.config.deallocExportName] !== wasm.functionEntry(capi.SQLITE_WASM_DEALLOC)){ toss("Internal error: sqlite3.wasm.exports["+ diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index 981fad92b..2b912c1dc 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -463,9 +463,13 @@ const char * sqlite3_wasm_enum_json(void){ DefGroup(blobFinalizers) { /* SQLITE_STATIC/TRANSIENT need to be handled explicitly as ** integers to avoid casting-related warnings. */ - out("\"SQLITE_STATIC\":0, \"SQLITE_TRANSIENT\":-1,"); - outf("\"SQLITE_WASM_DEALLOC\": %lld", + out("\"SQLITE_STATIC\":0, \"SQLITE_TRANSIENT\":-1"); +#if 0 + /* This approach to exporting SQLITE_WASM_DEALLOC as a pointer to + sqlite3_free fails in Safari. */ + outf(",\"SQLITE_WASM_DEALLOC\": %lld", (sqlite3_int64)(sqlite3_free)); +#endif } _DefGroup; DefGroup(changeset){ @@ -1593,6 +1597,11 @@ int sqlite3_wasm_config_j(int op, sqlite3_int64 arg){ return sqlite3_config(op, arg); } +SQLITE_WASM_KEEP +void * sqlite3_wasm_ptr_to_sqlite3_free(void){ + return (void*)sqlite3_free; +} + #if defined(__EMSCRIPTEN__) && defined(SQLITE_ENABLE_WASMFS) #include <emscripten/wasmfs.h> |