diff --git a/.github/workflows/verify_checked_apis.yml b/.github/workflows/verify_checked_apis.yml new file mode 100644 index 0000000000..1583438171 --- /dev/null +++ b/.github/workflows/verify_checked_apis.yml @@ -0,0 +1,59 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +name: Verify core/iwasm/include checked APIs to see if they are up to date + +on: + # will be triggered on PR events + pull_request: + types: + - opened + - synchronize + paths: + - "core/iwasm/include/**" + - ".github/workflows/verify_checked_apis.yml" + - "ci/generate_checked_functions.py" + push: + paths: + - "core/iwasm/include/**" + - ".github/workflows/verify_checked_apis.yml" + - "ci/generate_checked_functions.py" + +# Cancel any in-flight jobs for the same PR/branch so there's only one active +# at a time +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + verify_checked_apis: + name: Verify checked APIs + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + pip install pycparser + sudo apt-get update + sudo apt-get install -y clang-format-14 + + - name: Generate checked APIs + id: generate_checked_apis + run: | + python3 ci/generate_checked_functions.py + + - name: Check for differences + run: | + #it exits with 1 if there were differences and 0 means no differences + git diff --exit-code diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py new file mode 100644 index 0000000000..28c04887b9 --- /dev/null +++ b/ci/generate_checked_functions.py @@ -0,0 +1,318 @@ +""" +This script generates "checked" versions of functions from the specified header files. + +Usage: + python3 generate_checked_functions.py --headers ... + +Arguments: + --headers: A list of header file paths to process. Each header file will be parsed, and a corresponding + "_checked.h" file will be generated with additional null pointer checks and error handling. + If not provided, a default list of headers under "core/iwasm/include/" will be used. + +Example: + python3 generate_checked_functions.py + # OR + python3 generate_checked_functions.py --headers core/iwasm/include/wasm_export.h + +Description: + The script parses the provided header files using `pycparser` to extract function declarations and typedefs. + For each function, it generates a "checked" version that includes: + - Null pointer checks for pointer parameters. + - Error handling using a `Result` struct. + - Support for variadic arguments (e.g., ...). + + The generated "_checked.h" files include the original header file and define the `Result` struct, which + encapsulates the return value and error codes. The `Result` struct is dynamically generated based on the + return types of the functions in the header file. + +Dependencies: + - pycparser: Install it using `pip install pycparser`. + - clang-format-14: Ensure it is installed for formatting the generated files. + +Output: + For each input header file, a corresponding "_checked.h" file is created in the same directory. + The generated files are automatically formatted using clang-format-14. +""" + +import argparse +from pathlib import Path +from pycparser import c_ast, parse_file +import subprocess + +# Constants for repeated strings +CPP_ARGS = [ + "-E", + "-D__attribute__(x)=", + "-D__asm__(x)=", + "-D__asm(x)=", + "-D__builtin_va_list=int", + "-D__extension__=", + "-D__inline__=", + "-D__restrict=", + "-D__restrict__=", + "-D_Static_assert(x, y)=", + "-D__signed=", + "-D__volatile__(x)=", + "-Dstatic_assert(x, y)=", +] + +RESULT_STRUCT_TEMPLATE = """ + typedef struct { + int error_code; // Error code (0 for success, non-zero for errors) + union { + // Add other types as needed + } value; + } Result; +""" + +COPYRIGHT = """ +/* + * Copyright (C) 2025 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + """ + +INCLUDE_HEADERS = ["", "", ""] + + +def extract_typedefs(ast): + """Extract all typedefs from the AST.""" + return {node.name: node.type for node in ast.ext if isinstance(node, c_ast.Typedef)} + + +def generate_result_struct(return_types): + """Generate the Result struct based on return types.""" + result_struct = RESULT_STRUCT_TEMPLATE + for return_type in return_types: + if return_type == "void": + continue + + result_struct = result_struct.replace( + "// Add other types as needed", + f" {return_type} {return_type}_value;\n // Add other types as needed", + ) + return result_struct + + +def write_checked_header(output_path, result_struct, functions, typedefs): + """Write the checked header file.""" + + with open(output_path, "w") as f: + # copyright + f.write(COPYRIGHT) + f.write("\n") + + f.write("/*\n") + f.write(" * THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT!\n") + f.write(" */\n") + + # include guard + f.write( + f"#ifndef {output_path.stem.upper()}_H\n#define {output_path.stem.upper()}_H\n\n" + ) + + for header in INCLUDE_HEADERS: + f.write(f"#include {header}\n") + f.write("\n") + # include original header + original_header = output_path.stem.replace("_checked", "") + ".h" + f.write(f'#include "{original_header}"\n') + f.write("\n") + + f.write(result_struct + "\n") + + for func in functions: + new_func = generate_checked_function(func, typedefs) + f.write(new_func + "\n\n") + + f.write(f"#endif // {output_path.stem.upper()}_H\n") + + +def generate_checked_function(func, typedefs): + """Generate a checked version of the given function.""" + func_name = func.name # Access the name directly from Decl + new_func_name = f"{func_name}_checked" + + # Extract parameters + params = func.type.args.params if func.type.args else [] + + # Determine the return type + return_pointer = False + return_type = "void" # Default to void if no return type is specified + if isinstance(func.type.type, c_ast.TypeDecl): + return_type = " ".join(func.type.type.type.names) + + resolved_type = typedefs.get(return_type, return_type) + if isinstance(resolved_type, c_ast.PtrDecl): + return_pointer = True + + # Start building the new function + new_func = [f"static inline Result {new_func_name}("] + param_list = [] + for param in params: + if isinstance(param, c_ast.EllipsisParam): + # Handle variadic arguments (e.g., ...) + param_list.append("...") + new_func.append(" ...,") + continue + + param_name = param.name if param.name else "" + param_list.append(param_name) + param_type = ( + " ".join(param.type.type.names) + if isinstance(param.type, c_ast.TypeDecl) + else "void*" + ) + new_func.append(f" {param_type} {param_name},") + if param_list: + new_func[-1] = new_func[-1].rstrip(",") # Remove trailing comma + new_func.append(") {") + + # Add null checks for pointer parameters + new_func.append(f" Result res;") + has_variadic = False + for param in params: + if isinstance(param, c_ast.EllipsisParam): + # Restructure to use va_list + new_func.append(" va_list args;") + has_variadic = True + elif isinstance(param.type, c_ast.PtrDecl): + new_func.append(f" // Check for null pointer parameter: {param.name}") + new_func.append(f" if ({param.name} == NULL) {{") + new_func.append(f" res.error_code = -1;") + new_func.append(f" return res;") + new_func.append(f" }}") + + # Call the original function + new_func.append(f" // Execute the original function") + if return_type == "void": + new_func.append(f" {func_name}({', '.join(param_list)});") + elif has_variadic: + new_func.append(" va_start(args, " + param_list[-2] + ");") + new_func.append( + f" {return_type} original_result = {func_name}({', '.join(param_list[:-1])}, args);" + ) + new_func.append(" va_end(args);") + else: + new_func.append( + f" {return_type} original_result = {func_name}({', '.join(param_list)});" + ) + + # Handle returned values + new_func.append(f" // Assign return value and error code") + if return_type == "void": + new_func.append(f" res.error_code = 0;") + elif return_type == "_Bool": + new_func.append(f" res.error_code = original_result ? 0 : -2;") + new_func.append(f" res.value._Bool_value = original_result;") + # if return type is a pointer or typedef from pointer + elif return_pointer: + new_func.append(f" if (original_result != NULL) {{") + new_func.append(f" res.error_code = 0;") + new_func.append(f" res.value.{return_type}_value = original_result;") + new_func.append(f" }} else {{") + new_func.append(f" res.error_code = -2;") + new_func.append(f" }}") + else: + new_func.append(f" if (original_result == 0) {{") + new_func.append(f" res.error_code = 0;") + new_func.append(f" res.value.{return_type}_value = original_result;") + new_func.append(f" }} else {{") + new_func.append(f" res.error_code = -2;") + new_func.append(f" }}") + + new_func.append(f" return res;") + new_func.append(f"}}") + return "\n".join(new_func) + + +def parse_arguments(): + """Parse command-line arguments.""" + parser = argparse.ArgumentParser( + description="Generate checked functions from header files." + ) + parser.add_argument( + "--headers", + nargs="+", + required=False, + help="List of header file paths to process. Relative to the project root.", + default=[ + "core/iwasm/include/aot_comp_option.h", + "core/iwasm/include/aot_export.h", + "core/iwasm/include/gc_export.h", + "core/iwasm/include/lib_export.h", + "core/iwasm/include/wasm_c_api.h", + "core/iwasm/include/wasm_export.h", + ], + ) + return parser.parse_args() + + +def generate_checked_headers(header_paths): + """Process each header file and generate checked versions.""" + output_header = [] + for input_header in header_paths: + input_path = Path(input_header) + output_path = input_path.with_name(input_path.stem + "_checked.h") + + ast = parse_file( + str(input_path), + use_cpp=True, + cpp_path="gcc", + cpp_args=CPP_ARGS, + ) + + typedefs = extract_typedefs(ast) + functions = [ + node + for node in ast.ext + if isinstance(node, c_ast.Decl) and isinstance(node.type, c_ast.FuncDecl) + ] + # remove std headers functions + functions = [ + f + for f in functions + if f.name + not in ( + "__mempcpy", + "__stpcpy", + "memmem", + "memmove", + "mempcpy", + "memset", + "strcasestr", + "strcat", + "strchrnul", + "strcmp", + "strlcat", + "strlcpy", + "strlen", + ) + ] + functions = sorted(functions, key=lambda f: f.name) + + return_types = { + " ".join(func.type.type.type.names) + for func in functions + if isinstance(func.type.type, c_ast.TypeDecl) + } + return_types = sorted(return_types) + + result_struct = generate_result_struct(return_types) + write_checked_header(output_path, result_struct, functions, typedefs) + output_header.append(output_path) + + return output_header + + +def main(): + args = parse_arguments() + generated_headers = generate_checked_headers(args.headers) + + # format the generated files using clang-format-14 + for header in generated_headers: + subprocess.run(["clang-format-14", "--style=file", "-i", str(header)]) + + +if __name__ == "__main__": + main() diff --git a/core/iwasm/include/aot_comp_option.h b/core/iwasm/include/aot_comp_option.h index 9a9023ee2e..cb27919e06 100644 --- a/core/iwasm/include/aot_comp_option.h +++ b/core/iwasm/include/aot_comp_option.h @@ -7,6 +7,7 @@ #define __AOT_COMP_OPTION_H__ #include +#include #ifdef __cplusplus extern "C" { diff --git a/core/iwasm/include/aot_comp_option_checked.h b/core/iwasm/include/aot_comp_option_checked.h new file mode 100644 index 0000000000..698876458a --- /dev/null +++ b/core/iwasm/include/aot_comp_option_checked.h @@ -0,0 +1,42 @@ + +/* + * Copyright (C) 2025 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +/* + * THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT! + */ +#ifndef AOT_COMP_OPTION_CHECKED_H +#define AOT_COMP_OPTION_CHECKED_H + +#include +#include +#include + +#include "aot_comp_option.h" + +typedef struct { + int error_code; // Error code (0 for success, non-zero for errors) + union { + // Add other types as needed + } value; +} Result; + +static inline Result +aot_call_stack_features_init_default_checked(void *features) +{ + Result res; + // Check for null pointer parameter: features + if (features == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + aot_call_stack_features_init_default(features); + // Assign return value and error code + res.error_code = 0; + return res; +} + +#endif // AOT_COMP_OPTION_CHECKED_H diff --git a/core/iwasm/include/aot_export_checked.h b/core/iwasm/include/aot_export_checked.h new file mode 100644 index 0000000000..03c2dc9d19 --- /dev/null +++ b/core/iwasm/include/aot_export_checked.h @@ -0,0 +1,334 @@ + +/* + * Copyright (C) 2025 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +/* + * THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT! + */ +#ifndef AOT_EXPORT_CHECKED_H +#define AOT_EXPORT_CHECKED_H + +#include +#include +#include + +#include "aot_export.h" + +typedef struct { + int error_code; // Error code (0 for success, non-zero for errors) + union { + _Bool _Bool_value; + aot_comp_context_t aot_comp_context_t_value; + aot_comp_data_t aot_comp_data_t_value; + aot_obj_data_t aot_obj_data_t_value; + uint32_t uint32_t_value; + // Add other types as needed + } value; +} Result; + +static inline Result +aot_call_stack_features_init_default_checked(void *features) +{ + Result res; + // Check for null pointer parameter: features + if (features == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + aot_call_stack_features_init_default(features); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +aot_compile_wasm_checked(aot_comp_context_t comp_ctx) +{ + Result res; + // Execute the original function + _Bool original_result = aot_compile_wasm(comp_ctx); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +aot_compiler_destroy_checked(void) +{ + Result res; + // Execute the original function + aot_compiler_destroy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +aot_compiler_init_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = aot_compiler_init(); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +aot_create_comp_context_checked(aot_comp_data_t comp_data, + aot_comp_option_t option) +{ + Result res; + // Execute the original function + aot_comp_context_t original_result = + aot_create_comp_context(comp_data, option); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.aot_comp_context_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +aot_create_comp_data_checked(void *wasm_module, void *target_arch, + _Bool gc_enabled) +{ + Result res; + // Check for null pointer parameter: wasm_module + if (wasm_module == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: target_arch + if (target_arch == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + aot_comp_data_t original_result = + aot_create_comp_data(wasm_module, target_arch, gc_enabled); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.aot_comp_data_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +aot_destroy_aot_file_checked(void *aot_file) +{ + Result res; + // Check for null pointer parameter: aot_file + if (aot_file == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + aot_destroy_aot_file(aot_file); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +aot_destroy_comp_context_checked(aot_comp_context_t comp_ctx) +{ + Result res; + // Execute the original function + aot_destroy_comp_context(comp_ctx); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +aot_destroy_comp_data_checked(aot_comp_data_t comp_data) +{ + Result res; + // Execute the original function + aot_destroy_comp_data(comp_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +aot_emit_aot_file_checked(aot_comp_context_t comp_ctx, + aot_comp_data_t comp_data, void *file_name) +{ + Result res; + // Check for null pointer parameter: file_name + if (file_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = aot_emit_aot_file(comp_ctx, comp_data, file_name); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +aot_emit_aot_file_buf_checked(aot_comp_context_t comp_ctx, + aot_comp_data_t comp_data, void *p_aot_file_size) +{ + Result res; + // Check for null pointer parameter: p_aot_file_size + if (p_aot_file_size == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + aot_emit_aot_file_buf(comp_ctx, comp_data, p_aot_file_size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +aot_emit_aot_file_buf_ex_checked(aot_comp_context_t comp_ctx, + aot_comp_data_t comp_data, + aot_obj_data_t obj_data, void *aot_file_buf, + uint32_t aot_file_size) +{ + Result res; + // Check for null pointer parameter: aot_file_buf + if (aot_file_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = aot_emit_aot_file_buf_ex( + comp_ctx, comp_data, obj_data, aot_file_buf, aot_file_size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +aot_emit_llvm_file_checked(aot_comp_context_t comp_ctx, void *file_name) +{ + Result res; + // Check for null pointer parameter: file_name + if (file_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = aot_emit_llvm_file(comp_ctx, file_name); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +aot_emit_object_file_checked(aot_comp_context_t comp_ctx, void *file_name) +{ + Result res; + // Check for null pointer parameter: file_name + if (file_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = aot_emit_object_file(comp_ctx, file_name); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +aot_get_aot_file_size_checked(aot_comp_context_t comp_ctx, + aot_comp_data_t comp_data, + aot_obj_data_t obj_data) +{ + Result res; + // Execute the original function + uint32_t original_result = + aot_get_aot_file_size(comp_ctx, comp_data, obj_data); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +aot_get_last_error_checked(void) +{ + Result res; + // Execute the original function + aot_get_last_error(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +aot_get_plt_table_size_checked(void) +{ + Result res; + // Execute the original function + uint32_t original_result = aot_get_plt_table_size(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +aot_obj_data_create_checked(aot_comp_context_t comp_ctx) +{ + Result res; + // Execute the original function + aot_obj_data_t original_result = aot_obj_data_create(comp_ctx); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.aot_obj_data_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +aot_obj_data_destroy_checked(aot_obj_data_t obj_data) +{ + Result res; + // Execute the original function + aot_obj_data_destroy(obj_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +#endif // AOT_EXPORT_CHECKED_H diff --git a/core/iwasm/include/gc_export_checked.h b/core/iwasm/include/gc_export_checked.h new file mode 100644 index 0000000000..47b651bd27 --- /dev/null +++ b/core/iwasm/include/gc_export_checked.h @@ -0,0 +1,4010 @@ + +/* + * Copyright (C) 2025 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +/* + * THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT! + */ +#ifndef GC_EXPORT_CHECKED_H +#define GC_EXPORT_CHECKED_H + +#include +#include +#include + +#include "gc_export.h" + +typedef struct { + int error_code; // Error code (0 for success, non-zero for errors) + union { + RunningMode RunningMode_value; + _Bool _Bool_value; + double double_value; + int32_t int32_t_value; + package_type_t package_type_t_value; + uint32_t uint32_t_value; + uint64_t uint64_t_value; + wasm_anyref_obj_t wasm_anyref_obj_t_value; + wasm_array_obj_t wasm_array_obj_t_value; + wasm_defined_type_t wasm_defined_type_t_value; + wasm_exec_env_t wasm_exec_env_t_value; + wasm_externref_obj_t wasm_externref_obj_t_value; + wasm_func_obj_t wasm_func_obj_t_value; + wasm_func_type_t wasm_func_type_t_value; + wasm_function_inst_t wasm_function_inst_t_value; + wasm_i31_obj_t wasm_i31_obj_t_value; + wasm_memory_inst_t wasm_memory_inst_t_value; + wasm_module_inst_t wasm_module_inst_t_value; + wasm_module_t wasm_module_t_value; + wasm_obj_t wasm_obj_t_value; + wasm_ref_type_t wasm_ref_type_t_value; + wasm_shared_heap_t wasm_shared_heap_t_value; + wasm_struct_obj_t wasm_struct_obj_t_value; + wasm_valkind_t wasm_valkind_t_value; + // Add other types as needed + } value; +} Result; + +static inline Result +get_base_lib_export_apis_checked(void *p_base_lib_apis) +{ + Result res; + // Check for null pointer parameter: p_base_lib_apis + if (p_base_lib_apis == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = get_base_lib_export_apis(p_base_lib_apis); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +get_package_type_checked(void *buf, uint32_t size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + package_type_t original_result = get_package_type(buf, size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.package_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_anyref_obj_get_value_checked(wasm_anyref_obj_t anyref_obj) +{ + Result res; + // Execute the original function + wasm_anyref_obj_get_value(anyref_obj); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_anyref_obj_new_checked(wasm_exec_env_t exec_env, void *host_obj) +{ + Result res; + // Check for null pointer parameter: host_obj + if (host_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_anyref_obj_t original_result = wasm_anyref_obj_new(exec_env, host_obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_anyref_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_application_execute_func_checked(wasm_module_inst_t module_inst, + void *name, int32_t argc, void *argv) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_application_execute_func(module_inst, name, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_application_execute_main_checked(wasm_module_inst_t module_inst, + int32_t argc, void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_application_execute_main(module_inst, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_array_obj_copy_checked(wasm_array_obj_t dst_obj, uint32_t dst_idx, + wasm_array_obj_t src_obj, uint32_t src_idx, + uint32_t len) +{ + Result res; + // Execute the original function + wasm_array_obj_copy(dst_obj, dst_idx, src_obj, src_idx, len); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_array_obj_elem_addr_checked(wasm_array_obj_t array_obj, uint32_t elem_idx) +{ + Result res; + // Execute the original function + wasm_array_obj_elem_addr(array_obj, elem_idx); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_array_obj_first_elem_addr_checked(wasm_array_obj_t array_obj) +{ + Result res; + // Execute the original function + wasm_array_obj_first_elem_addr(array_obj); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_array_obj_get_elem_checked(wasm_array_obj_t array_obj, uint32_t elem_idx, + _Bool sign_extend, void *value) +{ + Result res; + // Check for null pointer parameter: value + if (value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_array_obj_get_elem(array_obj, elem_idx, sign_extend, value); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_array_obj_length_checked(wasm_array_obj_t array_obj) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_array_obj_length(array_obj); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_array_obj_new_with_type_checked(wasm_exec_env_t exec_env, + wasm_array_type_t type, uint32_t length, + void *init_value) +{ + Result res; + // Check for null pointer parameter: init_value + if (init_value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_array_obj_t original_result = + wasm_array_obj_new_with_type(exec_env, type, length, init_value); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_array_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_array_obj_new_with_typeidx_checked(wasm_exec_env_t exec_env, + uint32_t type_idx, uint32_t length, + void *init_value) +{ + Result res; + // Check for null pointer parameter: init_value + if (init_value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_array_obj_t original_result = + wasm_array_obj_new_with_typeidx(exec_env, type_idx, length, init_value); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_array_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_array_obj_set_elem_checked(wasm_array_obj_t array_obj, uint32_t elem_idx, + void *value) +{ + Result res; + // Check for null pointer parameter: value + if (value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_array_obj_set_elem(array_obj, elem_idx, value); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_array_type_get_elem_type_checked(wasm_array_type_t array_type, + void *p_is_mutable) +{ + Result res; + // Check for null pointer parameter: p_is_mutable + if (p_is_mutable == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_type_t original_result = + wasm_array_type_get_elem_type(array_type, p_is_mutable); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_ref_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_copy_callstack_checked(wasm_exec_env_t exec_env, void *buffer, + uint32_t length, uint32_t skip_n, void *error_buf, + uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: buffer + if (buffer == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = wasm_copy_callstack( + exec_env, buffer, length, skip_n, error_buf, error_buf_size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_defined_type_equal_checked(wasm_defined_type_t def_type1, + wasm_defined_type_t def_type2, + wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_defined_type_equal(def_type1, def_type2, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_defined_type_is_array_type_checked(wasm_defined_type_t def_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_defined_type_is_array_type(def_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_defined_type_is_func_type_checked(wasm_defined_type_t def_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_defined_type_is_func_type(def_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_defined_type_is_struct_type_checked(wasm_defined_type_t def_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_defined_type_is_struct_type(def_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_defined_type_is_subtype_of_checked(wasm_defined_type_t def_type1, + wasm_defined_type_t def_type2, + wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_defined_type_is_subtype_of(def_type1, def_type2, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_obj2ref_checked(wasm_module_inst_t module_inst, void *extern_obj, + void *p_externref_idx) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_externref_idx + if (p_externref_idx == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_externref_obj2ref(module_inst, extern_obj, p_externref_idx); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_obj_get_value_checked(wasm_externref_obj_t externref_obj) +{ + Result res; + // Execute the original function + wasm_externref_obj_get_value(externref_obj); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externref_obj_new_checked(wasm_exec_env_t exec_env, void *host_obj) +{ + Result res; + // Check for null pointer parameter: host_obj + if (host_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externref_obj_t original_result = + wasm_externref_obj_new(exec_env, host_obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_externref_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_externref_obj_to_internal_obj_checked(wasm_externref_obj_t externref_obj) +{ + Result res; + // Execute the original function + wasm_obj_t original_result = + wasm_externref_obj_to_internal_obj(externref_obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_externref_objdel_checked(wasm_module_inst_t module_inst, void *extern_obj) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_externref_objdel(module_inst, extern_obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_ref2obj_checked(uint32_t externref_idx, void *p_extern_obj) +{ + Result res; + // Check for null pointer parameter: p_extern_obj + if (p_extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_externref_ref2obj(externref_idx, p_extern_obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_retain_checked(uint32_t externref_idx) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_externref_retain(externref_idx); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_set_cleanup_checked(wasm_module_inst_t module_inst, + void *extern_obj, void *extern_obj_cleanup) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: extern_obj_cleanup + if (extern_obj_cleanup == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_externref_set_cleanup(module_inst, extern_obj, extern_obj_cleanup); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_func_get_param_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_func_get_param_count(func_inst, module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_get_param_types_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst, + void *param_types) +{ + Result res; + // Check for null pointer parameter: param_types + if (param_types == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_get_param_types(func_inst, module_inst, param_types); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_get_result_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_func_get_result_count(func_inst, module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_get_result_types_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst, + void *result_types) +{ + Result res; + // Check for null pointer parameter: result_types + if (result_types == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_get_result_types(func_inst, module_inst, result_types); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_obj_get_func_idx_bound_checked(wasm_func_obj_t func_obj) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_func_obj_get_func_idx_bound(func_obj); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_obj_get_func_type_checked(wasm_func_obj_t func_obj) +{ + Result res; + // Execute the original function + wasm_func_type_t original_result = wasm_func_obj_get_func_type(func_obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_func_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_obj_new_with_type_checked(wasm_exec_env_t exec_env, + wasm_func_type_t type, + uint32_t func_idx_bound) +{ + Result res; + // Execute the original function + wasm_func_obj_t original_result = + wasm_func_obj_new_with_type(exec_env, type, func_idx_bound); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_func_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_obj_new_with_typeidx_checked(wasm_exec_env_t exec_env, + uint32_t type_idx, + uint32_t func_idx_bound) +{ + Result res; + // Execute the original function + wasm_func_obj_t original_result = + wasm_func_obj_new_with_typeidx(exec_env, type_idx, func_idx_bound); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_func_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_param_count_checked(wasm_func_type_t func_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_func_type_get_param_count(func_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_param_type_checked(wasm_func_type_t func_type, + uint32_t param_idx) +{ + Result res; + // Execute the original function + wasm_ref_type_t original_result = + wasm_func_type_get_param_type(func_type, param_idx); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_ref_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_param_valkind_checked(wasm_func_type_t func_type, + uint32_t param_index) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = + wasm_func_type_get_param_valkind(func_type, param_index); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_result_count_checked(wasm_func_type_t func_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_func_type_get_result_count(func_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_result_type_checked(wasm_func_type_t func_type, + uint32_t result_idx) +{ + Result res; + // Execute the original function + wasm_ref_type_t original_result = + wasm_func_type_get_result_type(func_type, result_idx); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_ref_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_result_valkind_checked(wasm_func_type_t func_type, + uint32_t result_index) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = + wasm_func_type_get_result_valkind(func_type, result_index); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_get_defined_type_checked(wasm_module_t module, uint32_t index) +{ + Result res; + // Execute the original function + wasm_defined_type_t original_result = wasm_get_defined_type(module, index); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_defined_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_get_defined_type_count_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_get_defined_type_count(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_global_type_get_mutable_checked(wasm_global_type_t global_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_global_type_get_mutable(global_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_global_type_get_valkind_checked(wasm_global_type_t global_type) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = wasm_global_type_get_valkind(global_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_i31_obj_get_value_checked(wasm_i31_obj_t i31_obj, _Bool sign_extend) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_i31_obj_get_value(i31_obj, sign_extend); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_i31_obj_new_checked(uint32_t i31_value) +{ + Result res; + // Execute the original function + wasm_i31_obj_t original_result = wasm_i31_obj_new(i31_value); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_i31_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_internal_obj_to_externref_obj_checked(wasm_exec_env_t exec_env, + wasm_obj_t internal_obj) +{ + Result res; + // Execute the original function + wasm_externref_obj_t original_result = + wasm_internal_obj_to_externref_obj(exec_env, internal_obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_externref_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_enlarge_checked(wasm_memory_inst_t memory_inst, + uint64_t inc_page_count) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_enlarge(memory_inst, inc_page_count); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_get_base_address_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + wasm_memory_get_base_address(memory_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_get_bytes_per_page_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_bytes_per_page(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_cur_page_count_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_cur_page_count(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_max_page_count_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_max_page_count(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_shared_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_get_shared(memory_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_type_get_init_page_count_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_memory_type_get_init_page_count(memory_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_type_get_max_page_count_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_memory_type_get_max_page_count(memory_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_type_get_shared_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_type_get_shared(memory_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_get_defined_type_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + wasm_defined_type_t original_result = wasm_obj_get_defined_type(obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_defined_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_obj_get_defined_type_idx_checked(wasm_module_t module, wasm_obj_t obj) +{ + Result res; + // Execute the original function + int32_t original_result = wasm_obj_get_defined_type_idx(module, obj); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_obj_is_anyref_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_anyref_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_array_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_array_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_eq_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_eq_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_externref_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_externref_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_func_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_func_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_i31_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_i31_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_instance_of_defined_type_checked(wasm_obj_t obj, + wasm_defined_type_t defined_type, + wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_obj_is_instance_of_defined_type(obj, defined_type, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_instance_of_ref_type_checked(wasm_obj_t obj, void *ref_type) +{ + Result res; + // Check for null pointer parameter: ref_type + if (ref_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_obj_is_instance_of_ref_type(obj, ref_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_instance_of_type_idx_checked(wasm_obj_t obj, uint32_t type_idx, + wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_obj_is_instance_of_type_idx(obj, type_idx, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_internal_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_internal_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_struct_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_struct_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_set_gc_finalizer_checked(wasm_exec_env_t exec_env, wasm_obj_t obj, + wasm_obj_finalizer_t cb, void *data) +{ + Result res; + // Check for null pointer parameter: data + if (data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_obj_set_gc_finalizer(exec_env, obj, cb, data); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_unset_gc_finalizer_checked(wasm_exec_env_t exec_env, void *obj) +{ + Result res; + // Check for null pointer parameter: obj + if (obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_obj_unset_gc_finalizer(exec_env, obj); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_type_equal_checked(void *ref_type1, void *ref_type2, + wasm_module_t module) +{ + Result res; + // Check for null pointer parameter: ref_type1 + if (ref_type1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: ref_type2 + if (ref_type2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_ref_type_equal(ref_type1, ref_type2, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_ref_type_is_subtype_of_checked(void *ref_type1, void *ref_type2, + wasm_module_t module) +{ + Result res; + // Check for null pointer parameter: ref_type1 + if (ref_type1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: ref_type2 + if (ref_type2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_ref_type_is_subtype_of(ref_type1, ref_type2, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_ref_type_set_heap_type_checked(void *ref_type, _Bool nullable, + int32_t heap_type) +{ + Result res; + // Check for null pointer parameter: ref_type + if (ref_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_type_set_heap_type(ref_type, nullable, heap_type); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_type_set_type_idx_checked(void *ref_type, _Bool nullable, + int32_t type_idx) +{ + Result res; + // Check for null pointer parameter: ref_type + if (ref_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_type_set_type_idx(ref_type, nullable, type_idx); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_addr_app_to_native_checked(wasm_module_inst_t module_inst, + uint64_t app_offset) +{ + Result res; + // Execute the original function + wasm_runtime_addr_app_to_native(module_inst, app_offset); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_addr_native_to_app_checked(wasm_module_inst_t module_inst, + void *native_ptr) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint64_t original_result = + wasm_runtime_addr_native_to_app(module_inst, native_ptr); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_attach_shared_heap_checked(wasm_module_inst_t module_inst, + wasm_shared_heap_t shared_heap) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_attach_shared_heap(module_inst, shared_heap); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_begin_blocking_op_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_begin_blocking_op(exec_env); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_func_ref_checked(wasm_exec_env_t exec_env, + wasm_func_obj_t func_obj, uint32_t argc, + void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_call_func_ref(exec_env, func_obj, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_func_ref_a_checked(wasm_exec_env_t exec_env, + wasm_func_obj_t func_obj, + uint32_t num_results, void *results, + uint32_t num_args, void *args) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_call_func_ref_a( + exec_env, func_obj, num_results, results, num_args, args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_func_ref_v_checked(wasm_exec_env_t exec_env, + wasm_func_obj_t func_obj, + uint32_t num_results, void *results, + uint32_t num_args, ...) +{ + Result res; + va_list args; + // Execute the original function + va_start(args, num_args); + _Bool original_result = wasm_runtime_call_func_ref_v( + exec_env, func_obj, num_results, results, num_args, args); + va_end(args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_indirect_checked(wasm_exec_env_t exec_env, + uint32_t element_index, uint32_t argc, + void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_call_indirect(exec_env, element_index, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, uint32_t argc, + void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_call_wasm(exec_env, function, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_a_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, + uint32_t num_results, void *results, + uint32_t num_args, void *args) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_call_wasm_a( + exec_env, function, num_results, results, num_args, args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_v_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, + uint32_t num_results, void *results, + uint32_t num_args, ...) +{ + Result res; + va_list args; + // Execute the original function + va_start(args, num_args); + _Bool original_result = wasm_runtime_call_wasm_v( + exec_env, function, num_results, results, num_args, args); + va_end(args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_chain_shared_heaps_checked(wasm_shared_heap_t head, + wasm_shared_heap_t body) +{ + Result res; + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_chain_shared_heaps(head, body); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_clear_exception_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_clear_exception(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_create_context_key_checked(void *dtor) +{ + Result res; + // Check for null pointer parameter: dtor + if (dtor == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_create_context_key(dtor); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_create_exec_env_checked(wasm_module_inst_t module_inst, + uint32_t stack_size) +{ + Result res; + // Execute the original function + wasm_exec_env_t original_result = + wasm_runtime_create_exec_env(module_inst, stack_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_exec_env_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_create_shared_heap_checked(void *init_args) +{ + Result res; + // Check for null pointer parameter: init_args + if (init_args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_create_shared_heap(init_args); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_deinstantiate_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_deinstantiate(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_checked(void) +{ + Result res; + // Execute the original function + wasm_runtime_destroy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_context_key_checked(void *key) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_destroy_context_key(key); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_exec_env_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_exec_env(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_spawned_exec_env_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_spawned_exec_env(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_thread_env_checked(void) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_thread_env(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_detach_shared_heap_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_detach_shared_heap(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_detect_native_stack_overflow_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_detect_native_stack_overflow(exec_env); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_detect_native_stack_overflow_size_checked(wasm_exec_env_t exec_env, + uint32_t required_size) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_detect_native_stack_overflow_size(exec_env, required_size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_dump_call_stack_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_dump_call_stack(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_call_stack_to_buf_checked(wasm_exec_env_t exec_env, void *buf, + uint32_t len) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = + wasm_runtime_dump_call_stack_to_buf(exec_env, buf, len); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_dump_mem_consumption_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_dump_mem_consumption(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_perf_profiling_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_dump_perf_profiling(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_pgo_prof_data_to_buf_checked(wasm_module_inst_t module_inst, + void *buf, uint32_t len) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = + wasm_runtime_dump_pgo_prof_data_to_buf(module_inst, buf, len); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_end_blocking_op_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_end_blocking_op(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_enlarge_memory_checked(wasm_module_inst_t module_inst, + uint64_t inc_page_count) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_enlarge_memory(module_inst, inc_page_count); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_find_module_registered_checked(void *module_name) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = + wasm_runtime_find_module_registered(module_name); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_free_checked(void *ptr) +{ + Result res; + // Check for null pointer parameter: ptr + if (ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_free(ptr); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_full_init_checked(void *init_args) +{ + Result res; + // Check for null pointer parameter: init_args + if (init_args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_full_init(init_args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_app_addr_range_checked(wasm_module_inst_t module_inst, + uint64_t app_offset, + void *p_app_start_offset, + void *p_app_end_offset) +{ + Result res; + // Check for null pointer parameter: p_app_start_offset + if (p_app_start_offset == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_app_end_offset + if (p_app_end_offset == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_app_addr_range( + module_inst, app_offset, p_app_start_offset, p_app_end_offset); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_call_stack_buf_size_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_call_stack_buf_size(exec_env); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_context_checked(wasm_module_inst_t inst, void *key) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_context(inst, key); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_cur_local_obj_ref_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_get_cur_local_obj_ref(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_current_package_version_checked(package_type_t package_type) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_runtime_get_current_package_version(package_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_custom_data_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_get_custom_data(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_custom_section_checked(wasm_module_t module_comm, void *name, + void *len) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: len + if (len == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_custom_section(module_comm, name, len); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_default_memory_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_memory_inst_t original_result = + wasm_runtime_get_default_memory(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_memory_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_exception_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_get_exception(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_exec_env_singleton_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_exec_env_t original_result = + wasm_runtime_get_exec_env_singleton(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_exec_env_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_export_count_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + int32_t original_result = wasm_runtime_get_export_count(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_export_global_inst_checked(wasm_module_inst_t module_inst, + void *name, void *global_inst) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: global_inst + if (global_inst == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_get_export_global_inst(module_inst, name, global_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_export_table_inst_checked(wasm_module_inst_t module_inst, + void *name, void *table_inst) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: table_inst + if (table_inst == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_get_export_table_inst(module_inst, name, table_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_export_type_checked(wasm_module_t module, int32_t export_index, + void *export_type) +{ + Result res; + // Check for null pointer parameter: export_type + if (export_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_export_type(module, export_index, export_type); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_file_package_type_checked(void *buf, uint32_t size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + package_type_t original_result = + wasm_runtime_get_file_package_type(buf, size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.package_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_file_package_version_checked(void *buf, uint32_t size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = wasm_runtime_get_file_package_version(buf, size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_function_attachment_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_get_function_attachment(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_import_count_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + int32_t original_result = wasm_runtime_get_import_count(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_import_type_checked(wasm_module_t module, int32_t import_index, + void *import_type) +{ + Result res; + // Check for null pointer parameter: import_type + if (import_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_import_type(module, import_index, import_type); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_mem_alloc_info_checked(void *mem_alloc_info) +{ + Result res; + // Check for null pointer parameter: mem_alloc_info + if (mem_alloc_info == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_mem_alloc_info(mem_alloc_info); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_memory_checked(wasm_module_inst_t module_inst, uint32_t index) +{ + Result res; + // Execute the original function + wasm_memory_inst_t original_result = + wasm_runtime_get_memory(module_inst, index); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_memory_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_module_t original_result = wasm_runtime_get_module(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_hash_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_get_module_hash(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_module_inst_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_module_inst_t original_result = wasm_runtime_get_module_inst(exec_env); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_name_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_get_module_name(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_module_package_type_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + package_type_t original_result = + wasm_runtime_get_module_package_type(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.package_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_package_version_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_module_package_version(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_native_addr_range_checked(wasm_module_inst_t module_inst, + void *native_ptr, + void *p_native_start_addr, + void *p_native_end_addr) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_native_start_addr + if (p_native_start_addr == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_native_end_addr + if (p_native_end_addr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_native_addr_range( + module_inst, native_ptr, p_native_start_addr, p_native_end_addr); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_pgo_prof_data_size_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_pgo_prof_data_size(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_running_mode_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + RunningMode original_result = wasm_runtime_get_running_mode(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.RunningMode_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_user_data_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_get_user_data(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_version_checked(void *major, void *minor, void *patch) +{ + Result res; + // Check for null pointer parameter: major + if (major == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: minor + if (minor == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: patch + if (patch == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_version(major, minor, patch); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_wasi_exit_code_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_wasi_exit_code(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_wasm_func_exec_time_checked(wasm_module_inst_t inst, + void *func_name) +{ + Result res; + // Check for null pointer parameter: func_name + if (func_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + double original_result = + wasm_runtime_get_wasm_func_exec_time(inst, func_name); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.double_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_init_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_init(); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_init_thread_env_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_init_thread_env(); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_instantiate_checked(wasm_module_t module, + uint32_t default_stack_size, + uint32_t host_managed_heap_size, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_inst_t original_result = wasm_runtime_instantiate( + module, default_stack_size, host_managed_heap_size, error_buf, + error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_instantiate_ex_checked(wasm_module_t module, void *args, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_inst_t original_result = + wasm_runtime_instantiate_ex(module, args, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_instantiate_ex2_checked(wasm_module_t module, void *args, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_inst_t original_result = + wasm_runtime_instantiate_ex2(module, args, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_instantiation_args_create_checked(void *p) +{ + Result res; + // Check for null pointer parameter: p + if (p == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_instantiation_args_create(p); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_instantiation_args_destroy_checked(void *p) +{ + Result res; + // Check for null pointer parameter: p + if (p == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_instantiation_args_destroy(p); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_instantiation_args_set_default_stack_size_checked(void *p, + uint32_t v) +{ + Result res; + // Check for null pointer parameter: p + if (p == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_instantiation_args_set_default_stack_size(p, v); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_instantiation_args_set_host_managed_heap_size_checked(void *p, + uint32_t v) +{ + Result res; + // Check for null pointer parameter: p + if (p == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_instantiation_args_set_host_managed_heap_size(p, v); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_instantiation_args_set_max_memory_pages_checked(void *p, + uint32_t v) +{ + Result res; + // Check for null pointer parameter: p + if (p == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_instantiation_args_set_max_memory_pages(p, v); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_is_bounds_checks_enabled_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_is_bounds_checks_enabled(module_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_import_func_linked_checked(void *module_name, void *func_name) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: func_name + if (func_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_is_import_func_linked(module_name, func_name); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_import_global_linked_checked(void *module_name, + void *global_name) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: global_name + if (global_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_is_import_global_linked(module_name, global_name); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_running_mode_supported_checked(RunningMode running_mode) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_is_running_mode_supported(running_mode); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_underlying_binary_freeable_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_is_underlying_binary_freeable(module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_wasi_mode_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_is_wasi_mode(module_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_xip_file_checked(void *buf, uint32_t size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_is_xip_file(buf, size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_join_thread_checked(wasm_thread_t tid, void *retval) +{ + Result res; + // Check for null pointer parameter: retval + if (retval == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int32_t original_result = wasm_runtime_join_thread(tid, retval); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_load_checked(void *buf, uint32_t size, void *error_buf, + uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = + wasm_runtime_load(buf, size, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_load_ex_checked(void *buf, uint32_t size, void *args, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = + wasm_runtime_load_ex(buf, size, args, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_load_from_sections_checked(wasm_section_list_t section_list, + _Bool is_aot, void *error_buf, + uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = wasm_runtime_load_from_sections( + section_list, is_aot, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_lookup_function_checked(wasm_module_inst_t module_inst, void *name) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_function_inst_t original_result = + wasm_runtime_lookup_function(module_inst, name); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_function_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_lookup_memory_checked(wasm_module_inst_t module_inst, void *name) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_inst_t original_result = + wasm_runtime_lookup_memory(module_inst, name); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_memory_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_lookup_wasi_start_function_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_function_inst_t original_result = + wasm_runtime_lookup_wasi_start_function(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_function_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_malloc_checked(unsigned int size) +{ + Result res; + // Execute the original function + wasm_runtime_malloc(size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_module_dup_data_checked(wasm_module_inst_t module_inst, void *src, + uint64_t size) +{ + Result res; + // Check for null pointer parameter: src + if (src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint64_t original_result = + wasm_runtime_module_dup_data(module_inst, src, size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_module_free_checked(wasm_module_inst_t module_inst, uint64_t ptr) +{ + Result res; + // Execute the original function + wasm_runtime_module_free(module_inst, ptr); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_module_malloc_checked(wasm_module_inst_t module_inst, + uint64_t size, void *p_native_addr) +{ + Result res; + // Check for null pointer parameter: p_native_addr + if (p_native_addr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint64_t original_result = + wasm_runtime_module_malloc(module_inst, size, p_native_addr); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_pin_object_checked(wasm_exec_env_t exec_env, wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_pin_object(exec_env, obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_pop_local_obj_ref_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_pop_local_obj_ref(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_pop_local_obj_refs_checked(wasm_exec_env_t exec_env, uint32_t n) +{ + Result res; + // Execute the original function + wasm_runtime_pop_local_obj_refs(exec_env, n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_push_local_obj_ref_checked(wasm_exec_env_t exec_env, + void *local_obj_ref) +{ + Result res; + // Check for null pointer parameter: local_obj_ref + if (local_obj_ref == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_push_local_obj_ref(exec_env, local_obj_ref); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_realloc_checked(void *ptr, unsigned int size) +{ + Result res; + // Check for null pointer parameter: ptr + if (ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_realloc(ptr, size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_register_module_checked(void *module_name, wasm_module_t module, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_register_module( + module_name, module, error_buf, error_buf_size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_register_natives_checked(void *module_name, void *native_symbols, + uint32_t n_native_symbols) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: native_symbols + if (native_symbols == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_register_natives( + module_name, native_symbols, n_native_symbols); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_register_natives_raw_checked(void *module_name, + void *native_symbols, + uint32_t n_native_symbols) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: native_symbols + if (native_symbols == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_register_natives_raw( + module_name, native_symbols, n_native_symbols); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_resolve_symbols_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_resolve_symbols(module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_set_bounds_checks_checked(wasm_module_inst_t module_inst, + _Bool enable) +{ + Result res; + // Execute the original function + wasm_runtime_set_bounds_checks(module_inst, enable); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_context_checked(wasm_module_inst_t inst, void *key, void *ctx) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: ctx + if (ctx == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_context(inst, key, ctx); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_context_spread_checked(wasm_module_inst_t inst, void *key, + void *ctx) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: ctx + if (ctx == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_context_spread(inst, key, ctx); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_custom_data_checked(wasm_module_inst_t module_inst, + void *custom_data) +{ + Result res; + // Check for null pointer parameter: custom_data + if (custom_data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_custom_data(module_inst, custom_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_default_running_mode_checked(RunningMode running_mode) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_set_default_running_mode(running_mode); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_set_enlarge_mem_error_callback_checked( + enlarge_memory_error_callback_t callback, void *user_data) +{ + Result res; + // Check for null pointer parameter: user_data + if (user_data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_enlarge_mem_error_callback(callback, user_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_exception_checked(wasm_module_inst_t module_inst, + void *exception) +{ + Result res; + // Check for null pointer parameter: exception + if (exception == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_exception(module_inst, exception); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_instruction_count_limit_checked(wasm_exec_env_t exec_env, + int instruction_count) +{ + Result res; + // Execute the original function + wasm_runtime_set_instruction_count_limit(exec_env, instruction_count); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_log_level_checked(log_level_t level) +{ + Result res; + // Execute the original function + wasm_runtime_set_log_level(level); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_max_thread_num_checked(uint32_t num) +{ + Result res; + // Execute the original function + wasm_runtime_set_max_thread_num(num); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_module_inst_checked(wasm_exec_env_t exec_env, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_set_module_inst(exec_env, module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_module_name_checked(wasm_module_t module, void *name, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_set_module_name(module, name, error_buf, error_buf_size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_set_module_reader_checked(module_reader reader, + module_destroyer destroyer) +{ + Result res; + // Execute the original function + wasm_runtime_set_module_reader(reader, destroyer); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_native_stack_boundary_checked(wasm_exec_env_t exec_env, + void *native_stack_boundary) +{ + Result res; + // Check for null pointer parameter: native_stack_boundary + if (native_stack_boundary == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_native_stack_boundary(exec_env, native_stack_boundary); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_running_mode_checked(wasm_module_inst_t module_inst, + RunningMode running_mode) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_set_running_mode(module_inst, running_mode); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_set_user_data_checked(wasm_exec_env_t exec_env, void *user_data) +{ + Result res; + // Check for null pointer parameter: user_data + if (user_data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_user_data(exec_env, user_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_addr_pool_checked(wasm_module_t module, void *addr_pool, + uint32_t addr_pool_size) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_addr_pool(module, addr_pool, addr_pool_size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_args_checked(wasm_module_t module, void *dir_list, + uint32_t dir_count, void *map_dir_list, + uint32_t map_dir_count, void *env, + uint32_t env_count, void *argv, int argc) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_args(module, dir_list, dir_count, map_dir_list, + map_dir_count, env, env_count, argv, argc); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_args_ex_checked(wasm_module_t module, void *dir_list, + uint32_t dir_count, void *map_dir_list, + uint32_t map_dir_count, void *env, + uint32_t env_count, void *argv, int argc, + int64_t stdinfd, int64_t stdoutfd, + int64_t stderrfd) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_args_ex(module, dir_list, dir_count, map_dir_list, + map_dir_count, env, env_count, argv, argc, + stdinfd, stdoutfd, stderrfd); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_ns_lookup_pool_checked(wasm_module_t module, + void *ns_lookup_pool, + uint32_t ns_lookup_pool_size) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_ns_lookup_pool(module, ns_lookup_pool, + ns_lookup_pool_size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_shared_heap_free_checked(wasm_module_inst_t module_inst, + uint64_t ptr) +{ + Result res; + // Execute the original function + wasm_runtime_shared_heap_free(module_inst, ptr); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_shared_heap_malloc_checked(wasm_module_inst_t module_inst, + uint64_t size, void *p_native_addr) +{ + Result res; + // Check for null pointer parameter: p_native_addr + if (p_native_addr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint64_t original_result = + wasm_runtime_shared_heap_malloc(module_inst, size, p_native_addr); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_spawn_exec_env_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_exec_env_t original_result = wasm_runtime_spawn_exec_env(exec_env); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_exec_env_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_spawn_thread_checked(wasm_exec_env_t exec_env, void *tid, + wasm_thread_callback_t callback, void *arg) +{ + Result res; + // Check for null pointer parameter: tid + if (tid == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: arg + if (arg == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int32_t original_result = + wasm_runtime_spawn_thread(exec_env, tid, callback, arg); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_start_debug_instance_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_start_debug_instance(exec_env); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_start_debug_instance_with_port_checked(wasm_exec_env_t exec_env, + int32_t port) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_runtime_start_debug_instance_with_port(exec_env, port); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_sum_wasm_exec_time_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + double original_result = wasm_runtime_sum_wasm_exec_time(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.double_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_terminate_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_terminate(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_thread_env_inited_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_thread_env_inited(); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_unchain_shared_heaps_checked(wasm_shared_heap_t head, + _Bool entire_chain) +{ + Result res; + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_unchain_shared_heaps(head, entire_chain); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_unload_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_unload(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_unpin_object_checked(wasm_exec_env_t exec_env, wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_unpin_object(exec_env, obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_unregister_natives_checked(void *module_name, void *native_symbols) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: native_symbols + if (native_symbols == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_unregister_natives(module_name, native_symbols); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_app_addr_checked(wasm_module_inst_t module_inst, + uint64_t app_offset, uint64_t size) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_validate_app_addr(module_inst, app_offset, size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_app_str_addr_checked(wasm_module_inst_t module_inst, + uint64_t app_str_offset) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_validate_app_str_addr(module_inst, app_str_offset); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_native_addr_checked(wasm_module_inst_t module_inst, + void *native_ptr, uint64_t size) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_validate_native_addr(module_inst, native_ptr, size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_struct_obj_get_field_checked(wasm_struct_obj_t obj, uint32_t field_idx, + _Bool sign_extend, void *value) +{ + Result res; + // Check for null pointer parameter: value + if (value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_struct_obj_get_field(obj, field_idx, sign_extend, value); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_struct_obj_get_field_count_checked(wasm_struct_obj_t obj) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_struct_obj_get_field_count(obj); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_struct_obj_new_with_type_checked(wasm_exec_env_t exec_env, + wasm_struct_type_t type) +{ + Result res; + // Execute the original function + wasm_struct_obj_t original_result = + wasm_struct_obj_new_with_type(exec_env, type); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_struct_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_struct_obj_new_with_typeidx_checked(wasm_exec_env_t exec_env, + uint32_t type_idx) +{ + Result res; + // Execute the original function + wasm_struct_obj_t original_result = + wasm_struct_obj_new_with_typeidx(exec_env, type_idx); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_struct_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_struct_obj_set_field_checked(wasm_struct_obj_t obj, uint32_t field_idx, + void *value) +{ + Result res; + // Check for null pointer parameter: value + if (value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_struct_obj_set_field(obj, field_idx, value); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_struct_type_get_field_count_checked(wasm_struct_type_t struct_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_struct_type_get_field_count(struct_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_struct_type_get_field_type_checked(wasm_struct_type_t struct_type, + uint32_t field_idx, void *p_is_mutable) +{ + Result res; + // Check for null pointer parameter: p_is_mutable + if (p_is_mutable == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_type_t original_result = + wasm_struct_type_get_field_type(struct_type, field_idx, p_is_mutable); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_ref_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_get_func_inst_checked(wasm_module_inst_t module_inst, + void *table_inst, uint32_t idx) +{ + Result res; + // Check for null pointer parameter: table_inst + if (table_inst == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_function_inst_t original_result = + wasm_table_get_func_inst(module_inst, table_inst, idx); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_function_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_elem_kind_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = wasm_table_type_get_elem_kind(table_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_init_size_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_table_type_get_init_size(table_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_max_size_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_table_type_get_max_size(table_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_shared_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_table_type_get_shared(table_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +#endif // GC_EXPORT_CHECKED_H diff --git a/core/iwasm/include/lib_export_checked.h b/core/iwasm/include/lib_export_checked.h new file mode 100644 index 0000000000..e3f9362019 --- /dev/null +++ b/core/iwasm/include/lib_export_checked.h @@ -0,0 +1,49 @@ + +/* + * Copyright (C) 2025 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +/* + * THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT! + */ +#ifndef LIB_EXPORT_CHECKED_H +#define LIB_EXPORT_CHECKED_H + +#include +#include +#include + +#include "lib_export.h" + +typedef struct { + int error_code; // Error code (0 for success, non-zero for errors) + union { + uint32_t uint32_t_value; + // Add other types as needed + } value; +} Result; + +static inline Result +get_base_lib_export_apis_checked(void *p_base_lib_apis) +{ + Result res; + // Check for null pointer parameter: p_base_lib_apis + if (p_base_lib_apis == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = get_base_lib_export_apis(p_base_lib_apis); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +#endif // LIB_EXPORT_CHECKED_H diff --git a/core/iwasm/include/wasm_c_api_checked.h b/core/iwasm/include/wasm_c_api_checked.h new file mode 100644 index 0000000000..83e73a3199 --- /dev/null +++ b/core/iwasm/include/wasm_c_api_checked.h @@ -0,0 +1,6205 @@ + +/* + * Copyright (C) 2025 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +/* + * THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT! + */ +#ifndef WASM_C_API_CHECKED_H +#define WASM_C_API_CHECKED_H + +#include +#include +#include + +#include "wasm_c_api.h" + +typedef struct { + int error_code; // Error code (0 for success, non-zero for errors) + union { + _Bool _Bool_value; + double double_value; + int int_value; + size_t size_t_value; + uint32_t uint32_t_value; + wasm_externkind_t wasm_externkind_t_value; + wasm_memory_pages_t wasm_memory_pages_t_value; + wasm_mutability_t wasm_mutability_t_value; + wasm_table_size_t wasm_table_size_t_value; + wasm_valkind_t wasm_valkind_t_value; + // Add other types as needed + } value; +} Result; + +static inline Result +__assert_checked(void *__assertion, void *__file, int __line) +{ + Result res; + // Check for null pointer parameter: __assertion + if (__assertion == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __file + if (__file == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + __assert(__assertion, __file, __line); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +__assert_fail_checked(void *__assertion, void *__file, unsigned int __line, + void *__function) +{ + Result res; + // Check for null pointer parameter: __assertion + if (__assertion == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __file + if (__file == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __function + if (__function == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + __assert_fail(__assertion, __file, __line, __function); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +__assert_perror_fail_checked(int __errnum, void *__file, unsigned int __line, + void *__function) +{ + Result res; + // Check for null pointer parameter: __file + if (__file == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __function + if (__function == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + __assert_perror_fail(__errnum, __file, __line, __function); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +__memcmpeq_checked(void *__s1, void *__s2, size_t __n) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = __memcmpeq(__s1, __s2, __n); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +__stpncpy_checked(void *__dest, void *__src, size_t __n) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + __stpncpy(__dest, __src, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +__strtok_r_checked(void *__s, void *__delim, void *__save_ptr) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __delim + if (__delim == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __save_ptr + if (__save_ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + __strtok_r(__s, __delim, __save_ptr); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +bcmp_checked(void *__s1, void *__s2, size_t __n) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = bcmp(__s1, __s2, __n); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +bcopy_checked(void *__src, void *__dest, size_t __n) +{ + Result res; + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + bcopy(__src, __dest, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +bzero_checked(void *__s, size_t __n) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + bzero(__s, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +explicit_bzero_checked(void *__s, size_t __n) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + explicit_bzero(__s, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +ffs_checked(int __i) +{ + Result res; + // Execute the original function + int original_result = ffs(__i); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +ffsl_checked(long int __l) +{ + Result res; + // Execute the original function + int original_result = ffsl(__l); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +ffsll_checked(long long int __ll) +{ + Result res; + // Execute the original function + int original_result = ffsll(__ll); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +index_checked(void *__s, int __c) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + index(__s, __c); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +memccpy_checked(void *__dest, void *__src, int __c, size_t __n) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + memccpy(__dest, __src, __c, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +memchr_checked(void *__s, int __c, size_t __n) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + memchr(__s, __c, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +memcmp_checked(void *__s1, void *__s2, size_t __n) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = memcmp(__s1, __s2, __n); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +memcpy_checked(void *__dest, void *__src, size_t __n) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + memcpy(__dest, __src, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +rindex_checked(void *__s, int __c) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + rindex(__s, __c); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +stpcpy_checked(void *__dest, void *__src) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + stpcpy(__dest, __src); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +stpncpy_checked(void *__dest, void *__src, size_t __n) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + stpncpy(__dest, __src, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strcasecmp_checked(void *__s1, void *__s2) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strcasecmp(__s1, __s2); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strcasecmp_l_checked(void *__s1, void *__s2, locale_t __loc) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strcasecmp_l(__s1, __s2, __loc); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strchr_checked(void *__s, int __c) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strchr(__s, __c); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strcoll_checked(void *__s1, void *__s2) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strcoll(__s1, __s2); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strcoll_l_checked(void *__s1, void *__s2, locale_t __l) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strcoll_l(__s1, __s2, __l); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strcpy_checked(void *__dest, void *__src) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strcpy(__dest, __src); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strcspn_checked(void *__s, void *__reject) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __reject + if (__reject == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = strcspn(__s, __reject); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strdup_checked(void *__s) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strdup(__s); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strerror_checked(int __errnum) +{ + Result res; + // Execute the original function + strerror(__errnum); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strerror_l_checked(int __errnum, locale_t __l) +{ + Result res; + // Execute the original function + strerror_l(__errnum, __l); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strerror_r_checked(int __errnum, void *__buf, size_t __buflen) +{ + Result res; + // Check for null pointer parameter: __buf + if (__buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strerror_r(__errnum, __buf, __buflen); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strncasecmp_checked(void *__s1, void *__s2, size_t __n) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strncasecmp(__s1, __s2, __n); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strncasecmp_l_checked(void *__s1, void *__s2, size_t __n, locale_t __loc) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strncasecmp_l(__s1, __s2, __n, __loc); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strncat_checked(void *__dest, void *__src, size_t __n) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strncat(__dest, __src, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strncmp_checked(void *__s1, void *__s2, size_t __n) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strncmp(__s1, __s2, __n); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strncpy_checked(void *__dest, void *__src, size_t __n) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strncpy(__dest, __src, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strndup_checked(void *__string, size_t __n) +{ + Result res; + // Check for null pointer parameter: __string + if (__string == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strndup(__string, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strnlen_checked(void *__string, size_t __maxlen) +{ + Result res; + // Check for null pointer parameter: __string + if (__string == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = strnlen(__string, __maxlen); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strpbrk_checked(void *__s, void *__accept) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __accept + if (__accept == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strpbrk(__s, __accept); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strrchr_checked(void *__s, int __c) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strrchr(__s, __c); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strsep_checked(void *__stringp, void *__delim) +{ + Result res; + // Check for null pointer parameter: __stringp + if (__stringp == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __delim + if (__delim == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strsep(__stringp, __delim); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strsignal_checked(int __sig) +{ + Result res; + // Execute the original function + strsignal(__sig); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strspn_checked(void *__s, void *__accept) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __accept + if (__accept == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = strspn(__s, __accept); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strstr_checked(void *__haystack, void *__needle) +{ + Result res; + // Check for null pointer parameter: __haystack + if (__haystack == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __needle + if (__needle == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strstr(__haystack, __needle); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strtok_checked(void *__s, void *__delim) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __delim + if (__delim == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strtok(__s, __delim); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strtok_r_checked(void *__s, void *__delim, void *__save_ptr) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __delim + if (__delim == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __save_ptr + if (__save_ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strtok_r(__s, __delim, __save_ptr); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strxfrm_checked(void *__dest, void *__src, size_t __n) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = strxfrm(__dest, __src, __n); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strxfrm_l_checked(void *__dest, void *__src, size_t __n, locale_t __l) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = strxfrm_l(__dest, __src, __n, __l); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_byte_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_byte_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_byte_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_byte_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_byte_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_byte_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_byte_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_byte_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_byte_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_byte_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_config_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_config_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_config_new_checked(void) +{ + Result res; + // Execute the original function + wasm_config_new(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_config_set_linux_perf_opt_checked(void *, _Bool) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_config_set_linux_perf_opt(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_config_set_mem_alloc_opt_checked(void *, mem_alloc_type_t, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_config_set_mem_alloc_opt(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_config_set_segue_flags_checked(void *config, uint32_t segue_flags) +{ + Result res; + // Check for null pointer parameter: config + if (config == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_config_set_segue_flags(config, segue_flags); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_engine_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_engine_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_engine_new_checked(void) +{ + Result res; + // Execute the original function + wasm_engine_new(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_engine_new_with_args_checked(mem_alloc_type_t type, void *opts) +{ + Result res; + // Check for null pointer parameter: opts + if (opts == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_engine_new_with_args(type, opts); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_engine_new_with_config_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_engine_new_with_config(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_exporttype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_exporttype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_exporttype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_exporttype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_exporttype_name_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_exporttype_name(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_exporttype_new_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_exporttype_new(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_exporttype_type_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_exporttype_type(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_exporttype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_exporttype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_exporttype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_exporttype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_exporttype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_exporttype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_exporttype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_exporttype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_exporttype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_exporttype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_func_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_func(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_func_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_func_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_global_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_global(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_global_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_global_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_memory_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_memory(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_memory_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_memory_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_table_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_table(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_table_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_table_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_kind_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externkind_t original_result = wasm_extern_kind(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_externkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_extern_new_empty_checked(void *, wasm_externkind_t) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_new_empty(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_extern_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_extern_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_type_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_type(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_functype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_functype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_functype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_functype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_globaltype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_globaltype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_globaltype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_globaltype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_memorytype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_memorytype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_memorytype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_memorytype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_tabletype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_tabletype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_tabletype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_tabletype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_kind_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externkind_t original_result = wasm_externtype_kind(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_externkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_externtype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_new_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_new(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_foreign_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_foreign_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_frame_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_frame_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_frame_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_frame_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_frame_func_index_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = wasm_frame_func_index(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_frame_func_offset_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = wasm_frame_func_offset(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_frame_instance_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_frame_instance(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_frame_module_offset_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = wasm_frame_module_offset(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_frame_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_frame_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_frame_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_frame_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_frame_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_frame_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_frame_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_frame_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_frame_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_frame_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_as_extern_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_as_extern(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_as_extern_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_as_extern_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_call_checked(void *, void *args, void *results) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: results + if (results == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_call(, args, results); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_new_checked(void *, void *, wasm_func_callback_t) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_new(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_new_with_env_checked(void *, void *type, + wasm_func_callback_with_env_t, void *env, + void *finalizer) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: type + if (type == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: env + if (env == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: finalizer + if (finalizer == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_new_with_env(, type, , env, finalizer); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_param_arity_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = wasm_func_param_arity(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_result_arity_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = wasm_func_result_arity(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_func_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_func_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_type_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_type(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_as_externtype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_as_externtype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_as_externtype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_as_externtype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_new_checked(void *params, void *results) +{ + Result res; + // Check for null pointer parameter: params + if (params == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: results + if (results == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_new(params, results); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_params_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_params(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_results_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_results(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_as_extern_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_as_extern(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_as_extern_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_as_extern_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_get_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_get(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_new_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_new(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_global_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_global_set_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_set(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_type_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_type(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_globaltype_as_externtype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_globaltype_as_externtype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_globaltype_as_externtype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_globaltype_as_externtype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_globaltype_content_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_globaltype_content(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_globaltype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_globaltype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_globaltype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_globaltype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_globaltype_mutability_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_mutability_t original_result = wasm_globaltype_mutability(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_mutability_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_globaltype_new_checked(void *, wasm_mutability_t) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_globaltype_new(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_globaltype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_globaltype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_globaltype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_globaltype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_globaltype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_globaltype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_globaltype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_globaltype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_globaltype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_globaltype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_is_linked_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_importtype_is_linked(); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_importtype_module_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_module(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_name_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_name(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_new_checked(void *module, void *name, void *) +{ + Result res; + // Check for null pointer parameter: module + if (module == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_new(module, name, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_type_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_type(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_exports_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_exports(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_get_wasm_func_exec_time_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + double original_result = wasm_instance_get_wasm_func_exec_time(, ); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.double_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_instance_new_checked(void *, void *, void *imports, void *trap) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: imports + if (imports == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: trap + if (trap == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_new(, , imports, trap); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_new_with_args_checked(void *, void *, void *imports, void *trap, + uint32_t stack_size, uint32_t heap_size) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: imports + if (imports == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: trap + if (trap == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_new_with_args(, , imports, trap, stack_size, heap_size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_new_with_args_ex_checked(void *, void *, void *imports, + void *trap, void *inst_args) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: imports + if (imports == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: trap + if (trap == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: inst_args + if (inst_args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_new_with_args_ex(, , imports, trap, inst_args); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_instance_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_instance_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_sum_wasm_exec_time_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + double original_result = wasm_instance_sum_wasm_exec_time(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.double_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_as_extern_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_as_extern(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_as_extern_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_as_extern_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_data_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_data(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_data_size_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = wasm_memory_data_size(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_grow_checked(void *, wasm_memory_pages_t delta) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_memory_grow(, delta); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_new_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_new(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_memory_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_size_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_pages_t original_result = wasm_memory_size(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_memory_pages_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_type_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_type(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_as_externtype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_as_externtype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_as_externtype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_as_externtype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_limits_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_limits(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_new_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_new(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_deserialize_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_deserialize(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_exports_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_exports(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_get_name_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_get_name(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_imports_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_imports(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_is_underlying_binary_freeable_checked(void *module) +{ + Result res; + // Check for null pointer parameter: module + if (module == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_module_is_underlying_binary_freeable(module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_module_new_checked(void *, void *binary) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: binary + if (binary == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_new(, binary); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_new_ex_checked(void *, void *binary, void *args) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: binary + if (binary == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_new_ex(, binary, args); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_obtain_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_obtain(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_serialize_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_serialize(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_set_name_checked(void *, void *name) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_module_set_name(, name); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_module_share_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_share(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_validate_checked(void *, void *binary) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: binary + if (binary == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_module_validate(, binary); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_ref_as_extern_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_extern(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_extern_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_extern_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_foreign_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_foreign(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_foreign_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_foreign_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_func_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_func(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_func_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_func_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_global_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_global(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_global_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_global_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_instance_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_instance(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_instance_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_instance_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_memory_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_memory(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_memory_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_memory_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_table_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_table(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_table_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_table_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_trap_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_trap(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_trap_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_trap_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_ref_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_ref_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_shared_module_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_shared_module_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_store_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_store_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_store_new_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_store_new(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_as_extern_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_as_extern(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_as_extern_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_as_extern_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_get_checked(void *, wasm_table_size_t index) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_get(, index); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_grow_checked(void *, wasm_table_size_t delta, void *init) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: init + if (init == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_table_grow(, delta, init); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_table_new_checked(void *, void *, void *init) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: init + if (init == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_new(, , init); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_table_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_table_set_checked(void *, wasm_table_size_t index, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_table_set(, index, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_table_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_size_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_size_t original_result = wasm_table_size(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_table_size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_type(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_as_externtype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_as_externtype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_as_externtype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_as_externtype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_element_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_element(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_limits_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_limits(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_new_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_new(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_message_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_message(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_new_checked(void *store, void *) +{ + Result res; + // Check for null pointer parameter: store + if (store == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_new(store, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_origin_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_origin(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_trap_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_trap_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_trace_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_trace(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_delete_checked(void *v) +{ + Result res; + // Check for null pointer parameter: v + if (v == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_delete(v); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_kind_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valkind_t original_result = wasm_valtype_kind(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_valtype_new_checked(wasm_valkind_t) +{ + Result res; + // Execute the original function + wasm_valtype_new(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +#endif // WASM_C_API_CHECKED_H diff --git a/core/iwasm/include/wasm_export_checked.h b/core/iwasm/include/wasm_export_checked.h new file mode 100644 index 0000000000..c7610079ea --- /dev/null +++ b/core/iwasm/include/wasm_export_checked.h @@ -0,0 +1,2940 @@ + +/* + * Copyright (C) 2025 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +/* + * THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT! + */ +#ifndef WASM_EXPORT_CHECKED_H +#define WASM_EXPORT_CHECKED_H + +#include +#include +#include + +#include "wasm_export.h" + +typedef struct { + int error_code; // Error code (0 for success, non-zero for errors) + union { + RunningMode RunningMode_value; + _Bool _Bool_value; + double double_value; + int32_t int32_t_value; + package_type_t package_type_t_value; + uint32_t uint32_t_value; + uint64_t uint64_t_value; + wasm_exec_env_t wasm_exec_env_t_value; + wasm_function_inst_t wasm_function_inst_t_value; + wasm_memory_inst_t wasm_memory_inst_t_value; + wasm_module_inst_t wasm_module_inst_t_value; + wasm_module_t wasm_module_t_value; + wasm_shared_heap_t wasm_shared_heap_t_value; + wasm_valkind_t wasm_valkind_t_value; + // Add other types as needed + } value; +} Result; + +static inline Result +get_base_lib_export_apis_checked(void *p_base_lib_apis) +{ + Result res; + // Check for null pointer parameter: p_base_lib_apis + if (p_base_lib_apis == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = get_base_lib_export_apis(p_base_lib_apis); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +get_package_type_checked(void *buf, uint32_t size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + package_type_t original_result = get_package_type(buf, size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.package_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_application_execute_func_checked(wasm_module_inst_t module_inst, + void *name, int32_t argc, void *argv) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_application_execute_func(module_inst, name, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_application_execute_main_checked(wasm_module_inst_t module_inst, + int32_t argc, void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_application_execute_main(module_inst, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_copy_callstack_checked(wasm_exec_env_t exec_env, void *buffer, + uint32_t length, uint32_t skip_n, void *error_buf, + uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: buffer + if (buffer == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = wasm_copy_callstack( + exec_env, buffer, length, skip_n, error_buf, error_buf_size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_externref_obj2ref_checked(wasm_module_inst_t module_inst, void *extern_obj, + void *p_externref_idx) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_externref_idx + if (p_externref_idx == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_externref_obj2ref(module_inst, extern_obj, p_externref_idx); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_objdel_checked(wasm_module_inst_t module_inst, void *extern_obj) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_externref_objdel(module_inst, extern_obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_ref2obj_checked(uint32_t externref_idx, void *p_extern_obj) +{ + Result res; + // Check for null pointer parameter: p_extern_obj + if (p_extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_externref_ref2obj(externref_idx, p_extern_obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_retain_checked(uint32_t externref_idx) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_externref_retain(externref_idx); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_set_cleanup_checked(wasm_module_inst_t module_inst, + void *extern_obj, void *extern_obj_cleanup) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: extern_obj_cleanup + if (extern_obj_cleanup == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_externref_set_cleanup(module_inst, extern_obj, extern_obj_cleanup); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_func_get_param_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_func_get_param_count(func_inst, module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_get_param_types_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst, + void *param_types) +{ + Result res; + // Check for null pointer parameter: param_types + if (param_types == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_get_param_types(func_inst, module_inst, param_types); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_get_result_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_func_get_result_count(func_inst, module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_get_result_types_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst, + void *result_types) +{ + Result res; + // Check for null pointer parameter: result_types + if (result_types == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_get_result_types(func_inst, module_inst, result_types); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_type_get_param_count_checked(wasm_func_type_t func_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_func_type_get_param_count(func_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_param_valkind_checked(wasm_func_type_t func_type, + uint32_t param_index) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = + wasm_func_type_get_param_valkind(func_type, param_index); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_result_count_checked(wasm_func_type_t func_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_func_type_get_result_count(func_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_result_valkind_checked(wasm_func_type_t func_type, + uint32_t result_index) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = + wasm_func_type_get_result_valkind(func_type, result_index); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_global_type_get_mutable_checked(wasm_global_type_t global_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_global_type_get_mutable(global_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_global_type_get_valkind_checked(wasm_global_type_t global_type) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = wasm_global_type_get_valkind(global_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_enlarge_checked(wasm_memory_inst_t memory_inst, + uint64_t inc_page_count) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_enlarge(memory_inst, inc_page_count); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_get_base_address_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + wasm_memory_get_base_address(memory_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_get_bytes_per_page_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_bytes_per_page(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_cur_page_count_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_cur_page_count(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_max_page_count_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_max_page_count(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_shared_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_get_shared(memory_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_type_get_init_page_count_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_memory_type_get_init_page_count(memory_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_type_get_max_page_count_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_memory_type_get_max_page_count(memory_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_type_get_shared_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_type_get_shared(memory_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_addr_app_to_native_checked(wasm_module_inst_t module_inst, + uint64_t app_offset) +{ + Result res; + // Execute the original function + wasm_runtime_addr_app_to_native(module_inst, app_offset); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_addr_native_to_app_checked(wasm_module_inst_t module_inst, + void *native_ptr) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint64_t original_result = + wasm_runtime_addr_native_to_app(module_inst, native_ptr); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_attach_shared_heap_checked(wasm_module_inst_t module_inst, + wasm_shared_heap_t shared_heap) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_attach_shared_heap(module_inst, shared_heap); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_begin_blocking_op_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_begin_blocking_op(exec_env); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_indirect_checked(wasm_exec_env_t exec_env, + uint32_t element_index, uint32_t argc, + void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_call_indirect(exec_env, element_index, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, uint32_t argc, + void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_call_wasm(exec_env, function, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_a_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, + uint32_t num_results, void *results, + uint32_t num_args, void *args) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_call_wasm_a( + exec_env, function, num_results, results, num_args, args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_v_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, + uint32_t num_results, void *results, + uint32_t num_args, ...) +{ + Result res; + va_list args; + // Execute the original function + va_start(args, num_args); + _Bool original_result = wasm_runtime_call_wasm_v( + exec_env, function, num_results, results, num_args, args); + va_end(args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_chain_shared_heaps_checked(wasm_shared_heap_t head, + wasm_shared_heap_t body) +{ + Result res; + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_chain_shared_heaps(head, body); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_clear_exception_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_clear_exception(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_create_context_key_checked(void *dtor) +{ + Result res; + // Check for null pointer parameter: dtor + if (dtor == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_create_context_key(dtor); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_create_exec_env_checked(wasm_module_inst_t module_inst, + uint32_t stack_size) +{ + Result res; + // Execute the original function + wasm_exec_env_t original_result = + wasm_runtime_create_exec_env(module_inst, stack_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_exec_env_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_create_shared_heap_checked(void *init_args) +{ + Result res; + // Check for null pointer parameter: init_args + if (init_args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_create_shared_heap(init_args); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_deinstantiate_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_deinstantiate(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_checked(void) +{ + Result res; + // Execute the original function + wasm_runtime_destroy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_context_key_checked(void *key) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_destroy_context_key(key); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_exec_env_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_exec_env(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_spawned_exec_env_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_spawned_exec_env(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_thread_env_checked(void) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_thread_env(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_detach_shared_heap_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_detach_shared_heap(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_detect_native_stack_overflow_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_detect_native_stack_overflow(exec_env); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_detect_native_stack_overflow_size_checked(wasm_exec_env_t exec_env, + uint32_t required_size) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_detect_native_stack_overflow_size(exec_env, required_size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_dump_call_stack_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_dump_call_stack(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_call_stack_to_buf_checked(wasm_exec_env_t exec_env, void *buf, + uint32_t len) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = + wasm_runtime_dump_call_stack_to_buf(exec_env, buf, len); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_dump_mem_consumption_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_dump_mem_consumption(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_perf_profiling_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_dump_perf_profiling(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_pgo_prof_data_to_buf_checked(wasm_module_inst_t module_inst, + void *buf, uint32_t len) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = + wasm_runtime_dump_pgo_prof_data_to_buf(module_inst, buf, len); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_end_blocking_op_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_end_blocking_op(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_enlarge_memory_checked(wasm_module_inst_t module_inst, + uint64_t inc_page_count) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_enlarge_memory(module_inst, inc_page_count); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_find_module_registered_checked(void *module_name) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = + wasm_runtime_find_module_registered(module_name); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_free_checked(void *ptr) +{ + Result res; + // Check for null pointer parameter: ptr + if (ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_free(ptr); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_full_init_checked(void *init_args) +{ + Result res; + // Check for null pointer parameter: init_args + if (init_args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_full_init(init_args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_app_addr_range_checked(wasm_module_inst_t module_inst, + uint64_t app_offset, + void *p_app_start_offset, + void *p_app_end_offset) +{ + Result res; + // Check for null pointer parameter: p_app_start_offset + if (p_app_start_offset == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_app_end_offset + if (p_app_end_offset == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_app_addr_range( + module_inst, app_offset, p_app_start_offset, p_app_end_offset); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_call_stack_buf_size_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_call_stack_buf_size(exec_env); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_context_checked(wasm_module_inst_t inst, void *key) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_context(inst, key); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_current_package_version_checked(package_type_t package_type) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_runtime_get_current_package_version(package_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_custom_data_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_get_custom_data(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_custom_section_checked(wasm_module_t module_comm, void *name, + void *len) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: len + if (len == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_custom_section(module_comm, name, len); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_default_memory_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_memory_inst_t original_result = + wasm_runtime_get_default_memory(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_memory_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_exception_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_get_exception(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_exec_env_singleton_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_exec_env_t original_result = + wasm_runtime_get_exec_env_singleton(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_exec_env_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_export_count_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + int32_t original_result = wasm_runtime_get_export_count(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_export_global_inst_checked(wasm_module_inst_t module_inst, + void *name, void *global_inst) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: global_inst + if (global_inst == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_get_export_global_inst(module_inst, name, global_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_export_table_inst_checked(wasm_module_inst_t module_inst, + void *name, void *table_inst) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: table_inst + if (table_inst == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_get_export_table_inst(module_inst, name, table_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_export_type_checked(wasm_module_t module, int32_t export_index, + void *export_type) +{ + Result res; + // Check for null pointer parameter: export_type + if (export_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_export_type(module, export_index, export_type); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_file_package_type_checked(void *buf, uint32_t size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + package_type_t original_result = + wasm_runtime_get_file_package_type(buf, size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.package_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_file_package_version_checked(void *buf, uint32_t size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = wasm_runtime_get_file_package_version(buf, size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_function_attachment_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_get_function_attachment(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_import_count_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + int32_t original_result = wasm_runtime_get_import_count(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_import_type_checked(wasm_module_t module, int32_t import_index, + void *import_type) +{ + Result res; + // Check for null pointer parameter: import_type + if (import_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_import_type(module, import_index, import_type); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_mem_alloc_info_checked(void *mem_alloc_info) +{ + Result res; + // Check for null pointer parameter: mem_alloc_info + if (mem_alloc_info == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_mem_alloc_info(mem_alloc_info); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_memory_checked(wasm_module_inst_t module_inst, uint32_t index) +{ + Result res; + // Execute the original function + wasm_memory_inst_t original_result = + wasm_runtime_get_memory(module_inst, index); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_memory_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_module_t original_result = wasm_runtime_get_module(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_hash_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_get_module_hash(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_module_inst_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_module_inst_t original_result = wasm_runtime_get_module_inst(exec_env); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_name_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_get_module_name(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_module_package_type_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + package_type_t original_result = + wasm_runtime_get_module_package_type(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.package_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_package_version_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_module_package_version(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_native_addr_range_checked(wasm_module_inst_t module_inst, + void *native_ptr, + void *p_native_start_addr, + void *p_native_end_addr) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_native_start_addr + if (p_native_start_addr == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_native_end_addr + if (p_native_end_addr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_native_addr_range( + module_inst, native_ptr, p_native_start_addr, p_native_end_addr); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_pgo_prof_data_size_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_pgo_prof_data_size(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_running_mode_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + RunningMode original_result = wasm_runtime_get_running_mode(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.RunningMode_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_user_data_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_get_user_data(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_version_checked(void *major, void *minor, void *patch) +{ + Result res; + // Check for null pointer parameter: major + if (major == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: minor + if (minor == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: patch + if (patch == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_version(major, minor, patch); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_wasi_exit_code_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_wasi_exit_code(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_wasm_func_exec_time_checked(wasm_module_inst_t inst, + void *func_name) +{ + Result res; + // Check for null pointer parameter: func_name + if (func_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + double original_result = + wasm_runtime_get_wasm_func_exec_time(inst, func_name); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.double_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_init_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_init(); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_init_thread_env_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_init_thread_env(); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_instantiate_checked(wasm_module_t module, + uint32_t default_stack_size, + uint32_t host_managed_heap_size, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_inst_t original_result = wasm_runtime_instantiate( + module, default_stack_size, host_managed_heap_size, error_buf, + error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_instantiate_ex_checked(wasm_module_t module, void *args, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_inst_t original_result = + wasm_runtime_instantiate_ex(module, args, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_instantiate_ex2_checked(wasm_module_t module, void *args, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_inst_t original_result = + wasm_runtime_instantiate_ex2(module, args, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_instantiation_args_create_checked(void *p) +{ + Result res; + // Check for null pointer parameter: p + if (p == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_instantiation_args_create(p); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_instantiation_args_destroy_checked(void *p) +{ + Result res; + // Check for null pointer parameter: p + if (p == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_instantiation_args_destroy(p); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_instantiation_args_set_default_stack_size_checked(void *p, + uint32_t v) +{ + Result res; + // Check for null pointer parameter: p + if (p == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_instantiation_args_set_default_stack_size(p, v); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_instantiation_args_set_host_managed_heap_size_checked(void *p, + uint32_t v) +{ + Result res; + // Check for null pointer parameter: p + if (p == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_instantiation_args_set_host_managed_heap_size(p, v); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_instantiation_args_set_max_memory_pages_checked(void *p, + uint32_t v) +{ + Result res; + // Check for null pointer parameter: p + if (p == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_instantiation_args_set_max_memory_pages(p, v); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_is_bounds_checks_enabled_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_is_bounds_checks_enabled(module_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_import_func_linked_checked(void *module_name, void *func_name) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: func_name + if (func_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_is_import_func_linked(module_name, func_name); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_import_global_linked_checked(void *module_name, + void *global_name) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: global_name + if (global_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_is_import_global_linked(module_name, global_name); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_running_mode_supported_checked(RunningMode running_mode) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_is_running_mode_supported(running_mode); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_underlying_binary_freeable_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_is_underlying_binary_freeable(module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_wasi_mode_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_is_wasi_mode(module_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_is_xip_file_checked(void *buf, uint32_t size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_is_xip_file(buf, size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_join_thread_checked(wasm_thread_t tid, void *retval) +{ + Result res; + // Check for null pointer parameter: retval + if (retval == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int32_t original_result = wasm_runtime_join_thread(tid, retval); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_load_checked(void *buf, uint32_t size, void *error_buf, + uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = + wasm_runtime_load(buf, size, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_load_ex_checked(void *buf, uint32_t size, void *args, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = + wasm_runtime_load_ex(buf, size, args, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_load_from_sections_checked(wasm_section_list_t section_list, + _Bool is_aot, void *error_buf, + uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = wasm_runtime_load_from_sections( + section_list, is_aot, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_lookup_function_checked(wasm_module_inst_t module_inst, void *name) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_function_inst_t original_result = + wasm_runtime_lookup_function(module_inst, name); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_function_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_lookup_memory_checked(wasm_module_inst_t module_inst, void *name) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_inst_t original_result = + wasm_runtime_lookup_memory(module_inst, name); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_memory_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_lookup_wasi_start_function_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_function_inst_t original_result = + wasm_runtime_lookup_wasi_start_function(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_function_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_malloc_checked(unsigned int size) +{ + Result res; + // Execute the original function + wasm_runtime_malloc(size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_module_dup_data_checked(wasm_module_inst_t module_inst, void *src, + uint64_t size) +{ + Result res; + // Check for null pointer parameter: src + if (src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint64_t original_result = + wasm_runtime_module_dup_data(module_inst, src, size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_module_free_checked(wasm_module_inst_t module_inst, uint64_t ptr) +{ + Result res; + // Execute the original function + wasm_runtime_module_free(module_inst, ptr); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_module_malloc_checked(wasm_module_inst_t module_inst, + uint64_t size, void *p_native_addr) +{ + Result res; + // Check for null pointer parameter: p_native_addr + if (p_native_addr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint64_t original_result = + wasm_runtime_module_malloc(module_inst, size, p_native_addr); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_realloc_checked(void *ptr, unsigned int size) +{ + Result res; + // Check for null pointer parameter: ptr + if (ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_realloc(ptr, size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_register_module_checked(void *module_name, wasm_module_t module, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_register_module( + module_name, module, error_buf, error_buf_size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_register_natives_checked(void *module_name, void *native_symbols, + uint32_t n_native_symbols) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: native_symbols + if (native_symbols == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_register_natives( + module_name, native_symbols, n_native_symbols); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_register_natives_raw_checked(void *module_name, + void *native_symbols, + uint32_t n_native_symbols) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: native_symbols + if (native_symbols == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_register_natives_raw( + module_name, native_symbols, n_native_symbols); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_resolve_symbols_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_resolve_symbols(module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_set_bounds_checks_checked(wasm_module_inst_t module_inst, + _Bool enable) +{ + Result res; + // Execute the original function + wasm_runtime_set_bounds_checks(module_inst, enable); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_context_checked(wasm_module_inst_t inst, void *key, void *ctx) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: ctx + if (ctx == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_context(inst, key, ctx); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_context_spread_checked(wasm_module_inst_t inst, void *key, + void *ctx) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: ctx + if (ctx == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_context_spread(inst, key, ctx); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_custom_data_checked(wasm_module_inst_t module_inst, + void *custom_data) +{ + Result res; + // Check for null pointer parameter: custom_data + if (custom_data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_custom_data(module_inst, custom_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_default_running_mode_checked(RunningMode running_mode) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_set_default_running_mode(running_mode); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_set_enlarge_mem_error_callback_checked( + enlarge_memory_error_callback_t callback, void *user_data) +{ + Result res; + // Check for null pointer parameter: user_data + if (user_data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_enlarge_mem_error_callback(callback, user_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_exception_checked(wasm_module_inst_t module_inst, + void *exception) +{ + Result res; + // Check for null pointer parameter: exception + if (exception == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_exception(module_inst, exception); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_instruction_count_limit_checked(wasm_exec_env_t exec_env, + int instruction_count) +{ + Result res; + // Execute the original function + wasm_runtime_set_instruction_count_limit(exec_env, instruction_count); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_log_level_checked(log_level_t level) +{ + Result res; + // Execute the original function + wasm_runtime_set_log_level(level); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_max_thread_num_checked(uint32_t num) +{ + Result res; + // Execute the original function + wasm_runtime_set_max_thread_num(num); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_module_inst_checked(wasm_exec_env_t exec_env, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_set_module_inst(exec_env, module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_module_name_checked(wasm_module_t module, void *name, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_set_module_name(module, name, error_buf, error_buf_size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_set_module_reader_checked(module_reader reader, + module_destroyer destroyer) +{ + Result res; + // Execute the original function + wasm_runtime_set_module_reader(reader, destroyer); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_native_stack_boundary_checked(wasm_exec_env_t exec_env, + void *native_stack_boundary) +{ + Result res; + // Check for null pointer parameter: native_stack_boundary + if (native_stack_boundary == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_native_stack_boundary(exec_env, native_stack_boundary); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_running_mode_checked(wasm_module_inst_t module_inst, + RunningMode running_mode) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_set_running_mode(module_inst, running_mode); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_set_user_data_checked(wasm_exec_env_t exec_env, void *user_data) +{ + Result res; + // Check for null pointer parameter: user_data + if (user_data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_user_data(exec_env, user_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_addr_pool_checked(wasm_module_t module, void *addr_pool, + uint32_t addr_pool_size) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_addr_pool(module, addr_pool, addr_pool_size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_args_checked(wasm_module_t module, void *dir_list, + uint32_t dir_count, void *map_dir_list, + uint32_t map_dir_count, void *env, + uint32_t env_count, void *argv, int argc) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_args(module, dir_list, dir_count, map_dir_list, + map_dir_count, env, env_count, argv, argc); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_args_ex_checked(wasm_module_t module, void *dir_list, + uint32_t dir_count, void *map_dir_list, + uint32_t map_dir_count, void *env, + uint32_t env_count, void *argv, int argc, + int64_t stdinfd, int64_t stdoutfd, + int64_t stderrfd) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_args_ex(module, dir_list, dir_count, map_dir_list, + map_dir_count, env, env_count, argv, argc, + stdinfd, stdoutfd, stderrfd); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_ns_lookup_pool_checked(wasm_module_t module, + void *ns_lookup_pool, + uint32_t ns_lookup_pool_size) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_ns_lookup_pool(module, ns_lookup_pool, + ns_lookup_pool_size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_shared_heap_free_checked(wasm_module_inst_t module_inst, + uint64_t ptr) +{ + Result res; + // Execute the original function + wasm_runtime_shared_heap_free(module_inst, ptr); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_shared_heap_malloc_checked(wasm_module_inst_t module_inst, + uint64_t size, void *p_native_addr) +{ + Result res; + // Check for null pointer parameter: p_native_addr + if (p_native_addr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint64_t original_result = + wasm_runtime_shared_heap_malloc(module_inst, size, p_native_addr); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_spawn_exec_env_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_exec_env_t original_result = wasm_runtime_spawn_exec_env(exec_env); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_exec_env_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_spawn_thread_checked(wasm_exec_env_t exec_env, void *tid, + wasm_thread_callback_t callback, void *arg) +{ + Result res; + // Check for null pointer parameter: tid + if (tid == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: arg + if (arg == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int32_t original_result = + wasm_runtime_spawn_thread(exec_env, tid, callback, arg); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_start_debug_instance_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_start_debug_instance(exec_env); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_start_debug_instance_with_port_checked(wasm_exec_env_t exec_env, + int32_t port) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_runtime_start_debug_instance_with_port(exec_env, port); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_sum_wasm_exec_time_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + double original_result = wasm_runtime_sum_wasm_exec_time(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.double_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_terminate_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_terminate(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_thread_env_inited_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_thread_env_inited(); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_unchain_shared_heaps_checked(wasm_shared_heap_t head, + _Bool entire_chain) +{ + Result res; + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_unchain_shared_heaps(head, entire_chain); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_unload_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_unload(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_unregister_natives_checked(void *module_name, void *native_symbols) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: native_symbols + if (native_symbols == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_unregister_natives(module_name, native_symbols); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_app_addr_checked(wasm_module_inst_t module_inst, + uint64_t app_offset, uint64_t size) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_validate_app_addr(module_inst, app_offset, size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_app_str_addr_checked(wasm_module_inst_t module_inst, + uint64_t app_str_offset) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_validate_app_str_addr(module_inst, app_str_offset); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_native_addr_checked(wasm_module_inst_t module_inst, + void *native_ptr, uint64_t size) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_validate_native_addr(module_inst, native_ptr, size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_table_get_func_inst_checked(wasm_module_inst_t module_inst, + void *table_inst, uint32_t idx) +{ + Result res; + // Check for null pointer parameter: table_inst + if (table_inst == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_function_inst_t original_result = + wasm_table_get_func_inst(module_inst, table_inst, idx); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_function_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_elem_kind_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = wasm_table_type_get_elem_kind(table_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_init_size_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_table_type_get_init_size(table_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_max_size_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_table_type_get_max_size(table_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_shared_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_table_type_get_shared(table_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +#endif // WASM_EXPORT_CHECKED_H diff --git a/samples/checked-api/CMakeLists.txt b/samples/checked-api/CMakeLists.txt new file mode 100644 index 0000000000..d1ea8c6e41 --- /dev/null +++ b/samples/checked-api/CMakeLists.txt @@ -0,0 +1,61 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required (VERSION 3.14) + +project(checked_api_sample) + +# assertion required +set(CMAKE_BUILD_TYPE Debug) + +set(CMAKE_C_STANDARD 23) + +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake) +find_package(WASISDK REQUIRED) + +################ runtime settings ################ +string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) +include(CheckPIESupported) + +# aot and interp by default +set(WAMR_BUILD_AOT 1) +set(WAMR_BUILD_INTERP 1) +set(WAMR_BUILD_JIT 0) +# wasm32-wasi +set(WAMR_BUILD_LIBC_BUILTIN 0) +set(WAMR_BUILD_LIBC_WASI 1) +# mvp +set(WAMR_BUILD_BULK_MEMORY 1) +set(WAMR_BUILD_REF_TYPES 1) +set(WAMR_BUILD_SIMD 1) +set(WAMR_BUILD_TAIL_CALL 1) +# trap information +set(WAMR_BUILD_DUMP_CALL_STACK 1) + +# vmlib +set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..) +include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) +add_library(vmlib SHARED ${WAMR_RUNTIME_LIB_SOURCE}) +target_include_directories(vmlib INTERFACE ${WAMR_ROOT_DIR}/core/iwasm/include) +target_link_libraries (vmlib ${LLVM_AVAILABLE_LIBS} -lm -ldl) + +################ host ################ +include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) +add_executable(${PROJECT_NAME} src/demo.c ${UNCOMMON_SHARED_SOURCE}) +target_link_libraries(${PROJECT_NAME} vmlib) + +################ aot + wasm ################ +include(ExternalProject) +ExternalProject_Add(wasm + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps" + CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps -B build + -DCMAKE_TOOLCHAIN_FILE=${WASISDK_TOOLCHAIN} + BUILD_COMMAND ${CMAKE_COMMAND} --build build + INSTALL_COMMAND ${CMAKE_COMMAND} --install build --prefix ${CMAKE_CURRENT_BINARY_DIR} +) + +enable_testing() +add_test(NAME checked_api_sample_test + COMMAND ${PROJECT_NAME} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) diff --git a/samples/checked-api/src/demo.c b/samples/checked-api/src/demo.c new file mode 100644 index 0000000000..5546bd2f38 --- /dev/null +++ b/samples/checked-api/src/demo.c @@ -0,0 +1,110 @@ +#include +#include + +#include "bh_platform.h" +#include "bh_read_file.h" +#include "wasm_export_checked.h" + +#define VERIFY_API_RESULT(callee, result, fail_label) \ + do { \ + if (result.error_code != 0) { \ + printf("%s failed with error code: %d\n", #callee, \ + result.error_code); \ + goto fail_label; \ + } \ + } while (0) + +int +main(int argc, char *argv_main[]) +{ + Result api_result; + wasm_module_t module = NULL; + uint32 buf_size, stack_size = 8092, heap_size = 8092; + wasm_module_inst_t module_inst = NULL; + wasm_function_inst_t func = NULL; + wasm_exec_env_t exec_env = NULL; + int ret = EXIT_FAILURE; + + RuntimeInitArgs init_args; + // 512Kb + static char global_heap_buf[512 * 1024]; + char *wasm_path = "fib.wasm"; + char *buffer; + char error_buf[128]; + + memset(&init_args, 0, sizeof(RuntimeInitArgs)); + init_args.mem_alloc_type = Alloc_With_Pool; + init_args.mem_alloc_option.pool.heap_buf = global_heap_buf; + init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf); + + api_result = wasm_runtime_full_init_checked(&init_args); + VERIFY_API_RESULT(wasm_runtime_full_init_checked, api_result, fail); + + api_result = wasm_runtime_set_log_level_checked(WASM_LOG_LEVEL_VERBOSE); + VERIFY_API_RESULT(wasm_runtime_set_log_level_checked, api_result, + release_runtime); + + buffer = bh_read_file_to_buffer(wasm_path, &buf_size); + if (buffer == NULL) { + printf("Open wasm app file [%s] failed.\n", wasm_path); + goto release_runtime; + } + + api_result = wasm_runtime_load_checked((uint8 *)buffer, buf_size, error_buf, + sizeof(error_buf)); + VERIFY_API_RESULT(wasm_runtime_load_checked, api_result, release_file); + module = api_result.value.wasm_module_t_value; + + api_result = wasm_runtime_instantiate_checked(module, stack_size, heap_size, + error_buf, sizeof(error_buf)); + VERIFY_API_RESULT(wasm_runtime_instantiate_checked, api_result, + release_module); + module_inst = api_result.value.wasm_module_inst_t_value; + + api_result = wasm_runtime_create_exec_env_checked(module_inst, stack_size); + VERIFY_API_RESULT(wasm_runtime_create_exec_env_checked, api_result, + release_instance); + exec_env = api_result.value.wasm_exec_env_t_value; + + api_result = wasm_runtime_lookup_function_checked(module_inst, "fib"); + VERIFY_API_RESULT(wasm_runtime_lookup_function_checked, api_result, + release_exec_env); + func = api_result.value.wasm_function_inst_t_value; + + wasm_val_t result[1] = { { .kind = WASM_I32 } }; + wasm_val_t arguments[1] = { + { .kind = WASM_I32, .of.i32 = 6 }, + }; + + api_result = wasm_runtime_call_wasm_a_checked(exec_env, func, 1, result, 1, + arguments); + VERIFY_API_RESULT(wasm_runtime_call_wasm_a_checked, api_result, + release_runtime); + printf("Native finished calling wasm function: fib(%d), returned: %d\n", + arguments[0].of.i32, result[0].of.i32); + bh_assert(result[0].of.i32 == 8); + + arguments[0].of.i32 = 2; + api_result = wasm_runtime_call_wasm_a_checked(exec_env, func, 1, result, 1, + arguments); + VERIFY_API_RESULT(wasm_runtime_call_wasm_a_checked, api_result, + release_runtime); + printf("Native finished calling wasm function: fib(%d), returned: %d\n", + arguments[0].of.i32, result[0].of.i32); + bh_assert(result[0].of.i32 == 1); + + ret = EXIT_SUCCESS; + +release_exec_env: + wasm_runtime_destroy_exec_env_checked(exec_env); +release_instance: + wasm_runtime_deinstantiate_checked(module_inst); +release_module: + wasm_runtime_unload_checked(module); +release_file: + wasm_runtime_free(buffer); +release_runtime: + wasm_runtime_destroy_checked(); +fail: + return ret; +} diff --git a/samples/checked-api/wasm-apps/CMakeLists.txt b/samples/checked-api/wasm-apps/CMakeLists.txt new file mode 100644 index 0000000000..2ad7bb6af0 --- /dev/null +++ b/samples/checked-api/wasm-apps/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required (VERSION 3.14) + +project(checked_api_wasm_apps) + +include(CMakePrintHelpers) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +################ wasm ################ +add_executable(fib fib.c) +set_target_properties(fib PROPERTIES SUFFIX .wasm) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/fib.wasm DESTINATION .) diff --git a/samples/checked-api/wasm-apps/fib.c b/samples/checked-api/wasm-apps/fib.c new file mode 100644 index 0000000000..6603dfc590 --- /dev/null +++ b/samples/checked-api/wasm-apps/fib.c @@ -0,0 +1,31 @@ +#include +#include + +int +fibonacci(int n) +{ + if (n <= 0) + return 0; + + if (n == 1) + return 1; + + return fibonacci(n - 1) + fibonacci(n - 2); +} + +__attribute__((export_name("fib"))) int +fib(int n) +{ + int result = fibonacci(n); + return result; +} + +int +main(int argc, char **argv) +{ + int n = atoi(argv[1]); + + printf("fibonacci(%d)=%d\n", n, fibonacci(n)); + + return 0; +}