diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 05d2e74..cbee924 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -16,6 +16,12 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: 7.4 + - name: Install Wasmer + run: | + curl https://get.wasmer.io -sSfL | sh + source /home/runner/.wasmer/wasmer.sh + sudo mkdir -p /usr/local/lib/pkgconfig + wasmer config --pkg-config | sudo tee /usr/local/lib/pkgconfig/wasmer.pc - name: Checkout code uses: actions/checkout@v2 - name: Configure diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0cd708d..883a1e7 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -60,6 +60,12 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + - name: Install Wasmer + run: | + curl https://get.wasmer.io -sSfL | sh + source /home/runner/.wasmer/wasmer.sh + sudo mkdir -p /usr/local/lib/pkgconfig + wasmer config --pkg-config | sudo tee /usr/local/lib/pkgconfig/wasmer.pc - name: Checkout code uses: actions/checkout@v2 - name: Configure diff --git a/CMakeLists.txt b/CMakeLists.txt index c6b4616..59664e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,12 +15,20 @@ execute_process ( ) string(REGEX REPLACE "\n$" "" PHP_SOURCE "${PHP_SOURCE}") -message("Using source directory: ${PHP_SOURCE}") +execute_process ( + COMMAND wasmer config --includedir + OUTPUT_VARIABLE WASMER_SOURCE +) +string(REGEX REPLACE "\n$" "" WASMER_SOURCE "${WASMER_SOURCE}") + +message("Using PHP include directory: ${PHP_SOURCE}") +message("Using Wasmer include directory: ${WASMER_SOURCE}") include_directories(${PHP_SOURCE}) include_directories(${PHP_SOURCE}/main) include_directories(${PHP_SOURCE}/Zend) include_directories(${PHP_SOURCE}/TSRM) +include_directories(${WASMER_SOURCE}) include_directories(${PROJECT_SOURCE_DIR}) include_directories(${PROJECT_SOURCE_DIR}/include) diff --git a/config.m4 b/config.m4 index edf36be..a948fd0 100644 --- a/config.m4 +++ b/config.m4 @@ -1,13 +1,15 @@ dnl config.m4 for extension Wasmer -PHP_ARG_ENABLE(wasmer, whether to enable Wasmer support, - AS_HELP_STRING(--enable-wasmer, Enable Wasmer support)) +PHP_ARG_WITH(wasmer, for Wasmer support, + AS_HELP_STRING(--with-wasmer, Include Wasmer support)) if test "$PHP_WASMER" != "no"; then - AC_DEFINE(HAVE_WASMER, 1, [ Have Wasmer support ]) + PKG_CHECK_MODULES([LIBWASMER], [wasmer >= 1.0.2]) + PKG_CHECK_MODULES([LIBWASMER], [wasmer < 2.0.0]) + PHP_EVAL_INCLINE($LIBWASMER_CFLAGS) + PHP_EVAL_LIBLINE($LIBWASMER_LIBS, WASMER_SHARED_LIBADD) PHP_SUBST(WASMER_SHARED_LIBADD) - PHP_ADD_LIBRARY_WITH_PATH(wasmer, ./lib, WASMER_SHARED_LIBADD) WASMER_API="src/api/config.c src/api/engine.c src/api/store.c src/api/wasmer.c src/api/wat.c" WASMER_API_OBJECTS="src/api/objects/extern.c src/api/objects/foreign.c src/api/objects/func.c src/api/objects/frame.c src/api/objects/global.c src/api/objects/instance.c src/api/objects/memory.c src/api/objects/module.c src/api/objects/table.c src/api/objects/trap.c src/api/objects/val.c" diff --git a/include/wasm.h b/include/wasm.h deleted file mode 100644 index 25e0453..0000000 --- a/include/wasm.h +++ /dev/null @@ -1,723 +0,0 @@ -// WebAssembly C API - -#ifndef WASM_H -#define WASM_H - -#include -#include -#include -#include -#include - -#ifndef WASM_API_EXTERN -#ifdef _WIN32 -#define WASM_API_EXTERN __declspec(dllimport) -#else -#define WASM_API_EXTERN -#endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/////////////////////////////////////////////////////////////////////////////// -// Auxiliaries - -// Machine types - -inline void assertions() { - static_assert(sizeof(float) == sizeof(uint32_t), "incompatible float type"); - static_assert(sizeof(double) == sizeof(uint64_t), "incompatible double type"); - static_assert(sizeof(intptr_t) == sizeof(uint32_t) || - sizeof(intptr_t) == sizeof(uint64_t), - "incompatible pointer type"); -} - -typedef char byte_t; -typedef float float32_t; -typedef double float64_t; - - -// Ownership - -#define own - -// The qualifier `own` is used to indicate ownership of data in this API. -// It is intended to be interpreted similar to a `const` qualifier: -// -// - `own wasm_xxx_t*` owns the pointed-to data -// - `own wasm_xxx_t` distributes to all fields of a struct or union `xxx` -// - `own wasm_xxx_vec_t` owns the vector as well as its elements(!) -// - an `own` function parameter passes ownership from caller to callee -// - an `own` function result passes ownership from callee to caller -// - an exception are `own` pointer parameters named `out`, which are copy-back -// output parameters passing back ownership from callee to caller -// -// Own data is created by `wasm_xxx_new` functions and some others. -// It must be released with the corresponding `wasm_xxx_delete` function. -// -// Deleting a reference does not necessarily delete the underlying object, -// it merely indicates that this owner no longer uses it. -// -// For vectors, `const wasm_xxx_vec_t` is used informally to indicate that -// neither the vector nor its elements should be modified. -// TODO: introduce proper `wasm_xxx_const_vec_t`? - - -#define WASM_DECLARE_OWN(name) \ - typedef struct wasm_##name##_t wasm_##name##_t; \ - \ - WASM_API_EXTERN void wasm_##name##_delete(own wasm_##name##_t*); - - -// Vectors - -#define WASM_DECLARE_VEC(name, ptr_or_none) \ - typedef struct wasm_##name##_vec_t { \ - size_t size; \ - wasm_##name##_t ptr_or_none* data; \ - } wasm_##name##_vec_t; \ - \ - WASM_API_EXTERN void wasm_##name##_vec_new_empty(own wasm_##name##_vec_t* out); \ - WASM_API_EXTERN void wasm_##name##_vec_new_uninitialized( \ - own wasm_##name##_vec_t* out, size_t); \ - WASM_API_EXTERN void wasm_##name##_vec_new( \ - own wasm_##name##_vec_t* out, \ - size_t, own wasm_##name##_t ptr_or_none const[]); \ - WASM_API_EXTERN void wasm_##name##_vec_copy( \ - own wasm_##name##_vec_t* out, const wasm_##name##_vec_t*); \ - WASM_API_EXTERN void wasm_##name##_vec_delete(own wasm_##name##_vec_t*); - - -// Byte vectors - -typedef byte_t wasm_byte_t; -WASM_DECLARE_VEC(byte, ) - -typedef wasm_byte_vec_t wasm_name_t; - -#define wasm_name wasm_byte_vec -#define wasm_name_new wasm_byte_vec_new -#define wasm_name_new_empty wasm_byte_vec_new_empty -#define wasm_name_new_new_uninitialized wasm_byte_vec_new_uninitialized -#define wasm_name_copy wasm_byte_vec_copy -#define wasm_name_delete wasm_byte_vec_delete - -static inline void wasm_name_new_from_string( - own wasm_name_t* out, own const char* s -) { - wasm_name_new(out, strlen(s), s); -} - -static inline void wasm_name_new_from_string_nt( - own wasm_name_t* out, own const char* s -) { - wasm_name_new(out, strlen(s) + 1, s); -} - - -/////////////////////////////////////////////////////////////////////////////// -// Runtime Environment - -// Configuration - -WASM_DECLARE_OWN(config) - -WASM_API_EXTERN own wasm_config_t* wasm_config_new(); - -// Embedders may provide custom functions for manipulating configs. - - -// Engine - -WASM_DECLARE_OWN(engine) - -WASM_API_EXTERN own wasm_engine_t* wasm_engine_new(); -WASM_API_EXTERN own wasm_engine_t* wasm_engine_new_with_config(own wasm_config_t*); - - -// Store - -WASM_DECLARE_OWN(store) - -WASM_API_EXTERN own wasm_store_t* wasm_store_new(wasm_engine_t*); - - -/////////////////////////////////////////////////////////////////////////////// -// Type Representations - -// Type attributes - -typedef uint8_t wasm_mutability_t; -enum wasm_mutability_enum { - WASM_CONST, - WASM_VAR, -}; - -typedef struct wasm_limits_t { - uint32_t min; - uint32_t max; -} wasm_limits_t; - -static const uint32_t wasm_limits_max_default = 0xffffffff; - - -// Generic - -#define WASM_DECLARE_TYPE(name) \ - WASM_DECLARE_OWN(name) \ - WASM_DECLARE_VEC(name, *) \ - \ - WASM_API_EXTERN own wasm_##name##_t* wasm_##name##_copy(wasm_##name##_t*); - - -// Value Types - -WASM_DECLARE_TYPE(valtype) - -typedef uint8_t wasm_valkind_t; -enum wasm_valkind_enum { - WASM_I32, - WASM_I64, - WASM_F32, - WASM_F64, - WASM_ANYREF = 128, - WASM_FUNCREF, -}; - -WASM_API_EXTERN own wasm_valtype_t* wasm_valtype_new(wasm_valkind_t); - -WASM_API_EXTERN wasm_valkind_t wasm_valtype_kind(const wasm_valtype_t*); - -static inline bool wasm_valkind_is_num(wasm_valkind_t k) { - return k < WASM_ANYREF; -} -static inline bool wasm_valkind_is_ref(wasm_valkind_t k) { - return k >= WASM_ANYREF; -} - -static inline bool wasm_valtype_is_num(const wasm_valtype_t* t) { - return wasm_valkind_is_num(wasm_valtype_kind(t)); -} -static inline bool wasm_valtype_is_ref(const wasm_valtype_t* t) { - return wasm_valkind_is_ref(wasm_valtype_kind(t)); -} - - -// Function Types - -WASM_DECLARE_TYPE(functype) - -WASM_API_EXTERN own wasm_functype_t* wasm_functype_new( - own wasm_valtype_vec_t* params, own wasm_valtype_vec_t* results); - -WASM_API_EXTERN const wasm_valtype_vec_t* wasm_functype_params(const wasm_functype_t*); -WASM_API_EXTERN const wasm_valtype_vec_t* wasm_functype_results(const wasm_functype_t*); - - -// Global Types - -WASM_DECLARE_TYPE(globaltype) - -WASM_API_EXTERN own wasm_globaltype_t* wasm_globaltype_new( - own wasm_valtype_t*, wasm_mutability_t); - -WASM_API_EXTERN const wasm_valtype_t* wasm_globaltype_content(const wasm_globaltype_t*); -WASM_API_EXTERN wasm_mutability_t wasm_globaltype_mutability(const wasm_globaltype_t*); - - -// Table Types - -WASM_DECLARE_TYPE(tabletype) - -WASM_API_EXTERN own wasm_tabletype_t* wasm_tabletype_new( - own wasm_valtype_t*, const wasm_limits_t*); - -WASM_API_EXTERN const wasm_valtype_t* wasm_tabletype_element(const wasm_tabletype_t*); -WASM_API_EXTERN const wasm_limits_t* wasm_tabletype_limits(const wasm_tabletype_t*); - - -// Memory Types - -WASM_DECLARE_TYPE(memorytype) - -WASM_API_EXTERN own wasm_memorytype_t* wasm_memorytype_new(const wasm_limits_t*); - -WASM_API_EXTERN const wasm_limits_t* wasm_memorytype_limits(const wasm_memorytype_t*); - - -// Extern Types - -WASM_DECLARE_TYPE(externtype) - -typedef uint8_t wasm_externkind_t; -enum wasm_externkind_enum { - WASM_EXTERN_FUNC, - WASM_EXTERN_GLOBAL, - WASM_EXTERN_TABLE, - WASM_EXTERN_MEMORY, -}; - -WASM_API_EXTERN wasm_externkind_t wasm_externtype_kind(const wasm_externtype_t*); - -WASM_API_EXTERN wasm_externtype_t* wasm_functype_as_externtype(wasm_functype_t*); -WASM_API_EXTERN wasm_externtype_t* wasm_globaltype_as_externtype(wasm_globaltype_t*); -WASM_API_EXTERN wasm_externtype_t* wasm_tabletype_as_externtype(wasm_tabletype_t*); -WASM_API_EXTERN wasm_externtype_t* wasm_memorytype_as_externtype(wasm_memorytype_t*); - -WASM_API_EXTERN wasm_functype_t* wasm_externtype_as_functype(wasm_externtype_t*); -WASM_API_EXTERN wasm_globaltype_t* wasm_externtype_as_globaltype(wasm_externtype_t*); -WASM_API_EXTERN wasm_tabletype_t* wasm_externtype_as_tabletype(wasm_externtype_t*); -WASM_API_EXTERN wasm_memorytype_t* wasm_externtype_as_memorytype(wasm_externtype_t*); - -WASM_API_EXTERN const wasm_externtype_t* wasm_functype_as_externtype_const(const wasm_functype_t*); -WASM_API_EXTERN const wasm_externtype_t* wasm_globaltype_as_externtype_const(const wasm_globaltype_t*); -WASM_API_EXTERN const wasm_externtype_t* wasm_tabletype_as_externtype_const(const wasm_tabletype_t*); -WASM_API_EXTERN const wasm_externtype_t* wasm_memorytype_as_externtype_const(const wasm_memorytype_t*); - -WASM_API_EXTERN const wasm_functype_t* wasm_externtype_as_functype_const(const wasm_externtype_t*); -WASM_API_EXTERN const wasm_globaltype_t* wasm_externtype_as_globaltype_const(const wasm_externtype_t*); -WASM_API_EXTERN const wasm_tabletype_t* wasm_externtype_as_tabletype_const(const wasm_externtype_t*); -WASM_API_EXTERN const wasm_memorytype_t* wasm_externtype_as_memorytype_const(const wasm_externtype_t*); - - -// Import Types - -WASM_DECLARE_TYPE(importtype) - -WASM_API_EXTERN own wasm_importtype_t* wasm_importtype_new( - own wasm_name_t* module, own wasm_name_t* name, own wasm_externtype_t*); - -WASM_API_EXTERN const wasm_name_t* wasm_importtype_module(const wasm_importtype_t*); -WASM_API_EXTERN const wasm_name_t* wasm_importtype_name(const wasm_importtype_t*); -WASM_API_EXTERN const wasm_externtype_t* wasm_importtype_type(const wasm_importtype_t*); - - -// Export Types - -WASM_DECLARE_TYPE(exporttype) - -WASM_API_EXTERN own wasm_exporttype_t* wasm_exporttype_new( - own wasm_name_t*, own wasm_externtype_t*); - -WASM_API_EXTERN const wasm_name_t* wasm_exporttype_name(const wasm_exporttype_t*); -WASM_API_EXTERN const wasm_externtype_t* wasm_exporttype_type(const wasm_exporttype_t*); - - -/////////////////////////////////////////////////////////////////////////////// -// Runtime Objects - -// Values - -struct wasm_ref_t; - -typedef struct wasm_val_t { - wasm_valkind_t kind; - union { - int32_t i32; - int64_t i64; - float32_t f32; - float64_t f64; - struct wasm_ref_t* ref; - } of; -} wasm_val_t; - -WASM_API_EXTERN void wasm_val_delete(own wasm_val_t* v); -WASM_API_EXTERN void wasm_val_copy(own wasm_val_t* out, const wasm_val_t*); - -WASM_DECLARE_VEC(val, ) - - -// References - -#define WASM_DECLARE_REF_BASE(name) \ - WASM_DECLARE_OWN(name) \ - \ - WASM_API_EXTERN own wasm_##name##_t* wasm_##name##_copy(const wasm_##name##_t*); \ - WASM_API_EXTERN bool wasm_##name##_same(const wasm_##name##_t*, const wasm_##name##_t*); \ - \ - WASM_API_EXTERN void* wasm_##name##_get_host_info(const wasm_##name##_t*); \ - WASM_API_EXTERN void wasm_##name##_set_host_info(wasm_##name##_t*, void*); \ - WASM_API_EXTERN void wasm_##name##_set_host_info_with_finalizer( \ - wasm_##name##_t*, void*, void (*)(void*)); - -#define WASM_DECLARE_REF(name) \ - WASM_DECLARE_REF_BASE(name) \ - \ - WASM_API_EXTERN wasm_ref_t* wasm_##name##_as_ref(wasm_##name##_t*); \ - WASM_API_EXTERN wasm_##name##_t* wasm_ref_as_##name(wasm_ref_t*); \ - WASM_API_EXTERN const wasm_ref_t* wasm_##name##_as_ref_const(const wasm_##name##_t*); \ - WASM_API_EXTERN const wasm_##name##_t* wasm_ref_as_##name##_const(const wasm_ref_t*); - -#define WASM_DECLARE_SHARABLE_REF(name) \ - WASM_DECLARE_REF(name) \ - WASM_DECLARE_OWN(shared_##name) \ - \ - WASM_API_EXTERN own wasm_shared_##name##_t* wasm_##name##_share(const wasm_##name##_t*); \ - WASM_API_EXTERN own wasm_##name##_t* wasm_##name##_obtain(wasm_store_t*, const wasm_shared_##name##_t*); - - -WASM_DECLARE_REF_BASE(ref) - - -// Frames - -WASM_DECLARE_OWN(frame) -WASM_DECLARE_VEC(frame, *) -WASM_API_EXTERN own wasm_frame_t* wasm_frame_copy(const wasm_frame_t*); - -WASM_API_EXTERN struct wasm_instance_t* wasm_frame_instance(const wasm_frame_t*); -WASM_API_EXTERN uint32_t wasm_frame_func_index(const wasm_frame_t*); -WASM_API_EXTERN size_t wasm_frame_func_offset(const wasm_frame_t*); -WASM_API_EXTERN size_t wasm_frame_module_offset(const wasm_frame_t*); - - -// Traps - -typedef wasm_name_t wasm_message_t; // null terminated - -WASM_DECLARE_REF(trap) - -WASM_API_EXTERN own wasm_trap_t* wasm_trap_new(wasm_store_t* store, const wasm_message_t*); - -WASM_API_EXTERN void wasm_trap_message(const wasm_trap_t*, own wasm_message_t* out); -WASM_API_EXTERN own wasm_frame_t* wasm_trap_origin(const wasm_trap_t*); -WASM_API_EXTERN void wasm_trap_trace(const wasm_trap_t*, own wasm_frame_vec_t* out); - - -// Foreign Objects - -WASM_DECLARE_REF(foreign) - -WASM_API_EXTERN own wasm_foreign_t* wasm_foreign_new(wasm_store_t*); - - -// Modules - -WASM_DECLARE_SHARABLE_REF(module) - -WASM_API_EXTERN own wasm_module_t* wasm_module_new( - wasm_store_t*, const wasm_byte_vec_t* binary); - -WASM_API_EXTERN bool wasm_module_validate(wasm_store_t*, const wasm_byte_vec_t* binary); - -WASM_API_EXTERN void wasm_module_imports(const wasm_module_t*, own wasm_importtype_vec_t* out); -WASM_API_EXTERN void wasm_module_exports(const wasm_module_t*, own wasm_exporttype_vec_t* out); - -WASM_API_EXTERN void wasm_module_serialize(const wasm_module_t*, own wasm_byte_vec_t* out); -WASM_API_EXTERN own wasm_module_t* wasm_module_deserialize(wasm_store_t*, const wasm_byte_vec_t*); - - -// Function Instances - -WASM_DECLARE_REF(func) - -typedef own wasm_trap_t* (*wasm_func_callback_t)( - const wasm_val_vec_t* args, own wasm_val_vec_t* results); -typedef own wasm_trap_t* (*wasm_func_callback_with_env_t)( - void* env, const wasm_val_vec_t* args, wasm_val_vec_t* results); - -WASM_API_EXTERN own wasm_func_t* wasm_func_new( - wasm_store_t*, const wasm_functype_t*, wasm_func_callback_t); -WASM_API_EXTERN own wasm_func_t* wasm_func_new_with_env( - wasm_store_t*, const wasm_functype_t* type, wasm_func_callback_with_env_t, - void* env, void (*finalizer)(void*)); - -WASM_API_EXTERN own wasm_functype_t* wasm_func_type(const wasm_func_t*); -WASM_API_EXTERN size_t wasm_func_param_arity(const wasm_func_t*); -WASM_API_EXTERN size_t wasm_func_result_arity(const wasm_func_t*); - -WASM_API_EXTERN own wasm_trap_t* wasm_func_call( - const wasm_func_t*, const wasm_val_vec_t* args, wasm_val_vec_t* results); - - -// Global Instances - -WASM_DECLARE_REF(global) - -WASM_API_EXTERN own wasm_global_t* wasm_global_new( - wasm_store_t*, const wasm_globaltype_t*, const wasm_val_t*); - -WASM_API_EXTERN own wasm_globaltype_t* wasm_global_type(const wasm_global_t*); - -WASM_API_EXTERN void wasm_global_get(const wasm_global_t*, own wasm_val_t* out); -WASM_API_EXTERN void wasm_global_set(wasm_global_t*, const wasm_val_t*); - - -// Table Instances - -WASM_DECLARE_REF(table) - -typedef uint32_t wasm_table_size_t; - -WASM_API_EXTERN own wasm_table_t* wasm_table_new( - wasm_store_t*, const wasm_tabletype_t*, wasm_ref_t* init); - -WASM_API_EXTERN own wasm_tabletype_t* wasm_table_type(const wasm_table_t*); - -WASM_API_EXTERN own wasm_ref_t* wasm_table_get(const wasm_table_t*, wasm_table_size_t index); -WASM_API_EXTERN bool wasm_table_set(wasm_table_t*, wasm_table_size_t index, wasm_ref_t*); - -WASM_API_EXTERN wasm_table_size_t wasm_table_size(const wasm_table_t*); -WASM_API_EXTERN bool wasm_table_grow(wasm_table_t*, wasm_table_size_t delta, wasm_ref_t* init); - - -// Memory Instances - -WASM_DECLARE_REF(memory) - -typedef uint32_t wasm_memory_pages_t; - -static const size_t MEMORY_PAGE_SIZE = 0x10000; - -WASM_API_EXTERN own wasm_memory_t* wasm_memory_new(wasm_store_t*, const wasm_memorytype_t*); - -WASM_API_EXTERN own wasm_memorytype_t* wasm_memory_type(const wasm_memory_t*); - -WASM_API_EXTERN byte_t* wasm_memory_data(wasm_memory_t*); -WASM_API_EXTERN size_t wasm_memory_data_size(const wasm_memory_t*); - -WASM_API_EXTERN wasm_memory_pages_t wasm_memory_size(const wasm_memory_t*); -WASM_API_EXTERN bool wasm_memory_grow(wasm_memory_t*, wasm_memory_pages_t delta); - - -// Externals - -WASM_DECLARE_REF(extern) -WASM_DECLARE_VEC(extern, *) - -WASM_API_EXTERN wasm_externkind_t wasm_extern_kind(const wasm_extern_t*); -WASM_API_EXTERN own wasm_externtype_t* wasm_extern_type(const wasm_extern_t*); - -WASM_API_EXTERN wasm_extern_t* wasm_func_as_extern(wasm_func_t*); -WASM_API_EXTERN wasm_extern_t* wasm_global_as_extern(wasm_global_t*); -WASM_API_EXTERN wasm_extern_t* wasm_table_as_extern(wasm_table_t*); -WASM_API_EXTERN wasm_extern_t* wasm_memory_as_extern(wasm_memory_t*); - -WASM_API_EXTERN wasm_func_t* wasm_extern_as_func(wasm_extern_t*); -WASM_API_EXTERN wasm_global_t* wasm_extern_as_global(wasm_extern_t*); -WASM_API_EXTERN wasm_table_t* wasm_extern_as_table(wasm_extern_t*); -WASM_API_EXTERN wasm_memory_t* wasm_extern_as_memory(wasm_extern_t*); - -WASM_API_EXTERN const wasm_extern_t* wasm_func_as_extern_const(const wasm_func_t*); -WASM_API_EXTERN const wasm_extern_t* wasm_global_as_extern_const(const wasm_global_t*); -WASM_API_EXTERN const wasm_extern_t* wasm_table_as_extern_const(const wasm_table_t*); -WASM_API_EXTERN const wasm_extern_t* wasm_memory_as_extern_const(const wasm_memory_t*); - -WASM_API_EXTERN const wasm_func_t* wasm_extern_as_func_const(const wasm_extern_t*); -WASM_API_EXTERN const wasm_global_t* wasm_extern_as_global_const(const wasm_extern_t*); -WASM_API_EXTERN const wasm_table_t* wasm_extern_as_table_const(const wasm_extern_t*); -WASM_API_EXTERN const wasm_memory_t* wasm_extern_as_memory_const(const wasm_extern_t*); - - -// Module Instances - -WASM_DECLARE_REF(instance) - -WASM_API_EXTERN own wasm_instance_t* wasm_instance_new( - wasm_store_t*, const wasm_module_t*, const wasm_extern_vec_t* imports, - own wasm_trap_t** -); - -WASM_API_EXTERN void wasm_instance_exports(const wasm_instance_t*, own wasm_extern_vec_t* out); - - -/////////////////////////////////////////////////////////////////////////////// -// Convenience - -// Vectors - -#define WASM_EMPTY_VEC {0, NULL} -#define WASM_ARRAY_VEC(array) {sizeof(array)/sizeof(*(array)), array} - - -// Value Type construction short-hands - -static inline own wasm_valtype_t* wasm_valtype_new_i32() { - return wasm_valtype_new(WASM_I32); -} -static inline own wasm_valtype_t* wasm_valtype_new_i64() { - return wasm_valtype_new(WASM_I64); -} -static inline own wasm_valtype_t* wasm_valtype_new_f32() { - return wasm_valtype_new(WASM_F32); -} -static inline own wasm_valtype_t* wasm_valtype_new_f64() { - return wasm_valtype_new(WASM_F64); -} - -static inline own wasm_valtype_t* wasm_valtype_new_anyref() { - return wasm_valtype_new(WASM_ANYREF); -} -static inline own wasm_valtype_t* wasm_valtype_new_funcref() { - return wasm_valtype_new(WASM_FUNCREF); -} - - -// Function Types construction short-hands - -static inline own wasm_functype_t* wasm_functype_new_0_0() { - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new_empty(¶ms); - wasm_valtype_vec_new_empty(&results); - return wasm_functype_new(¶ms, &results); -} - -static inline own wasm_functype_t* wasm_functype_new_1_0( - own wasm_valtype_t* p -) { - wasm_valtype_t* ps[1] = {p}; - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new(¶ms, 1, ps); - wasm_valtype_vec_new_empty(&results); - return wasm_functype_new(¶ms, &results); -} - -static inline own wasm_functype_t* wasm_functype_new_2_0( - own wasm_valtype_t* p1, own wasm_valtype_t* p2 -) { - wasm_valtype_t* ps[2] = {p1, p2}; - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new(¶ms, 2, ps); - wasm_valtype_vec_new_empty(&results); - return wasm_functype_new(¶ms, &results); -} - -static inline own wasm_functype_t* wasm_functype_new_3_0( - own wasm_valtype_t* p1, own wasm_valtype_t* p2, own wasm_valtype_t* p3 -) { - wasm_valtype_t* ps[3] = {p1, p2, p3}; - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new(¶ms, 3, ps); - wasm_valtype_vec_new_empty(&results); - return wasm_functype_new(¶ms, &results); -} - -static inline own wasm_functype_t* wasm_functype_new_0_1( - own wasm_valtype_t* r -) { - wasm_valtype_t* rs[1] = {r}; - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new_empty(¶ms); - wasm_valtype_vec_new(&results, 1, rs); - return wasm_functype_new(¶ms, &results); -} - -static inline own wasm_functype_t* wasm_functype_new_1_1( - own wasm_valtype_t* p, own wasm_valtype_t* r -) { - wasm_valtype_t* ps[1] = {p}; - wasm_valtype_t* rs[1] = {r}; - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new(¶ms, 1, ps); - wasm_valtype_vec_new(&results, 1, rs); - return wasm_functype_new(¶ms, &results); -} - -static inline own wasm_functype_t* wasm_functype_new_2_1( - own wasm_valtype_t* p1, own wasm_valtype_t* p2, own wasm_valtype_t* r -) { - wasm_valtype_t* ps[2] = {p1, p2}; - wasm_valtype_t* rs[1] = {r}; - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new(¶ms, 2, ps); - wasm_valtype_vec_new(&results, 1, rs); - return wasm_functype_new(¶ms, &results); -} - -static inline own wasm_functype_t* wasm_functype_new_3_1( - own wasm_valtype_t* p1, own wasm_valtype_t* p2, own wasm_valtype_t* p3, - own wasm_valtype_t* r -) { - wasm_valtype_t* ps[3] = {p1, p2, p3}; - wasm_valtype_t* rs[1] = {r}; - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new(¶ms, 3, ps); - wasm_valtype_vec_new(&results, 1, rs); - return wasm_functype_new(¶ms, &results); -} - -static inline own wasm_functype_t* wasm_functype_new_0_2( - own wasm_valtype_t* r1, own wasm_valtype_t* r2 -) { - wasm_valtype_t* rs[2] = {r1, r2}; - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new_empty(¶ms); - wasm_valtype_vec_new(&results, 2, rs); - return wasm_functype_new(¶ms, &results); -} - -static inline own wasm_functype_t* wasm_functype_new_1_2( - own wasm_valtype_t* p, own wasm_valtype_t* r1, own wasm_valtype_t* r2 -) { - wasm_valtype_t* ps[1] = {p}; - wasm_valtype_t* rs[2] = {r1, r2}; - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new(¶ms, 1, ps); - wasm_valtype_vec_new(&results, 2, rs); - return wasm_functype_new(¶ms, &results); -} - -static inline own wasm_functype_t* wasm_functype_new_2_2( - own wasm_valtype_t* p1, own wasm_valtype_t* p2, - own wasm_valtype_t* r1, own wasm_valtype_t* r2 -) { - wasm_valtype_t* ps[2] = {p1, p2}; - wasm_valtype_t* rs[2] = {r1, r2}; - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new(¶ms, 2, ps); - wasm_valtype_vec_new(&results, 2, rs); - return wasm_functype_new(¶ms, &results); -} - -static inline own wasm_functype_t* wasm_functype_new_3_2( - own wasm_valtype_t* p1, own wasm_valtype_t* p2, own wasm_valtype_t* p3, - own wasm_valtype_t* r1, own wasm_valtype_t* r2 -) { - wasm_valtype_t* ps[3] = {p1, p2, p3}; - wasm_valtype_t* rs[2] = {r1, r2}; - wasm_valtype_vec_t params, results; - wasm_valtype_vec_new(¶ms, 3, ps); - wasm_valtype_vec_new(&results, 2, rs); - return wasm_functype_new(¶ms, &results); -} - - -// Value construction short-hands - -static inline void wasm_val_init_ptr(own wasm_val_t* out, void* p) { -#if UINTPTR_MAX == UINT32_MAX - out->kind = WASM_I32; - out->of.i32 = (intptr_t)p; -#elif UINTPTR_MAX == UINT64_MAX - out->kind = WASM_I64; - out->of.i64 = (intptr_t)p; -#endif -} - -static inline void* wasm_val_ptr(const wasm_val_t* val) { -#if UINTPTR_MAX == UINT32_MAX - return (void*)(intptr_t)val->of.i32; -#elif UINTPTR_MAX == UINT64_MAX - return (void*)(intptr_t)val->of.i64; -#endif -} - -#define WASM_I32_VAL(i) {.kind = WASM_I32, .of = {.i32 = i}} -#define WASM_I64_VAL(i) {.kind = WASM_I64, .of = {.i64 = i}} -#define WASM_F32_VAL(z) {.kind = WASM_F32, .of = {.f32 = z}} -#define WASM_F64_VAL(z) {.kind = WASM_F64, .of = {.f64 = z}} -#define WASM_REF_VAL(r) {.kind = WASM_ANYREF, .of = {.ref = r}} -#define WASM_INIT_VAL {.kind = WASM_ANYREF, .of = {.ref = NULL}} - - -/////////////////////////////////////////////////////////////////////////////// - -#undef own - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // #ifdef WASM_H diff --git a/include/wasmer_wasm.h b/include/wasmer_wasm.h deleted file mode 100644 index c4debd5..0000000 --- a/include/wasmer_wasm.h +++ /dev/null @@ -1,562 +0,0 @@ -// The Wasmer C/C++ header file compatible with the `wasm-c-api` standard API. -// This file is generated by lib/c-api/build.rs. - -#if !defined(WASMER_WASM_H_PRELUDE) - -#define WASMER_WASM_H_PRELUDE - -// Define the `ARCH_X86_X64` constant. -#if defined(MSVC) && defined(_M_AMD64) -# define ARCH_X86_64 -#elif (defined(GCC) || defined(__GNUC__) || defined(__clang__)) && defined(__x86_64__) -# define ARCH_X86_64 -#endif - -// Compatibility with non-Clang compilers. -#if !defined(__has_attribute) -# define __has_attribute(x) 0 -#endif - -// Compatibility with non-Clang compilers. -#if !defined(__has_declspec_attribute) -# define __has_declspec_attribute(x) 0 -#endif - -// Define the `DEPRECATED` macro. -#if defined(GCC) || defined(__GNUC__) || __has_attribute(deprecated) -# define DEPRECATED(message) __attribute__((deprecated(message))) -#elif defined(MSVC) || __has_declspec_attribute(deprecated) -# define DEPRECATED(message) __declspec(deprecated(message)) -#endif - -// The `jit` feature has been enabled for this build. -#define WASMER_JIT_ENABLED - -// The `compiler` feature has been enabled for this build. -#define WASMER_COMPILER_ENABLED - -// The `wasi` feature has been enabled for this build. -#define WASMER_WASI_ENABLED - -// This file corresponds to the following Wasmer version. -#define WASMER_VERSION "1.0.1" -#define WASMER_VERSION_MAJOR 1 -#define WASMER_VERSION_MINOR 0 -#define WASMER_VERSION_PATCH 1 -#define WASMER_VERSION_PRE "" - -#endif // WASMER_WASM_H_PRELUDE - - -// -// OK, here we go. The code below is automatically generated. -// - - -#ifndef WASMER_WASM_H -#define WASMER_WASM_H - -#include -#include -#include -#include -#include "wasm.h" - -#if defined(WASMER_COMPILER_ENABLED) -/** - * Kind of compilers that can be used by the engines. - * - * This is a Wasmer-specific type with Wasmer-specific functions for - * manipulating it. - */ -typedef enum { - /** - * Variant to represent the Cranelift compiler. See the - * [`wasmer_compiler_cranelift`] Rust crate. - */ - CRANELIFT = 0, - /** - * Variant to represent the LLVM compiler. See the - * [`wasmer_compiler_llvm`] Rust crate. - */ - LLVM = 1, - /** - * Variant to represent the Singlepass compiler. See the - * [`wasmer_compiler_singlepass`] Rust crate. - */ - SINGLEPASS = 2, -} wasmer_compiler_t; -#endif - -/** - * Kind of engines that can be used by the store. - * - * This is a Wasmer-specific type with Wasmer-specific functions for - * manipulating it. - */ -typedef enum { - /** - * Variant to represent the JIT engine. See the - * [`wasmer_engine_jit`] Rust crate. - */ - JIT = 0, - /** - * Variant to represent the Native engine. See the - * [`wasmer_engine_native`] Rust crate. - */ - NATIVE = 1, - /** - * Variant to represent the Object File engine. See the - * [`wasmer_engine_object_file`] Rust crate. - */ - OBJECT_FILE = 2, -} wasmer_engine_t; - -#if defined(WASMER_WASI_ENABLED) -typedef struct wasi_config_t wasi_config_t; -#endif - -#if defined(WASMER_WASI_ENABLED) -typedef struct wasi_env_t wasi_env_t; -#endif - -#if defined(WASMER_WASI_ENABLED) -typedef struct wasi_version_t wasi_version_t; -#endif - -#if defined(WASMER_WASI_ENABLED) -void wasi_config_arg(wasi_config_t *config, const char *arg); -#endif - -#if defined(WASMER_WASI_ENABLED) -void wasi_config_env(wasi_config_t *config, const char *key, const char *value); -#endif - -#if defined(WASMER_WASI_ENABLED) -void wasi_config_inherit_stderr(wasi_config_t *config); -#endif - -#if defined(WASMER_WASI_ENABLED) -void wasi_config_inherit_stdin(wasi_config_t *config); -#endif - -#if defined(WASMER_WASI_ENABLED) -void wasi_config_inherit_stdout(wasi_config_t *config); -#endif - -#if defined(WASMER_WASI_ENABLED) -bool wasi_config_mapdir(wasi_config_t *config, const char *alias, const char *dir); -#endif - -#if defined(WASMER_WASI_ENABLED) -wasi_config_t *wasi_config_new(const char *program_name); -#endif - -#if defined(WASMER_WASI_ENABLED) -bool wasi_config_preopen_dir(wasi_config_t *config, const char *dir); -#endif - -#if defined(WASMER_WASI_ENABLED) -void wasi_env_delete(wasi_env_t *_state); -#endif - -#if defined(WASMER_WASI_ENABLED) -/** - * Takes ownership over the `wasi_config_t`. - */ -wasi_env_t *wasi_env_new(wasi_config_t *config); -#endif - -#if defined(WASMER_WASI_ENABLED) -intptr_t wasi_env_read_stderr(wasi_env_t *env, char *buffer, uintptr_t buffer_len); -#endif - -#if defined(WASMER_WASI_ENABLED) -intptr_t wasi_env_read_stdout(wasi_env_t *env, char *buffer, uintptr_t buffer_len); -#endif - -#if defined(WASMER_WASI_ENABLED) -/** - * This function is deprecated. You may safely remove all calls to it and everything - * will continue to work. - */ -bool wasi_env_set_instance(wasi_env_t *env, const wasm_instance_t *instance); -#endif - -#if defined(WASMER_WASI_ENABLED) -/** - * This function is deprecated. You may safely remove all calls to it and everything - * will continue to work. - */ -void wasi_env_set_memory(wasi_env_t *env, const wasm_memory_t *memory); -#endif - -#if defined(WASMER_WASI_ENABLED) -/** - * Takes ownership of `wasi_env_t`. - */ -bool wasi_get_imports(const wasm_store_t *store, - const wasm_module_t *module, - const wasi_env_t *wasi_env, - wasm_extern_vec_t *imports); -#endif - -#if defined(WASMER_WASI_ENABLED) -wasm_func_t *wasi_get_start_function(wasm_instance_t *instance); -#endif - -#if defined(WASMER_WASI_ENABLED) -wasi_version_t wasi_get_wasi_version(const wasm_module_t *module); -#endif - -#if defined(WASMER_COMPILER_ENABLED) -/** - * Updates the configuration to specify a particular compiler to use. - * - * This is a Wasmer-specific function. - * - * # Example - * - * ```rust,no_run - * # use inline_c::assert_c; - * # fn main() { - * # (assert_c! { - * # #include "tests/wasmer_wasm.h" - * # - * int main() { - * // Create the configuration. - * wasm_config_t* config = wasm_config_new(); - * - * // Use the Cranelift compiler. - * wasm_config_set_compiler(config, CRANELIFT); - * - * // Create the engine. - * wasm_engine_t* engine = wasm_engine_new_with_config(config); - * - * // Check we have an engine! - * assert(engine); - * - * // Free everything. - * wasm_engine_delete(engine); - * - * return 0; - * } - * # }) - * # .success(); - * # } - * ``` - */ -void wasm_config_set_compiler(wasm_config_t *config, wasmer_compiler_t compiler); -#endif - -/** - * Updates the configuration to specify a particular engine to use. - * - * This is a Wasmer-specific function. - * - * # Example - * - * ```rust,no_run - * # use inline_c::assert_c; - * # fn main() { - * # (assert_c! { - * # #include "tests/wasmer_wasm.h" - * # - * int main() { - * // Create the configuration. - * wasm_config_t* config = wasm_config_new(); - * - * // Use the JIT engine. - * wasm_config_set_engine(config, JIT); - * - * // Create the engine. - * wasm_engine_t* engine = wasm_engine_new_with_config(config); - * - * // Check we have an engine! - * assert(engine); - * - * // Free everything. - * wasm_engine_delete(engine); - * - * return 0; - * } - * # }) - * # .success(); - * # } - * ``` - */ -void wasm_config_set_engine(wasm_config_t *config, wasmer_engine_t engine); - -/** - * Non-standard Wasmer-specific API to get the module's name, - * otherwise `out->size` is set to `0` and `out->data` to `NULL`. - * - * # Example - * - * ```rust - * # use inline_c::assert_c; - * # fn main() { - * # (assert_c! { - * # #include "tests/wasmer_wasm.h" - * # - * int main() { - * // Create the engine and the store. - * wasm_engine_t* engine = wasm_engine_new(); - * wasm_store_t* store = wasm_store_new(engine); - * - * // Create a WebAssembly module from a WAT definition. - * wasm_byte_vec_t wat; - * wasmer_byte_vec_new_from_string(&wat, "(module $moduleName)"); - * // ^~~~~~~~~~~ that's the name! - * wasm_byte_vec_t wasm; - * wat2wasm(&wat, &wasm); - * - * // Create the module. - * wasm_module_t* module = wasm_module_new(store, &wasm); - * - * // Read the module's name. - * wasm_name_t name; - * wasm_module_name(module, &name); - * - * // It works! - * wasmer_assert_name(&name, "moduleName"); - * - * // Free everything. - * wasm_byte_vec_delete(&name); - * wasm_module_delete(module); - * wasm_byte_vec_delete(&wasm); - * wasm_byte_vec_delete(&wat); - * wasm_store_delete(store); - * wasm_engine_delete(engine); - * - * return 0; - * } - * # }) - * # .success(); - * # } - * ``` - */ -void wasm_module_name(const wasm_module_t *module, wasm_name_t *out); - -/** - * Non-standard Wasmer-specific API to set the module's name. The - * function returns `true` if the name has been updated, `false` - * otherwise. - * - * # Example - * - * ```rust - * # use inline_c::assert_c; - * # fn main() { - * # (assert_c! { - * # #include "tests/wasmer_wasm.h" - * # - * int main() { - * // Create the engine and the store. - * wasm_engine_t* engine = wasm_engine_new(); - * wasm_store_t* store = wasm_store_new(engine); - * - * // Create a WebAssembly module from a WAT definition. - * wasm_byte_vec_t wat; - * wasmer_byte_vec_new_from_string(&wat, "(module)"); - * wasm_byte_vec_t wasm; - * wat2wasm(&wat, &wasm); - * - * // Create the module. - * wasm_module_t* module = wasm_module_new(store, &wasm); - * - * // Read the module's name. There is none for the moment. - * { - * wasm_name_t name; - * wasm_module_name(module, &name); - * - * assert(name.size == 0); - * } - * - * // So, let's set a new name. - * { - * wasm_name_t name; - * wasmer_byte_vec_new_from_string(&name, "hello"); - * wasm_module_set_name(module, &name); - * } - * - * // And now, let's see the new name. - * { - * wasm_name_t name; - * wasm_module_name(module, &name); - * - * // It works! - * wasmer_assert_name(&name, "hello"); - * - * wasm_byte_vec_delete(&name); - * } - * - * // Free everything. - * wasm_module_delete(module); - * wasm_byte_vec_delete(&wasm); - * wasm_byte_vec_delete(&wat); - * wasm_store_delete(store); - * wasm_engine_delete(engine); - * - * return 0; - * } - * # }) - * # .success(); - * # } - * ``` - */ -bool wasm_module_set_name(wasm_module_t *module, const wasm_name_t *name); - -/** - * Gets the length in bytes of the last error if any, zero otherwise. - * - * This can be used to dynamically allocate a buffer with the correct number of - * bytes needed to store a message. - * - * # Example - * - * See this module's documentation to get a complete example. - */ -int wasmer_last_error_length(void); - -/** - * Gets the last error message if any into the provided buffer - * `buffer` up to the given `length`. - * - * The `length` parameter must be large enough to store the last - * error message. Ideally, the value should come from - * [`wasmer_last_error_length`]. - * - * The function returns the length of the string in bytes, `-1` if an - * error occurs. Potential errors are: - * - * * The `buffer` is a null pointer, - * * The `buffer` is too small to hold the error message. - * - * Note: The error message always has a trailing NUL character. - * - * Important note: If the provided `buffer` is non-null, once this - * function has been called, regardless whether it fails or succeeds, - * the error is cleared. - * - * # Example - * - * See this module's documentation to get a complete example. - */ -int wasmer_last_error_message(char *buffer, int length); - -/** - * Get the version of the Wasmer C API. - * - * The `.h` files already define variables like `WASMER_VERSION*`, - * but if this file is unreachable, one can use this function to - * retrieve the full semver version of the Wasmer C API. - * - * The returned string is statically allocated. It must _not_ be - * freed! - * - * # Example - * - * See the module's documentation. - */ -const char *wasmer_version(void); - -/** - * Get the major version of the Wasmer C API. - * - * See [`wasmer_version`] to learn more. - * - * # Example - * - * ```rust - * # use inline_c::assert_c; - * # fn main() { - * # (assert_c! { - * # #include "tests/wasmer_wasm.h" - * # - * int main() { - * // Get and print the version components. - * uint8_t version_major = wasmer_version_major(); - * uint8_t version_minor = wasmer_version_minor(); - * uint8_t version_patch = wasmer_version_patch(); - * - * printf("%d.%d.%d", version_major, version_minor, version_patch); - * - * return 0; - * } - * # }) - * # .success() - * # .stdout( - * # format!( - * # "{}.{}.{}", - * # env!("CARGO_PKG_VERSION_MAJOR"), - * # env!("CARGO_PKG_VERSION_MINOR"), - * # env!("CARGO_PKG_VERSION_PATCH") - * # ) - * # ); - * # } - * ``` - */ -uint8_t wasmer_version_major(void); - -/** - * Get the minor version of the Wasmer C API. - * - * See [`wasmer_version_major`] to learn more and get an example. - */ -uint8_t wasmer_version_minor(void); - -/** - * Get the patch version of the Wasmer C API. - * - * See [`wasmer_version_major`] to learn more and get an example. - */ -uint8_t wasmer_version_patch(void); - -/** - * Get the minor version of the Wasmer C API. - * - * See [`wasmer_version_major`] to learn more. - * - * The returned string is statically allocated. It must _not_ be - * freed! - * - * # Example - * - * ```rust - * # use inline_c::assert_c; - * # fn main() { - * # (assert_c! { - * # #include "tests/wasmer_wasm.h" - * # - * int main() { - * // Get and print the pre version. - * const char* version_pre = wasmer_version_pre(); - * printf("%s", version_pre); - * - * // No need to free the string. It's statically allocated on - * // the Rust side. - * - * return 0; - * } - * # }) - * # .success() - * # .stdout(env!("CARGO_PKG_VERSION_PRE")); - * # } - * ``` - */ -const char *wasmer_version_pre(void); - -/** - * Parses in-memory bytes as either the WAT format, or a binary Wasm - * module. This is wasmer-specific. - * - * In case of failure, `wat2wasm` sets the `out->data = NULL` and `out->size = 0`. - * - * # Example - * - * See the module's documentation. - */ -void wat2wasm(const wasm_byte_vec_t *wat, wasm_byte_vec_t *out); - -#endif /* WASMER_WASM_H */ diff --git a/lib/libwasmer.dylib b/lib/libwasmer.dylib deleted file mode 100755 index 1207129..0000000 Binary files a/lib/libwasmer.dylib and /dev/null differ diff --git a/lib/libwasmer.so b/lib/libwasmer.so deleted file mode 100755 index d9980c5..0000000 Binary files a/lib/libwasmer.so and /dev/null differ diff --git a/tests/api/objects/func/02-wasm_func_new.phpt b/tests/api/objects/func/02-wasm_func_new.phpt index 437a1ad..ae389ea 100644 --- a/tests/api/objects/func/02-wasm_func_new.phpt +++ b/tests/api/objects/func/02-wasm_func_new.phpt @@ -1,6 +1,8 @@ --TEST-- Func API: wasm_func_new +--INI-- +report_memleaks=Off --FILE-- --EXPECTF-- -string(5) "1.0.1" +string(5) "%d.%d.%d" diff --git a/tests/api/wasmer/wasmer_version_major.phpt b/tests/api/wasmer/wasmer_version_major.phpt index 3eff7ab..ac195a3 100644 --- a/tests/api/wasmer/wasmer_version_major.phpt +++ b/tests/api/wasmer/wasmer_version_major.phpt @@ -8,4 +8,4 @@ var_dump(wasmer_version_major()); ?> --EXPECTF-- -int(1) +int(%d) diff --git a/tests/api/wasmer/wasmer_version_minor.phpt b/tests/api/wasmer/wasmer_version_minor.phpt index 98c02ca..94837c4 100644 --- a/tests/api/wasmer/wasmer_version_minor.phpt +++ b/tests/api/wasmer/wasmer_version_minor.phpt @@ -8,4 +8,4 @@ var_dump(wasmer_version_minor()); ?> --EXPECTF-- -int(0) +int(%d) diff --git a/tests/api/wasmer/wasmer_version_patch.phpt b/tests/api/wasmer/wasmer_version_patch.phpt index c239094..7d43cb9 100644 --- a/tests/api/wasmer/wasmer_version_patch.phpt +++ b/tests/api/wasmer/wasmer_version_patch.phpt @@ -8,4 +8,4 @@ var_dump(wasmer_version_patch()); ?> --EXPECTF-- -int(1) +int(%d)