diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-03-08 10:51:41 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-03-08 10:51:41 +0900 |
| commit | a7ce31249948e4f0c1950de93f3c4f7cdda51cf4 (patch) | |
| tree | c4c740f0cccd15f825596f7a115f3b8f8eb8ffa7 /worker/php-wasm.c | |
| parent | 7f4d16dca85263dcbc7b3bb29f5fc50f4371739d (diff) | |
| parent | c06d46eae30c9468535fb6af5e9b822acadbbdb6 (diff) | |
| download | phperkaigi-2025-albatross-a7ce31249948e4f0c1950de93f3c4f7cdda51cf4.tar.gz phperkaigi-2025-albatross-a7ce31249948e4f0c1950de93f3c4f7cdda51cf4.tar.zst phperkaigi-2025-albatross-a7ce31249948e4f0c1950de93f3c4f7cdda51cf4.zip | |
Merge branch 'phperkaigi-2025'
Diffstat (limited to 'worker/php-wasm.c')
| -rw-r--r-- | worker/php-wasm.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/worker/php-wasm.c b/worker/php-wasm.c new file mode 100644 index 0000000..9c71ca1 --- /dev/null +++ b/worker/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; +} |
