diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-03-17 22:19:18 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-03-17 22:19:18 +0900 |
| commit | facdf9357e576f6d47e7dd23f4f7b2b34f6a8d30 (patch) | |
| tree | 21c6aee60b3ddc26ff88ee3273c887125bb5828f /wasm/php-wasm.c | |
| parent | c739bbfa7cbb68a51755254d59abf15e514795ca (diff) | |
| download | PHPerKaigi2025-tokens-facdf9357e576f6d47e7dd23f4f7b2b34f6a8d30.tar.gz PHPerKaigi2025-tokens-facdf9357e576f6d47e7dd23f4f7b2b34f6a8d30.tar.zst PHPerKaigi2025-tokens-facdf9357e576f6d47e7dd23f4f7b2b34f6a8d30.zip | |
commit files
Diffstat (limited to 'wasm/php-wasm.c')
| -rw-r--r-- | wasm/php-wasm.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/wasm/php-wasm.c b/wasm/php-wasm.c new file mode 100644 index 0000000..9c71ca1 --- /dev/null +++ b/wasm/php-wasm.c @@ -0,0 +1,22 @@ +#include <stdio.h> +#include <emscripten.h> +#include <Zend/zend_execute.h> +#include <sapi/embed/php_embed.h> + +int EMSCRIPTEN_KEEPALIVE php_wasm_run(const char* code) { + zend_result result; + + int argc = 1; + char* argv[] = { "php.wasm", NULL }; + + PHP_EMBED_START_BLOCK(argc, argv); + + result = zend_eval_string_ex(code, NULL, "php.wasm code", 1); + + PHP_EMBED_END_BLOCK(); + + fflush(stdout); + fflush(stderr); + + return result == SUCCESS ? 0 : 1; +} |
