From 356b575148950f0664db34467fb94747e7ea05a5 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Sat, 11 Oct 2025 07:48:05 +0000 Subject: [PATCH 01/27] feat: add generate_checked_functions script to dynamically create checked function wrappers --- ci/generate_checked_functions.py | 179 +++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 ci/generate_checked_functions.py diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py new file mode 100644 index 0000000000..65b8a9739d --- /dev/null +++ b/ci/generate_checked_functions.py @@ -0,0 +1,179 @@ +from pycparser import c_parser, c_ast, parse_file +import os + +# Define the Result struct as a string +RESULT_STRUCT = """ +typedef struct { + int error_code; // Error code (0 for success, non-zero for errors) + union { + bool bool_value; + void *ptr_value; + int int_value; + // Add other types as needed + } value; +} Result; +""" + +# Input and output file paths +INPUT_HEADER = "core/iwasm/include/wasm_export.h" +OUTPUT_HEADER = "core/iwasm/include/wasm_export_checked.h" + + +# Helper function to determine if a parameter is a pointer +def is_pointer(param): + return isinstance(param.type, c_ast.PtrDecl) + + +# Updated generate_checked_function to dynamically update Result definition for new return types + + +def generate_checked_function(func): + global RESULT_STRUCT # Access the global Result definition + + 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_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) + + # Check if the return type is already in Result, if not, add it + if return_type not in ["bool", "void*", "int", "uint32_t"]: + # Add a new field to the Result struct dynamically + RESULT_STRUCT = RESULT_STRUCT.replace( + "// Add other types as needed", + f" {return_type} {return_type}_value;\n // Add other types as needed", + ) + + # Start building the new function + new_func = [f"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 + for param in params: + if isinstance(param, c_ast.EllipsisParam): + continue # Skip variadic arguments + if is_pointer(param): + new_func.append(f" if ({param.name} == NULL) {{") + new_func.append(f" Result res = {{ .error_code = -1 }};") + new_func.append(f" return res;") + new_func.append(f" }}") + + # Call the original function + if return_type == "void": + new_func.append(f" {func_name}({', '.join(param_list)});") + new_func.append(f" Result res = {{ .error_code = 0 }};") + else: + new_func.append( + f" {return_type} original_result = {func_name}({', '.join(param_list)});" + ) + new_func.append(f" Result res;") + new_func.append(f" if (original_result == 0) {{") + new_func.append(f" res.error_code = 0;") + if return_type == "bool": + new_func.append(f" res.value.bool_value = original_result;") + elif return_type == "void*": + new_func.append(f" res.value.ptr_value = original_result;") + elif return_type == "uint32_t": + new_func.append(f" res.value.int_value = original_result;") + else: + 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("}") + + return "\n".join(new_func) + + +# Updated process_header to scan all return types and create a proper Result type + +def process_header(): + global RESULT_STRUCT # Access the global Result definition + + # Parse the header file with preprocessing + ast = parse_file( + INPUT_HEADER, + use_cpp=True, + cpp_path="gcc", + 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)=", + ], + ) + + # Collect all function declarations + functions = [ + node + for node in ast.ext + if isinstance(node, c_ast.Decl) and isinstance(node.type, c_ast.FuncDecl) + ] + + # Scan all return types and update Result struct + return_types = set() + for func in functions: + if isinstance(func.type.type, c_ast.TypeDecl): + return_type = " ".join(func.type.type.type.names) + return_types.add(return_type) + + # Update the Result struct with all return types + for return_type in return_types: + if return_type not in ["bool", "void*", "int", "uint32_t"]: + RESULT_STRUCT = RESULT_STRUCT.replace( + "// Add other types as needed", + f" {return_type} {return_type}_value;\n // Add other types as needed", + ) + + # Generate the new header file + with open(OUTPUT_HEADER, "w") as f: + f.write("#ifndef WASM_EXPORT_CHECKED_H\n#define WASM_EXPORT_CHECKED_H\n\n") + + # Write the updated Result struct + f.write(RESULT_STRUCT + "\n") + + for func in functions: + new_func = generate_checked_function(func) + f.write(new_func + "\n\n") + + f.write("#endif // WASM_EXPORT_CHECKED_H\n") + + +if __name__ == "__main__": + process_header() From 2860ead56664c86466ccf1d7693459e36048ff8f Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Sat, 11 Oct 2025 07:51:59 +0000 Subject: [PATCH 02/27] refactor: based on current file location to adjust header file paths --- ci/generate_checked_functions.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 65b8a9739d..e067910069 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -14,10 +14,6 @@ } Result; """ -# Input and output file paths -INPUT_HEADER = "core/iwasm/include/wasm_export.h" -OUTPUT_HEADER = "core/iwasm/include/wasm_export_checked.h" - # Helper function to determine if a parameter is a pointer def is_pointer(param): @@ -99,9 +95,7 @@ def generate_checked_function(func): elif return_type == "uint32_t": new_func.append(f" res.value.int_value = original_result;") else: - new_func.append( - f" res.value.{return_type}_value = original_result;" - ) + 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" }}") @@ -114,12 +108,19 @@ def generate_checked_function(func): # Updated process_header to scan all return types and create a proper Result type + def process_header(): global RESULT_STRUCT # Access the global Result definition + # Based on current file location, adjust the path to the header file + input_header = os.path.join( + os.path.dirname(__file__), "../core/iwasm/include/wasm_export.h" + ) + output_header = input_header.replace("wasm_export.h", "wasm_export_checked.h") + # Parse the header file with preprocessing ast = parse_file( - INPUT_HEADER, + input_header, use_cpp=True, cpp_path="gcc", cpp_args=[ @@ -162,7 +163,7 @@ def process_header(): ) # Generate the new header file - with open(OUTPUT_HEADER, "w") as f: + with open(output_header, "w") as f: f.write("#ifndef WASM_EXPORT_CHECKED_H\n#define WASM_EXPORT_CHECKED_H\n\n") # Write the updated Result struct From a94ca0b5d392ece940c9177b5bfae153a8fe84a8 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Sat, 11 Oct 2025 07:58:31 +0000 Subject: [PATCH 03/27] refactor: Make Result struct definition locally and remove dynamic type addition --- ci/generate_checked_functions.py | 42 ++++++++++---------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index e067910069..c901456863 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -1,19 +1,6 @@ from pycparser import c_parser, c_ast, parse_file import os -# Define the Result struct as a string -RESULT_STRUCT = """ -typedef struct { - int error_code; // Error code (0 for success, non-zero for errors) - union { - bool bool_value; - void *ptr_value; - int int_value; - // Add other types as needed - } value; -} Result; -""" - # Helper function to determine if a parameter is a pointer def is_pointer(param): @@ -24,8 +11,6 @@ def is_pointer(param): def generate_checked_function(func): - global RESULT_STRUCT # Access the global Result definition - func_name = func.name # Access the name directly from Decl new_func_name = f"{func_name}_checked" @@ -37,14 +22,6 @@ def generate_checked_function(func): if isinstance(func.type.type, c_ast.TypeDecl): return_type = " ".join(func.type.type.type.names) - # Check if the return type is already in Result, if not, add it - if return_type not in ["bool", "void*", "int", "uint32_t"]: - # Add a new field to the Result struct dynamically - RESULT_STRUCT = RESULT_STRUCT.replace( - "// Add other types as needed", - f" {return_type} {return_type}_value;\n // Add other types as needed", - ) - # Start building the new function new_func = [f"Result {new_func_name}("] param_list = [] @@ -110,7 +87,15 @@ def generate_checked_function(func): def process_header(): - global RESULT_STRUCT # Access the global Result definition + # Define the Result struct as a string + RESULT_STRUCT = """ + typedef struct { + int error_code; // Error code (0 for success, non-zero for errors) + union { + // Add other types as needed + } value; + } Result; + """ # Based on current file location, adjust the path to the header file input_header = os.path.join( @@ -156,11 +141,10 @@ def process_header(): # Update the Result struct with all return types for return_type in return_types: - if return_type not in ["bool", "void*", "int", "uint32_t"]: - RESULT_STRUCT = RESULT_STRUCT.replace( - "// Add other types as needed", - f" {return_type} {return_type}_value;\n // Add other types as needed", - ) + RESULT_STRUCT = RESULT_STRUCT.replace( + "// Add other types as needed", + f" {return_type} {return_type}_value;\n // Add other types as needed", + ) # Generate the new header file with open(output_header, "w") as f: From e1a10571a6f6be264fefeddb29412dec18ebd4d1 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Sat, 11 Oct 2025 08:04:03 +0000 Subject: [PATCH 04/27] feat: include original wasm_export.h and necessary headers in generated header file --- ci/generate_checked_functions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index c901456863..f35a271eec 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -150,6 +150,12 @@ def process_header(): with open(output_header, "w") as f: f.write("#ifndef WASM_EXPORT_CHECKED_H\n#define WASM_EXPORT_CHECKED_H\n\n") + # necessary headers + f.write("#include \n") + f.write("#include \n") + f.write("#include \n") + f.write('#include "wasm_export.h"\n\n') + # Write the updated Result struct f.write(RESULT_STRUCT + "\n") From 16d35155a5f0bc4dd00cde8fc4a09f6230f481cc Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 14 Oct 2025 07:35:18 +0000 Subject: [PATCH 05/27] refactor: streamline Result handling by consolidating return type assignments and excluding void type --- ci/generate_checked_functions.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index f35a271eec..5310822e67 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -65,14 +65,8 @@ def generate_checked_function(func): new_func.append(f" Result res;") new_func.append(f" if (original_result == 0) {{") new_func.append(f" res.error_code = 0;") - if return_type == "bool": - new_func.append(f" res.value.bool_value = original_result;") - elif return_type == "void*": - new_func.append(f" res.value.ptr_value = original_result;") - elif return_type == "uint32_t": - new_func.append(f" res.value.int_value = original_result;") - else: - new_func.append(f" res.value.{return_type}_value = original_result;") + + 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" }}") @@ -141,6 +135,9 @@ def process_header(): # Update the Result struct with all return types for return_type in return_types: + if return_type == "void": + continue # No need to add void type + RESULT_STRUCT = RESULT_STRUCT.replace( "// Add other types as needed", f" {return_type} {return_type}_value;\n // Add other types as needed", From 90bfd394da9d5f6275ea45031d8d840b1ad4e92e Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Thu, 16 Oct 2025 02:36:36 +0000 Subject: [PATCH 06/27] feat: enhance generate_checked_function to support variadic arguments and update Result handling --- ci/generate_checked_functions.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 5310822e67..bc6383285a 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -2,11 +2,6 @@ import os -# Helper function to determine if a parameter is a pointer -def is_pointer(param): - return isinstance(param.type, c_ast.PtrDecl) - - # Updated generate_checked_function to dynamically update Result definition for new return types @@ -45,10 +40,13 @@ def generate_checked_function(func): new_func.append(") {") # Add null checks for pointer parameters + has_variadic = False for param in params: if isinstance(param, c_ast.EllipsisParam): - continue # Skip variadic arguments - if is_pointer(param): + # 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" if ({param.name} == NULL) {{") new_func.append(f" Result res = {{ .error_code = -1 }};") new_func.append(f" return res;") @@ -58,6 +56,19 @@ def generate_checked_function(func): if return_type == "void": new_func.append(f" {func_name}({', '.join(param_list)});") new_func.append(f" Result res = {{ .error_code = 0 }};") + 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);") + new_func.append(f" Result res;") + 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" }}") else: new_func.append( f" {return_type} original_result = {func_name}({', '.join(param_list)});" @@ -151,7 +162,10 @@ def process_header(): f.write("#include \n") f.write("#include \n") f.write("#include \n") - f.write('#include "wasm_export.h"\n\n') + f.write("\n") + f.write('#include "wasm_export.h"\n') + f.write('#include "lib_export.h"\n') + f.write("\n") # Write the updated Result struct f.write(RESULT_STRUCT + "\n") From 4e0b85eccf85db983ebaa8836edbf66d28006994 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Thu, 16 Oct 2025 06:37:37 +0000 Subject: [PATCH 07/27] fix: update generate_checked_function to include static inline in function declaration --- ci/generate_checked_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index bc6383285a..3fbdb6fb08 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -18,7 +18,7 @@ def generate_checked_function(func): return_type = " ".join(func.type.type.type.names) # Start building the new function - new_func = [f"Result {new_func_name}("] + new_func = [f"static inline Result {new_func_name}("] param_list = [] for param in params: if isinstance(param, c_ast.EllipsisParam): From 629d01b9bda857db831e6da4d79f65fe31baad30 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Mon, 20 Oct 2025 09:25:49 +0800 Subject: [PATCH 08/27] WIP. fix bugs about returning a pointer --- ci/generate_checked_functions.py | 79 +++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 16 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 3fbdb6fb08..7a1937f9ac 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -1,11 +1,42 @@ from pycparser import c_parser, c_ast, parse_file import os +from pprint import pprint # Updated generate_checked_function to dynamically update Result definition for new return types -def generate_checked_function(func): +def collect_typedefs(ast): + typedefs = {} + for node in ast.ext: + if isinstance(node, c_ast.Typedef): + typedefs[node.name] = node.type + return typedefs + +def resolve_typedef(typedefs, type_name): + resolved_type = typedefs.get(type_name) + + # Return the original type name if not a typedef + if not resolved_type: + return type_name + + print(f"Resolving typedef for {type_name}: {resolved_type}\n") + + if isinstance(resolved_type, c_ast.TypeDecl): + # Base case: Return the type name + return " ".join(resolved_type.declname) + elif isinstance(resolved_type, c_ast.PtrDecl): + # Handle pointer typedefs + resolved_type.show() + base_type = " ".join(resolved_type.type.type.name) + return f"{base_type} *" + elif isinstance(resolved_type, c_ast.ArrayDecl): + # Handle array typedefs + base_type = resolve_typedef(resolved_type.type.declname, typedefs) + return f"{base_type} *" + + +def generate_checked_function(func, typedefs): func_name = func.name # Access the name directly from Decl new_func_name = f"{func_name}_checked" @@ -16,6 +47,8 @@ def generate_checked_function(func): 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 = resolve_typedef(typedefs, return_type) + return_type = resolved_type # Start building the new function new_func = [f"static inline Result {new_func_name}("] @@ -55,32 +88,41 @@ def generate_checked_function(func): # Call the original function if return_type == "void": new_func.append(f" {func_name}({', '.join(param_list)});") - new_func.append(f" Result res = {{ .error_code = 0 }};") 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);") - new_func.append(f" Result res;") - 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" }}") else: new_func.append( f" {return_type} original_result = {func_name}({', '.join(param_list)});" ) - new_func.append(f" Result res;") - 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;") + # Handle result return from the original function + new_func.append(f" Result res;") + # if it is bool type + if return_type == "_Bool": + new_func.append(f" if (original_result == 1) {{") + new_func.append(f" res.error_code = 0;") + new_func.append(f" res.value._Bool_value = original_result;") new_func.append(f" }} else {{") - new_func.append(f" res.error_code = -2;") + new_func.append(f" res.error_code = -1;") new_func.append(f" }}") + # if it is void type + elif return_type == "void": + new_func.append(f" res.error_code = 0;") + else: + if isinstance(func.type.type, c_ast.PtrDecl): + 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 = -1;") + new_func.append(f" }}") + else: + new_func.append(f" res.error_code = 0;") + new_func.append(f" res.value.{return_type}_value = original_result;") new_func.append(f" return res;") new_func.append("}") @@ -130,6 +172,10 @@ def process_header(): ], ) + # Collect typedefs + typedefs = collect_typedefs(ast) + # pprint(typedefs) + # Collect all function declarations functions = [ node @@ -142,7 +188,8 @@ def process_header(): for func in functions: if isinstance(func.type.type, c_ast.TypeDecl): return_type = " ".join(func.type.type.type.names) - return_types.add(return_type) + resolved_type = resolve_typedef(typedefs, return_type) + return_types.add(resolved_type) # Update the Result struct with all return types for return_type in return_types: @@ -171,7 +218,7 @@ def process_header(): f.write(RESULT_STRUCT + "\n") for func in functions: - new_func = generate_checked_function(func) + new_func = generate_checked_function(func, typedefs) f.write(new_func + "\n\n") f.write("#endif // WASM_EXPORT_CHECKED_H\n") From 2de30f7b6f50e4a300acb7c2fdf6576532de0249 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Mon, 20 Oct 2025 05:53:10 +0000 Subject: [PATCH 09/27] Revert "WIP. fix bugs about returning a pointer" This reverts commit 4f9f6422cd9c32b71890d5ef668a8e3c15e15aa8. --- ci/generate_checked_functions.py | 79 +++++++------------------------- 1 file changed, 16 insertions(+), 63 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 7a1937f9ac..3fbdb6fb08 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -1,42 +1,11 @@ from pycparser import c_parser, c_ast, parse_file import os -from pprint import pprint # Updated generate_checked_function to dynamically update Result definition for new return types -def collect_typedefs(ast): - typedefs = {} - for node in ast.ext: - if isinstance(node, c_ast.Typedef): - typedefs[node.name] = node.type - return typedefs - -def resolve_typedef(typedefs, type_name): - resolved_type = typedefs.get(type_name) - - # Return the original type name if not a typedef - if not resolved_type: - return type_name - - print(f"Resolving typedef for {type_name}: {resolved_type}\n") - - if isinstance(resolved_type, c_ast.TypeDecl): - # Base case: Return the type name - return " ".join(resolved_type.declname) - elif isinstance(resolved_type, c_ast.PtrDecl): - # Handle pointer typedefs - resolved_type.show() - base_type = " ".join(resolved_type.type.type.name) - return f"{base_type} *" - elif isinstance(resolved_type, c_ast.ArrayDecl): - # Handle array typedefs - base_type = resolve_typedef(resolved_type.type.declname, typedefs) - return f"{base_type} *" - - -def generate_checked_function(func, typedefs): +def generate_checked_function(func): func_name = func.name # Access the name directly from Decl new_func_name = f"{func_name}_checked" @@ -47,8 +16,6 @@ def generate_checked_function(func, typedefs): 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 = resolve_typedef(typedefs, return_type) - return_type = resolved_type # Start building the new function new_func = [f"static inline Result {new_func_name}("] @@ -88,41 +55,32 @@ def generate_checked_function(func, typedefs): # Call the original function if return_type == "void": new_func.append(f" {func_name}({', '.join(param_list)});") + new_func.append(f" Result res = {{ .error_code = 0 }};") 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);") + new_func.append(f" Result res;") + 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" }}") else: new_func.append( f" {return_type} original_result = {func_name}({', '.join(param_list)});" ) - - # Handle result return from the original function - new_func.append(f" Result res;") - # if it is bool type - if return_type == "_Bool": - new_func.append(f" if (original_result == 1) {{") + new_func.append(f" Result res;") + new_func.append(f" if (original_result == 0) {{") new_func.append(f" res.error_code = 0;") - new_func.append(f" res.value._Bool_value = original_result;") + + new_func.append(f" res.value.{return_type}_value = original_result;") new_func.append(f" }} else {{") - new_func.append(f" res.error_code = -1;") + new_func.append(f" res.error_code = -2;") new_func.append(f" }}") - # if it is void type - elif return_type == "void": - new_func.append(f" res.error_code = 0;") - else: - if isinstance(func.type.type, c_ast.PtrDecl): - 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 = -1;") - new_func.append(f" }}") - else: - new_func.append(f" res.error_code = 0;") - new_func.append(f" res.value.{return_type}_value = original_result;") new_func.append(f" return res;") new_func.append("}") @@ -172,10 +130,6 @@ def process_header(): ], ) - # Collect typedefs - typedefs = collect_typedefs(ast) - # pprint(typedefs) - # Collect all function declarations functions = [ node @@ -188,8 +142,7 @@ def process_header(): for func in functions: if isinstance(func.type.type, c_ast.TypeDecl): return_type = " ".join(func.type.type.type.names) - resolved_type = resolve_typedef(typedefs, return_type) - return_types.add(resolved_type) + return_types.add(return_type) # Update the Result struct with all return types for return_type in return_types: @@ -218,7 +171,7 @@ def process_header(): f.write(RESULT_STRUCT + "\n") for func in functions: - new_func = generate_checked_function(func, typedefs) + new_func = generate_checked_function(func) f.write(new_func + "\n\n") f.write("#endif // WASM_EXPORT_CHECKED_H\n") From edefd13a8d4500c93aa339a1cf68e6ea6f2b1695 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Mon, 20 Oct 2025 06:18:09 +0000 Subject: [PATCH 10/27] fix: enhance return type handling in generate_checked_function to support pointer types --- ci/generate_checked_functions.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 3fbdb6fb08..572d946465 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -13,9 +13,13 @@ def generate_checked_function(func): 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) + # TODO: figure out a better way to detect typedef from pointer + if isinstance(func.type.type, c_ast.PtrDecl): + return_pointer = True # Start building the new function new_func = [f"static inline Result {new_func_name}("] @@ -55,36 +59,41 @@ def generate_checked_function(func): # Call the original function if return_type == "void": new_func.append(f" {func_name}({', '.join(param_list)});") - new_func.append(f" Result res = {{ .error_code = 0 }};") 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);") - new_func.append(f" Result res;") - new_func.append(f" if (original_result == 0) {{") + else: + new_func.append( + f" {return_type} original_result = {func_name}({', '.join(param_list)});" + ) + + # Handle returned values + new_func.append(f" Result res;") + if return_type == "void": + new_func.append(f" res = {{ .error_code = 0 }};") + elif return_type == "_Bool": + new_func.append(f" res.error_code = 0 ? original_result : -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" {return_type} original_result = {func_name}({', '.join(param_list)});" - ) - new_func.append(f" Result res;") 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" res.value._Bool_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("}") - return "\n".join(new_func) From 4cd5e2e689ed9af14cd3cd9580e6fa775888526b Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Mon, 20 Oct 2025 07:55:37 +0000 Subject: [PATCH 11/27] fix: update generate_checked_function to resolve typedefs and enhance Result handling for new return types --- ci/generate_checked_functions.py | 88 +++++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 7 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 572d946465..f682fd6764 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -2,10 +2,78 @@ import os -# Updated generate_checked_function to dynamically update Result definition for new return types +def collect_typedefs(ast): + """Collect all typedefs in the AST.""" + typedefs = {} + for node in ast.ext: + if not isinstance(node, c_ast.Typedef): + continue + + typedef_name = node.name + typedef_type = node.type + typedefs[typedef_name] = typedef_type + return typedefs + + +def resolve_typedef(typedefs, type_name): + """Resolve a typedef to its underlying type.""" + + def resolve_base_type(ptr_decl): + # handle cases like: typedef int******* ptr; + cur_type = ptr_decl + pointer_type_name = "" + + while isinstance(cur_type, c_ast.PtrDecl) or isinstance( + cur_type, c_ast.TypeDecl + ): + if isinstance(cur_type, c_ast.PtrDecl): + cur_type = cur_type.type + pointer_type_name += "*" + elif isinstance(cur_type, c_ast.TypeDecl): + if isinstance(cur_type.type, c_ast.IdentifierType): + base_type_name = " ".join(cur_type.type.names) + pointer_type_name = base_type_name + pointer_type_name + return pointer_type_name + else: + pointer_type_name = "".join(cur_type.type.name) + pointer_type_name + return pointer_type_name + return None + + resolved_type = typedefs.get(type_name) + + if resolved_type is None: + return type_name + + if isinstance(resolved_type, c_ast.TypeDecl): + if isinstance(resolved_type.type, c_ast.Enum): + print(f"Resolved enum typedef {type_name}") + return type_name + if isinstance(resolved_type.type, c_ast.Struct): + print(f"Resolved struct typedef {type_name}") + return type_name -def generate_checked_function(func): + if isinstance(resolved_type.type, c_ast.Union): + print(f"Resolved union typedef {type_name}") + return type_name + + if isinstance(resolved_type.type, c_ast.IdentifierType): + base_type_name = " ".join(resolved_type.type.names) + print(f"Resolved base typedef {type_name} to {base_type_name}") + return type_name + + resolved_type.show() + raise Exception(f"Unhandled TypeDecl typedef {type_name}") + elif isinstance(resolved_type, c_ast.PtrDecl): + pointer_type_name = resolve_base_type(resolved_type) + print(f"Resolved pointer typedef {type_name} to {pointer_type_name}") + return pointer_type_name + else: + resolved_type.show() + raise Exception(f"Unhandled typedef {type_name}") + + +def generate_checked_function(func, typedefs): func_name = func.name # Access the name directly from Decl new_func_name = f"{func_name}_checked" @@ -17,8 +85,9 @@ def generate_checked_function(func): 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) - # TODO: figure out a better way to detect typedef from pointer - if isinstance(func.type.type, c_ast.PtrDecl): + + resolved_type = resolve_typedef(typedefs, return_type) + if resolved_type.endswith("*"): return_pointer = True # Start building the new function @@ -88,12 +157,13 @@ def generate_checked_function(func): else: new_func.append(f" if (original_result == 0) {{") new_func.append(f" res.error_code = 0;") - new_func.append(f" res.value._Bool_value = original_result;") + 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) @@ -139,6 +209,9 @@ def process_header(): ], ) + # Collect all typedefs + typedefs = collect_typedefs(ast) + # Collect all function declarations functions = [ node @@ -151,7 +224,8 @@ def process_header(): for func in functions: if isinstance(func.type.type, c_ast.TypeDecl): return_type = " ".join(func.type.type.type.names) - return_types.add(return_type) + resolved_type = resolve_typedef(typedefs, return_type) + return_types.add(resolved_type) # Update the Result struct with all return types for return_type in return_types: @@ -180,7 +254,7 @@ def process_header(): f.write(RESULT_STRUCT + "\n") for func in functions: - new_func = generate_checked_function(func) + new_func = generate_checked_function(func, typedefs) f.write(new_func + "\n\n") f.write("#endif // WASM_EXPORT_CHECKED_H\n") From 170b23d27b7aa311ba14f68a3b59d0c953c0e056 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 28 Oct 2025 06:50:49 +0000 Subject: [PATCH 12/27] fix: add duplicate typedef check and improve pointer handling in generate_checked_function --- ci/generate_checked_functions.py | 51 ++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index f682fd6764..ac5ef524ec 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -9,9 +9,13 @@ def collect_typedefs(ast): if not isinstance(node, c_ast.Typedef): continue + if node.name in typedefs: + raise Exception(f"Duplicate typedef found: {node.name}") + typedef_name = node.name typedef_type = node.type typedefs[typedef_name] = typedef_type + return typedefs @@ -23,31 +27,30 @@ def resolve_base_type(ptr_decl): cur_type = ptr_decl pointer_type_name = "" - while isinstance(cur_type, c_ast.PtrDecl) or isinstance( - cur_type, c_ast.TypeDecl - ): - if isinstance(cur_type, c_ast.PtrDecl): - cur_type = cur_type.type - pointer_type_name += "*" - elif isinstance(cur_type, c_ast.TypeDecl): - if isinstance(cur_type.type, c_ast.IdentifierType): - base_type_name = " ".join(cur_type.type.names) - pointer_type_name = base_type_name + pointer_type_name - return pointer_type_name - else: - pointer_type_name = "".join(cur_type.type.name) + pointer_type_name - return pointer_type_name - return None + while isinstance(cur_type, c_ast.PtrDecl): + cur_type = cur_type.type + pointer_type_name += "*" + + assert isinstance(cur_type, c_ast.TypeDecl) + if isinstance(cur_type.type, c_ast.IdentifierType): + base_type_name = " ".join(cur_type.type.names) + pointer_type_name = base_type_name + pointer_type_name + else: + pointer_type_name = "".join(cur_type.type.name) + pointer_type_name + + return pointer_type_name resolved_type = typedefs.get(type_name) if resolved_type is None: return type_name + print(f"\n\nResolving typedef {type_name}:") + if isinstance(resolved_type, c_ast.TypeDecl): if isinstance(resolved_type.type, c_ast.Enum): print(f"Resolved enum typedef {type_name}") - return type_name + return type_name if isinstance(resolved_type.type, c_ast.Struct): print(f"Resolved struct typedef {type_name}") @@ -60,9 +63,8 @@ def resolve_base_type(ptr_decl): if isinstance(resolved_type.type, c_ast.IdentifierType): base_type_name = " ".join(resolved_type.type.names) print(f"Resolved base typedef {type_name} to {base_type_name}") - return type_name + return type_name - resolved_type.show() raise Exception(f"Unhandled TypeDecl typedef {type_name}") elif isinstance(resolved_type, c_ast.PtrDecl): pointer_type_name = resolve_base_type(resolved_type) @@ -113,6 +115,7 @@ def generate_checked_function(func, typedefs): 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): @@ -120,12 +123,14 @@ def generate_checked_function(func, typedefs): 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" Result res = {{ .error_code = -1 }};") + 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: @@ -140,9 +145,9 @@ def generate_checked_function(func, typedefs): ) # Handle returned values - new_func.append(f" Result res;") + new_func.append(f" // Assign return value and error code") if return_type == "void": - new_func.append(f" res = {{ .error_code = 0 }};") + new_func.append(f" res.error_code = 0;") elif return_type == "_Bool": new_func.append(f" res.error_code = 0 ? original_result : -2;") new_func.append(f" res.value._Bool_value = original_result;") @@ -224,8 +229,8 @@ def process_header(): for func in functions: if isinstance(func.type.type, c_ast.TypeDecl): return_type = " ".join(func.type.type.type.names) - resolved_type = resolve_typedef(typedefs, return_type) - return_types.add(resolved_type) + # resolved_type = resolve_typedef(typedefs, return_type) + return_types.add(return_type) # Update the Result struct with all return types for return_type in return_types: From 22a969e67c3fad1fe70af03847c3bcfc211a9fae Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 28 Oct 2025 06:57:46 +0000 Subject: [PATCH 13/27] fix: correct error code assignment for boolean return type in generate_checked_function --- ci/generate_checked_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index ac5ef524ec..630c0b86aa 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -149,7 +149,7 @@ def generate_checked_function(func, typedefs): if return_type == "void": new_func.append(f" res.error_code = 0;") elif return_type == "_Bool": - new_func.append(f" res.error_code = 0 ? original_result : -2;") + 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: From 7a9d37a20eb3069b78d14d4696d3c8aad0a7b274 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 28 Oct 2025 07:06:23 +0000 Subject: [PATCH 14/27] feat: add checked API sample with Fibonacci example and CMake configuration --- samples/checked-api/CMakeLists.txt | 56 +++++++++++ samples/checked-api/src/demo.c | 100 +++++++++++++++++++ samples/checked-api/wasm-apps/CMakeLists.txt | 17 ++++ samples/checked-api/wasm-apps/fib.c | 32 ++++++ 4 files changed, 205 insertions(+) create mode 100644 samples/checked-api/CMakeLists.txt create mode 100644 samples/checked-api/src/demo.c create mode 100644 samples/checked-api/wasm-apps/CMakeLists.txt create mode 100644 samples/checked-api/wasm-apps/fib.c diff --git a/samples/checked-api/CMakeLists.txt b/samples/checked-api/CMakeLists.txt new file mode 100644 index 0000000000..e3015b9c04 --- /dev/null +++ b/samples/checked-api/CMakeLists.txt @@ -0,0 +1,56 @@ +# 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) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +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} +) diff --git a/samples/checked-api/src/demo.c b/samples/checked-api/src/demo.c new file mode 100644 index 0000000000..4db49fa472 --- /dev/null +++ b/samples/checked-api/src/demo.c @@ -0,0 +1,100 @@ +#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, returned: %d\n", + result[0].of.i32); + + 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..22a63b9b18 --- /dev/null +++ b/samples/checked-api/wasm-apps/fib.c @@ -0,0 +1,32 @@ +#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); + printf("fibonacci(%d)=%d\n", n, result); + return result; +} + +int +main(int argc, char **argv) +{ + int n = atoi(argv[1]); + + printf("fibonacci(%d)=%d\n", n, fibonacci(n)); + + return 0; +} From 1a1112f3d966770f8bc8bfc939e65aa452ab8715 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 28 Oct 2025 07:24:44 +0000 Subject: [PATCH 15/27] Add command-line options to accept paths of headers as a list of multiple file paths --- ci/generate_checked_functions.py | 158 +++++++++++++++++-------------- 1 file changed, 85 insertions(+), 73 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 630c0b86aa..fc24a03a22 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -1,5 +1,6 @@ from pycparser import c_parser, c_ast, parse_file import os +import argparse def collect_typedefs(ast): @@ -172,10 +173,23 @@ def generate_checked_function(func, typedefs): return "\n".join(new_func) +def parse_arguments(): + parser = argparse.ArgumentParser( + description="Generate checked functions from header files." + ) + parser.add_argument( + "--headers", + nargs="+", + required=True, + help="List of header file paths to process.", + ) + return parser.parse_args() + + # Updated process_header to scan all return types and create a proper Result type -def process_header(): +def process_headers(header_paths): # Define the Result struct as a string RESULT_STRUCT = """ typedef struct { @@ -186,84 +200,82 @@ def process_header(): } Result; """ - # Based on current file location, adjust the path to the header file - input_header = os.path.join( - os.path.dirname(__file__), "../core/iwasm/include/wasm_export.h" - ) - output_header = input_header.replace("wasm_export.h", "wasm_export_checked.h") - - # Parse the header file with preprocessing - ast = parse_file( - input_header, - use_cpp=True, - cpp_path="gcc", - 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)=", - ], - ) - - # Collect all typedefs - typedefs = collect_typedefs(ast) - - # Collect all function declarations - functions = [ - node - for node in ast.ext - if isinstance(node, c_ast.Decl) and isinstance(node.type, c_ast.FuncDecl) - ] - - # Scan all return types and update Result struct - return_types = set() - for func in functions: - if isinstance(func.type.type, c_ast.TypeDecl): - return_type = " ".join(func.type.type.type.names) - # resolved_type = resolve_typedef(typedefs, return_type) - return_types.add(return_type) - - # Update the Result struct with all return types - for return_type in return_types: - if return_type == "void": - continue # No need to add void type - - RESULT_STRUCT = RESULT_STRUCT.replace( - "// Add other types as needed", - f" {return_type} {return_type}_value;\n // Add other types as needed", + for input_header in header_paths: + output_header = input_header.replace(".h", "_checked.h") + + # Parse the header file with preprocessing + ast = parse_file( + input_header, + use_cpp=True, + cpp_path="gcc", + 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)=", + ], ) - # Generate the new header file - with open(output_header, "w") as f: - f.write("#ifndef WASM_EXPORT_CHECKED_H\n#define WASM_EXPORT_CHECKED_H\n\n") + # Collect all typedefs + typedefs = collect_typedefs(ast) - # necessary headers - f.write("#include \n") - f.write("#include \n") - f.write("#include \n") - f.write("\n") - f.write('#include "wasm_export.h"\n') - f.write('#include "lib_export.h"\n') - f.write("\n") - - # Write the updated Result struct - f.write(RESULT_STRUCT + "\n") + # Collect all function declarations + functions = [ + node + for node in ast.ext + if isinstance(node, c_ast.Decl) and isinstance(node.type, c_ast.FuncDecl) + ] + # Scan all return types and update Result struct + return_types = set() for func in functions: - new_func = generate_checked_function(func, typedefs) - f.write(new_func + "\n\n") + if isinstance(func.type.type, c_ast.TypeDecl): + return_type = " ".join(func.type.type.type.names) + # resolved_type = resolve_typedef(typedefs, return_type) + return_types.add(return_type) + + # Update the Result struct with all return types + for return_type in return_types: + if return_type == "void": + continue # No need to add void type + + RESULT_STRUCT = RESULT_STRUCT.replace( + "// Add other types as needed", + f" {return_type} {return_type}_value;\n // Add other types as needed", + ) + + # Generate the new header file + with open(output_header, "w") as f: + f.write("#ifndef WASM_EXPORT_CHECKED_H\n#define WASM_EXPORT_CHECKED_H\n\n") + + # necessary headers + f.write("#include \n") + f.write("#include \n") + f.write("#include \n") + f.write("\n") + f.write('#include "wasm_export.h"\n') + f.write('#include "lib_export.h"\n') + f.write("\n") + + # Write the updated Result struct + f.write(RESULT_STRUCT + "\n") + + for func in functions: + new_func = generate_checked_function(func, typedefs) + f.write(new_func + "\n\n") - f.write("#endif // WASM_EXPORT_CHECKED_H\n") + f.write("#endif // WASM_EXPORT_CHECKED_H\n") if __name__ == "__main__": - process_header() + args = parse_arguments() + process_headers(args.headers) From 42ec04cd9fd1cfa48cd8e10d4d8f5925cbd5a9cf Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 28 Oct 2025 07:57:04 +0000 Subject: [PATCH 16/27] Add docstring to introduce script usage, arguments, and output --- ci/generate_checked_functions.py | 69 ++++++++++++++------------------ 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index fc24a03a22..781006def5 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -1,5 +1,33 @@ -from pycparser import c_parser, c_ast, parse_file -import os +""" +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. + +Example: + 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. + + The generated "_checked.h" files include the original header file and define the `Result` struct, which + encapsulates the return value and error codes. + +Dependencies: + - pycparser: Install it using `pip install pycparser`. + +Output: + For each input header file, a corresponding "_checked.h" file is created in the same directory. +""" + +from pycparser import c_ast, parse_file import argparse @@ -46,30 +74,22 @@ def resolve_base_type(ptr_decl): if resolved_type is None: return type_name - print(f"\n\nResolving typedef {type_name}:") - if isinstance(resolved_type, c_ast.TypeDecl): if isinstance(resolved_type.type, c_ast.Enum): - print(f"Resolved enum typedef {type_name}") return type_name if isinstance(resolved_type.type, c_ast.Struct): - print(f"Resolved struct typedef {type_name}") return type_name if isinstance(resolved_type.type, c_ast.Union): - print(f"Resolved union typedef {type_name}") return type_name if isinstance(resolved_type.type, c_ast.IdentifierType): - base_type_name = " ".join(resolved_type.type.names) - print(f"Resolved base typedef {type_name} to {base_type_name}") return type_name raise Exception(f"Unhandled TypeDecl typedef {type_name}") elif isinstance(resolved_type, c_ast.PtrDecl): pointer_type_name = resolve_base_type(resolved_type) - print(f"Resolved pointer typedef {type_name} to {pointer_type_name}") return pointer_type_name else: resolved_type.show() @@ -215,35 +235,6 @@ def process_headers(header_paths): "-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)=", - ], - ) - - # Collect all typedefs - typedefs = collect_typedefs(ast) - - # Collect all function declarations - functions = [ - node - for node in ast.ext - if isinstance(node, c_ast.Decl) and isinstance(node.type, c_ast.FuncDecl) - ] - - # Scan all return types and update Result struct - return_types = set() - for func in functions: - if isinstance(func.type.type, c_ast.TypeDecl): - return_type = " ".join(func.type.type.type.names) - # resolved_type = resolve_typedef(typedefs, return_type) - return_types.add(return_type) - - # Update the Result struct with all return types for return_type in return_types: if return_type == "void": continue # No need to add void type From b7126c18fc9750b1ac325c5097fd90ebc91659b0 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 28 Oct 2025 17:14:07 +0000 Subject: [PATCH 17/27] refactor: rename and break process_headers into small ones --- ci/generate_checked_functions.py | 151 ++++++++++++++++++------------- 1 file changed, 88 insertions(+), 63 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 781006def5..c3a618e617 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -29,23 +29,73 @@ from pycparser import c_ast, parse_file import argparse +from pathlib import Path + +# 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; +""" +INCLUDE_HEADERS = ["", "", ""] -def collect_typedefs(ast): - """Collect all typedefs in the AST.""" - typedefs = {} - for node in ast.ext: - if not isinstance(node, c_ast.Typedef): - continue - if node.name in typedefs: - raise Exception(f"Duplicate typedef found: {node.name}") +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": + 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: + f.write("#ifndef WASM_EXPORT_CHECKED_H\n#define WASM_EXPORT_CHECKED_H\n\n") + + for header in INCLUDE_HEADERS: + f.write(f"#include {header}\n") + f.write("\n") + f.write('#include "wasm_export.h"\n') + f.write('#include "lib_export.h"\n') + f.write("\n") - typedef_name = node.name - typedef_type = node.type - typedefs[typedef_name] = typedef_type + f.write(result_struct + "\n") - return typedefs + for func in functions: + new_func = generate_checked_function(func, typedefs) + f.write(new_func + "\n\n") + + f.write("#endif // WASM_EXPORT_CHECKED_H\n") def resolve_typedef(typedefs, type_name): @@ -97,6 +147,7 @@ def resolve_base_type(ptr_decl): 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" @@ -194,6 +245,7 @@ def generate_checked_function(func, typedefs): def parse_arguments(): + """Parse command-line arguments.""" parser = argparse.ArgumentParser( description="Generate checked functions from header files." ) @@ -206,67 +258,40 @@ def parse_arguments(): return parser.parse_args() -# Updated process_header to scan all return types and create a proper Result type - - -def process_headers(header_paths): - # Define the Result struct as a string - RESULT_STRUCT = """ - typedef struct { - int error_code; // Error code (0 for success, non-zero for errors) - union { - // Add other types as needed - } value; - } Result; - """ - +def generate_checked_headers(header_paths): + """Process each header file and generate checked versions.""" for input_header in header_paths: - output_header = input_header.replace(".h", "_checked.h") + input_path = Path(input_header) + output_path = input_path.with_name(input_path.stem + "_checked.h") - # Parse the header file with preprocessing ast = parse_file( - input_header, + str(input_path), use_cpp=True, cpp_path="gcc", - cpp_args=[ - "-E", - "-D__attribute__(x)=", - "-D__asm__(x)=", - "-D__asm(x)=", - "-D__builtin_va_list=int", - "-D__extension__=", - for return_type in return_types: - if return_type == "void": - continue # No need to add void type - - RESULT_STRUCT = RESULT_STRUCT.replace( - "// Add other types as needed", - f" {return_type} {return_type}_value;\n // Add other types as needed", - ) + cpp_args=CPP_ARGS, + ) - # Generate the new header file - with open(output_header, "w") as f: - f.write("#ifndef WASM_EXPORT_CHECKED_H\n#define WASM_EXPORT_CHECKED_H\n\n") + typedefs = extract_typedefs(ast) + functions = [ + node + for node in ast.ext + if isinstance(node, c_ast.Decl) and isinstance(node.type, c_ast.FuncDecl) + ] - # necessary headers - f.write("#include \n") - f.write("#include \n") - f.write("#include \n") - f.write("\n") - f.write('#include "wasm_export.h"\n') - f.write('#include "lib_export.h"\n') - f.write("\n") + return_types = { + " ".join(func.type.type.type.names) + for func in functions + if isinstance(func.type.type, c_ast.TypeDecl) + } - # Write the updated Result struct - f.write(RESULT_STRUCT + "\n") + result_struct = generate_result_struct(return_types) + write_checked_header(output_path, result_struct, functions, typedefs) - for func in functions: - new_func = generate_checked_function(func, typedefs) - f.write(new_func + "\n\n") - f.write("#endif // WASM_EXPORT_CHECKED_H\n") +def main(): + args = parse_arguments() + generate_checked_headers(args.headers) if __name__ == "__main__": - args = parse_arguments() - process_headers(args.headers) + main() From 15bc48b70b33438ebec9b7f4da60b53bb6223f9f Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 28 Oct 2025 23:47:59 +0000 Subject: [PATCH 18/27] fix: update copyright notice and improve header file generation comments --- ci/generate_checked_functions.py | 40 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index c3a618e617..f1744b34c7 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -57,6 +57,13 @@ } Result; """ +COPYRIGHT = """ +/* + * Copyright (C) 2025 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + """ + INCLUDE_HEADERS = ["", "", ""] @@ -69,24 +76,39 @@ 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": - result_struct = result_struct.replace( - "// Add other types as needed", - f" {return_type} {return_type}_value;\n // Add other types as needed", - ) + 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: - f.write("#ifndef WASM_EXPORT_CHECKED_H\n#define WASM_EXPORT_CHECKED_H\n\n") + # 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") - f.write('#include "wasm_export.h"\n') - f.write('#include "lib_export.h"\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") @@ -95,7 +117,7 @@ def write_checked_header(output_path, result_struct, functions, typedefs): new_func = generate_checked_function(func, typedefs) f.write(new_func + "\n\n") - f.write("#endif // WASM_EXPORT_CHECKED_H\n") + f.write(f"#endif // {output_path.stem.upper()}_H\n") def resolve_typedef(typedefs, type_name): From 39e83431526a11f456f2d74ae06d1bf7d1d4991e Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Wed, 29 Oct 2025 00:07:37 +0000 Subject: [PATCH 19/27] refactor: remove unused resolve_typedef function and simplify type resolution --- ci/generate_checked_functions.py | 52 ++------------------------------ 1 file changed, 2 insertions(+), 50 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index f1744b34c7..8b2b579aea 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -120,54 +120,6 @@ def write_checked_header(output_path, result_struct, functions, typedefs): f.write(f"#endif // {output_path.stem.upper()}_H\n") -def resolve_typedef(typedefs, type_name): - """Resolve a typedef to its underlying type.""" - - def resolve_base_type(ptr_decl): - # handle cases like: typedef int******* ptr; - cur_type = ptr_decl - pointer_type_name = "" - - while isinstance(cur_type, c_ast.PtrDecl): - cur_type = cur_type.type - pointer_type_name += "*" - - assert isinstance(cur_type, c_ast.TypeDecl) - if isinstance(cur_type.type, c_ast.IdentifierType): - base_type_name = " ".join(cur_type.type.names) - pointer_type_name = base_type_name + pointer_type_name - else: - pointer_type_name = "".join(cur_type.type.name) + pointer_type_name - - return pointer_type_name - - resolved_type = typedefs.get(type_name) - - if resolved_type is None: - return type_name - - if isinstance(resolved_type, c_ast.TypeDecl): - if isinstance(resolved_type.type, c_ast.Enum): - return type_name - - if isinstance(resolved_type.type, c_ast.Struct): - return type_name - - if isinstance(resolved_type.type, c_ast.Union): - return type_name - - if isinstance(resolved_type.type, c_ast.IdentifierType): - return type_name - - raise Exception(f"Unhandled TypeDecl typedef {type_name}") - elif isinstance(resolved_type, c_ast.PtrDecl): - pointer_type_name = resolve_base_type(resolved_type) - return pointer_type_name - else: - resolved_type.show() - raise Exception(f"Unhandled typedef {type_name}") - - def generate_checked_function(func, typedefs): """Generate a checked version of the given function.""" func_name = func.name # Access the name directly from Decl @@ -182,8 +134,8 @@ def generate_checked_function(func, typedefs): if isinstance(func.type.type, c_ast.TypeDecl): return_type = " ".join(func.type.type.type.names) - resolved_type = resolve_typedef(typedefs, return_type) - if resolved_type.endswith("*"): + resolved_type = typedefs.get(return_type, return_type) + if isinstance(resolved_type, c_ast.PtrDecl): return_pointer = True # Start building the new function From be4dc9fcf9ffae56557014e26244352564221767 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Wed, 29 Oct 2025 01:50:04 +0000 Subject: [PATCH 20/27] fix: correct indentation in RESULT_STRUCT_TEMPLATE for clarity --- ci/generate_checked_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 8b2b579aea..51df56a0f0 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -52,7 +52,7 @@ typedef struct { int error_code; // Error code (0 for success, non-zero for errors) union { - // Add other types as needed + // Add other types as needed } value; } Result; """ From 29d5070e7f2f0fb8d097faa90aa1ed53347361d8 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Wed, 29 Oct 2025 02:07:39 +0000 Subject: [PATCH 21/27] refactor: update CMakeLists.txt for testing support and modify demo output --- samples/checked-api/CMakeLists.txt | 11 ++++++++--- samples/checked-api/src/demo.c | 14 ++++++++++++-- samples/checked-api/wasm-apps/fib.c | 1 - 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/samples/checked-api/CMakeLists.txt b/samples/checked-api/CMakeLists.txt index e3015b9c04..d1ea8c6e41 100644 --- a/samples/checked-api/CMakeLists.txt +++ b/samples/checked-api/CMakeLists.txt @@ -5,9 +5,8 @@ cmake_minimum_required (VERSION 3.14) project(checked_api_sample) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) -endif() +# assertion required +set(CMAKE_BUILD_TYPE Debug) set(CMAKE_C_STANDARD 23) @@ -54,3 +53,9 @@ ExternalProject_Add(wasm 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 index 4db49fa472..5546bd2f38 100644 --- a/samples/checked-api/src/demo.c +++ b/samples/checked-api/src/demo.c @@ -80,8 +80,18 @@ main(int argc, char *argv_main[]) arguments); VERIFY_API_RESULT(wasm_runtime_call_wasm_a_checked, api_result, release_runtime); - printf("Native finished calling wasm function: fib, returned: %d\n", - result[0].of.i32); + 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; diff --git a/samples/checked-api/wasm-apps/fib.c b/samples/checked-api/wasm-apps/fib.c index 22a63b9b18..6603dfc590 100644 --- a/samples/checked-api/wasm-apps/fib.c +++ b/samples/checked-api/wasm-apps/fib.c @@ -17,7 +17,6 @@ __attribute__((export_name("fib"))) int fib(int n) { int result = fibonacci(n); - printf("fibonacci(%d)=%d\n", n, result); return result; } From ab079c139491060d07444ecf03911801bc835035 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Wed, 29 Oct 2025 02:29:26 +0000 Subject: [PATCH 22/27] refactor: enhance header generation script with default headers and formatting support --- ci/generate_checked_functions.py | 34 +++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 51df56a0f0..4243202edb 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -7,8 +7,11 @@ 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: @@ -16,20 +19,25 @@ 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. + 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. """ -from pycparser import c_ast, parse_file import argparse from pathlib import Path +from pycparser import c_ast, parse_file +import subprocess # Constants for repeated strings CPP_ARGS = [ @@ -226,14 +234,23 @@ def parse_arguments(): parser.add_argument( "--headers", nargs="+", - required=True, - help="List of header file paths to process.", + 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") @@ -260,11 +277,18 @@ def generate_checked_headers(header_paths): 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() - generate_checked_headers(args.headers) + 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__": From 612b4bd614508cdf3634e5980af779ed8b0a247e Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Wed, 29 Oct 2025 02:42:32 +0000 Subject: [PATCH 23/27] fix: include stdbool.h for boolean type support in aot_comp_option.h --- core/iwasm/include/aot_comp_option.h | 1 + 1 file changed, 1 insertion(+) 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" { From bef501b5a21b0ca3b19bca2c1ae613be29fe9309 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Wed, 29 Oct 2025 02:45:03 +0000 Subject: [PATCH 24/27] feat: A new job in CI to check if checked APIs are up to date --- .github/workflows/verify_checked_apis.yml | 59 +++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/verify_checked_apis.yml 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 From 94dce59c7a88c19cef3fde2b3d509e311b3d1b64 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Wed, 29 Oct 2025 02:47:27 +0000 Subject: [PATCH 25/27] add generated checked APIs --- core/iwasm/include/aot_comp_option_checked.h | 42 + core/iwasm/include/aot_export_checked.h | 334 + core/iwasm/include/gc_export_checked.h | 4010 +++++++++++ core/iwasm/include/lib_export_checked.h | 49 + core/iwasm/include/wasm_c_api_checked.h | 6333 ++++++++++++++++++ core/iwasm/include/wasm_export_checked.h | 2940 ++++++++ 6 files changed, 13708 insertions(+) create mode 100644 core/iwasm/include/aot_comp_option_checked.h create mode 100644 core/iwasm/include/aot_export_checked.h create mode 100644 core/iwasm/include/gc_export_checked.h create mode 100644 core/iwasm/include/lib_export_checked.h create mode 100644 core/iwasm/include/wasm_c_api_checked.h create mode 100644 core/iwasm/include/wasm_export_checked.h 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..7dfab11529 --- /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 { + uint32_t uint32_t_value; + _Bool _Bool_value; + aot_obj_data_t aot_obj_data_t_value; + aot_comp_data_t aot_comp_data_t_value; + aot_comp_context_t aot_comp_context_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_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_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_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_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_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_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_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_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; +} + +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_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_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_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_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; +} + +#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..4c584de14a --- /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 { + wasm_array_obj_t wasm_array_obj_t_value; + wasm_struct_obj_t wasm_struct_obj_t_value; + wasm_exec_env_t wasm_exec_env_t_value; + wasm_func_type_t wasm_func_type_t_value; + wasm_memory_inst_t wasm_memory_inst_t_value; + wasm_module_t wasm_module_t_value; + wasm_defined_type_t wasm_defined_type_t_value; + wasm_function_inst_t wasm_function_inst_t_value; + wasm_externref_obj_t wasm_externref_obj_t_value; + package_type_t package_type_t_value; + wasm_i31_obj_t wasm_i31_obj_t_value; + wasm_ref_type_t wasm_ref_type_t_value; + wasm_module_inst_t wasm_module_inst_t_value; + _Bool _Bool_value; + double double_value; + wasm_func_obj_t wasm_func_obj_t_value; + wasm_obj_t wasm_obj_t_value; + uint64_t uint64_t_value; + wasm_shared_heap_t wasm_shared_heap_t_value; + RunningMode RunningMode_value; + int32_t int32_t_value; + wasm_valkind_t wasm_valkind_t_value; + uint32_t uint32_t_value; + wasm_anyref_obj_t wasm_anyref_obj_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 +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_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_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_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_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_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_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_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_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_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 +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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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; +} + +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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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; +} + +#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..b6aa24b748 --- /dev/null +++ b/core/iwasm/include/wasm_c_api_checked.h @@ -0,0 +1,6333 @@ + +/* + * 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 { + wasm_valkind_t wasm_valkind_t_value; + wasm_mutability_t wasm_mutability_t_value; + uint32_t uint32_t_value; + wasm_table_size_t wasm_table_size_t_value; + _Bool _Bool_value; + double double_value; + wasm_externkind_t wasm_externkind_t_value; + wasm_memory_pages_t wasm_memory_pages_t_value; + int int_value; + size_t size_t_value; + // Add other types as needed + } value; +} Result; + +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 +memmove_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 + memmove(__dest, __src, __n); + // 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 +memset_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 + memset(__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 +__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 +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 +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 +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 +strcat_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 + strcat(__dest, __src); + // Assign return value and error code + res.error_code = 0; + 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 +strcmp_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 = strcmp(__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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +strlen_checked(void *__s) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = strlen(__s); + // 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 +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 +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_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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +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 +__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 +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 +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 +__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 +__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 +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_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_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_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_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_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_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_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_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_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_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_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; +} + +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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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; +} + +#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..2a8b2fea2d --- /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 { + wasm_valkind_t wasm_valkind_t_value; + wasm_module_t wasm_module_t_value; + uint32_t uint32_t_value; + RunningMode RunningMode_value; + _Bool _Bool_value; + wasm_function_inst_t wasm_function_inst_t_value; + double double_value; + package_type_t package_type_t_value; + wasm_exec_env_t wasm_exec_env_t_value; + wasm_memory_inst_t wasm_memory_inst_t_value; + uint64_t uint64_t_value; + wasm_shared_heap_t wasm_shared_heap_t_value; + int32_t int32_t_value; + wasm_module_inst_t wasm_module_inst_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 +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_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_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_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_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_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_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_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_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_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 +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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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; +} + +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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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; +} + +#endif // WASM_EXPORT_CHECKED_H From 096461cbafbd8ec729a8de75eeabc0f413507ebc Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Wed, 29 Oct 2025 06:06:50 +0000 Subject: [PATCH 26/27] Use sorted lists to maintain consistency between CI and local. --- ci/generate_checked_functions.py | 2 + core/iwasm/include/aot_export_checked.h | 182 +- core/iwasm/include/gc_export_checked.h | 3278 +++++++++++----------- core/iwasm/include/wasm_c_api_checked.h | 3226 ++++++++++----------- core/iwasm/include/wasm_export_checked.h | 2540 ++++++++--------- 5 files changed, 4615 insertions(+), 4613 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 4243202edb..faa8a275ea 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -268,12 +268,14 @@ def generate_checked_headers(header_paths): for node in ast.ext if isinstance(node, c_ast.Decl) and isinstance(node.type, c_ast.FuncDecl) ] + 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) diff --git a/core/iwasm/include/aot_export_checked.h b/core/iwasm/include/aot_export_checked.h index 7dfab11529..03c2dc9d19 100644 --- a/core/iwasm/include/aot_export_checked.h +++ b/core/iwasm/include/aot_export_checked.h @@ -19,11 +19,11 @@ typedef struct { int error_code; // Error code (0 for success, non-zero for errors) union { - uint32_t uint32_t_value; _Bool _Bool_value; - aot_obj_data_t aot_obj_data_t_value; - aot_comp_data_t aot_comp_data_t_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; @@ -45,40 +45,23 @@ aot_call_stack_features_init_default_checked(void *features) } static inline Result -aot_create_comp_data_checked(void *wasm_module, void *target_arch, - _Bool gc_enabled) +aot_compile_wasm_checked(aot_comp_context_t comp_ctx) { 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); + _Bool original_result = aot_compile_wasm(comp_ctx); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -aot_destroy_comp_data_checked(aot_comp_data_t comp_data) +aot_compiler_destroy_checked(void) { Result res; // Execute the original function - aot_destroy_comp_data(comp_data); + aot_compiler_destroy(); // Assign return value and error code res.error_code = 0; return res; @@ -96,17 +79,6 @@ aot_compiler_init_checked(void) 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_create_comp_context_checked(aot_comp_data_t comp_data, aot_comp_option_t option) @@ -127,73 +99,87 @@ aot_create_comp_context_checked(aot_comp_data_t comp_data, } static inline Result -aot_destroy_comp_context_checked(aot_comp_context_t comp_ctx) +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_destroy_comp_context(comp_ctx); + aot_comp_data_t original_result = + aot_create_comp_data(wasm_module, target_arch, gc_enabled); // Assign return value and error code - res.error_code = 0; + 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_compile_wasm_checked(aot_comp_context_t comp_ctx) +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 - _Bool original_result = aot_compile_wasm(comp_ctx); + aot_destroy_aot_file(aot_file); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -aot_obj_data_create_checked(aot_comp_context_t comp_ctx) +aot_destroy_comp_context_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); + aot_destroy_comp_context(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; - } + res.error_code = 0; return res; } static inline Result -aot_obj_data_destroy_checked(aot_obj_data_t obj_data) +aot_destroy_comp_data_checked(aot_comp_data_t comp_data) { Result res; // Execute the original function - aot_obj_data_destroy(obj_data); + aot_destroy_comp_data(comp_data); // Assign return value and error code res.error_code = 0; 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) +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 - uint32_t original_result = - aot_get_aot_file_size(comp_ctx, comp_data, obj_data); + _Bool original_result = aot_emit_aot_file(comp_ctx, comp_data, file_name); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } @@ -270,60 +256,63 @@ aot_emit_object_file_checked(aot_comp_context_t comp_ctx, void *file_name) } static inline Result -aot_emit_aot_file_checked(aot_comp_context_t comp_ctx, - aot_comp_data_t comp_data, void *file_name) +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; - // 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); + uint32_t original_result = + aot_get_aot_file_size(comp_ctx, comp_data, obj_data); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_destroy_aot_file_checked(void *aot_file) +aot_get_last_error_checked(void) { 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); + aot_get_last_error(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -aot_get_last_error_checked(void) +aot_get_plt_table_size_checked(void) { Result res; // Execute the original function - aot_get_last_error(); + uint32_t original_result = aot_get_plt_table_size(); // Assign return value and error code - res.error_code = 0; + 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_plt_table_size_checked(void) +aot_obj_data_create_checked(aot_comp_context_t comp_ctx) { Result res; // Execute the original function - uint32_t original_result = aot_get_plt_table_size(); + aot_obj_data_t original_result = aot_obj_data_create(comp_ctx); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.uint32_t_value = original_result; + res.value.aot_obj_data_t_value = original_result; } else { res.error_code = -2; @@ -331,4 +320,15 @@ aot_get_plt_table_size_checked(void) 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 index 4c584de14a..47b651bd27 100644 --- a/core/iwasm/include/gc_export_checked.h +++ b/core/iwasm/include/gc_export_checked.h @@ -19,30 +19,30 @@ 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_struct_obj_t wasm_struct_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_memory_inst_t wasm_memory_inst_t_value; - wasm_module_t wasm_module_t_value; - wasm_defined_type_t wasm_defined_type_t_value; wasm_function_inst_t wasm_function_inst_t_value; - wasm_externref_obj_t wasm_externref_obj_t_value; - package_type_t package_type_t_value; wasm_i31_obj_t wasm_i31_obj_t_value; - wasm_ref_type_t wasm_ref_type_t_value; + wasm_memory_inst_t wasm_memory_inst_t_value; wasm_module_inst_t wasm_module_inst_t_value; - _Bool _Bool_value; - double double_value; - wasm_func_obj_t wasm_func_obj_t_value; + wasm_module_t wasm_module_t_value; wasm_obj_t wasm_obj_t_value; - uint64_t uint64_t_value; + wasm_ref_type_t wasm_ref_type_t_value; wasm_shared_heap_t wasm_shared_heap_t_value; - RunningMode RunningMode_value; - int32_t int32_t_value; + wasm_struct_obj_t wasm_struct_obj_t_value; wasm_valkind_t wasm_valkind_t_value; - uint32_t uint32_t_value; - wasm_anyref_obj_t wasm_anyref_obj_t_value; // Add other types as needed } value; } Result; @@ -70,52 +70,73 @@ get_base_lib_export_apis_checked(void *p_base_lib_apis) } static inline Result -wasm_runtime_init_checked(void) +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 - _Bool original_result = wasm_runtime_init(); + package_type_t original_result = get_package_type(buf, size); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_full_init_checked(void *init_args) +wasm_anyref_obj_get_value_checked(wasm_anyref_obj_t anyref_obj) { 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); + wasm_anyref_obj_get_value(anyref_obj); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_set_log_level_checked(log_level_t level) +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_runtime_set_log_level(level); + wasm_anyref_obj_t original_result = wasm_anyref_obj_new(exec_env, host_obj); // Assign return value and error code - res.error_code = 0; + 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_runtime_is_running_mode_supported_checked(RunningMode running_mode) +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_runtime_is_running_mode_supported(running_mode); + 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; @@ -123,11 +144,13 @@ wasm_runtime_is_running_mode_supported_checked(RunningMode running_mode) } static inline Result -wasm_runtime_set_default_running_mode_checked(RunningMode running_mode) +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_runtime_set_default_running_mode(running_mode); + _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; @@ -135,91 +158,92 @@ wasm_runtime_set_default_running_mode_checked(RunningMode running_mode) } static inline Result -wasm_runtime_destroy_checked(void) +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_runtime_destroy(); + 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_runtime_malloc_checked(unsigned int size) +wasm_array_obj_elem_addr_checked(wasm_array_obj_t array_obj, uint32_t elem_idx) { Result res; // Execute the original function - wasm_runtime_malloc(size); + 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_runtime_realloc_checked(void *ptr, unsigned int size) +wasm_array_obj_first_elem_addr_checked(wasm_array_obj_t array_obj) { 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); + wasm_array_obj_first_elem_addr(array_obj); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_free_checked(void *ptr) +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: ptr - if (ptr == NULL) { + // Check for null pointer parameter: value + if (value == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_free(ptr); + 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_runtime_get_mem_alloc_info_checked(void *mem_alloc_info) +wasm_array_obj_length_checked(wasm_array_obj_t array_obj) { 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); + uint32_t original_result = wasm_array_obj_length(array_obj); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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) +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: buf - if (buf == NULL) { + // Check for null pointer parameter: init_value + if (init_value == NULL) { res.error_code = -1; return res; } // Execute the original function - package_type_t original_result = get_package_type(buf, size); + 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 == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.package_type_t_value = original_result; + res.value.wasm_array_obj_t_value = original_result; } else { res.error_code = -2; @@ -228,21 +252,23 @@ get_package_type_checked(void *buf, uint32_t size) } static inline Result -wasm_runtime_get_file_package_type_checked(void *buf, uint32_t size) +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: buf - if (buf == NULL) { + // Check for null pointer parameter: init_value + if (init_value == NULL) { res.error_code = -1; return res; } // Execute the original function - package_type_t original_result = - wasm_runtime_get_file_package_type(buf, size); + 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 == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.package_type_t_value = original_result; + res.value.wasm_array_obj_t_value = original_result; } else { res.error_code = -2; @@ -251,38 +277,39 @@ wasm_runtime_get_file_package_type_checked(void *buf, uint32_t size) } static inline Result -wasm_runtime_get_module_package_type_checked(wasm_module_t module) +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 - package_type_t original_result = - wasm_runtime_get_module_package_type(module); + wasm_array_obj_set_elem(array_obj, elem_idx, value); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_get_file_package_version_checked(void *buf, uint32_t size) +wasm_array_type_get_elem_type_checked(wasm_array_type_t array_type, + void *p_is_mutable) { Result res; - // Check for null pointer parameter: buf - if (buf == NULL) { + // Check for null pointer parameter: p_is_mutable + if (p_is_mutable == NULL) { res.error_code = -1; return res; } // Execute the original function - uint32_t original_result = wasm_runtime_get_file_package_version(buf, size); + 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.uint32_t_value = original_result; + res.value.wasm_ref_type_t_value = original_result; } else { res.error_code = -2; @@ -291,11 +318,24 @@ wasm_runtime_get_file_package_version_checked(void *buf, uint32_t size) } static inline Result -wasm_runtime_get_module_package_version_checked(wasm_module_t module) +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_runtime_get_module_package_version(module); + 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; @@ -308,34 +348,26 @@ wasm_runtime_get_module_package_version_checked(wasm_module_t module) } static inline Result -wasm_runtime_get_current_package_version_checked(package_type_t package_type) +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 - uint32_t original_result = - wasm_runtime_get_current_package_version(package_type); + _Bool original_result = + wasm_defined_type_equal(def_type1, def_type2, 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; - } + 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) +wasm_defined_type_is_array_type_checked(wasm_defined_type_t def_type) { 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); + _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; @@ -343,35 +375,23 @@ wasm_runtime_is_xip_file_checked(void *buf, uint32_t size) } static inline Result -wasm_runtime_set_module_reader_checked(module_reader reader, - module_destroyer destroyer) +wasm_defined_type_is_func_type_checked(wasm_defined_type_t def_type) { Result res; // Execute the original function - wasm_runtime_set_module_reader(reader, destroyer); + _Bool original_result = wasm_defined_type_is_func_type(def_type); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; 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) +wasm_defined_type_is_struct_type_checked(wasm_defined_type_t def_type) { 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); + _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; @@ -379,121 +399,71 @@ wasm_runtime_register_module_checked(void *module_name, wasm_module_t module, } 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_load_checked(void *buf, uint32_t size, void *error_buf, - uint32_t error_buf_size) +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; - // 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); + _Bool original_result = + wasm_defined_type_is_subtype_of(def_type1, def_type2, module); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; 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) +wasm_externref_obj2ref_checked(wasm_module_inst_t module_inst, void *extern_obj, + void *p_externref_idx) { 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) { + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: error_buf - if (error_buf == NULL) { + // Check for null pointer parameter: p_externref_idx + if (p_externref_idx == 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); + _Bool original_result = + wasm_externref_obj2ref(module_inst, extern_obj, p_externref_idx); // 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; - } + 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) +wasm_externref_obj_get_value_checked(wasm_externref_obj_t externref_obj) { Result res; // Execute the original function - _Bool original_result = wasm_runtime_resolve_symbols(module); + wasm_externref_obj_get_value(externref_obj); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; 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) +wasm_externref_obj_new_checked(wasm_exec_env_t exec_env, void *host_obj) { Result res; - // Check for null pointer parameter: error_buf - if (error_buf == NULL) { + // Check for null pointer parameter: host_obj + if (host_obj == 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); + 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_module_t_value = original_result; + res.value.wasm_externref_obj_t_value = original_result; } else { res.error_code = -2; @@ -502,106 +472,16 @@ wasm_runtime_load_from_sections_checked(wasm_section_list_t section_list, } 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_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_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_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_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_ns_lookup_pool_checked(wasm_module_t module, - void *ns_lookup_pool, - uint32_t ns_lookup_pool_size) +wasm_externref_obj_to_internal_obj_checked(wasm_externref_obj_t externref_obj) { 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_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); + 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_module_inst_t_value = original_result; + res.value.wasm_obj_t_value = original_result; } else { res.error_code = -2; @@ -610,45 +490,33 @@ wasm_runtime_instantiate_checked(wasm_module_t module, } static inline Result -wasm_runtime_instantiate_ex_checked(wasm_module_t module, void *args, - void *error_buf, uint32_t error_buf_size) +wasm_externref_objdel_checked(wasm_module_inst_t module_inst, void *extern_obj) { 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) { + // Check for null pointer parameter: extern_obj + if (extern_obj == 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); + _Bool original_result = wasm_externref_objdel(module_inst, extern_obj); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_instantiation_args_create_checked(void *p) +wasm_externref_ref2obj_checked(uint32_t externref_idx, void *p_extern_obj) { Result res; - // Check for null pointer parameter: p - if (p == NULL) { + // 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_runtime_instantiation_args_create(p); + _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; @@ -656,94 +524,90 @@ wasm_runtime_instantiation_args_create_checked(void *p) } static inline Result -wasm_runtime_instantiation_args_destroy_checked(void *p) +wasm_externref_retain_checked(uint32_t externref_idx) { 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); + _Bool original_result = wasm_externref_retain(externref_idx); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_instantiation_args_set_default_stack_size_checked(void *p, - uint32_t v) +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: p - if (p == NULL) { + // 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 - wasm_runtime_instantiation_args_set_default_stack_size(p, v); + _Bool original_result = + wasm_externref_set_cleanup(module_inst, extern_obj, extern_obj_cleanup); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_instantiation_args_set_host_managed_heap_size_checked(void *p, - uint32_t v) +wasm_func_get_param_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) { 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); + uint32_t original_result = + wasm_func_get_param_count(func_inst, module_inst); // Assign return value and error code - res.error_code = 0; + 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_instantiation_args_set_max_memory_pages_checked(void *p, - uint32_t v) +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: p - if (p == NULL) { + // Check for null pointer parameter: param_types + if (param_types == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_instantiation_args_set_max_memory_pages(p, v); + 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_runtime_instantiate_ex2_checked(wasm_module_t module, void *args, - void *error_buf, uint32_t error_buf_size) +wasm_func_get_result_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) { 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); + uint32_t original_result = + wasm_func_get_result_count(func_inst, module_inst); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_module_inst_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -752,29 +616,33 @@ wasm_runtime_instantiate_ex2_checked(wasm_module_t module, void *args, } static inline Result -wasm_runtime_set_running_mode_checked(wasm_module_inst_t module_inst, - RunningMode running_mode) +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 - _Bool original_result = - wasm_runtime_set_running_mode(module_inst, running_mode); + wasm_func_get_result_types(func_inst, module_inst, result_types); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_get_running_mode_checked(wasm_module_inst_t module_inst) +wasm_func_obj_get_func_idx_bound_checked(wasm_func_obj_t func_obj) { Result res; // Execute the original function - RunningMode original_result = wasm_runtime_get_running_mode(module_inst); + 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.RunningMode_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -783,26 +651,35 @@ wasm_runtime_get_running_mode_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_deinstantiate_checked(wasm_module_inst_t module_inst) +wasm_func_obj_get_func_type_checked(wasm_func_obj_t func_obj) { Result res; // Execute the original function - wasm_runtime_deinstantiate(module_inst); + wasm_func_type_t original_result = wasm_func_obj_get_func_type(func_obj); // Assign return value and error code - res.error_code = 0; + 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_runtime_get_module_checked(wasm_module_inst_t module_inst) +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_module_t original_result = wasm_runtime_get_module(module_inst); + 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_module_t_value = original_result; + res.value.wasm_func_obj_t_value = original_result; } else { res.error_code = -2; @@ -811,28 +688,35 @@ wasm_runtime_get_module_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_is_wasi_mode_checked(wasm_module_inst_t module_inst) +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 - _Bool original_result = wasm_runtime_is_wasi_mode(module_inst); + 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 - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_runtime_lookup_wasi_start_function_checked(wasm_module_inst_t module_inst) +wasm_func_type_get_param_count_checked(wasm_func_type_t func_type) { Result res; // Execute the original function - wasm_function_inst_t original_result = - wasm_runtime_lookup_wasi_start_function(module_inst); + uint32_t original_result = wasm_func_type_get_param_count(func_type); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_function_inst_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -841,15 +725,17 @@ wasm_runtime_lookup_wasi_start_function_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_get_wasi_exit_code_checked(wasm_module_inst_t module_inst) +wasm_func_type_get_param_type_checked(wasm_func_type_t func_type, + uint32_t param_idx) { Result res; // Execute the original function - uint32_t original_result = wasm_runtime_get_wasi_exit_code(module_inst); + 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.uint32_t_value = original_result; + res.value.wasm_ref_type_t_value = original_result; } else { res.error_code = -2; @@ -858,21 +744,17 @@ wasm_runtime_get_wasi_exit_code_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_lookup_function_checked(wasm_module_inst_t module_inst, void *name) +wasm_func_type_get_param_valkind_checked(wasm_func_type_t func_type, + uint32_t param_index) { 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); + wasm_valkind_t original_result = + wasm_func_type_get_param_valkind(func_type, param_index); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_function_inst_t_value = original_result; + res.value.wasm_valkind_t_value = original_result; } else { res.error_code = -2; @@ -881,13 +763,11 @@ wasm_runtime_lookup_function_checked(wasm_module_inst_t module_inst, void *name) } static inline Result -wasm_func_get_param_count_checked(wasm_function_inst_t func_inst, - wasm_module_inst_t module_inst) +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_get_param_count(func_inst, module_inst); + 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; @@ -900,17 +780,17 @@ wasm_func_get_param_count_checked(wasm_function_inst_t func_inst, } static inline Result -wasm_func_get_result_count_checked(wasm_function_inst_t func_inst, - wasm_module_inst_t module_inst) +wasm_func_type_get_result_type_checked(wasm_func_type_t func_type, + uint32_t result_idx) { Result res; // Execute the original function - uint32_t original_result = - wasm_func_get_result_count(func_inst, module_inst); + 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.uint32_t_value = original_result; + res.value.wasm_ref_type_t_value = original_result; } else { res.error_code = -2; @@ -919,53 +799,51 @@ wasm_func_get_result_count_checked(wasm_function_inst_t func_inst, } static inline Result -wasm_func_get_param_types_checked(wasm_function_inst_t func_inst, - wasm_module_inst_t module_inst, - void *param_types) +wasm_func_type_get_result_valkind_checked(wasm_func_type_t func_type, + uint32_t result_index) { 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); + wasm_valkind_t original_result = + wasm_func_type_get_result_valkind(func_type, result_index); // Assign return value and error code - res.error_code = 0; + 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_get_result_types_checked(wasm_function_inst_t func_inst, - wasm_module_inst_t module_inst, - void *result_types) + +static inline Result +wasm_get_defined_type_checked(wasm_module_t module, uint32_t index) { 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); + wasm_defined_type_t original_result = wasm_get_defined_type(module, index); // Assign return value and error code - res.error_code = 0; + 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_runtime_create_exec_env_checked(wasm_module_inst_t module_inst, - uint32_t stack_size) +wasm_get_defined_type_count_checked(wasm_module_t module) { Result res; // Execute the original function - wasm_exec_env_t original_result = - wasm_runtime_create_exec_env(module_inst, stack_size); + uint32_t original_result = wasm_get_defined_type_count(module); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_exec_env_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -974,39 +852,27 @@ wasm_runtime_create_exec_env_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_destroy_exec_env_checked(wasm_exec_env_t exec_env) +wasm_global_type_get_mutable_checked(wasm_global_type_t global_type) { Result res; // Execute the original function - wasm_runtime_destroy_exec_env(exec_env); + _Bool original_result = wasm_global_type_get_mutable(global_type); // Assign return value and error code - res.error_code = 0; + 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) +wasm_global_type_get_valkind_checked(wasm_global_type_t global_type) { 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); + 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.uint32_t_value = original_result; + res.value.wasm_valkind_t_value = original_result; } else { res.error_code = -2; @@ -1015,16 +881,15 @@ wasm_copy_callstack_checked(wasm_exec_env_t exec_env, void *buffer, } static inline Result -wasm_runtime_get_exec_env_singleton_checked(wasm_module_inst_t module_inst) +wasm_i31_obj_get_value_checked(wasm_i31_obj_t i31_obj, _Bool sign_extend) { Result res; // Execute the original function - wasm_exec_env_t original_result = - wasm_runtime_get_exec_env_singleton(module_inst); + uint32_t original_result = wasm_i31_obj_get_value(i31_obj, sign_extend); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_exec_env_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -1033,17 +898,15 @@ wasm_runtime_get_exec_env_singleton_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_start_debug_instance_with_port_checked(wasm_exec_env_t exec_env, - int32_t port) +wasm_i31_obj_new_checked(uint32_t i31_value) { Result res; // Execute the original function - uint32_t original_result = - wasm_runtime_start_debug_instance_with_port(exec_env, port); + 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.uint32_t_value = original_result; + res.value.wasm_i31_obj_t_value = original_result; } else { res.error_code = -2; @@ -1052,15 +915,17 @@ wasm_runtime_start_debug_instance_with_port_checked(wasm_exec_env_t exec_env, } static inline Result -wasm_runtime_start_debug_instance_checked(wasm_exec_env_t exec_env) +wasm_internal_obj_to_externref_obj_checked(wasm_exec_env_t exec_env, + wasm_obj_t internal_obj) { Result res; // Execute the original function - uint32_t original_result = wasm_runtime_start_debug_instance(exec_env); + 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 == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.uint32_t_value = original_result; + res.value.wasm_externref_obj_t_value = original_result; } else { res.error_code = -2; @@ -1069,11 +934,12 @@ wasm_runtime_start_debug_instance_checked(wasm_exec_env_t exec_env) } static inline Result -wasm_runtime_init_thread_env_checked(void) +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_runtime_init_thread_env(); + _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; @@ -1081,38 +947,43 @@ wasm_runtime_init_thread_env_checked(void) } static inline Result -wasm_runtime_destroy_thread_env_checked(void) +wasm_memory_get_base_address_checked(wasm_memory_inst_t memory_inst) { Result res; // Execute the original function - wasm_runtime_destroy_thread_env(); + wasm_memory_get_base_address(memory_inst); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_thread_env_inited_checked(void) +wasm_memory_get_bytes_per_page_checked(wasm_memory_inst_t memory_inst) { Result res; // Execute the original function - _Bool original_result = wasm_runtime_thread_env_inited(); + uint64_t original_result = wasm_memory_get_bytes_per_page(memory_inst); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_get_module_inst_checked(wasm_exec_env_t exec_env) +wasm_memory_get_cur_page_count_checked(wasm_memory_inst_t memory_inst) { Result res; // Execute the original function - wasm_module_inst_t original_result = wasm_runtime_get_module_inst(exec_env); + uint64_t original_result = wasm_memory_get_cur_page_count(memory_inst); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_module_inst_t_value = original_result; + res.value.uint64_t_value = original_result; } else { res.error_code = -2; @@ -1121,33 +992,45 @@ wasm_runtime_get_module_inst_checked(wasm_exec_env_t exec_env) } static inline Result -wasm_runtime_set_module_inst_checked(wasm_exec_env_t exec_env, - wasm_module_inst_t module_inst) +wasm_memory_get_max_page_count_checked(wasm_memory_inst_t memory_inst) { Result res; // Execute the original function - wasm_runtime_set_module_inst(exec_env, module_inst); + uint64_t original_result = wasm_memory_get_max_page_count(memory_inst); // Assign return value and error code - res.error_code = 0; + 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_lookup_memory_checked(wasm_module_inst_t module_inst, void *name) +wasm_memory_get_shared_checked(wasm_memory_inst_t memory_inst) { 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); + _Bool original_result = wasm_memory_get_shared(memory_inst); // Assign return value and error code - if (original_result != NULL) { + 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.wasm_memory_inst_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -1156,16 +1039,15 @@ wasm_runtime_lookup_memory_checked(wasm_module_inst_t module_inst, void *name) } static inline Result -wasm_runtime_get_default_memory_checked(wasm_module_inst_t module_inst) +wasm_memory_type_get_max_page_count_checked(wasm_memory_type_t memory_type) { Result res; // Execute the original function - wasm_memory_inst_t original_result = - wasm_runtime_get_default_memory(module_inst); + uint32_t original_result = wasm_memory_type_get_max_page_count(memory_type); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_memory_inst_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -1174,16 +1056,27 @@ wasm_runtime_get_default_memory_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_get_memory_checked(wasm_module_inst_t module_inst, uint32_t index) +wasm_memory_type_get_shared_checked(wasm_memory_type_t memory_type) { Result res; // Execute the original function - wasm_memory_inst_t original_result = - wasm_runtime_get_memory(module_inst, index); + _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_memory_inst_t_value = original_result; + res.value.wasm_defined_type_t_value = original_result; } else { res.error_code = -2; @@ -1192,15 +1085,15 @@ wasm_runtime_get_memory_checked(wasm_module_inst_t module_inst, uint32_t index) } static inline Result -wasm_memory_get_cur_page_count_checked(wasm_memory_inst_t memory_inst) +wasm_obj_get_defined_type_idx_checked(wasm_module_t module, wasm_obj_t obj) { Result res; // Execute the original function - uint64_t original_result = wasm_memory_get_cur_page_count(memory_inst); + 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.uint64_t_value = original_result; + res.value.int32_t_value = original_result; } else { res.error_code = -2; @@ -1209,45 +1102,35 @@ wasm_memory_get_cur_page_count_checked(wasm_memory_inst_t memory_inst) } static inline Result -wasm_memory_get_max_page_count_checked(wasm_memory_inst_t memory_inst) +wasm_obj_is_anyref_obj_checked(wasm_obj_t obj) { Result res; // Execute the original function - uint64_t original_result = wasm_memory_get_max_page_count(memory_inst); + _Bool original_result = wasm_obj_is_anyref_obj(obj); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_memory_get_bytes_per_page_checked(wasm_memory_inst_t memory_inst) +wasm_obj_is_array_obj_checked(wasm_obj_t obj) { Result res; // Execute the original function - uint64_t original_result = wasm_memory_get_bytes_per_page(memory_inst); + _Bool original_result = wasm_obj_is_array_obj(obj); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_memory_get_shared_checked(wasm_memory_inst_t memory_inst) +wasm_obj_is_eq_obj_checked(wasm_obj_t obj) { Result res; // Execute the original function - _Bool original_result = wasm_memory_get_shared(memory_inst); + _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; @@ -1255,23 +1138,23 @@ wasm_memory_get_shared_checked(wasm_memory_inst_t memory_inst) } static inline Result -wasm_memory_get_base_address_checked(wasm_memory_inst_t memory_inst) +wasm_obj_is_externref_obj_checked(wasm_obj_t obj) { Result res; // Execute the original function - wasm_memory_get_base_address(memory_inst); + _Bool original_result = wasm_obj_is_externref_obj(obj); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_memory_enlarge_checked(wasm_memory_inst_t memory_inst, - uint64_t inc_page_count) +wasm_obj_is_func_obj_checked(wasm_obj_t obj) { Result res; // Execute the original function - _Bool original_result = wasm_memory_enlarge(memory_inst, inc_page_count); + _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; @@ -1279,14 +1162,26 @@ wasm_memory_enlarge_checked(wasm_memory_inst_t memory_inst, } static inline Result -wasm_runtime_call_wasm_checked(wasm_exec_env_t exec_env, - wasm_function_inst_t function, uint32_t argc, - void *argv) +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_runtime_call_wasm(exec_env, function, argc, argv); + 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; @@ -1294,20 +1189,16 @@ wasm_runtime_call_wasm_checked(wasm_exec_env_t exec_env, } 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) +wasm_obj_is_instance_of_ref_type_checked(wasm_obj_t obj, void *ref_type) { Result res; - // Check for null pointer parameter: args - if (args == NULL) { + // 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_runtime_call_wasm_a( - exec_env, function, num_results, results, num_args, args); + _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; @@ -1315,18 +1206,13 @@ wasm_runtime_call_wasm_a_checked(wasm_exec_env_t exec_env, } 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, ...) +wasm_obj_is_instance_of_type_idx_checked(wasm_obj_t obj, uint32_t type_idx, + wasm_module_t module) { 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); + _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; @@ -1334,14 +1220,11 @@ wasm_runtime_call_wasm_v_checked(wasm_exec_env_t exec_env, } static inline Result -wasm_runtime_call_indirect_checked(wasm_exec_env_t exec_env, - uint32_t element_index, uint32_t argc, - void *argv) +wasm_obj_is_internal_obj_checked(wasm_obj_t obj) { Result res; // Execute the original function - _Bool original_result = - wasm_runtime_call_indirect(exec_env, element_index, argc, argv); + _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; @@ -1349,13 +1232,11 @@ wasm_runtime_call_indirect_checked(wasm_exec_env_t exec_env, } static inline Result -wasm_application_execute_main_checked(wasm_module_inst_t module_inst, - int32_t argc, void *argv) +wasm_obj_is_struct_obj_checked(wasm_obj_t obj) { Result res; // Execute the original function - _Bool original_result = - wasm_application_execute_main(module_inst, argc, argv); + _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; @@ -1363,18 +1244,17 @@ wasm_application_execute_main_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_application_execute_func_checked(wasm_module_inst_t module_inst, - void *name, int32_t argc, void *argv) +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: name - if (name == NULL) { + // Check for null pointer parameter: data + if (data == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = - wasm_application_execute_func(module_inst, name, argc, argv); + _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; @@ -1382,101 +1262,146 @@ wasm_application_execute_func_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_get_exception_checked(wasm_module_inst_t module_inst) +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_runtime_get_exception(module_inst); + wasm_obj_unset_gc_finalizer(exec_env, obj); // 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) +wasm_ref_type_equal_checked(void *ref_type1, void *ref_type2, + wasm_module_t module) { Result res; - // Check for null pointer parameter: exception - if (exception == NULL) { + // 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 - wasm_runtime_set_exception(module_inst, exception); + _Bool original_result = wasm_ref_type_equal(ref_type1, ref_type2, module); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_clear_exception_checked(wasm_module_inst_t module_inst) +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 - wasm_runtime_clear_exception(module_inst); + _Bool original_result = + wasm_ref_type_is_subtype_of(ref_type1, ref_type2, module); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_terminate_checked(wasm_module_inst_t module_inst) +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_runtime_terminate(module_inst); + 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_runtime_set_custom_data_checked(wasm_module_inst_t module_inst, - void *custom_data) +wasm_ref_type_set_type_idx_checked(void *ref_type, _Bool nullable, + int32_t type_idx) { Result res; - // Check for null pointer parameter: custom_data - if (custom_data == NULL) { + // Check for null pointer parameter: ref_type + if (ref_type == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_set_custom_data(module_inst, custom_data); + 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_get_custom_data_checked(wasm_module_inst_t module_inst) +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_get_custom_data(module_inst); + 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_set_bounds_checks_checked(wasm_module_inst_t module_inst, - _Bool enable) +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 - wasm_runtime_set_bounds_checks(module_inst, enable); + uint64_t original_result = + wasm_runtime_addr_native_to_app(module_inst, native_ptr); // Assign return value and error code - res.error_code = 0; + 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_is_bounds_checks_enabled_checked(wasm_module_inst_t module_inst) +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_is_bounds_checks_enabled(module_inst); + _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; @@ -1484,72 +1409,81 @@ wasm_runtime_is_bounds_checks_enabled_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_module_malloc_checked(wasm_module_inst_t module_inst, - uint64_t size, void *p_native_addr) +wasm_runtime_begin_blocking_op_checked(wasm_exec_env_t exec_env) { 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); + _Bool original_result = wasm_runtime_begin_blocking_op(exec_env); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_module_free_checked(wasm_module_inst_t module_inst, uint64_t ptr) +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 - wasm_runtime_module_free(module_inst, ptr); + _Bool original_result = + wasm_runtime_call_func_ref(exec_env, func_obj, argc, argv); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_module_dup_data_checked(wasm_module_inst_t module_inst, void *src, - uint64_t size) +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: src - if (src == NULL) { + // Check for null pointer parameter: args + if (args == NULL) { res.error_code = -1; return res; } // Execute the original function - uint64_t original_result = - wasm_runtime_module_dup_data(module_inst, src, size); + _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 - if (original_result == 0) { - res.error_code = 0; - res.value.uint64_t_value = original_result; - } - else { - res.error_code = -2; - } + 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) +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_validate_app_addr(module_inst, app_offset, size); + 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; @@ -1557,13 +1491,14 @@ wasm_runtime_validate_app_addr_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_validate_app_str_addr_checked(wasm_module_inst_t module_inst, - uint64_t app_str_offset) +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_validate_app_str_addr(module_inst, app_str_offset); + 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; @@ -1571,18 +1506,20 @@ wasm_runtime_validate_app_str_addr_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_validate_native_addr_checked(wasm_module_inst_t module_inst, - void *native_ptr, uint64_t size) +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: native_ptr - if (native_ptr == NULL) { + // Check for null pointer parameter: args + if (args == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = - wasm_runtime_validate_native_addr(module_inst, native_ptr, size); + _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; @@ -1590,34 +1527,36 @@ wasm_runtime_validate_native_addr_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_addr_app_to_native_checked(wasm_module_inst_t module_inst, - uint64_t app_offset) +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 - wasm_runtime_addr_app_to_native(module_inst, app_offset); + 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 = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_addr_native_to_app_checked(wasm_module_inst_t module_inst, - void *native_ptr) +wasm_runtime_chain_shared_heaps_checked(wasm_shared_heap_t head, + wasm_shared_heap_t body) { 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); + wasm_shared_heap_t original_result = + wasm_runtime_chain_shared_heaps(head, body); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.uint64_t_value = original_result; + res.value.wasm_shared_heap_t_value = original_result; } else { res.error_code = -2; @@ -1626,72 +1565,44 @@ wasm_runtime_addr_native_to_app_checked(wasm_module_inst_t module_inst, } 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) +wasm_runtime_clear_exception_checked(wasm_module_inst_t module_inst) { 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); + wasm_runtime_clear_exception(module_inst); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; 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) +wasm_runtime_create_context_key_checked(void *dtor) { 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) { + // Check for null pointer parameter: dtor + if (dtor == 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); + wasm_runtime_create_context_key(dtor); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_get_import_count_checked(wasm_module_t module) +wasm_runtime_create_exec_env_checked(wasm_module_inst_t module_inst, + uint32_t stack_size) { Result res; // Execute the original function - int32_t original_result = wasm_runtime_get_import_count(module); + wasm_exec_env_t original_result = + wasm_runtime_create_exec_env(module_inst, stack_size); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.int32_t_value = original_result; + res.value.wasm_exec_env_t_value = original_result; } else { res.error_code = -2; @@ -1700,151 +1611,116 @@ wasm_runtime_get_import_count_checked(wasm_module_t module) } static inline Result -wasm_runtime_get_import_type_checked(wasm_module_t module, int32_t import_index, - void *import_type) +wasm_runtime_create_shared_heap_checked(void *init_args) { Result res; - // Check for null pointer parameter: import_type - if (import_type == NULL) { + // Check for null pointer parameter: init_args + if (init_args == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_get_import_type(module, import_index, import_type); + wasm_shared_heap_t original_result = + wasm_runtime_create_shared_heap(init_args); // Assign return value and error code - res.error_code = 0; + 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_get_export_count_checked(wasm_module_t module) +wasm_runtime_deinstantiate_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - int32_t original_result = wasm_runtime_get_export_count(module); + wasm_runtime_deinstantiate(module_inst); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_get_export_type_checked(wasm_module_t module, int32_t export_index, - void *export_type) +wasm_runtime_destroy_checked(void) { 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); + wasm_runtime_destroy(); // 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) +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 - uint32_t original_result = wasm_func_type_get_param_count(func_type); + wasm_runtime_destroy_context_key(key); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_func_type_get_param_valkind_checked(wasm_func_type_t func_type, - uint32_t param_index) +wasm_runtime_destroy_exec_env_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - wasm_valkind_t original_result = - wasm_func_type_get_param_valkind(func_type, param_index); + wasm_runtime_destroy_exec_env(exec_env); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_func_type_get_result_count_checked(wasm_func_type_t func_type) +wasm_runtime_destroy_spawned_exec_env_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - uint32_t original_result = wasm_func_type_get_result_count(func_type); + wasm_runtime_destroy_spawned_exec_env(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; - } + res.error_code = 0; return res; } static inline Result -wasm_func_type_get_result_valkind_checked(wasm_func_type_t func_type, - uint32_t result_index) +wasm_runtime_destroy_thread_env_checked(void) { Result res; // Execute the original function - wasm_valkind_t original_result = - wasm_func_type_get_result_valkind(func_type, result_index); + wasm_runtime_destroy_thread_env(); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_global_type_get_valkind_checked(wasm_global_type_t global_type) +wasm_runtime_detach_shared_heap_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - wasm_valkind_t original_result = wasm_global_type_get_valkind(global_type); + wasm_runtime_detach_shared_heap(module_inst); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_global_type_get_mutable_checked(wasm_global_type_t global_type) +wasm_runtime_detect_native_stack_overflow_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - _Bool original_result = wasm_global_type_get_mutable(global_type); + _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; @@ -1852,11 +1728,13 @@ wasm_global_type_get_mutable_checked(wasm_global_type_t global_type) } static inline Result -wasm_memory_type_get_shared_checked(wasm_memory_type_t memory_type) +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_memory_type_get_shared(memory_type); + _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; @@ -1864,29 +1742,29 @@ wasm_memory_type_get_shared_checked(wasm_memory_type_t memory_type) } static inline Result -wasm_memory_type_get_init_page_count_checked(wasm_memory_type_t memory_type) +wasm_runtime_dump_call_stack_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - uint32_t original_result = - wasm_memory_type_get_init_page_count(memory_type); + wasm_runtime_dump_call_stack(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; - } + res.error_code = 0; return res; } static inline Result -wasm_memory_type_get_max_page_count_checked(wasm_memory_type_t memory_type) +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_memory_type_get_max_page_count(memory_type); + 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; @@ -1899,40 +1777,40 @@ wasm_memory_type_get_max_page_count_checked(wasm_memory_type_t memory_type) } static inline Result -wasm_table_type_get_elem_kind_checked(wasm_table_type_t table_type) +wasm_runtime_dump_mem_consumption_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - wasm_valkind_t original_result = wasm_table_type_get_elem_kind(table_type); + wasm_runtime_dump_mem_consumption(exec_env); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_table_type_get_shared_checked(wasm_table_type_t table_type) +wasm_runtime_dump_perf_profiling_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - _Bool original_result = wasm_table_type_get_shared(table_type); + wasm_runtime_dump_perf_profiling(module_inst); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_table_type_get_init_size_checked(wasm_table_type_t table_type) +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_table_type_get_init_size(table_type); + 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; @@ -1945,40 +1823,24 @@ wasm_table_type_get_init_size_checked(wasm_table_type_t table_type) } static inline Result -wasm_table_type_get_max_size_checked(wasm_table_type_t table_type) +wasm_runtime_end_blocking_op_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - uint32_t original_result = wasm_table_type_get_max_size(table_type); + wasm_runtime_end_blocking_op(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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_register_natives_checked(void *module_name, void *native_symbols, - uint32_t n_native_symbols) +wasm_runtime_enlarge_memory_checked(wasm_module_inst_t module_inst, + uint64_t inc_page_count) { 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); + _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; @@ -1986,9 +1848,7 @@ wasm_runtime_register_natives_checked(void *module_name, void *native_symbols, } static inline Result -wasm_runtime_register_natives_raw_checked(void *module_name, - void *native_symbols, - uint32_t n_native_symbols) +wasm_runtime_find_module_registered_checked(void *module_name) { Result res; // Check for null pointer parameter: module_name @@ -1996,61 +1856,47 @@ wasm_runtime_register_natives_raw_checked(void *module_name, 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); + wasm_module_t original_result = + wasm_runtime_find_module_registered(module_name); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_unregister_natives_checked(void *module_name, void *native_symbols) +wasm_runtime_free_checked(void *ptr) { 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) { + // Check for null pointer parameter: ptr + if (ptr == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = - wasm_runtime_unregister_natives(module_name, native_symbols); + wasm_runtime_free(ptr); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_get_export_global_inst_checked(wasm_module_inst_t module_inst, - void *name, void *global_inst) +wasm_runtime_full_init_checked(void *init_args) { 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) { + // 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_get_export_global_inst(module_inst, name, global_inst); + _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; @@ -2058,23 +1904,25 @@ wasm_runtime_get_export_global_inst_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_get_export_table_inst_checked(wasm_module_inst_t module_inst, - void *name, void *table_inst) +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: name - if (name == NULL) { + // 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: table_inst - if (table_inst == NULL) { + // 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_export_table_inst(module_inst, name, table_inst); + _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; @@ -2082,22 +1930,15 @@ wasm_runtime_get_export_table_inst_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_table_get_func_inst_checked(wasm_module_inst_t module_inst, - void *table_inst, uint32_t idx) +wasm_runtime_get_call_stack_buf_size_checked(wasm_exec_env_t exec_env) { 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); + uint32_t original_result = wasm_runtime_get_call_stack_buf_size(exec_env); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_function_inst_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -2106,104 +1947,123 @@ wasm_table_get_func_inst_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_get_function_attachment_checked(wasm_exec_env_t exec_env) +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_function_attachment(exec_env); + wasm_runtime_get_context(inst, key); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_set_user_data_checked(wasm_exec_env_t exec_env, void *user_data) +wasm_runtime_get_cur_local_obj_ref_checked(wasm_exec_env_t exec_env) { 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); + 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_user_data_checked(wasm_exec_env_t exec_env) +wasm_runtime_get_current_package_version_checked(package_type_t package_type) { Result res; // Execute the original function - wasm_runtime_get_user_data(exec_env); + uint32_t original_result = + wasm_runtime_get_current_package_version(package_type); // Assign return value and error code - res.error_code = 0; + 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_set_native_stack_boundary_checked(wasm_exec_env_t exec_env, - void *native_stack_boundary) +wasm_runtime_get_custom_data_checked(wasm_module_inst_t module_inst) { 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); + wasm_runtime_get_custom_data(module_inst); // 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) +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_set_instruction_count_limit(exec_env, instruction_count); + 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_dump_mem_consumption_checked(wasm_exec_env_t exec_env) +wasm_runtime_get_default_memory_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - wasm_runtime_dump_mem_consumption(exec_env); + wasm_memory_inst_t original_result = + wasm_runtime_get_default_memory(module_inst); // Assign return value and error code - res.error_code = 0; + 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_dump_perf_profiling_checked(wasm_module_inst_t module_inst) +wasm_runtime_get_exception_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - wasm_runtime_dump_perf_profiling(module_inst); + wasm_runtime_get_exception(module_inst); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_sum_wasm_exec_time_checked(wasm_module_inst_t module_inst) +wasm_runtime_get_exec_env_singleton_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - double original_result = wasm_runtime_sum_wasm_exec_time(module_inst); + wasm_exec_env_t original_result = + wasm_runtime_get_exec_env_singleton(module_inst); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.double_value = original_result; + res.value.wasm_exec_env_t_value = original_result; } else { res.error_code = -2; @@ -2212,22 +2072,15 @@ wasm_runtime_sum_wasm_exec_time_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_get_wasm_func_exec_time_checked(wasm_module_inst_t inst, - void *func_name) +wasm_runtime_get_export_count_checked(wasm_module_t module) { 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); + 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.double_value = original_result; + res.value.int32_t_value = original_result; } else { res.error_code = -2; @@ -2236,66 +2089,86 @@ wasm_runtime_get_wasm_func_exec_time_checked(wasm_module_inst_t inst, } static inline Result -wasm_runtime_set_max_thread_num_checked(uint32_t num) +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 - wasm_runtime_set_max_thread_num(num); + _Bool original_result = + wasm_runtime_get_export_global_inst(module_inst, name, global_inst); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_spawn_exec_env_checked(wasm_exec_env_t exec_env) +wasm_runtime_get_export_table_inst_checked(wasm_module_inst_t module_inst, + void *name, void *table_inst) { 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; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; } - else { - res.error_code = -2; + // 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_destroy_spawned_exec_env_checked(wasm_exec_env_t exec_env) +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_destroy_spawned_exec_env(exec_env); + 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_spawn_thread_checked(wasm_exec_env_t exec_env, void *tid, - wasm_thread_callback_t callback, void *arg) +static inline Result +wasm_runtime_get_file_package_type_checked(void *buf, uint32_t size) { 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) { + // Check for null pointer parameter: buf + if (buf == NULL) { res.error_code = -1; return res; } // Execute the original function - int32_t original_result = - wasm_runtime_spawn_thread(exec_env, tid, callback, arg); + 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.int32_t_value = original_result; + res.value.package_type_t_value = original_result; } else { res.error_code = -2; @@ -2304,20 +2177,20 @@ wasm_runtime_spawn_thread_checked(wasm_exec_env_t exec_env, void *tid, } static inline Result -wasm_runtime_join_thread_checked(wasm_thread_t tid, void *retval) +wasm_runtime_get_file_package_version_checked(void *buf, uint32_t size) { Result res; - // Check for null pointer parameter: retval - if (retval == NULL) { + // Check for null pointer parameter: buf + if (buf == NULL) { res.error_code = -1; return res; } // Execute the original function - int32_t original_result = wasm_runtime_join_thread(tid, retval); + 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.int32_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -2326,81 +2199,61 @@ wasm_runtime_join_thread_checked(wasm_thread_t tid, void *retval) } static inline Result -wasm_externref_obj2ref_checked(wasm_module_inst_t module_inst, void *extern_obj, - void *p_externref_idx) +wasm_runtime_get_function_attachment_checked(wasm_exec_env_t exec_env) { 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); + wasm_runtime_get_function_attachment(exec_env); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_externref_objdel_checked(wasm_module_inst_t module_inst, void *extern_obj) +wasm_runtime_get_import_count_checked(wasm_module_t module) { 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); + int32_t original_result = wasm_runtime_get_import_count(module); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_externref_set_cleanup_checked(wasm_module_inst_t module_inst, - void *extern_obj, void *extern_obj_cleanup) +wasm_runtime_get_import_type_checked(wasm_module_t module, int32_t import_index, + void *import_type) { 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) { + // Check for null pointer parameter: import_type + if (import_type == 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); + wasm_runtime_get_import_type(module, import_index, import_type); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_externref_ref2obj_checked(uint32_t externref_idx, void *p_extern_obj) +wasm_runtime_get_mem_alloc_info_checked(void *mem_alloc_info) { Result res; - // Check for null pointer parameter: p_extern_obj - if (p_extern_obj == NULL) { + // 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_externref_ref2obj(externref_idx, p_extern_obj); + _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; @@ -2408,38 +2261,61 @@ wasm_externref_ref2obj_checked(uint32_t externref_idx, void *p_extern_obj) } static inline Result -wasm_externref_retain_checked(uint32_t externref_idx) +wasm_runtime_get_memory_checked(wasm_module_inst_t module_inst, uint32_t index) { Result res; // Execute the original function - _Bool original_result = wasm_externref_retain(externref_idx); + wasm_memory_inst_t original_result = + wasm_runtime_get_memory(module_inst, index); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_dump_call_stack_checked(wasm_exec_env_t exec_env) +wasm_runtime_get_module_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - wasm_runtime_dump_call_stack(exec_env); + 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_call_stack_buf_size_checked(wasm_exec_env_t exec_env) +wasm_runtime_get_module_inst_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); + wasm_module_inst_t original_result = wasm_runtime_get_module_inst(exec_env); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.uint32_t_value = original_result; + res.value.wasm_module_inst_t_value = original_result; } else { res.error_code = -2; @@ -2448,39 +2324,27 @@ wasm_runtime_get_call_stack_buf_size_checked(wasm_exec_env_t exec_env) } static inline Result -wasm_runtime_dump_call_stack_to_buf_checked(wasm_exec_env_t exec_env, void *buf, - uint32_t len) +wasm_runtime_get_module_name_checked(wasm_module_t module) { 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); + wasm_runtime_get_module_name(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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_get_pgo_prof_data_size_checked(wasm_module_inst_t module_inst) +wasm_runtime_get_module_package_type_checked(wasm_module_t module) { Result res; // Execute the original function - uint32_t original_result = wasm_runtime_get_pgo_prof_data_size(module_inst); + 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.uint32_t_value = original_result; + res.value.package_type_t_value = original_result; } else { res.error_code = -2; @@ -2489,18 +2353,11 @@ wasm_runtime_get_pgo_prof_data_size_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_dump_pgo_prof_data_to_buf_checked(wasm_module_inst_t module_inst, - void *buf, uint32_t len) +wasm_runtime_get_module_package_version_checked(wasm_module_t module) { 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); + 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; @@ -2513,228 +2370,268 @@ wasm_runtime_dump_pgo_prof_data_to_buf_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_get_custom_section_checked(wasm_module_t module_comm, void *name, - void *len) +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: name - if (name == NULL) { + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: len - if (len == NULL) { + // 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 - wasm_runtime_get_custom_section(module_comm, name, len); + _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 = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_get_version_checked(void *major, void *minor, void *patch) +wasm_runtime_get_pgo_prof_data_size_checked(wasm_module_inst_t module_inst) { 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); + uint32_t original_result = wasm_runtime_get_pgo_prof_data_size(module_inst); // Assign return value and error code - res.error_code = 0; + 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_is_import_func_linked_checked(void *module_name, void *func_name) +wasm_runtime_get_running_mode_checked(wasm_module_inst_t module_inst) { Result res; - // Check for null pointer parameter: module_name - if (module_name == NULL) { - res.error_code = -1; - return 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; } - // Check for null pointer parameter: func_name - if (func_name == NULL) { - res.error_code = -1; - return res; + 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 - _Bool original_result = - wasm_runtime_is_import_func_linked(module_name, func_name); + wasm_runtime_get_user_data(exec_env); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_is_import_global_linked_checked(void *module_name, - void *global_name) +wasm_runtime_get_version_checked(void *major, void *minor, void *patch) { Result res; - // Check for null pointer parameter: module_name - if (module_name == NULL) { + // Check for null pointer parameter: major + if (major == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: global_name - if (global_name == NULL) { + // 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 - _Bool original_result = - wasm_runtime_is_import_global_linked(module_name, global_name); + wasm_runtime_get_version(major, minor, patch); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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) +wasm_runtime_get_wasi_exit_code_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - _Bool original_result = - wasm_runtime_enlarge_memory(module_inst, inc_page_count); + uint32_t original_result = wasm_runtime_get_wasi_exit_code(module_inst); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_set_enlarge_mem_error_callback_checked( - enlarge_memory_error_callback_t callback, void *user_data) +wasm_runtime_get_wasm_func_exec_time_checked(wasm_module_inst_t inst, + void *func_name) { Result res; - // Check for null pointer parameter: user_data - if (user_data == NULL) { + // Check for null pointer parameter: func_name + if (func_name == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_set_enlarge_mem_error_callback(callback, user_data); + double original_result = + wasm_runtime_get_wasm_func_exec_time(inst, func_name); // Assign return value and error code - res.error_code = 0; + 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_create_context_key_checked(void *dtor) +wasm_runtime_init_checked(void) { 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); + _Bool original_result = wasm_runtime_init(); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_destroy_context_key_checked(void *key) +wasm_runtime_init_thread_env_checked(void) { 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); + _Bool original_result = wasm_runtime_init_thread_env(); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_set_context_checked(wasm_module_inst_t inst, void *key, void *ctx) +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: key - if (key == NULL) { - res.error_code = -1; - return res; - } - // Check for null pointer parameter: ctx - if (ctx == NULL) { + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_set_context(inst, key, ctx); + 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 - res.error_code = 0; + 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_set_context_spread_checked(wasm_module_inst_t inst, void *key, - void *ctx) +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: key - if (key == NULL) { + // Check for null pointer parameter: args + if (args == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: ctx - if (ctx == NULL) { + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_set_context_spread(inst, key, ctx); + wasm_module_inst_t original_result = + wasm_runtime_instantiate_ex(module, args, error_buf, error_buf_size); // Assign return value and error code - res.error_code = 0; + 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_context_checked(wasm_module_inst_t inst, void *key) +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: key - if (key == NULL) { + // 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_runtime_get_context(inst, key); + wasm_module_inst_t original_result = + wasm_runtime_instantiate_ex2(module, args, error_buf, error_buf_size); // Assign return value and error code - res.error_code = 0; + 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_begin_blocking_op_checked(wasm_exec_env_t exec_env) +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_begin_blocking_op(exec_env); + _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; @@ -2742,71 +2639,78 @@ wasm_runtime_begin_blocking_op_checked(wasm_exec_env_t exec_env) } static inline Result -wasm_runtime_end_blocking_op_checked(wasm_exec_env_t exec_env) +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_end_blocking_op(exec_env); + wasm_runtime_instantiation_args_destroy(p); // 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) +wasm_runtime_instantiation_args_set_default_stack_size_checked(void *p, + uint32_t v) { 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) { + // Check for null pointer parameter: p + if (p == 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); + wasm_runtime_instantiation_args_set_default_stack_size(p, v); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_get_module_name_checked(wasm_module_t module) +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_get_module_name(module); + 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_detect_native_stack_overflow_checked(wasm_exec_env_t exec_env) +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 - _Bool original_result = wasm_runtime_detect_native_stack_overflow(exec_env); + wasm_runtime_instantiation_args_set_max_memory_pages(p, v); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_detect_native_stack_overflow_size_checked(wasm_exec_env_t exec_env, - uint32_t required_size) +wasm_runtime_is_bounds_checks_enabled_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - _Bool original_result = - wasm_runtime_detect_native_stack_overflow_size(exec_env, required_size); + _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; @@ -2814,11 +2718,22 @@ wasm_runtime_detect_native_stack_overflow_size_checked(wasm_exec_env_t exec_env, } static inline Result -wasm_runtime_is_underlying_binary_freeable_checked(wasm_module_t module) +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_underlying_binary_freeable(module); + _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; @@ -2826,74 +2741,60 @@ wasm_runtime_is_underlying_binary_freeable_checked(wasm_module_t module) } static inline Result -wasm_runtime_create_shared_heap_checked(void *init_args) +wasm_runtime_is_import_global_linked_checked(void *module_name, + void *global_name) { Result res; - // Check for null pointer parameter: init_args - if (init_args == NULL) { + // 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 - wasm_shared_heap_t original_result = - wasm_runtime_create_shared_heap(init_args); + _Bool original_result = + wasm_runtime_is_import_global_linked(module_name, global_name); // 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; - } + 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) +wasm_runtime_is_running_mode_supported_checked(RunningMode running_mode) { Result res; // Execute the original function - wasm_shared_heap_t original_result = - wasm_runtime_chain_shared_heaps(head, body); + _Bool original_result = + wasm_runtime_is_running_mode_supported(running_mode); // 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; - } + 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) +wasm_runtime_is_underlying_binary_freeable_checked(wasm_module_t module) { Result res; // Execute the original function - wasm_shared_heap_t original_result = - wasm_runtime_unchain_shared_heaps(head, entire_chain); + _Bool original_result = wasm_runtime_is_underlying_binary_freeable(module); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_attach_shared_heap_checked(wasm_module_inst_t module_inst, - wasm_shared_heap_t shared_heap) +wasm_runtime_is_wasi_mode_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - _Bool original_result = - wasm_runtime_attach_shared_heap(module_inst, shared_heap); + _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; @@ -2901,33 +2802,37 @@ wasm_runtime_attach_shared_heap_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_detach_shared_heap_checked(wasm_module_inst_t module_inst) +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 - wasm_runtime_detach_shared_heap(module_inst); + _Bool original_result = wasm_runtime_is_xip_file(buf, size); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_shared_heap_malloc_checked(wasm_module_inst_t module_inst, - uint64_t size, void *p_native_addr) +wasm_runtime_join_thread_checked(wasm_thread_t tid, void *retval) { Result res; - // Check for null pointer parameter: p_native_addr - if (p_native_addr == NULL) { + // Check for null pointer parameter: retval + if (retval == 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); + 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.uint64_t_value = original_result; + res.value.int32_t_value = original_result; } else { res.error_code = -2; @@ -2936,27 +2841,27 @@ wasm_runtime_shared_heap_malloc_checked(wasm_module_inst_t module_inst, } 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_get_defined_type_count_checked(wasm_module_t module) +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 - uint32_t original_result = wasm_get_defined_type_count(module); + wasm_module_t original_result = + wasm_runtime_load(buf, size, error_buf, error_buf_size); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.uint32_t_value = original_result; + res.value.wasm_module_t_value = original_result; } else { res.error_code = -2; @@ -2965,15 +2870,32 @@ wasm_get_defined_type_count_checked(wasm_module_t module) } static inline Result -wasm_get_defined_type_checked(wasm_module_t module, uint32_t index) +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_defined_type_t original_result = wasm_get_defined_type(module, index); + 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_defined_type_t_value = original_result; + res.value.wasm_module_t_value = original_result; } else { res.error_code = -2; @@ -2982,15 +2904,23 @@ wasm_get_defined_type_checked(wasm_module_t module, uint32_t index) } static inline Result -wasm_obj_get_defined_type_checked(wasm_obj_t obj) +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_defined_type_t original_result = wasm_obj_get_defined_type(obj); + 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_defined_type_t_value = original_result; + res.value.wasm_module_t_value = original_result; } else { res.error_code = -2; @@ -2999,15 +2929,21 @@ wasm_obj_get_defined_type_checked(wasm_obj_t obj) } static inline Result -wasm_obj_get_defined_type_idx_checked(wasm_module_t module, wasm_obj_t obj) +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 - int32_t original_result = wasm_obj_get_defined_type_idx(module, obj); + wasm_function_inst_t original_result = + wasm_runtime_lookup_function(module_inst, name); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.int32_t_value = original_result; + res.value.wasm_function_inst_t_value = original_result; } else { res.error_code = -2; @@ -3016,53 +2952,74 @@ wasm_obj_get_defined_type_idx_checked(wasm_module_t module, wasm_obj_t obj) } static inline Result -wasm_defined_type_is_func_type_checked(wasm_defined_type_t def_type) +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 - _Bool original_result = wasm_defined_type_is_func_type(def_type); + wasm_memory_inst_t original_result = + wasm_runtime_lookup_memory(module_inst, name); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_defined_type_is_struct_type_checked(wasm_defined_type_t def_type) +wasm_runtime_lookup_wasi_start_function_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - _Bool original_result = wasm_defined_type_is_struct_type(def_type); + wasm_function_inst_t original_result = + wasm_runtime_lookup_wasi_start_function(module_inst); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_defined_type_is_array_type_checked(wasm_defined_type_t def_type) +wasm_runtime_malloc_checked(unsigned int size) { Result res; // Execute the original function - _Bool original_result = wasm_defined_type_is_array_type(def_type); + wasm_runtime_malloc(size); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_func_type_get_param_type_checked(wasm_func_type_t func_type, - uint32_t param_idx) +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 - wasm_ref_type_t original_result = - wasm_func_type_get_param_type(func_type, param_idx); + 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.wasm_ref_type_t_value = original_result; + res.value.uint64_t_value = original_result; } else { res.error_code = -2; @@ -3071,34 +3028,33 @@ wasm_func_type_get_param_type_checked(wasm_func_type_t func_type, } static inline Result -wasm_func_type_get_result_type_checked(wasm_func_type_t func_type, - uint32_t result_idx) +wasm_runtime_module_free_checked(wasm_module_inst_t module_inst, uint64_t ptr) { Result res; // Execute the original function - wasm_ref_type_t original_result = - wasm_func_type_get_result_type(func_type, result_idx); + wasm_runtime_module_free(module_inst, ptr); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_struct_type_get_field_count_checked(wasm_struct_type_t struct_type) +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 - uint32_t original_result = wasm_struct_type_get_field_count(struct_type); + 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.uint32_t_value = original_result; + res.value.uint64_t_value = original_result; } else { res.error_code = -2; @@ -3107,134 +3063,114 @@ wasm_struct_type_get_field_count_checked(wasm_struct_type_t struct_type) } static inline Result -wasm_struct_type_get_field_type_checked(wasm_struct_type_t struct_type, - uint32_t field_idx, void *p_is_mutable) +wasm_runtime_pin_object_checked(wasm_exec_env_t exec_env, wasm_obj_t obj) { 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); + _Bool original_result = wasm_runtime_pin_object(exec_env, obj); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; 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; - } +static inline Result +wasm_runtime_pop_local_obj_ref_checked(wasm_exec_env_t exec_env) +{ + Result res; // Execute the original function - wasm_ref_type_t original_result = - wasm_array_type_get_elem_type(array_type, p_is_mutable); + wasm_runtime_pop_local_obj_ref(exec_env); // 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; - } + res.error_code = 0; 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) +wasm_runtime_pop_local_obj_refs_checked(wasm_exec_env_t exec_env, uint32_t n) { Result res; // Execute the original function - _Bool original_result = - wasm_defined_type_equal(def_type1, def_type2, module); + wasm_runtime_pop_local_obj_refs(exec_env, n); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; 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) +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 - _Bool original_result = - wasm_defined_type_is_subtype_of(def_type1, def_type2, module); + wasm_runtime_push_local_obj_ref(exec_env, local_obj_ref); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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) +wasm_runtime_realloc_checked(void *ptr, unsigned int size) { Result res; - // Check for null pointer parameter: ref_type - if (ref_type == NULL) { + // Check for null pointer parameter: ptr + if (ptr == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_ref_type_set_type_idx(ref_type, nullable, type_idx); + wasm_runtime_realloc(ptr, size); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_type_set_heap_type_checked(void *ref_type, _Bool nullable, - int32_t heap_type) +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: ref_type - if (ref_type == NULL) { + // 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 - wasm_ref_type_set_heap_type(ref_type, nullable, heap_type); + _Bool original_result = wasm_runtime_register_module( + module_name, module, error_buf, error_buf_size); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_ref_type_equal_checked(void *ref_type1, void *ref_type2, - wasm_module_t module) +wasm_runtime_register_natives_checked(void *module_name, void *native_symbols, + uint32_t n_native_symbols) { Result res; - // Check for null pointer parameter: ref_type1 - if (ref_type1 == NULL) { + // Check for null pointer parameter: module_name + if (module_name == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: ref_type2 - if (ref_type2 == NULL) { + // 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_ref_type_equal(ref_type1, ref_type2, module); + _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; @@ -3242,23 +3178,24 @@ wasm_ref_type_equal_checked(void *ref_type1, void *ref_type2, } static inline Result -wasm_ref_type_is_subtype_of_checked(void *ref_type1, void *ref_type2, - wasm_module_t module) +wasm_runtime_register_natives_raw_checked(void *module_name, + void *native_symbols, + uint32_t n_native_symbols) { Result res; - // Check for null pointer parameter: ref_type1 - if (ref_type1 == NULL) { + // Check for null pointer parameter: module_name + if (module_name == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: ref_type2 - if (ref_type2 == NULL) { + // 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_ref_type_is_subtype_of(ref_type1, ref_type2, module); + _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; @@ -3266,375 +3203,352 @@ wasm_ref_type_is_subtype_of_checked(void *ref_type1, void *ref_type2, } static inline Result -wasm_struct_obj_new_with_typeidx_checked(wasm_exec_env_t exec_env, - uint32_t type_idx) +wasm_runtime_resolve_symbols_checked(wasm_module_t module) { Result res; // Execute the original function - wasm_struct_obj_t original_result = - wasm_struct_obj_new_with_typeidx(exec_env, type_idx); + _Bool original_result = wasm_runtime_resolve_symbols(module); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_struct_obj_new_with_type_checked(wasm_exec_env_t exec_env, - wasm_struct_type_t type) +wasm_runtime_set_bounds_checks_checked(wasm_module_inst_t module_inst, + _Bool enable) { Result res; // Execute the original function - wasm_struct_obj_t original_result = - wasm_struct_obj_new_with_type(exec_env, type); + wasm_runtime_set_bounds_checks(module_inst, enable); // Assign return value and error code - if (original_result != NULL) { - res.error_code = 0; - res.value.wasm_struct_obj_t_value = original_result; + 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; } - else { - res.error_code = -2; + // 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_struct_obj_set_field_checked(wasm_struct_obj_t obj, uint32_t field_idx, - void *value) +wasm_runtime_set_context_spread_checked(wasm_module_inst_t inst, void *key, + void *ctx) { Result res; - // Check for null pointer parameter: value - if (value == NULL) { + // 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_struct_obj_set_field(obj, field_idx, value); + wasm_runtime_set_context_spread(inst, key, ctx); // Assign return value and error code res.error_code = 0; 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) +wasm_runtime_set_custom_data_checked(wasm_module_inst_t module_inst, + void *custom_data) { Result res; - // Check for null pointer parameter: value - if (value == NULL) { + // Check for null pointer parameter: custom_data + if (custom_data == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_struct_obj_get_field(obj, field_idx, sign_extend, value); + 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_struct_obj_get_field_count_checked(wasm_struct_obj_t obj) +wasm_runtime_set_default_running_mode_checked(RunningMode running_mode) { Result res; // Execute the original function - uint32_t original_result = wasm_struct_obj_get_field_count(obj); + _Bool original_result = wasm_runtime_set_default_running_mode(running_mode); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; 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) +wasm_runtime_set_enlarge_mem_error_callback_checked( + enlarge_memory_error_callback_t callback, void *user_data) { Result res; - // Check for null pointer parameter: init_value - if (init_value == NULL) { + // Check for null pointer parameter: user_data + if (user_data == 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); + wasm_runtime_set_enlarge_mem_error_callback(callback, user_data); // 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; - } + res.error_code = 0; 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) +wasm_runtime_set_exception_checked(wasm_module_inst_t module_inst, + void *exception) { Result res; - // Check for null pointer parameter: init_value - if (init_value == NULL) { + // Check for null pointer parameter: exception + if (exception == 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); + wasm_runtime_set_exception(module_inst, exception); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_array_obj_set_elem_checked(wasm_array_obj_t array_obj, uint32_t elem_idx, - void *value) +wasm_runtime_set_instruction_count_limit_checked(wasm_exec_env_t exec_env, + int instruction_count) { 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); + 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_array_obj_get_elem_checked(wasm_array_obj_t array_obj, uint32_t elem_idx, - _Bool sign_extend, void *value) +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; - // 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); + wasm_runtime_set_max_thread_num(num); // Assign return value and error code res.error_code = 0; 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) +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_array_obj_copy(dst_obj, dst_idx, src_obj, src_idx, len); + 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_array_obj_length_checked(wasm_array_obj_t array_obj) +wasm_runtime_set_module_name_checked(wasm_module_t module, void *name, + void *error_buf, uint32_t error_buf_size) { 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; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; } - else { - res.error_code = -2; + // 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_array_obj_first_elem_addr_checked(wasm_array_obj_t array_obj) +wasm_runtime_set_module_reader_checked(module_reader reader, + module_destroyer destroyer) { Result res; // Execute the original function - wasm_array_obj_first_elem_addr(array_obj); + wasm_runtime_set_module_reader(reader, destroyer); // 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) +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_array_obj_elem_addr(array_obj, elem_idx); + 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_func_obj_new_with_typeidx_checked(wasm_exec_env_t exec_env, - uint32_t type_idx, - uint32_t func_idx_bound) +wasm_runtime_set_running_mode_checked(wasm_module_inst_t module_inst, + RunningMode running_mode) { 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); + _Bool original_result = + wasm_runtime_set_running_mode(module_inst, running_mode); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; 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) +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_func_obj_t original_result = - wasm_func_obj_new_with_type(exec_env, type, func_idx_bound); + wasm_runtime_set_user_data(exec_env, user_data); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_func_obj_get_func_idx_bound_checked(wasm_func_obj_t func_obj) +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 - uint32_t original_result = wasm_func_obj_get_func_idx_bound(func_obj); + wasm_runtime_set_wasi_addr_pool(module, addr_pool, addr_pool_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; - } + res.error_code = 0; return res; } static inline Result -wasm_func_obj_get_func_type_checked(wasm_func_obj_t func_obj) +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_func_type_t original_result = wasm_func_obj_get_func_type(func_obj); + 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 - if (original_result != NULL) { - res.error_code = 0; - res.value.wasm_func_type_t_value = original_result; - } - else { - res.error_code = -2; - } + res.error_code = 0; 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) +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 - _Bool original_result = - wasm_runtime_call_func_ref(exec_env, func_obj, argc, argv); + 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 = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; 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) +wasm_runtime_set_wasi_ns_lookup_pool_checked(wasm_module_t module, + void *ns_lookup_pool, + uint32_t ns_lookup_pool_size) { 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); + wasm_runtime_set_wasi_ns_lookup_pool(module, ns_lookup_pool, + ns_lookup_pool_size); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; 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, ...) +wasm_runtime_shared_heap_free_checked(wasm_module_inst_t module_inst, + uint64_t ptr) { 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); + wasm_runtime_shared_heap_free(module_inst, ptr); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_externref_obj_new_checked(wasm_exec_env_t exec_env, void *host_obj) +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: host_obj - if (host_obj == NULL) { + // Check for null pointer parameter: p_native_addr + if (p_native_addr == 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); + uint64_t original_result = + wasm_runtime_shared_heap_malloc(module_inst, size, p_native_addr); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_externref_obj_t_value = original_result; + res.value.uint64_t_value = original_result; } else { res.error_code = -2; @@ -3643,31 +3557,44 @@ wasm_externref_obj_new_checked(wasm_exec_env_t exec_env, void *host_obj) } static inline Result -wasm_externref_obj_get_value_checked(wasm_externref_obj_t externref_obj) +wasm_runtime_spawn_exec_env_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - wasm_externref_obj_get_value(externref_obj); + wasm_exec_env_t original_result = wasm_runtime_spawn_exec_env(exec_env); // Assign return value and error code - res.error_code = 0; + 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_anyref_obj_new_checked(wasm_exec_env_t exec_env, void *host_obj) +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: host_obj - if (host_obj == NULL) { + // 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 - wasm_anyref_obj_t original_result = wasm_anyref_obj_new(exec_env, host_obj); + int32_t original_result = + wasm_runtime_spawn_thread(exec_env, tid, callback, arg); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_anyref_obj_t_value = original_result; + res.value.int32_t_value = original_result; } else { res.error_code = -2; @@ -3676,27 +3603,34 @@ wasm_anyref_obj_new_checked(wasm_exec_env_t exec_env, void *host_obj) } static inline Result -wasm_anyref_obj_get_value_checked(wasm_anyref_obj_t anyref_obj) +wasm_runtime_start_debug_instance_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - wasm_anyref_obj_get_value(anyref_obj); + uint32_t original_result = wasm_runtime_start_debug_instance(exec_env); // Assign return value and error code - res.error_code = 0; + 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_obj_to_internal_obj_checked(wasm_externref_obj_t externref_obj) +wasm_runtime_start_debug_instance_with_port_checked(wasm_exec_env_t exec_env, + int32_t port) { Result res; // Execute the original function - wasm_obj_t original_result = - wasm_externref_obj_to_internal_obj(externref_obj); + uint32_t original_result = + wasm_runtime_start_debug_instance_with_port(exec_env, port); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_obj_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -3705,17 +3639,15 @@ wasm_externref_obj_to_internal_obj_checked(wasm_externref_obj_t externref_obj) } static inline Result -wasm_internal_obj_to_externref_obj_checked(wasm_exec_env_t exec_env, - wasm_obj_t internal_obj) +wasm_runtime_sum_wasm_exec_time_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - wasm_externref_obj_t original_result = - wasm_internal_obj_to_externref_obj(exec_env, internal_obj); + double original_result = wasm_runtime_sum_wasm_exec_time(module_inst); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_externref_obj_t_value = original_result; + res.value.double_value = original_result; } else { res.error_code = -2; @@ -3724,32 +3656,40 @@ wasm_internal_obj_to_externref_obj_checked(wasm_exec_env_t exec_env, } static inline Result -wasm_i31_obj_new_checked(uint32_t i31_value) +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 - wasm_i31_obj_t original_result = wasm_i31_obj_new(i31_value); + _Bool original_result = wasm_runtime_thread_env_inited(); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_i31_obj_get_value_checked(wasm_i31_obj_t i31_obj, _Bool sign_extend) +wasm_runtime_unchain_shared_heaps_checked(wasm_shared_heap_t head, + _Bool entire_chain) { Result res; // Execute the original function - uint32_t original_result = wasm_i31_obj_get_value(i31_obj, sign_extend); + wasm_shared_heap_t original_result = + wasm_runtime_unchain_shared_heaps(head, entire_chain); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.uint32_t_value = original_result; + res.value.wasm_shared_heap_t_value = original_result; } else { res.error_code = -2; @@ -3758,14 +3698,13 @@ wasm_i31_obj_get_value_checked(wasm_i31_obj_t i31_obj, _Bool sign_extend) } static inline Result -wasm_runtime_pin_object_checked(wasm_exec_env_t exec_env, wasm_obj_t obj) +wasm_runtime_unload_checked(wasm_module_t module) { Result res; // Execute the original function - _Bool original_result = wasm_runtime_pin_object(exec_env, obj); + wasm_runtime_unload(module); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } @@ -3782,11 +3721,22 @@ wasm_runtime_unpin_object_checked(wasm_exec_env_t exec_env, wasm_obj_t obj) } static inline Result -wasm_obj_is_struct_obj_checked(wasm_obj_t obj) +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_obj_is_struct_obj(obj); + _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; @@ -3794,11 +3744,13 @@ wasm_obj_is_struct_obj_checked(wasm_obj_t obj) } static inline Result -wasm_obj_is_array_obj_checked(wasm_obj_t obj) +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_obj_is_array_obj(obj); + _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; @@ -3806,11 +3758,13 @@ wasm_obj_is_array_obj_checked(wasm_obj_t obj) } static inline Result -wasm_obj_is_func_obj_checked(wasm_obj_t obj) +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_obj_is_func_obj(obj); + _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; @@ -3818,11 +3772,18 @@ wasm_obj_is_func_obj_checked(wasm_obj_t obj) } static inline Result -wasm_obj_is_i31_obj_checked(wasm_obj_t obj) +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_obj_is_i31_obj(obj); + _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; @@ -3830,181 +3791,220 @@ wasm_obj_is_i31_obj_checked(wasm_obj_t obj) } static inline Result -wasm_obj_is_externref_obj_checked(wasm_obj_t obj) +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 - _Bool original_result = wasm_obj_is_externref_obj(obj); + wasm_struct_obj_get_field(obj, field_idx, sign_extend, value); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_obj_is_anyref_obj_checked(wasm_obj_t obj) +wasm_struct_obj_get_field_count_checked(wasm_struct_obj_t obj) { Result res; // Execute the original function - _Bool original_result = wasm_obj_is_anyref_obj(obj); + uint32_t original_result = wasm_struct_obj_get_field_count(obj); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_obj_is_internal_obj_checked(wasm_obj_t obj) +wasm_struct_obj_new_with_type_checked(wasm_exec_env_t exec_env, + wasm_struct_type_t type) { Result res; // Execute the original function - _Bool original_result = wasm_obj_is_internal_obj(obj); + wasm_struct_obj_t original_result = + wasm_struct_obj_new_with_type(exec_env, type); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_obj_is_eq_obj_checked(wasm_obj_t obj) +wasm_struct_obj_new_with_typeidx_checked(wasm_exec_env_t exec_env, + uint32_t type_idx) { Result res; // Execute the original function - _Bool original_result = wasm_obj_is_eq_obj(obj); + wasm_struct_obj_t original_result = + wasm_struct_obj_new_with_typeidx(exec_env, type_idx); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_obj_is_instance_of_defined_type_checked(wasm_obj_t obj, - wasm_defined_type_t defined_type, - wasm_module_t module) +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 - _Bool original_result = - wasm_obj_is_instance_of_defined_type(obj, defined_type, module); + wasm_struct_obj_set_field(obj, field_idx, value); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; 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) +wasm_struct_type_get_field_count_checked(wasm_struct_type_t struct_type) { Result res; // Execute the original function - _Bool original_result = - wasm_obj_is_instance_of_type_idx(obj, type_idx, module); + uint32_t original_result = wasm_struct_type_get_field_count(struct_type); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_obj_is_instance_of_ref_type_checked(wasm_obj_t obj, void *ref_type) +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: ref_type - if (ref_type == NULL) { + // Check for null pointer parameter: p_is_mutable + if (p_is_mutable == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = wasm_obj_is_instance_of_ref_type(obj, ref_type); + 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 - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_runtime_push_local_obj_ref_checked(wasm_exec_env_t exec_env, - void *local_obj_ref) +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: local_obj_ref - if (local_obj_ref == NULL) { + // Check for null pointer parameter: table_inst + if (table_inst == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_push_local_obj_ref(exec_env, local_obj_ref); + wasm_function_inst_t original_result = + wasm_table_get_func_inst(module_inst, table_inst, idx); // Assign return value and error code - res.error_code = 0; + 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_pop_local_obj_ref_checked(wasm_exec_env_t exec_env) +wasm_table_type_get_elem_kind_checked(wasm_table_type_t table_type) { Result res; // Execute the original function - wasm_runtime_pop_local_obj_ref(exec_env); + wasm_valkind_t original_result = wasm_table_type_get_elem_kind(table_type); // Assign return value and error code - res.error_code = 0; + 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_runtime_pop_local_obj_refs_checked(wasm_exec_env_t exec_env, uint32_t n) +wasm_table_type_get_init_size_checked(wasm_table_type_t table_type) { Result res; // Execute the original function - wasm_runtime_pop_local_obj_refs(exec_env, n); + uint32_t original_result = wasm_table_type_get_init_size(table_type); // Assign return value and error code - res.error_code = 0; + 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_cur_local_obj_ref_checked(wasm_exec_env_t exec_env) +wasm_table_type_get_max_size_checked(wasm_table_type_t table_type) { Result res; // Execute the original function - wasm_runtime_get_cur_local_obj_ref(exec_env); + uint32_t original_result = wasm_table_type_get_max_size(table_type); // Assign return value and error code - res.error_code = 0; + 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_obj_set_gc_finalizer_checked(wasm_exec_env_t exec_env, wasm_obj_t obj, - wasm_obj_finalizer_t cb, void *data) +wasm_table_type_get_shared_checked(wasm_table_type_t table_type) { 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); + _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; } -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; -} - #endif // GC_EXPORT_CHECKED_H diff --git a/core/iwasm/include/wasm_c_api_checked.h b/core/iwasm/include/wasm_c_api_checked.h index b6aa24b748..05a7582438 100644 --- a/core/iwasm/include/wasm_c_api_checked.h +++ b/core/iwasm/include/wasm_c_api_checked.h @@ -19,123 +19,87 @@ typedef struct { int error_code; // Error code (0 for success, non-zero for errors) union { - wasm_valkind_t wasm_valkind_t_value; - wasm_mutability_t wasm_mutability_t_value; - uint32_t uint32_t_value; - wasm_table_size_t wasm_table_size_t_value; _Bool _Bool_value; double double_value; - wasm_externkind_t wasm_externkind_t_value; - wasm_memory_pages_t wasm_memory_pages_t_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 -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 -memmove_checked(void *__dest, void *__src, size_t __n) +__assert_checked(void *__assertion, void *__file, int __line) { Result res; - // Check for null pointer parameter: __dest - if (__dest == NULL) { + // Check for null pointer parameter: __assertion + if (__assertion == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __src - if (__src == NULL) { + // Check for null pointer parameter: __file + if (__file == NULL) { res.error_code = -1; return res; } // Execute the original function - memmove(__dest, __src, __n); + __assert(__assertion, __file, __line); // 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) +__assert_fail_checked(void *__assertion, void *__file, unsigned int __line, + void *__function) { Result res; - // Check for null pointer parameter: __dest - if (__dest == NULL) { + // Check for null pointer parameter: __assertion + if (__assertion == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __src - if (__src == NULL) { + // Check for null pointer parameter: __file + if (__file == 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 -memset_checked(void *__s, int __c, size_t __n) -{ - Result res; - // Check for null pointer parameter: __s - if (__s == NULL) { + // Check for null pointer parameter: __function + if (__function == NULL) { res.error_code = -1; return res; } // Execute the original function - memset(__s, __c, __n); + __assert_fail(__assertion, __file, __line, __function); // Assign return value and error code res.error_code = 0; return res; } static inline Result -memcmp_checked(void *__s1, void *__s2, size_t __n) +__assert_perror_fail_checked(int __errnum, void *__file, unsigned int __line, + void *__function) { Result res; - // Check for null pointer parameter: __s1 - if (__s1 == NULL) { + // Check for null pointer parameter: __file + if (__file == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __s2 - if (__s2 == NULL) { + // Check for null pointer parameter: __function + if (__function == NULL) { res.error_code = -1; return res; } // Execute the original function - int original_result = memcmp(__s1, __s2, __n); + __assert_perror_fail(__errnum, __file, __line, __function); // 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; - } + res.error_code = 0; return res; } @@ -167,23 +131,7 @@ __memcmpeq_checked(void *__s1, void *__s2, size_t __n) } 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 -strcpy_checked(void *__dest, void *__src) +__stpcpy_checked(void *__dest, void *__src) { Result res; // Check for null pointer parameter: __dest @@ -197,14 +145,14 @@ strcpy_checked(void *__dest, void *__src) return res; } // Execute the original function - strcpy(__dest, __src); + __stpcpy(__dest, __src); // Assign return value and error code res.error_code = 0; return res; } static inline Result -strncpy_checked(void *__dest, void *__src, size_t __n) +__stpncpy_checked(void *__dest, void *__src, size_t __n) { Result res; // Check for null pointer parameter: __dest @@ -218,56 +166,40 @@ strncpy_checked(void *__dest, void *__src, size_t __n) return res; } // Execute the original function - strncpy(__dest, __src, __n); + __stpncpy(__dest, __src, __n); // Assign return value and error code res.error_code = 0; return res; } static inline Result -strcat_checked(void *__dest, void *__src) +__strtok_r_checked(void *__s, void *__delim, void *__save_ptr) { 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) { + // Check for null pointer parameter: __s + if (__s == NULL) { res.error_code = -1; return res; } - // Execute the original function - strcat(__dest, __src); - // Assign return value and error code - res.error_code = 0; - 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) { + // Check for null pointer parameter: __delim + if (__delim == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __src - if (__src == NULL) { + // Check for null pointer parameter: __save_ptr + if (__save_ptr == NULL) { res.error_code = -1; return res; } // Execute the original function - strncat(__dest, __src, __n); + __strtok_r(__s, __delim, __save_ptr); // Assign return value and error code res.error_code = 0; return res; } static inline Result -strcmp_checked(void *__s1, void *__s2) +bcmp_checked(void *__s1, void *__s2, size_t __n) { Result res; // Check for null pointer parameter: __s1 @@ -281,7 +213,7 @@ strcmp_checked(void *__s1, void *__s2) return res; } // Execute the original function - int original_result = strcmp(__s1, __s2); + int original_result = bcmp(__s1, __s2, __n); // Assign return value and error code if (original_result == 0) { res.error_code = 0; @@ -294,48 +226,64 @@ strcmp_checked(void *__s1, void *__s2) } static inline Result -strncmp_checked(void *__s1, void *__s2, size_t __n) +bcopy_checked(void *__src, void *__dest, size_t __n) { Result res; - // Check for null pointer parameter: __s1 - if (__s1 == NULL) { + // Check for null pointer parameter: __src + if (__src == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __s2 - if (__s2 == NULL) { + // Check for null pointer parameter: __dest + if (__dest == NULL) { res.error_code = -1; return res; } // Execute the original function - int original_result = strncmp(__s1, __s2, __n); + bcopy(__src, __dest, __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; - } + res.error_code = 0; return res; } static inline Result -strcoll_checked(void *__s1, void *__s2) +bzero_checked(void *__s, size_t __n) { Result res; - // Check for null pointer parameter: __s1 - if (__s1 == NULL) { + // Check for null pointer parameter: __s + if (__s == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __s2 - if (__s2 == NULL) { + // 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 - int original_result = strcoll(__s1, __s2); + 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; @@ -348,25 +296,15 @@ strcoll_checked(void *__s1, void *__s2) } static inline Result -strxfrm_checked(void *__dest, void *__src, size_t __n) +ffsl_checked(long int __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(__dest, __src, __n); + int original_result = ffsl(__l); // Assign return value and error code if (original_result == 0) { res.error_code = 0; - res.value.size_t_value = original_result; + res.value.int_value = original_result; } else { res.error_code = -2; @@ -375,21 +313,11 @@ strxfrm_checked(void *__dest, void *__src, size_t __n) } static inline Result -strcoll_l_checked(void *__s1, void *__s2, locale_t __l) +ffsll_checked(long long int __ll) { 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); + int original_result = ffsll(__ll); // Assign return value and error code if (original_result == 0) { res.error_code = 0; @@ -402,7 +330,23 @@ strcoll_l_checked(void *__s1, void *__s2, locale_t __l) } static inline Result -strxfrm_l_checked(void *__dest, void *__src, size_t __n, locale_t __l) +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 @@ -416,20 +360,14 @@ strxfrm_l_checked(void *__dest, void *__src, size_t __n, locale_t __l) return res; } // Execute the original function - size_t original_result = strxfrm_l(__dest, __src, __n, __l); + memccpy(__dest, __src, __c, __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; - } + res.error_code = 0; return res; } static inline Result -strdup_checked(void *__s) +memchr_checked(void *__s, int __c, size_t __n) { Result res; // Check for null pointer parameter: __s @@ -438,62 +376,83 @@ strdup_checked(void *__s) return res; } // Execute the original function - strdup(__s); + memchr(__s, __c, __n); // Assign return value and error code res.error_code = 0; return res; } static inline Result -strndup_checked(void *__string, size_t __n) +memcmp_checked(void *__s1, void *__s2, size_t __n) { Result res; - // Check for null pointer parameter: __string - if (__string == NULL) { + // 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 - strndup(__string, __n); + int original_result = memcmp(__s1, __s2, __n); // Assign return value and error code - res.error_code = 0; + 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) +memcpy_checked(void *__dest, void *__src, size_t __n) { Result res; - // Check for null pointer parameter: __s - if (__s == NULL) { + // 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 - strchr(__s, __c); + memcpy(__dest, __src, __n); // Assign return value and error code res.error_code = 0; return res; } static inline Result -strrchr_checked(void *__s, int __c) +memmove_checked(void *__dest, void *__src, size_t __n) { Result res; - // Check for null pointer parameter: __s - if (__s == NULL) { + // 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 - strrchr(__s, __c); + memmove(__dest, __src, __n); // Assign return value and error code res.error_code = 0; return res; } static inline Result -strcspn_checked(void *__s, void *__reject) +memset_checked(void *__s, int __c, size_t __n) { Result res; // Check for null pointer parameter: __s @@ -501,26 +460,15 @@ strcspn_checked(void *__s, void *__reject) 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); + memset(__s, __c, __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; - } + res.error_code = 0; return res; } static inline Result -strspn_checked(void *__s, void *__accept) +rindex_checked(void *__s, int __c) { Result res; // Check for null pointer parameter: __s @@ -528,141 +476,132 @@ strspn_checked(void *__s, void *__accept) 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); + rindex(__s, __c); // 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; - } + res.error_code = 0; return res; } static inline Result -strpbrk_checked(void *__s, void *__accept) +stpcpy_checked(void *__dest, void *__src) { Result res; - // Check for null pointer parameter: __s - if (__s == NULL) { + // Check for null pointer parameter: __dest + if (__dest == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __accept - if (__accept == NULL) { + // Check for null pointer parameter: __src + if (__src == NULL) { res.error_code = -1; return res; } // Execute the original function - strpbrk(__s, __accept); + stpcpy(__dest, __src); // Assign return value and error code res.error_code = 0; return res; } static inline Result -strstr_checked(void *__haystack, void *__needle) +stpncpy_checked(void *__dest, void *__src, size_t __n) { Result res; - // Check for null pointer parameter: __haystack - if (__haystack == NULL) { + // Check for null pointer parameter: __dest + if (__dest == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __needle - if (__needle == NULL) { + // Check for null pointer parameter: __src + if (__src == NULL) { res.error_code = -1; return res; } // Execute the original function - strstr(__haystack, __needle); + stpncpy(__dest, __src, __n); // Assign return value and error code res.error_code = 0; return res; } static inline Result -strtok_checked(void *__s, void *__delim) +strcasecmp_checked(void *__s1, void *__s2) { Result res; - // Check for null pointer parameter: __s - if (__s == NULL) { + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __delim - if (__delim == NULL) { + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { res.error_code = -1; return res; } // Execute the original function - strtok(__s, __delim); + int original_result = strcasecmp(__s1, __s2); // Assign return value and error code - res.error_code = 0; + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } return res; } static inline Result -__strtok_r_checked(void *__s, void *__delim, void *__save_ptr) +strcasecmp_l_checked(void *__s1, void *__s2, locale_t __loc) { 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) { + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __save_ptr - if (__save_ptr == NULL) { + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { res.error_code = -1; return res; } // Execute the original function - __strtok_r(__s, __delim, __save_ptr); + int original_result = strcasecmp_l(__s1, __s2, __loc); // Assign return value and error code - res.error_code = 0; + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } return res; } static inline Result -strtok_r_checked(void *__s, void *__delim, void *__save_ptr) +strcat_checked(void *__dest, void *__src) { 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) { + // Check for null pointer parameter: __dest + if (__dest == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __save_ptr - if (__save_ptr == NULL) { + // Check for null pointer parameter: __src + if (__src == NULL) { res.error_code = -1; return res; } // Execute the original function - strtok_r(__s, __delim, __save_ptr); + strcat(__dest, __src); // Assign return value and error code res.error_code = 0; return res; } static inline Result -strlen_checked(void *__s) +strchr_checked(void *__s, int __c) { Result res; // Check for null pointer parameter: __s @@ -671,33 +610,32 @@ strlen_checked(void *__s) return res; } // Execute the original function - size_t original_result = strlen(__s); + strchr(__s, __c); // 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; - } + res.error_code = 0; return res; } static inline Result -strnlen_checked(void *__string, size_t __maxlen) +strcmp_checked(void *__s1, void *__s2) { Result res; - // Check for null pointer parameter: __string - if (__string == NULL) { + // 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 - size_t original_result = strnlen(__string, __maxlen); + int original_result = strcmp(__s1, __s2); // Assign return value and error code if (original_result == 0) { res.error_code = 0; - res.value.size_t_value = original_result; + res.value.int_value = original_result; } else { res.error_code = -2; @@ -706,27 +644,21 @@ strnlen_checked(void *__string, size_t __maxlen) } 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_r_checked(int __errnum, void *__buf, size_t __buflen) +strcoll_checked(void *__s1, void *__s2) { Result res; - // Check for null pointer parameter: __buf - if (__buf == NULL) { + // 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 = strerror_r(__errnum, __buf, __buflen); + int original_result = strcoll(__s1, __s2); // Assign return value and error code if (original_result == 0) { res.error_code = 0; @@ -739,18 +671,7 @@ strerror_r_checked(int __errnum, void *__buf, size_t __buflen) } 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 -bcmp_checked(void *__s1, void *__s2, size_t __n) +strcoll_l_checked(void *__s1, void *__s2, locale_t __l) { Result res; // Check for null pointer parameter: __s1 @@ -764,7 +685,7 @@ bcmp_checked(void *__s1, void *__s2, size_t __n) return res; } // Execute the original function - int original_result = bcmp(__s1, __s2, __n); + int original_result = strcoll_l(__s1, __s2, __l); // Assign return value and error code if (original_result == 0) { res.error_code = 0; @@ -777,28 +698,28 @@ bcmp_checked(void *__s1, void *__s2, size_t __n) } static inline Result -bcopy_checked(void *__src, void *__dest, size_t __n) +strcpy_checked(void *__dest, void *__src) { Result res; - // Check for null pointer parameter: __src - if (__src == NULL) { + // Check for null pointer parameter: __dest + if (__dest == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __dest - if (__dest == NULL) { + // Check for null pointer parameter: __src + if (__src == NULL) { res.error_code = -1; return res; } // Execute the original function - bcopy(__src, __dest, __n); + strcpy(__dest, __src); // Assign return value and error code res.error_code = 0; return res; } static inline Result -bzero_checked(void *__s, size_t __n) +strcspn_checked(void *__s, void *__reject) { Result res; // Check for null pointer parameter: __s @@ -806,15 +727,26 @@ bzero_checked(void *__s, size_t __n) 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 - bzero(__s, __n); + size_t original_result = strcspn(__s, __reject); // Assign return value and error code - res.error_code = 0; + 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 -index_checked(void *__s, int __c) +strdup_checked(void *__s) { Result res; // Check for null pointer parameter: __s @@ -823,34 +755,45 @@ index_checked(void *__s, int __c) return res; } // Execute the original function - index(__s, __c); + strdup(__s); // Assign return value and error code res.error_code = 0; return res; } static inline Result -rindex_checked(void *__s, int __c) +strerror_checked(int __errnum) { Result res; - // Check for null pointer parameter: __s - if (__s == NULL) { - res.error_code = -1; - return res; - } // Execute the original function - rindex(__s, __c); + strerror(__errnum); // Assign return value and error code res.error_code = 0; return res; } static inline Result -ffs_checked(int __i) +strerror_l_checked(int __errnum, locale_t __l) { Result res; // Execute the original function - int original_result = ffs(__i); + 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; @@ -863,15 +806,20 @@ ffs_checked(int __i) } static inline Result -ffsl_checked(long int __l) +strlen_checked(void *__s) { Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } // Execute the original function - int original_result = ffsl(__l); + size_t original_result = strlen(__s); // Assign return value and error code if (original_result == 0) { res.error_code = 0; - res.value.int_value = original_result; + res.value.size_t_value = original_result; } else { res.error_code = -2; @@ -880,11 +828,21 @@ ffsl_checked(long int __l) } static inline Result -ffsll_checked(long long int __ll) +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 = ffsll(__ll); + int original_result = strncasecmp(__s1, __s2, __n); // Assign return value and error code if (original_result == 0) { res.error_code = 0; @@ -897,7 +855,7 @@ ffsll_checked(long long int __ll) } static inline Result -strcasecmp_checked(void *__s1, void *__s2) +strncasecmp_l_checked(void *__s1, void *__s2, size_t __n, locale_t __loc) { Result res; // Check for null pointer parameter: __s1 @@ -911,7 +869,7 @@ strcasecmp_checked(void *__s1, void *__s2) return res; } // Execute the original function - int original_result = strcasecmp(__s1, __s2); + int original_result = strncasecmp_l(__s1, __s2, __n, __loc); // Assign return value and error code if (original_result == 0) { res.error_code = 0; @@ -924,7 +882,28 @@ strcasecmp_checked(void *__s1, void *__s2) } static inline Result -strncasecmp_checked(void *__s1, void *__s2, size_t __n) +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 @@ -938,7 +917,7 @@ strncasecmp_checked(void *__s1, void *__s2, size_t __n) return res; } // Execute the original function - int original_result = strncasecmp(__s1, __s2, __n); + int original_result = strncmp(__s1, __s2, __n); // Assign return value and error code if (original_result == 0) { res.error_code = 0; @@ -951,25 +930,57 @@ strncasecmp_checked(void *__s1, void *__s2, size_t __n) } static inline Result -strcasecmp_l_checked(void *__s1, void *__s2, locale_t __loc) +strncpy_checked(void *__dest, void *__src, size_t __n) { Result res; - // Check for null pointer parameter: __s1 - if (__s1 == NULL) { + // Check for null pointer parameter: __dest + if (__dest == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __s2 - if (__s2 == NULL) { + // Check for null pointer parameter: __src + if (__src == NULL) { res.error_code = -1; return res; } // Execute the original function - int original_result = strcasecmp_l(__s1, __s2, __loc); + 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.int_value = original_result; + res.value.size_t_value = original_result; } else { res.error_code = -2; @@ -978,34 +989,28 @@ strcasecmp_l_checked(void *__s1, void *__s2, locale_t __loc) } static inline Result -strncasecmp_l_checked(void *__s1, void *__s2, size_t __n, locale_t __loc) +strpbrk_checked(void *__s, void *__accept) { Result res; - // Check for null pointer parameter: __s1 - if (__s1 == NULL) { + // Check for null pointer parameter: __s + if (__s == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __s2 - if (__s2 == NULL) { + // Check for null pointer parameter: __accept + if (__accept == NULL) { res.error_code = -1; return res; } // Execute the original function - int original_result = strncasecmp_l(__s1, __s2, __n, __loc); + strpbrk(__s, __accept); // 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; - } + res.error_code = 0; return res; } static inline Result -explicit_bzero_checked(void *__s, size_t __n) +strrchr_checked(void *__s, int __c) { Result res; // Check for null pointer parameter: __s @@ -1014,7 +1019,7 @@ explicit_bzero_checked(void *__s, size_t __n) return res; } // Execute the original function - explicit_bzero(__s, __n); + strrchr(__s, __c); // Assign return value and error code res.error_code = 0; return res; @@ -1053,161 +1058,156 @@ strsignal_checked(int __sig) } static inline Result -__stpcpy_checked(void *__dest, void *__src) +strspn_checked(void *__s, void *__accept) { Result res; - // Check for null pointer parameter: __dest - if (__dest == NULL) { + // Check for null pointer parameter: __s + if (__s == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __src - if (__src == NULL) { + // Check for null pointer parameter: __accept + if (__accept == NULL) { res.error_code = -1; return res; } // Execute the original function - __stpcpy(__dest, __src); + size_t original_result = strspn(__s, __accept); // 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; + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; } - // Check for null pointer parameter: __src - if (__src == NULL) { - res.error_code = -1; - return res; + else { + res.error_code = -2; } - // 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) +strstr_checked(void *__haystack, void *__needle) { Result res; - // Check for null pointer parameter: __dest - if (__dest == NULL) { + // Check for null pointer parameter: __haystack + if (__haystack == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __src - if (__src == NULL) { + // Check for null pointer parameter: __needle + if (__needle == NULL) { res.error_code = -1; return res; } // Execute the original function - __stpncpy(__dest, __src, __n); + strstr(__haystack, __needle); // Assign return value and error code res.error_code = 0; return res; } static inline Result -stpncpy_checked(void *__dest, void *__src, size_t __n) +strtok_checked(void *__s, void *__delim) { Result res; - // Check for null pointer parameter: __dest - if (__dest == NULL) { + // Check for null pointer parameter: __s + if (__s == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __src - if (__src == NULL) { + // Check for null pointer parameter: __delim + if (__delim == NULL) { res.error_code = -1; return res; } // Execute the original function - stpncpy(__dest, __src, __n); + strtok(__s, __delim); // 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) +strtok_r_checked(void *__s, void *__delim, void *__save_ptr) { Result res; - // Check for null pointer parameter: __assertion - if (__assertion == NULL) { + // Check for null pointer parameter: __s + if (__s == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __file - if (__file == NULL) { + // Check for null pointer parameter: __delim + if (__delim == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __function - if (__function == NULL) { + // Check for null pointer parameter: __save_ptr + if (__save_ptr == NULL) { res.error_code = -1; return res; } // Execute the original function - __assert_fail(__assertion, __file, __line, __function); + strtok_r(__s, __delim, __save_ptr); // 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) +strxfrm_checked(void *__dest, void *__src, size_t __n) { Result res; - // Check for null pointer parameter: __file - if (__file == NULL) { + // Check for null pointer parameter: __dest + if (__dest == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __function - if (__function == NULL) { + // Check for null pointer parameter: __src + if (__src == NULL) { res.error_code = -1; return res; } // Execute the original function - __assert_perror_fail(__errnum, __file, __line, __function); + size_t original_result = strxfrm(__dest, __src, __n); // Assign return value and error code - res.error_code = 0; + 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 -__assert_checked(void *__assertion, void *__file, int __line) +strxfrm_l_checked(void *__dest, void *__src, size_t __n, locale_t __l) { Result res; - // Check for null pointer parameter: __assertion - if (__assertion == NULL) { + // Check for null pointer parameter: __dest + if (__dest == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __file - if (__file == NULL) { + // Check for null pointer parameter: __src + if (__src == NULL) { res.error_code = -1; return res; } // Execute the original function - __assert(__assertion, __file, __line); + size_t original_result = strxfrm_l(__dest, __src, __n, __l); // Assign return value and error code - res.error_code = 0; + 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_new_empty_checked(void *out) +wasm_byte_vec_copy_checked(void *out, void *) { Result res; // Check for null pointer parameter: out @@ -1215,24 +1215,29 @@ wasm_byte_vec_new_empty_checked(void *out) 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_new_empty(out); + wasm_byte_vec_copy(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) +wasm_byte_vec_delete_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_byte_vec_new_uninitialized(out, ); + wasm_byte_vec_delete(); // Assign return value and error code res.error_code = 0; return res; @@ -1255,7 +1260,7 @@ wasm_byte_vec_new_checked(void *out, size_t, void *) } static inline Result -wasm_byte_vec_copy_checked(void *out, void *) +wasm_byte_vec_new_empty_checked(void *out) { Result res; // Check for null pointer parameter: out @@ -1263,29 +1268,24 @@ wasm_byte_vec_copy_checked(void *out, void *) 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, ); + wasm_byte_vec_new_empty(out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_byte_vec_delete_checked(void *) +wasm_byte_vec_new_uninitialized_checked(void *out, size_t) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_byte_vec_delete(); + wasm_byte_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; @@ -1319,7 +1319,7 @@ wasm_config_new_checked(void) } static inline Result -wasm_config_set_mem_alloc_opt_checked(void *, mem_alloc_type_t, void *) +wasm_config_set_linux_perf_opt_checked(void *, _Bool) { Result res; // Check for null pointer parameter: None @@ -1327,20 +1327,15 @@ wasm_config_set_mem_alloc_opt_checked(void *, mem_alloc_type_t, void *) 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(, , ); + wasm_config_set_linux_perf_opt(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_config_set_linux_perf_opt_checked(void *, _Bool) +wasm_config_set_mem_alloc_opt_checked(void *, mem_alloc_type_t, void *) { Result res; // Check for null pointer parameter: None @@ -1348,8 +1343,13 @@ wasm_config_set_linux_perf_opt_checked(void *, _Bool) 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_linux_perf_opt(, ); + wasm_config_set_mem_alloc_opt(, , ); // Assign return value and error code res.error_code = 0; return res; @@ -1398,22 +1398,6 @@ wasm_engine_new_checked(void) 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_engine_new_with_args_checked(mem_alloc_type_t type, void *opts) { @@ -1431,7 +1415,7 @@ wasm_engine_new_with_args_checked(mem_alloc_type_t type, void *opts) } static inline Result -wasm_store_delete_checked(void *) +wasm_engine_new_with_config_checked(void *) { Result res; // Check for null pointer parameter: None @@ -1440,14 +1424,14 @@ wasm_store_delete_checked(void *) return res; } // Execute the original function - wasm_store_delete(); + wasm_engine_new_with_config(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_store_new_checked(void *) +wasm_exporttype_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -1456,14 +1440,14 @@ wasm_store_new_checked(void *) return res; } // Execute the original function - wasm_store_new(); + wasm_exporttype_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_valtype_delete_checked(void *) +wasm_exporttype_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -1472,66 +1456,34 @@ wasm_valtype_delete_checked(void *) 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_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, ); + wasm_exporttype_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 *) +wasm_exporttype_name_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_valtype_vec_new(out, , ); + wasm_exporttype_name(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_valtype_vec_copy_checked(void *out, void *) +wasm_exporttype_new_checked(void *, void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } @@ -1541,14 +1493,14 @@ wasm_valtype_vec_copy_checked(void *out, void *) return res; } // Execute the original function - wasm_valtype_vec_copy(out, ); + wasm_exporttype_new(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_valtype_vec_delete_checked(void *) +wasm_exporttype_type_checked(void *) { Result res; // Check for null pointer parameter: None @@ -1557,79 +1509,83 @@ wasm_valtype_vec_delete_checked(void *) return res; } // Execute the original function - wasm_valtype_vec_delete(); + wasm_exporttype_type(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_valtype_copy_checked(void *) +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_valtype_copy(); + wasm_exporttype_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_valtype_new_checked(wasm_valkind_t) +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_valtype_new(); + wasm_exporttype_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_valtype_kind_checked(void *) +wasm_exporttype_vec_new_checked(void *out, size_t, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_valkind_t original_result = wasm_valtype_kind(); + wasm_exporttype_vec_new(out, , ); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_functype_delete_checked(void *) +wasm_exporttype_vec_new_empty_checked(void *out) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_functype_delete(); + wasm_exporttype_vec_new_empty(out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_functype_vec_new_empty_checked(void *out) +wasm_exporttype_vec_new_uninitialized_checked(void *out, size_t) { Result res; // Check for null pointer parameter: out @@ -1638,67 +1594,62 @@ wasm_functype_vec_new_empty_checked(void *out) return res; } // Execute the original function - wasm_functype_vec_new_empty(out); + wasm_exporttype_vec_new_uninitialized(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) +wasm_extern_as_func_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_functype_vec_new_uninitialized(out, ); + wasm_extern_as_func(); // 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 *) +wasm_extern_as_func_const_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_functype_vec_new(out, , ); + wasm_extern_as_func_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_functype_vec_copy_checked(void *out, void *) +wasm_extern_as_global_checked(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, ); + wasm_extern_as_global(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_functype_vec_delete_checked(void *) +wasm_extern_as_global_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -1707,14 +1658,14 @@ wasm_functype_vec_delete_checked(void *) return res; } // Execute the original function - wasm_functype_vec_delete(); + wasm_extern_as_global_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_functype_copy_checked(void *) +wasm_extern_as_memory_checked(void *) { Result res; // Check for null pointer parameter: None @@ -1723,35 +1674,30 @@ wasm_functype_copy_checked(void *) return res; } // Execute the original function - wasm_functype_copy(); + wasm_extern_as_memory(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_functype_new_checked(void *params, void *results) +wasm_extern_as_memory_const_checked(void *) { 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) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_functype_new(params, results); + wasm_extern_as_memory_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_functype_params_checked(void *) +wasm_extern_as_ref_checked(void *) { Result res; // Check for null pointer parameter: None @@ -1760,14 +1706,14 @@ wasm_functype_params_checked(void *) return res; } // Execute the original function - wasm_functype_params(); + wasm_extern_as_ref(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_functype_results_checked(void *) +wasm_extern_as_ref_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -1776,14 +1722,14 @@ wasm_functype_results_checked(void *) return res; } // Execute the original function - wasm_functype_results(); + wasm_extern_as_ref_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_globaltype_delete_checked(void *) +wasm_extern_as_table_checked(void *) { Result res; // Check for null pointer parameter: None @@ -1792,83 +1738,78 @@ wasm_globaltype_delete_checked(void *) return res; } // Execute the original function - wasm_globaltype_delete(); + wasm_extern_as_table(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_globaltype_vec_new_empty_checked(void *out) +wasm_extern_as_table_const_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_globaltype_vec_new_empty(out); + wasm_extern_as_table_const(); // 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) +wasm_extern_copy_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_globaltype_vec_new_uninitialized(out, ); + wasm_extern_copy(); // 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 *) +wasm_extern_delete_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_globaltype_vec_new(out, , ); + wasm_extern_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_globaltype_vec_copy_checked(void *out, void *) +wasm_extern_get_host_info_checked(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, ); + wasm_extern_get_host_info(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_globaltype_vec_delete_checked(void *) +wasm_extern_kind_checked(void *) { Result res; // Check for null pointer parameter: None @@ -1877,14 +1818,20 @@ wasm_globaltype_vec_delete_checked(void *) return res; } // Execute the original function - wasm_globaltype_vec_delete(); + wasm_externkind_t original_result = wasm_extern_kind(); // Assign return value and error code - res.error_code = 0; + 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_globaltype_copy_checked(void *) +wasm_extern_new_empty_checked(void *, wasm_externkind_t) { Result res; // Check for null pointer parameter: None @@ -1893,14 +1840,14 @@ wasm_globaltype_copy_checked(void *) return res; } // Execute the original function - wasm_globaltype_copy(); + wasm_extern_new_empty(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_globaltype_new_checked(void *, wasm_mutability_t) +wasm_extern_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -1908,15 +1855,21 @@ wasm_globaltype_new_checked(void *, wasm_mutability_t) 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_new(, ); + _Bool original_result = wasm_extern_same(, ); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_globaltype_content_checked(void *) +wasm_extern_set_host_info_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -1924,15 +1877,20 @@ wasm_globaltype_content_checked(void *) 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_content(); + wasm_extern_set_host_info(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_globaltype_mutability_checked(void *) +wasm_extern_set_host_info_with_finalizer_checked(void *, void *, void *) { Result res; // Check for null pointer parameter: None @@ -1940,21 +1898,25 @@ wasm_globaltype_mutability_checked(void *) 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; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; } - else { - res.error_code = -2; + // 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_tabletype_delete_checked(void *) +wasm_extern_type_checked(void *) { Result res; // Check for null pointer parameter: None @@ -1963,14 +1925,14 @@ wasm_tabletype_delete_checked(void *) return res; } // Execute the original function - wasm_tabletype_delete(); + wasm_extern_type(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_tabletype_vec_new_empty_checked(void *out) +wasm_extern_vec_copy_checked(void *out, void *) { Result res; // Check for null pointer parameter: out @@ -1978,31 +1940,36 @@ wasm_tabletype_vec_new_empty_checked(void *out) 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_new_empty(out); + wasm_extern_vec_copy(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) +wasm_extern_vec_delete_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_tabletype_vec_new_uninitialized(out, ); + wasm_extern_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 *) +wasm_extern_vec_new_checked(void *out, size_t, void *) { Result res; // Check for null pointer parameter: out @@ -2011,14 +1978,14 @@ wasm_tabletype_vec_new_checked(void *out, size_t, void *) return res; } // Execute the original function - wasm_tabletype_vec_new(out, , ); + wasm_extern_vec_new(out, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_tabletype_vec_copy_checked(void *out, void *) +wasm_extern_vec_new_empty_checked(void *out) { Result res; // Check for null pointer parameter: out @@ -2026,36 +1993,31 @@ wasm_tabletype_vec_copy_checked(void *out, void *) 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, ); + wasm_extern_vec_new_empty(out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_tabletype_vec_delete_checked(void *) +wasm_extern_vec_new_uninitialized_checked(void *out, size_t) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_tabletype_vec_delete(); + wasm_extern_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_tabletype_copy_checked(void *) +wasm_externtype_as_functype_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2064,14 +2026,14 @@ wasm_tabletype_copy_checked(void *) return res; } // Execute the original function - wasm_tabletype_copy(); + wasm_externtype_as_functype(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_tabletype_new_checked(void *, void *) +wasm_externtype_as_functype_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2079,20 +2041,15 @@ wasm_tabletype_new_checked(void *, void *) 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(, ); + wasm_externtype_as_functype_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_tabletype_element_checked(void *) +wasm_externtype_as_globaltype_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2101,14 +2058,14 @@ wasm_tabletype_element_checked(void *) return res; } // Execute the original function - wasm_tabletype_element(); + wasm_externtype_as_globaltype(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_tabletype_limits_checked(void *) +wasm_externtype_as_globaltype_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2117,14 +2074,14 @@ wasm_tabletype_limits_checked(void *) return res; } // Execute the original function - wasm_tabletype_limits(); + wasm_externtype_as_globaltype_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memorytype_delete_checked(void *) +wasm_externtype_as_memorytype_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2133,83 +2090,78 @@ wasm_memorytype_delete_checked(void *) return res; } // Execute the original function - wasm_memorytype_delete(); + wasm_externtype_as_memorytype(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memorytype_vec_new_empty_checked(void *out) +wasm_externtype_as_memorytype_const_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_memorytype_vec_new_empty(out); + wasm_externtype_as_memorytype_const(); // 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) +wasm_externtype_as_tabletype_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_memorytype_vec_new_uninitialized(out, ); + wasm_externtype_as_tabletype(); // 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 *) +wasm_externtype_as_tabletype_const_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_memorytype_vec_new(out, , ); + wasm_externtype_as_tabletype_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memorytype_vec_copy_checked(void *out, void *) +wasm_externtype_copy_checked(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, ); + wasm_externtype_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memorytype_vec_delete_checked(void *) +wasm_externtype_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2218,14 +2170,14 @@ wasm_memorytype_vec_delete_checked(void *) return res; } // Execute the original function - wasm_memorytype_vec_delete(); + wasm_externtype_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memorytype_copy_checked(void *) +wasm_externtype_kind_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2234,30 +2186,41 @@ wasm_memorytype_copy_checked(void *) return res; } // Execute the original function - wasm_memorytype_copy(); + wasm_externkind_t original_result = wasm_externtype_kind(); // Assign return value and error code - res.error_code = 0; + 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_memorytype_new_checked(void *) +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_memorytype_new(); + wasm_externtype_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memorytype_limits_checked(void *) +wasm_externtype_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2266,23 +2229,23 @@ wasm_memorytype_limits_checked(void *) return res; } // Execute the original function - wasm_memorytype_limits(); + wasm_externtype_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_delete_checked(void *) +wasm_externtype_vec_new_checked(void *out, size_t, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_externtype_delete(); + wasm_externtype_vec_new(out, , ); // Assign return value and error code res.error_code = 0; return res; @@ -2321,44 +2284,39 @@ wasm_externtype_vec_new_uninitialized_checked(void *out, size_t) } static inline Result -wasm_externtype_vec_new_checked(void *out, size_t, void *) +wasm_foreign_as_ref_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_externtype_vec_new(out, , ); + wasm_foreign_as_ref(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_vec_copy_checked(void *out, void *) +wasm_foreign_as_ref_const_checked(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, ); + wasm_foreign_as_ref_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_vec_delete_checked(void *) +wasm_foreign_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2367,14 +2325,14 @@ wasm_externtype_vec_delete_checked(void *) return res; } // Execute the original function - wasm_externtype_vec_delete(); + wasm_foreign_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_copy_checked(void *) +wasm_foreign_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2383,14 +2341,14 @@ wasm_externtype_copy_checked(void *) return res; } // Execute the original function - wasm_externtype_copy(); + wasm_foreign_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_kind_checked(void *) +wasm_foreign_get_host_info_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2399,20 +2357,14 @@ wasm_externtype_kind_checked(void *) return res; } // Execute the original function - wasm_externkind_t original_result = wasm_externtype_kind(); + wasm_foreign_get_host_info(); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_functype_as_externtype_checked(void *) +wasm_foreign_new_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2421,14 +2373,14 @@ wasm_functype_as_externtype_checked(void *) return res; } // Execute the original function - wasm_functype_as_externtype(); + wasm_foreign_new(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_globaltype_as_externtype_checked(void *) +wasm_foreign_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -2436,15 +2388,21 @@ wasm_globaltype_as_externtype_checked(void *) 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_as_externtype(); + _Bool original_result = wasm_foreign_same(, ); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_tabletype_as_externtype_checked(void *) +wasm_foreign_set_host_info_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -2452,15 +2410,20 @@ wasm_tabletype_as_externtype_checked(void *) 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_as_externtype(); + wasm_foreign_set_host_info(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memorytype_as_externtype_checked(void *) +wasm_foreign_set_host_info_with_finalizer_checked(void *, void *, void *) { Result res; // Check for null pointer parameter: None @@ -2468,15 +2431,25 @@ wasm_memorytype_as_externtype_checked(void *) 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_memorytype_as_externtype(); + wasm_foreign_set_host_info_with_finalizer(, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_as_functype_checked(void *) +wasm_frame_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2485,14 +2458,14 @@ wasm_externtype_as_functype_checked(void *) return res; } // Execute the original function - wasm_externtype_as_functype(); + wasm_frame_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_as_globaltype_checked(void *) +wasm_frame_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2501,14 +2474,14 @@ wasm_externtype_as_globaltype_checked(void *) return res; } // Execute the original function - wasm_externtype_as_globaltype(); + wasm_frame_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_as_tabletype_checked(void *) +wasm_frame_func_index_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2517,14 +2490,20 @@ wasm_externtype_as_tabletype_checked(void *) return res; } // Execute the original function - wasm_externtype_as_tabletype(); + uint32_t original_result = wasm_frame_func_index(); // Assign return value and error code - res.error_code = 0; + 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_externtype_as_memorytype_checked(void *) +wasm_frame_func_offset_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2533,14 +2512,20 @@ wasm_externtype_as_memorytype_checked(void *) return res; } // Execute the original function - wasm_externtype_as_memorytype(); + size_t original_result = wasm_frame_func_offset(); // Assign return value and error code - res.error_code = 0; + 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_functype_as_externtype_const_checked(void *) +wasm_frame_instance_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2549,14 +2534,14 @@ wasm_functype_as_externtype_const_checked(void *) return res; } // Execute the original function - wasm_functype_as_externtype_const(); + wasm_frame_instance(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_globaltype_as_externtype_const_checked(void *) +wasm_frame_module_offset_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2565,30 +2550,41 @@ wasm_globaltype_as_externtype_const_checked(void *) return res; } // Execute the original function - wasm_globaltype_as_externtype_const(); + size_t original_result = wasm_frame_module_offset(); // Assign return value and error code - res.error_code = 0; + 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_tabletype_as_externtype_const_checked(void *) +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_tabletype_as_externtype_const(); + wasm_frame_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memorytype_as_externtype_const_checked(void *) +wasm_frame_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2597,62 +2593,62 @@ wasm_memorytype_as_externtype_const_checked(void *) return res; } // Execute the original function - wasm_memorytype_as_externtype_const(); + wasm_frame_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_as_functype_const_checked(void *) +wasm_frame_vec_new_checked(void *out, size_t, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_externtype_as_functype_const(); + wasm_frame_vec_new(out, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_as_globaltype_const_checked(void *) +wasm_frame_vec_new_empty_checked(void *out) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_externtype_as_globaltype_const(); + wasm_frame_vec_new_empty(out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_as_tabletype_const_checked(void *) +wasm_frame_vec_new_uninitialized_checked(void *out, size_t) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_externtype_as_tabletype_const(); + wasm_frame_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_externtype_as_memorytype_const_checked(void *) +wasm_func_as_extern_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2661,14 +2657,14 @@ wasm_externtype_as_memorytype_const_checked(void *) return res; } // Execute the original function - wasm_externtype_as_memorytype_const(); + wasm_func_as_extern(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_importtype_delete_checked(void *) +wasm_func_as_extern_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2677,83 +2673,88 @@ wasm_importtype_delete_checked(void *) return res; } // Execute the original function - wasm_importtype_delete(); + wasm_func_as_extern_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_importtype_vec_new_empty_checked(void *out) +wasm_func_as_ref_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_importtype_vec_new_empty(out); + wasm_func_as_ref(); // 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) +wasm_func_as_ref_const_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_importtype_vec_new_uninitialized(out, ); + wasm_func_as_ref_const(); // 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 *) +wasm_func_call_checked(void *, void *args, void *results) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // 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_importtype_vec_new(out, , ); + wasm_func_call(, args, results); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_importtype_vec_copy_checked(void *out, void *) +wasm_func_copy_checked(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, ); + wasm_func_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_importtype_vec_delete_checked(void *) +wasm_func_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2762,14 +2763,14 @@ wasm_importtype_vec_delete_checked(void *) return res; } // Execute the original function - wasm_importtype_vec_delete(); + wasm_func_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_importtype_copy_checked(void *) +wasm_func_get_host_info_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2778,23 +2779,18 @@ wasm_importtype_copy_checked(void *) return res; } // Execute the original function - wasm_importtype_copy(); + wasm_func_get_host_info(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_importtype_new_checked(void *module, void *name, void *) +wasm_func_new_checked(void *, void *, wasm_func_callback_t) { 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) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } @@ -2804,14 +2800,16 @@ wasm_importtype_new_checked(void *module, void *name, void *) return res; } // Execute the original function - wasm_importtype_new(module, name, ); + wasm_func_new(, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_importtype_module_checked(void *) +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 @@ -2819,15 +2817,30 @@ wasm_importtype_module_checked(void *) 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_importtype_module(); + wasm_func_new_with_env(, type, , env, finalizer); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_importtype_name_checked(void *) +wasm_func_param_arity_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2836,14 +2849,20 @@ wasm_importtype_name_checked(void *) return res; } // Execute the original function - wasm_importtype_name(); + size_t original_result = wasm_func_param_arity(); // Assign return value and error code - res.error_code = 0; + 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_importtype_type_checked(void *) +wasm_func_result_arity_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2852,14 +2871,20 @@ wasm_importtype_type_checked(void *) return res; } // Execute the original function - wasm_importtype_type(); + size_t original_result = wasm_func_result_arity(); // Assign return value and error code - res.error_code = 0; + 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_importtype_is_linked_checked(void *) +wasm_func_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -2867,8 +2892,13 @@ wasm_importtype_is_linked_checked(void *) 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_importtype_is_linked(); + _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; @@ -2876,7 +2906,7 @@ wasm_importtype_is_linked_checked(void *) } static inline Result -wasm_exporttype_delete_checked(void *) +wasm_func_set_host_info_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -2884,84 +2914,94 @@ wasm_exporttype_delete_checked(void *) 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_delete(); + wasm_func_set_host_info(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_exporttype_vec_new_empty_checked(void *out) +wasm_func_set_host_info_with_finalizer_checked(void *, void *, void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // 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_exporttype_vec_new_empty(out); + wasm_func_set_host_info_with_finalizer(, , ); // 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) +wasm_func_type_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_exporttype_vec_new_uninitialized(out, ); + wasm_func_type(); // 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 *) +wasm_functype_as_externtype_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_exporttype_vec_new(out, , ); + wasm_functype_as_externtype(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_exporttype_vec_copy_checked(void *out, void *) +wasm_functype_as_externtype_const_checked(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, ); + wasm_functype_as_externtype_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_exporttype_vec_delete_checked(void *) +wasm_functype_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2970,14 +3010,14 @@ wasm_exporttype_vec_delete_checked(void *) return res; } // Execute the original function - wasm_exporttype_vec_delete(); + wasm_functype_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_exporttype_copy_checked(void *) +wasm_functype_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -2986,35 +3026,35 @@ wasm_exporttype_copy_checked(void *) return res; } // Execute the original function - wasm_exporttype_copy(); + wasm_functype_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_exporttype_new_checked(void *, void *) +wasm_functype_new_checked(void *params, void *results) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: params + if (params == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: results + if (results == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_exporttype_new(, ); + wasm_functype_new(params, results); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_exporttype_name_checked(void *) +wasm_functype_params_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3023,14 +3063,14 @@ wasm_exporttype_name_checked(void *) return res; } // Execute the original function - wasm_exporttype_name(); + wasm_functype_params(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_exporttype_type_checked(void *) +wasm_functype_results_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3039,51 +3079,51 @@ wasm_exporttype_type_checked(void *) return res; } // Execute the original function - wasm_exporttype_type(); + wasm_functype_results(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_val_delete_checked(void *v) +wasm_functype_vec_copy_checked(void *out, void *) { Result res; - // Check for null pointer parameter: v - if (v == NULL) { + // 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_delete(v); + wasm_functype_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_val_copy_checked(void *out, void *) +wasm_functype_vec_delete_checked(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, ); + wasm_functype_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_val_vec_new_empty_checked(void *out) +wasm_functype_vec_new_checked(void *out, size_t, void *) { Result res; // Check for null pointer parameter: out @@ -3092,14 +3132,14 @@ wasm_val_vec_new_empty_checked(void *out) return res; } // Execute the original function - wasm_val_vec_new_empty(out); + wasm_functype_vec_new(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) +wasm_functype_vec_new_empty_checked(void *out) { Result res; // Check for null pointer parameter: out @@ -3108,14 +3148,14 @@ wasm_val_vec_new_uninitialized_checked(void *out, size_t) return res; } // Execute the original function - wasm_val_vec_new_uninitialized(out, ); + wasm_functype_vec_new_empty(out); // 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 *) +wasm_functype_vec_new_uninitialized_checked(void *out, size_t) { Result res; // Check for null pointer parameter: out @@ -3124,35 +3164,46 @@ wasm_val_vec_new_checked(void *out, size_t, void *) return res; } // Execute the original function - wasm_val_vec_new(out, , ); + wasm_functype_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_val_vec_copy_checked(void *out, void *) +wasm_global_as_extern_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // 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_val_vec_copy(out, ); + wasm_global_as_extern_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_val_vec_delete_checked(void *) +wasm_global_as_ref_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3161,14 +3212,14 @@ wasm_val_vec_delete_checked(void *) return res; } // Execute the original function - wasm_val_vec_delete(); + wasm_global_as_ref(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_delete_checked(void *) +wasm_global_as_ref_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3177,14 +3228,14 @@ wasm_ref_delete_checked(void *) return res; } // Execute the original function - wasm_ref_delete(); + wasm_global_as_ref_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_copy_checked(void *) +wasm_global_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3193,14 +3244,14 @@ wasm_ref_copy_checked(void *) return res; } // Execute the original function - wasm_ref_copy(); + wasm_global_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_same_checked(void *, void *) +wasm_global_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3208,21 +3259,15 @@ wasm_ref_same_checked(void *, void *) 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(, ); + wasm_global_delete(); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_ref_get_host_info_checked(void *) +wasm_global_get_checked(void *, void *out) { Result res; // Check for null pointer parameter: None @@ -3230,15 +3275,20 @@ wasm_ref_get_host_info_checked(void *) 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_ref_get_host_info(); + wasm_global_get(, out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_set_host_info_checked(void *, void *) +wasm_global_get_host_info_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3246,20 +3296,15 @@ wasm_ref_set_host_info_checked(void *, void *) 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(, ); + wasm_global_get_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 *) +wasm_global_new_checked(void *, void *, void *) { Result res; // Check for null pointer parameter: None @@ -3278,14 +3323,14 @@ wasm_ref_set_host_info_with_finalizer_checked(void *, void *, void *) return res; } // Execute the original function - wasm_ref_set_host_info_with_finalizer(, , ); + wasm_global_new(, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_frame_delete_checked(void *) +wasm_global_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -3293,84 +3338,105 @@ wasm_frame_delete_checked(void *) 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_delete(); + _Bool original_result = wasm_global_same(, ); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_frame_vec_new_empty_checked(void *out) +wasm_global_set_checked(void *, void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // 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_frame_vec_new_empty(out); + wasm_global_set(, ); // 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) +wasm_global_set_host_info_checked(void *, void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // 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_frame_vec_new_uninitialized(out, ); + wasm_global_set_host_info(, ); // 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 *) +wasm_global_set_host_info_with_finalizer_checked(void *, void *, void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // 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_frame_vec_new(out, , ); + wasm_global_set_host_info_with_finalizer(, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_frame_vec_copy_checked(void *out, void *) +wasm_global_type_checked(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, ); + wasm_global_type(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_frame_vec_delete_checked(void *) +wasm_globaltype_as_externtype_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3379,14 +3445,14 @@ wasm_frame_vec_delete_checked(void *) return res; } // Execute the original function - wasm_frame_vec_delete(); + wasm_globaltype_as_externtype(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_frame_copy_checked(void *) +wasm_globaltype_as_externtype_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3395,14 +3461,14 @@ wasm_frame_copy_checked(void *) return res; } // Execute the original function - wasm_frame_copy(); + wasm_globaltype_as_externtype_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_frame_instance_checked(void *) +wasm_globaltype_content_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3411,14 +3477,14 @@ wasm_frame_instance_checked(void *) return res; } // Execute the original function - wasm_frame_instance(); + wasm_globaltype_content(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_frame_func_index_checked(void *) +wasm_globaltype_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3427,20 +3493,14 @@ wasm_frame_func_index_checked(void *) return res; } // Execute the original function - uint32_t original_result = wasm_frame_func_index(); + wasm_globaltype_copy(); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_frame_func_offset_checked(void *) +wasm_globaltype_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3449,20 +3509,14 @@ wasm_frame_func_offset_checked(void *) return res; } // Execute the original function - size_t original_result = wasm_frame_func_offset(); + wasm_globaltype_delete(); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_frame_module_offset_checked(void *) +wasm_globaltype_mutability_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3471,11 +3525,11 @@ wasm_frame_module_offset_checked(void *) return res; } // Execute the original function - size_t original_result = wasm_frame_module_offset(); + wasm_mutability_t original_result = wasm_globaltype_mutability(); // Assign return value and error code if (original_result == 0) { res.error_code = 0; - res.value.size_t_value = original_result; + res.value.wasm_mutability_t_value = original_result; } else { res.error_code = -2; @@ -3484,7 +3538,7 @@ wasm_frame_module_offset_checked(void *) } static inline Result -wasm_trap_delete_checked(void *) +wasm_globaltype_new_checked(void *, wasm_mutability_t) { Result res; // Check for null pointer parameter: None @@ -3493,30 +3547,35 @@ wasm_trap_delete_checked(void *) return res; } // Execute the original function - wasm_trap_delete(); + wasm_globaltype_new(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_trap_copy_checked(void *) +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_trap_copy(); + wasm_globaltype_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_trap_same_checked(void *, void *) +wasm_globaltype_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3524,84 +3583,63 @@ wasm_trap_same_checked(void *, void *) 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(, ); + wasm_globaltype_vec_delete(); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_trap_get_host_info_checked(void *) +wasm_globaltype_vec_new_checked(void *out, size_t, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_trap_get_host_info(); + wasm_globaltype_vec_new(out, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_trap_set_host_info_checked(void *, void *) +wasm_globaltype_vec_new_empty_checked(void *out) { 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) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_trap_set_host_info(, ); + wasm_globaltype_vec_new_empty(out); // 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 *) +wasm_globaltype_vec_new_uninitialized_checked(void *out, size_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; - } - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_trap_set_host_info_with_finalizer(, , ); + wasm_globaltype_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 *) +wasm_importtype_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3610,14 +3648,14 @@ wasm_trap_as_ref_checked(void *) return res; } // Execute the original function - wasm_trap_as_ref(); + wasm_importtype_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_trap_checked(void *) +wasm_importtype_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3626,14 +3664,14 @@ wasm_ref_as_trap_checked(void *) return res; } // Execute the original function - wasm_ref_as_trap(); + wasm_importtype_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_trap_as_ref_const_checked(void *) +wasm_importtype_is_linked_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3642,14 +3680,15 @@ wasm_trap_as_ref_const_checked(void *) return res; } // Execute the original function - wasm_trap_as_ref_const(); + _Bool original_result = wasm_importtype_is_linked(); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_ref_as_trap_const_checked(void *) +wasm_importtype_module_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3658,56 +3697,56 @@ wasm_ref_as_trap_const_checked(void *) return res; } // Execute the original function - wasm_ref_as_trap_const(); + wasm_importtype_module(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_trap_new_checked(void *store, void *) +wasm_importtype_name_checked(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, ); + wasm_importtype_name(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_trap_message_checked(void *, void *out) +wasm_importtype_new_checked(void *module, void *name, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // 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: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_trap_message(, out); + wasm_importtype_new(module, name, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_trap_origin_checked(void *) +wasm_importtype_type_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3716,35 +3755,35 @@ wasm_trap_origin_checked(void *) return res; } // Execute the original function - wasm_trap_origin(); + wasm_importtype_type(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_trap_trace_checked(void *, void *out) +wasm_importtype_vec_copy_checked(void *out, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_trap_trace(, out); + wasm_importtype_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_foreign_delete_checked(void *) +wasm_importtype_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3753,68 +3792,62 @@ wasm_foreign_delete_checked(void *) return res; } // Execute the original function - wasm_foreign_delete(); + wasm_importtype_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_foreign_copy_checked(void *) +wasm_importtype_vec_new_checked(void *out, size_t, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_foreign_copy(); + wasm_importtype_vec_new(out, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_foreign_same_checked(void *, void *) +wasm_importtype_vec_new_empty_checked(void *out) { 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) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = wasm_foreign_same(, ); + wasm_importtype_vec_new_empty(out); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_foreign_get_host_info_checked(void *) +wasm_importtype_vec_new_uninitialized_checked(void *out, size_t) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_foreign_get_host_info(); + wasm_importtype_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_foreign_set_host_info_checked(void *, void *) +wasm_instance_as_ref_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3822,20 +3855,15 @@ wasm_foreign_set_host_info_checked(void *, void *) 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(, ); + wasm_instance_as_ref(); // 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 *) +wasm_instance_as_ref_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3843,25 +3871,15 @@ wasm_foreign_set_host_info_with_finalizer_checked(void *, void *, void *) 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(, , ); + wasm_instance_as_ref_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_foreign_as_ref_checked(void *) +wasm_instance_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3870,14 +3888,14 @@ wasm_foreign_as_ref_checked(void *) return res; } // Execute the original function - wasm_foreign_as_ref(); + wasm_instance_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_foreign_checked(void *) +wasm_instance_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3886,14 +3904,14 @@ wasm_ref_as_foreign_checked(void *) return res; } // Execute the original function - wasm_ref_as_foreign(); + wasm_instance_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_foreign_as_ref_const_checked(void *) +wasm_instance_exports_checked(void *, void *out) { Result res; // Check for null pointer parameter: None @@ -3901,15 +3919,20 @@ wasm_foreign_as_ref_const_checked(void *) 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_foreign_as_ref_const(); + wasm_instance_exports(, out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_foreign_const_checked(void *) +wasm_instance_get_host_info_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3918,14 +3941,14 @@ wasm_ref_as_foreign_const_checked(void *) return res; } // Execute the original function - wasm_ref_as_foreign_const(); + wasm_instance_get_host_info(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_foreign_new_checked(void *) +wasm_instance_get_wasm_func_exec_time_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -3933,15 +3956,26 @@ wasm_foreign_new_checked(void *) 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_new(); + double original_result = wasm_instance_get_wasm_func_exec_time(, ); // Assign return value and error code - res.error_code = 0; + 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_module_new_checked(void *, void *binary) +wasm_instance_new_checked(void *, void *, void *imports, void *trap) { Result res; // Check for null pointer parameter: None @@ -3949,20 +3983,31 @@ wasm_module_new_checked(void *, void *binary) res.error_code = -1; return res; } - // Check for null pointer parameter: binary - if (binary == NULL) { + // 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_module_new(, binary); + wasm_instance_new(, , imports, trap); // 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) +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 @@ -3970,25 +4015,31 @@ wasm_module_new_ex_checked(void *, void *binary, void *args) res.error_code = -1; return res; } - // Check for null pointer parameter: binary - if (binary == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: args - if (args == NULL) { + // 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_module_new_ex(, binary, args); + 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_module_delete_checked(void *) +wasm_instance_new_with_args_ex_checked(void *, void *, void *imports, + void *trap, void *inst_args) { Result res; // Check for null pointer parameter: None @@ -3996,15 +4047,35 @@ wasm_module_delete_checked(void *) 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_module_delete(); + 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_module_validate_checked(void *, void *binary) +wasm_instance_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -4012,13 +4083,13 @@ wasm_module_validate_checked(void *, void *binary) res.error_code = -1; return res; } - // Check for null pointer parameter: binary - if (binary == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = wasm_module_validate(, binary); + _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; @@ -4026,7 +4097,7 @@ wasm_module_validate_checked(void *, void *binary) } static inline Result -wasm_module_imports_checked(void *, void *out) +wasm_instance_set_host_info_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -4034,20 +4105,20 @@ wasm_module_imports_checked(void *, void *out) res.error_code = -1; return res; } - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_module_imports(, out); + wasm_instance_set_host_info(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_module_exports_checked(void *, void *out) +wasm_instance_set_host_info_with_finalizer_checked(void *, void *, void *) { Result res; // Check for null pointer parameter: None @@ -4055,20 +4126,25 @@ wasm_module_exports_checked(void *, void *out) res.error_code = -1; return res; } - // Check for null pointer parameter: out - if (out == NULL) { + // 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_exports(, out); + wasm_instance_set_host_info_with_finalizer(, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_module_serialize_checked(void *, void *out) +wasm_instance_sum_wasm_exec_time_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4076,20 +4152,21 @@ wasm_module_serialize_checked(void *, void *out) 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); + double original_result = wasm_instance_sum_wasm_exec_time(); // Assign return value and error code - res.error_code = 0; + 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_module_deserialize_checked(void *, void *) +wasm_memory_as_extern_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4097,20 +4174,15 @@ wasm_module_deserialize_checked(void *, void *) 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(, ); + wasm_memory_as_extern(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_module_share_checked(void *) +wasm_memory_as_extern_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4119,14 +4191,14 @@ wasm_module_share_checked(void *) return res; } // Execute the original function - wasm_module_share(); + wasm_memory_as_extern_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_module_obtain_checked(void *, void *) +wasm_memory_as_ref_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4134,20 +4206,31 @@ wasm_module_obtain_checked(void *, void *) 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_module_obtain(, ); + wasm_memory_as_ref_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_shared_module_delete_checked(void *) +wasm_memory_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4156,14 +4239,14 @@ wasm_shared_module_delete_checked(void *) return res; } // Execute the original function - wasm_shared_module_delete(); + wasm_memory_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_module_set_name_checked(void *, void *name) +wasm_memory_data_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4171,21 +4254,15 @@ wasm_module_set_name_checked(void *, void *name) 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); + wasm_memory_data(); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_module_get_name_checked(void *) +wasm_memory_data_size_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4194,31 +4271,36 @@ wasm_module_get_name_checked(void *) return res; } // Execute the original function - wasm_module_get_name(); + size_t original_result = wasm_memory_data_size(); // Assign return value and error code - res.error_code = 0; + 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_module_is_underlying_binary_freeable_checked(void *module) +wasm_memory_delete_checked(void *) { Result res; - // Check for null pointer parameter: module - if (module == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = wasm_module_is_underlying_binary_freeable(module); + wasm_memory_delete(); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_func_delete_checked(void *) +wasm_memory_get_host_info_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4227,14 +4309,14 @@ wasm_func_delete_checked(void *) return res; } // Execute the original function - wasm_func_delete(); + wasm_memory_get_host_info(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_func_copy_checked(void *) +wasm_memory_grow_checked(void *, wasm_memory_pages_t delta) { Result res; // Check for null pointer parameter: None @@ -4243,14 +4325,15 @@ wasm_func_copy_checked(void *) return res; } // Execute the original function - wasm_func_copy(); + _Bool original_result = wasm_memory_grow(, delta); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_func_same_checked(void *, void *) +wasm_memory_new_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -4264,15 +4347,14 @@ wasm_func_same_checked(void *, void *) return res; } // Execute the original function - _Bool original_result = wasm_func_same(, ); + wasm_memory_new(, ); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_func_get_host_info_checked(void *) +wasm_memory_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -4280,15 +4362,21 @@ wasm_func_get_host_info_checked(void *) 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_get_host_info(); + _Bool original_result = wasm_memory_same(, ); // Assign return value and error code - res.error_code = 0; + 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 *) +wasm_memory_set_host_info_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -4302,14 +4390,14 @@ wasm_func_set_host_info_checked(void *, void *) return res; } // Execute the original function - wasm_func_set_host_info(, ); + wasm_memory_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 *) +wasm_memory_set_host_info_with_finalizer_checked(void *, void *, void *) { Result res; // Check for null pointer parameter: None @@ -4328,14 +4416,14 @@ wasm_func_set_host_info_with_finalizer_checked(void *, void *, void *) return res; } // Execute the original function - wasm_func_set_host_info_with_finalizer(, , ); + wasm_memory_set_host_info_with_finalizer(, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_func_as_ref_checked(void *) +wasm_memory_size_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4344,14 +4432,20 @@ wasm_func_as_ref_checked(void *) return res; } // Execute the original function - wasm_func_as_ref(); + wasm_memory_pages_t original_result = wasm_memory_size(); // Assign return value and error code - res.error_code = 0; + 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_ref_as_func_checked(void *) +wasm_memory_type_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4360,14 +4454,14 @@ wasm_ref_as_func_checked(void *) return res; } // Execute the original function - wasm_ref_as_func(); + wasm_memory_type(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_func_as_ref_const_checked(void *) +wasm_memorytype_as_externtype_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4376,14 +4470,14 @@ wasm_func_as_ref_const_checked(void *) return res; } // Execute the original function - wasm_func_as_ref_const(); + wasm_memorytype_as_externtype(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_func_const_checked(void *) +wasm_memorytype_as_externtype_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4392,14 +4486,14 @@ wasm_ref_as_func_const_checked(void *) return res; } // Execute the original function - wasm_ref_as_func_const(); + wasm_memorytype_as_externtype_const(); // 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) +wasm_memorytype_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4407,22 +4501,15 @@ wasm_func_new_checked(void *, void *, wasm_func_callback_t) 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(, , ); + wasm_memorytype_copy(); // 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) +wasm_memorytype_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4430,30 +4517,15 @@ wasm_func_new_with_env_checked(void *, void *type, 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); + wasm_memorytype_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_func_type_checked(void *) +wasm_memorytype_limits_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4462,14 +4534,14 @@ wasm_func_type_checked(void *) return res; } // Execute the original function - wasm_func_type(); + wasm_memorytype_limits(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_func_param_arity_checked(void *) +wasm_memorytype_new_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4478,42 +4550,35 @@ wasm_func_param_arity_checked(void *) return res; } // Execute the original function - size_t original_result = wasm_func_param_arity(); + wasm_memorytype_new(); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_func_result_arity_checked(void *) +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 - size_t original_result = wasm_func_result_arity(); + wasm_memorytype_vec_copy(out, ); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_func_call_checked(void *, void *args, void *results) +wasm_memorytype_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4521,79 +4586,63 @@ wasm_func_call_checked(void *, void *args, void *results) 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); + wasm_memorytype_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_delete_checked(void *) +wasm_memorytype_vec_new_checked(void *out, size_t, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_global_delete(); + wasm_memorytype_vec_new(out, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_copy_checked(void *) +wasm_memorytype_vec_new_empty_checked(void *out) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_global_copy(); + wasm_memorytype_vec_new_empty(out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_same_checked(void *, void *) +wasm_memorytype_vec_new_uninitialized_checked(void *out, size_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) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = wasm_global_same(, ); + wasm_memorytype_vec_new_uninitialized(out, ); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_global_get_host_info_checked(void *) +wasm_module_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4602,14 +4651,14 @@ wasm_global_get_host_info_checked(void *) return res; } // Execute the original function - wasm_global_get_host_info(); + wasm_module_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_set_host_info_checked(void *, void *) +wasm_module_deserialize_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -4623,14 +4672,14 @@ wasm_global_set_host_info_checked(void *, void *) return res; } // Execute the original function - wasm_global_set_host_info(, ); + wasm_module_deserialize(, ); // 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 *) +wasm_module_exports_checked(void *, void *out) { Result res; // Check for null pointer parameter: None @@ -4638,25 +4687,20 @@ wasm_global_set_host_info_with_finalizer_checked(void *, void *, void *) 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) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_global_set_host_info_with_finalizer(, , ); + wasm_module_exports(, out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_as_ref_checked(void *) +wasm_module_get_name_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4665,14 +4709,14 @@ wasm_global_as_ref_checked(void *) return res; } // Execute the original function - wasm_global_as_ref(); + wasm_module_get_name(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_global_checked(void *) +wasm_module_imports_checked(void *, void *out) { Result res; // Check for null pointer parameter: None @@ -4680,31 +4724,37 @@ wasm_ref_as_global_checked(void *) 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_ref_as_global(); + wasm_module_imports(, out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_as_ref_const_checked(void *) +wasm_module_is_underlying_binary_freeable_checked(void *module) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: module + if (module == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_global_as_ref_const(); + _Bool original_result = wasm_module_is_underlying_binary_freeable(module); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_ref_as_global_const_checked(void *) +wasm_module_new_checked(void *, void *binary) { Result res; // Check for null pointer parameter: None @@ -4712,15 +4762,20 @@ wasm_ref_as_global_const_checked(void *) 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_ref_as_global_const(); + wasm_module_new(, binary); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_new_checked(void *, void *, void *) +wasm_module_new_ex_checked(void *, void *binary, void *args) { Result res; // Check for null pointer parameter: None @@ -4728,25 +4783,25 @@ wasm_global_new_checked(void *, void *, void *) res.error_code = -1; return res; } - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: binary + if (binary == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: args + if (args == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_global_new(, , ); + wasm_module_new_ex(, binary, args); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_type_checked(void *) +wasm_module_obtain_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -4754,15 +4809,20 @@ wasm_global_type_checked(void *) 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_type(); + wasm_module_obtain(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_get_checked(void *, void *out) +wasm_module_serialize_checked(void *, void *out) { Result res; // Check for null pointer parameter: None @@ -4776,14 +4836,14 @@ wasm_global_get_checked(void *, void *out) return res; } // Execute the original function - wasm_global_get(, out); + wasm_module_serialize(, out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_set_checked(void *, void *) +wasm_module_set_name_checked(void *, void *name) { Result res; // Check for null pointer parameter: None @@ -4791,20 +4851,21 @@ wasm_global_set_checked(void *, void *) res.error_code = -1; return res; } - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: name + if (name == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_global_set(, ); + _Bool original_result = wasm_module_set_name(, name); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_table_delete_checked(void *) +wasm_module_share_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4813,14 +4874,14 @@ wasm_table_delete_checked(void *) return res; } // Execute the original function - wasm_table_delete(); + wasm_module_share(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_copy_checked(void *) +wasm_module_validate_checked(void *, void *binary) { Result res; // Check for null pointer parameter: None @@ -4828,15 +4889,21 @@ wasm_table_copy_checked(void *) 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_table_copy(); + _Bool original_result = wasm_module_validate(, binary); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_table_same_checked(void *, void *) +wasm_ref_as_extern_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4844,21 +4911,15 @@ wasm_table_same_checked(void *, void *) 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(, ); + wasm_ref_as_extern(); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_table_get_host_info_checked(void *) +wasm_ref_as_extern_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4867,14 +4928,14 @@ wasm_table_get_host_info_checked(void *) return res; } // Execute the original function - wasm_table_get_host_info(); + wasm_ref_as_extern_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_set_host_info_checked(void *, void *) +wasm_ref_as_foreign_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4882,20 +4943,15 @@ wasm_table_set_host_info_checked(void *, void *) 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(, ); + wasm_ref_as_foreign(); // 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 *) +wasm_ref_as_foreign_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4903,25 +4959,15 @@ wasm_table_set_host_info_with_finalizer_checked(void *, void *, void *) 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(, , ); + wasm_ref_as_foreign_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_as_ref_checked(void *) +wasm_ref_as_func_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4930,14 +4976,14 @@ wasm_table_as_ref_checked(void *) return res; } // Execute the original function - wasm_table_as_ref(); + wasm_ref_as_func(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_table_checked(void *) +wasm_ref_as_func_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4946,14 +4992,14 @@ wasm_ref_as_table_checked(void *) return res; } // Execute the original function - wasm_ref_as_table(); + wasm_ref_as_func_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_as_ref_const_checked(void *) +wasm_ref_as_global_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4962,14 +5008,14 @@ wasm_table_as_ref_const_checked(void *) return res; } // Execute the original function - wasm_table_as_ref_const(); + wasm_ref_as_global(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_table_const_checked(void *) +wasm_ref_as_global_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4978,14 +5024,14 @@ wasm_ref_as_table_const_checked(void *) return res; } // Execute the original function - wasm_ref_as_table_const(); + wasm_ref_as_global_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_new_checked(void *, void *, void *init) +wasm_ref_as_instance_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4993,25 +5039,15 @@ wasm_table_new_checked(void *, void *, void *init) 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); + wasm_ref_as_instance(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_type_checked(void *) +wasm_ref_as_instance_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5020,14 +5056,14 @@ wasm_table_type_checked(void *) return res; } // Execute the original function - wasm_table_type(); + wasm_ref_as_instance_const(); // 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) +wasm_ref_as_memory_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5036,14 +5072,14 @@ wasm_table_get_checked(void *, wasm_table_size_t index) return res; } // Execute the original function - wasm_table_get(, index); + wasm_ref_as_memory(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_set_checked(void *, wasm_table_size_t index, void *) +wasm_ref_as_memory_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5051,21 +5087,15 @@ wasm_table_set_checked(void *, wasm_table_size_t index, void *) 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, ); + wasm_ref_as_memory_const(); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_table_size_checked(void *) +wasm_ref_as_table_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5074,20 +5104,14 @@ wasm_table_size_checked(void *) return res; } // Execute the original function - wasm_table_size_t original_result = wasm_table_size(); + wasm_ref_as_table(); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_table_grow_checked(void *, wasm_table_size_t delta, void *init) +wasm_ref_as_table_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5095,21 +5119,15 @@ wasm_table_grow_checked(void *, wasm_table_size_t delta, void *init) 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); + wasm_ref_as_table_const(); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_memory_delete_checked(void *) +wasm_ref_as_trap_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5118,14 +5136,14 @@ wasm_memory_delete_checked(void *) return res; } // Execute the original function - wasm_memory_delete(); + wasm_ref_as_trap(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_copy_checked(void *) +wasm_ref_as_trap_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5134,14 +5152,14 @@ wasm_memory_copy_checked(void *) return res; } // Execute the original function - wasm_memory_copy(); + wasm_ref_as_trap_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_same_checked(void *, void *) +wasm_ref_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5149,21 +5167,31 @@ wasm_memory_same_checked(void *, void *) 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 - _Bool original_result = wasm_memory_same(, ); + wasm_ref_delete(); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_memory_get_host_info_checked(void *) +wasm_ref_get_host_info_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5172,14 +5200,14 @@ wasm_memory_get_host_info_checked(void *) return res; } // Execute the original function - wasm_memory_get_host_info(); + wasm_ref_get_host_info(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_set_host_info_checked(void *, void *) +wasm_ref_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -5193,14 +5221,15 @@ wasm_memory_set_host_info_checked(void *, void *) return res; } // Execute the original function - wasm_memory_set_host_info(, ); + _Bool original_result = wasm_ref_same(, ); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_memory_set_host_info_with_finalizer_checked(void *, void *, void *) +wasm_ref_set_host_info_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -5213,20 +5242,15 @@ wasm_memory_set_host_info_with_finalizer_checked(void *, void *, void *) 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(, , ); + wasm_ref_set_host_info(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_as_ref_checked(void *) +wasm_ref_set_host_info_with_finalizer_checked(void *, void *, void *) { Result res; // Check for null pointer parameter: None @@ -5234,15 +5258,25 @@ wasm_memory_as_ref_checked(void *) 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_as_ref(); + wasm_ref_set_host_info_with_finalizer(, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_memory_checked(void *) +wasm_shared_module_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5251,14 +5285,14 @@ wasm_ref_as_memory_checked(void *) return res; } // Execute the original function - wasm_ref_as_memory(); + wasm_shared_module_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_as_ref_const_checked(void *) +wasm_store_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5267,14 +5301,14 @@ wasm_memory_as_ref_const_checked(void *) return res; } // Execute the original function - wasm_memory_as_ref_const(); + wasm_store_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_memory_const_checked(void *) +wasm_store_new_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5283,14 +5317,14 @@ wasm_ref_as_memory_const_checked(void *) return res; } // Execute the original function - wasm_ref_as_memory_const(); + wasm_store_new(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_new_checked(void *, void *) +wasm_table_as_extern_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5298,20 +5332,15 @@ wasm_memory_new_checked(void *, void *) 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(, ); + wasm_table_as_extern(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_type_checked(void *) +wasm_table_as_extern_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5320,14 +5349,14 @@ wasm_memory_type_checked(void *) return res; } // Execute the original function - wasm_memory_type(); + wasm_table_as_extern_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_data_checked(void *) +wasm_table_as_ref_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5336,14 +5365,14 @@ wasm_memory_data_checked(void *) return res; } // Execute the original function - wasm_memory_data(); + wasm_table_as_ref(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_data_size_checked(void *) +wasm_table_as_ref_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5352,20 +5381,14 @@ wasm_memory_data_size_checked(void *) return res; } // Execute the original function - size_t original_result = wasm_memory_data_size(); + wasm_table_as_ref_const(); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_memory_size_checked(void *) +wasm_table_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5374,20 +5397,14 @@ wasm_memory_size_checked(void *) return res; } // Execute the original function - wasm_memory_pages_t original_result = wasm_memory_size(); + wasm_table_copy(); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_memory_grow_checked(void *, wasm_memory_pages_t delta) +wasm_table_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5396,15 +5413,14 @@ wasm_memory_grow_checked(void *, wasm_memory_pages_t delta) return res; } // Execute the original function - _Bool original_result = wasm_memory_grow(, delta); + wasm_table_delete(); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_extern_delete_checked(void *) +wasm_table_get_checked(void *, wasm_table_size_t index) { Result res; // Check for null pointer parameter: None @@ -5413,14 +5429,14 @@ wasm_extern_delete_checked(void *) return res; } // Execute the original function - wasm_extern_delete(); + wasm_table_get(, index); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_copy_checked(void *) +wasm_table_get_host_info_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5429,14 +5445,14 @@ wasm_extern_copy_checked(void *) return res; } // Execute the original function - wasm_extern_copy(); + wasm_table_get_host_info(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_same_checked(void *, void *) +wasm_table_grow_checked(void *, wasm_table_size_t delta, void *init) { Result res; // Check for null pointer parameter: None @@ -5444,13 +5460,13 @@ wasm_extern_same_checked(void *, void *) res.error_code = -1; return res; } - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: init + if (init == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = wasm_extern_same(, ); + _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; @@ -5458,7 +5474,7 @@ wasm_extern_same_checked(void *, void *) } static inline Result -wasm_extern_get_host_info_checked(void *) +wasm_table_new_checked(void *, void *, void *init) { Result res; // Check for null pointer parameter: None @@ -5466,15 +5482,25 @@ wasm_extern_get_host_info_checked(void *) 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_extern_get_host_info(); + wasm_table_new(, , init); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_set_host_info_checked(void *, void *) +wasm_table_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -5488,14 +5514,15 @@ wasm_extern_set_host_info_checked(void *, void *) return res; } // Execute the original function - wasm_extern_set_host_info(, ); + _Bool original_result = wasm_table_same(, ); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_extern_set_host_info_with_finalizer_checked(void *, void *, void *) +wasm_table_set_checked(void *, wasm_table_size_t index, void *) { Result res; // Check for null pointer parameter: None @@ -5508,20 +5535,16 @@ wasm_extern_set_host_info_with_finalizer_checked(void *, void *, void *) 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(, , ); + _Bool original_result = wasm_table_set(, index, ); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_extern_as_ref_checked(void *) +wasm_table_set_host_info_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -5529,31 +5552,20 @@ wasm_extern_as_ref_checked(void *) 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_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(); + wasm_table_set_host_info(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_as_ref_const_checked(void *) +wasm_table_set_host_info_with_finalizer_checked(void *, void *, void *) { Result res; // Check for null pointer parameter: None @@ -5561,15 +5573,25 @@ wasm_extern_as_ref_const_checked(void *) 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_as_ref_const(); + wasm_table_set_host_info_with_finalizer(, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_extern_const_checked(void *) +wasm_table_size_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5578,83 +5600,84 @@ wasm_ref_as_extern_const_checked(void *) return res; } // Execute the original function - wasm_ref_as_extern_const(); + wasm_table_size_t original_result = wasm_table_size(); // Assign return value and error code - res.error_code = 0; + 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_extern_vec_new_empty_checked(void *out) +wasm_table_type_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_extern_vec_new_empty(out); + wasm_table_type(); // 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) +wasm_tabletype_as_externtype_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_extern_vec_new_uninitialized(out, ); + wasm_tabletype_as_externtype(); // 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 *) +wasm_tabletype_as_externtype_const_checked(void *) { Result res; - // Check for null pointer parameter: out - if (out == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_extern_vec_new(out, , ); + wasm_tabletype_as_externtype_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_vec_copy_checked(void *out, void *) +wasm_tabletype_copy_checked(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, ); + wasm_tabletype_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_vec_delete_checked(void *) +wasm_tabletype_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5663,14 +5686,14 @@ wasm_extern_vec_delete_checked(void *) return res; } // Execute the original function - wasm_extern_vec_delete(); + wasm_tabletype_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_kind_checked(void *) +wasm_tabletype_element_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5679,20 +5702,14 @@ wasm_extern_kind_checked(void *) return res; } // Execute the original function - wasm_externkind_t original_result = wasm_extern_kind(); + wasm_tabletype_element(); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_extern_type_checked(void *) +wasm_tabletype_limits_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5701,14 +5718,14 @@ wasm_extern_type_checked(void *) return res; } // Execute the original function - wasm_extern_type(); + wasm_tabletype_limits(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_func_as_extern_checked(void *) +wasm_tabletype_new_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -5716,31 +5733,41 @@ wasm_func_as_extern_checked(void *) 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_as_extern(); + wasm_tabletype_new(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_as_extern_checked(void *) +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_global_as_extern(); + wasm_tabletype_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_as_extern_checked(void *) +wasm_tabletype_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5749,62 +5776,62 @@ wasm_table_as_extern_checked(void *) return res; } // Execute the original function - wasm_table_as_extern(); + wasm_tabletype_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_as_extern_checked(void *) +wasm_tabletype_vec_new_checked(void *out, size_t, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_memory_as_extern(); + wasm_tabletype_vec_new(out, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_as_func_checked(void *) +wasm_tabletype_vec_new_empty_checked(void *out) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_extern_as_func(); + wasm_tabletype_vec_new_empty(out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_as_global_checked(void *) +wasm_tabletype_vec_new_uninitialized_checked(void *out, size_t) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_extern_as_global(); + wasm_tabletype_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_as_table_checked(void *) +wasm_trap_as_ref_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5813,14 +5840,14 @@ wasm_extern_as_table_checked(void *) return res; } // Execute the original function - wasm_extern_as_table(); + wasm_trap_as_ref(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_as_memory_checked(void *) +wasm_trap_as_ref_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5829,14 +5856,14 @@ wasm_extern_as_memory_checked(void *) return res; } // Execute the original function - wasm_extern_as_memory(); + wasm_trap_as_ref_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_func_as_extern_const_checked(void *) +wasm_trap_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5845,14 +5872,14 @@ wasm_func_as_extern_const_checked(void *) return res; } // Execute the original function - wasm_func_as_extern_const(); + wasm_trap_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_as_extern_const_checked(void *) +wasm_trap_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5861,14 +5888,14 @@ wasm_global_as_extern_const_checked(void *) return res; } // Execute the original function - wasm_global_as_extern_const(); + wasm_trap_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_as_extern_const_checked(void *) +wasm_trap_get_host_info_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5877,14 +5904,14 @@ wasm_table_as_extern_const_checked(void *) return res; } // Execute the original function - wasm_table_as_extern_const(); + wasm_trap_get_host_info(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_as_extern_const_checked(void *) +wasm_trap_message_checked(void *, void *out) { Result res; // Check for null pointer parameter: None @@ -5892,31 +5919,41 @@ wasm_memory_as_extern_const_checked(void *) 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_memory_as_extern_const(); + wasm_trap_message(, out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_as_func_const_checked(void *) +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_extern_as_func_const(); + wasm_trap_new(store, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_as_global_const_checked(void *) +wasm_trap_origin_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5925,14 +5962,14 @@ wasm_extern_as_global_const_checked(void *) return res; } // Execute the original function - wasm_extern_as_global_const(); + wasm_trap_origin(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_as_table_const_checked(void *) +wasm_trap_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -5940,15 +5977,21 @@ wasm_extern_as_table_const_checked(void *) 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_as_table_const(); + _Bool original_result = wasm_trap_same(, ); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_extern_as_memory_const_checked(void *) +wasm_trap_set_host_info_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -5956,15 +5999,20 @@ wasm_extern_as_memory_const_checked(void *) 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_as_memory_const(); + wasm_trap_set_host_info(, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_instance_delete_checked(void *) +wasm_trap_set_host_info_with_finalizer_checked(void *, void *, void *) { Result res; // Check for null pointer parameter: None @@ -5972,15 +6020,25 @@ wasm_instance_delete_checked(void *) 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_delete(); + wasm_trap_set_host_info_with_finalizer(, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_instance_copy_checked(void *) +wasm_trap_trace_checked(void *, void *out) { Result res; // Check for null pointer parameter: None @@ -5988,19 +6046,24 @@ wasm_instance_copy_checked(void *) 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_copy(); + wasm_trap_trace(, out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_instance_same_checked(void *, void *) +wasm_val_copy_checked(void *out, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } @@ -6010,35 +6073,34 @@ wasm_instance_same_checked(void *, void *) return res; } // Execute the original function - _Bool original_result = wasm_instance_same(, ); + wasm_val_copy(out, ); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_instance_get_host_info_checked(void *) +wasm_val_delete_checked(void *v) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: v + if (v == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_instance_get_host_info(); + wasm_val_delete(v); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_instance_set_host_info_checked(void *, void *) +wasm_val_vec_copy_checked(void *out, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } @@ -6048,14 +6110,14 @@ wasm_instance_set_host_info_checked(void *, void *) return res; } // Execute the original function - wasm_instance_set_host_info(, ); + wasm_val_vec_copy(out, ); // 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 *) +wasm_val_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -6063,73 +6125,63 @@ wasm_instance_set_host_info_with_finalizer_checked(void *, void *, void *) 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(, , ); + wasm_val_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_instance_as_ref_checked(void *) +wasm_val_vec_new_checked(void *out, size_t, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_instance_as_ref(); + wasm_val_vec_new(out, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_instance_checked(void *) +wasm_val_vec_new_empty_checked(void *out) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_ref_as_instance(); + wasm_val_vec_new_empty(out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_instance_as_ref_const_checked(void *) +wasm_val_vec_new_uninitialized_checked(void *out, size_t) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_instance_as_ref_const(); + wasm_val_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_instance_const_checked(void *) +wasm_valtype_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -6138,14 +6190,14 @@ wasm_ref_as_instance_const_checked(void *) return res; } // Execute the original function - wasm_ref_as_instance_const(); + wasm_valtype_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_instance_new_checked(void *, void *, void *imports, void *trap) +wasm_valtype_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -6153,31 +6205,15 @@ wasm_instance_new_checked(void *, void *, void *imports, void *trap) 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); + wasm_valtype_delete(); // 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) +wasm_valtype_kind_checked(void *) { Result res; // Check for null pointer parameter: None @@ -6185,35 +6221,36 @@ wasm_instance_new_with_args_checked(void *, void *, void *imports, void *trap, 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; + // 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; } - // Check for null pointer parameter: trap - if (trap == NULL) { - res.error_code = -1; - return res; + else { + res.error_code = -2; } + return res; +} + +static inline Result +wasm_valtype_new_checked(wasm_valkind_t) +{ + Result res; // Execute the original function - wasm_instance_new_with_args(, , imports, trap, stack_size, heap_size); + wasm_valtype_new(); // 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) +wasm_valtype_vec_copy_checked(void *out, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } @@ -6222,30 +6259,15 @@ wasm_instance_new_with_args_ex_checked(void *, void *, void *imports, 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); + wasm_valtype_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_instance_exports_checked(void *, void *out) +wasm_valtype_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -6253,78 +6275,56 @@ wasm_instance_exports_checked(void *, void *out) 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); + wasm_valtype_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_instance_sum_wasm_exec_time_checked(void *) +wasm_valtype_vec_new_checked(void *out, size_t, void *) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - double original_result = wasm_instance_sum_wasm_exec_time(); + wasm_valtype_vec_new(out, , ); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_instance_get_wasm_func_exec_time_checked(void *, void *) +wasm_valtype_vec_new_empty_checked(void *out) { 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) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - double original_result = wasm_instance_get_wasm_func_exec_time(, ); + wasm_valtype_vec_new_empty(out); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_extern_new_empty_checked(void *, wasm_externkind_t) +wasm_valtype_vec_new_uninitialized_checked(void *out, size_t) { Result res; - // Check for null pointer parameter: None - if (None == NULL) { + // Check for null pointer parameter: out + if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_extern_new_empty(, ); + wasm_valtype_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; diff --git a/core/iwasm/include/wasm_export_checked.h b/core/iwasm/include/wasm_export_checked.h index 2a8b2fea2d..c7610079ea 100644 --- a/core/iwasm/include/wasm_export_checked.h +++ b/core/iwasm/include/wasm_export_checked.h @@ -19,20 +19,20 @@ typedef struct { int error_code; // Error code (0 for success, non-zero for errors) union { - wasm_valkind_t wasm_valkind_t_value; - wasm_module_t wasm_module_t_value; - uint32_t uint32_t_value; RunningMode RunningMode_value; _Bool _Bool_value; - wasm_function_inst_t wasm_function_inst_t_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; - uint64_t uint64_t_value; - wasm_shared_heap_t wasm_shared_heap_t_value; - int32_t int32_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; @@ -60,28 +60,40 @@ get_base_lib_export_apis_checked(void *p_base_lib_apis) } static inline Result -wasm_runtime_init_checked(void) +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 - _Bool original_result = wasm_runtime_init(); + package_type_t original_result = get_package_type(buf, size); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_full_init_checked(void *init_args) +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: init_args - if (init_args == NULL) { + // Check for null pointer parameter: name + if (name == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = wasm_runtime_full_init(init_args); + _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; @@ -89,23 +101,67 @@ wasm_runtime_full_init_checked(void *init_args) } static inline Result -wasm_runtime_set_log_level_checked(log_level_t level) +wasm_application_execute_main_checked(wasm_module_inst_t module_inst, + int32_t argc, void *argv) { Result res; // Execute the original function - wasm_runtime_set_log_level(level); + _Bool original_result = + wasm_application_execute_main(module_inst, argc, argv); // Assign return value and error code - res.error_code = 0; + 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) +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_runtime_is_running_mode_supported(running_mode); + 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; @@ -113,11 +169,16 @@ wasm_runtime_is_running_mode_supported_checked(RunningMode running_mode) } static inline Result -wasm_runtime_set_default_running_mode_checked(RunningMode running_mode) +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_runtime_set_default_running_mode(running_mode); + _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; @@ -125,91 +186,107 @@ wasm_runtime_set_default_running_mode_checked(RunningMode running_mode) } static inline Result -wasm_runtime_destroy_checked(void) +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 - wasm_runtime_destroy(); + _Bool original_result = wasm_externref_ref2obj(externref_idx, p_extern_obj); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_malloc_checked(unsigned int size) +wasm_externref_retain_checked(uint32_t externref_idx) { Result res; // Execute the original function - wasm_runtime_malloc(size); + _Bool original_result = wasm_externref_retain(externref_idx); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_realloc_checked(void *ptr, unsigned int size) +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: ptr - if (ptr == NULL) { + // 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 - wasm_runtime_realloc(ptr, size); + _Bool original_result = + wasm_externref_set_cleanup(module_inst, extern_obj, extern_obj_cleanup); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_free_checked(void *ptr) +wasm_func_get_param_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) { 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); + uint32_t original_result = + wasm_func_get_param_count(func_inst, module_inst); // Assign return value and error code - res.error_code = 0; + 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_mem_alloc_info_checked(void *mem_alloc_info) +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: mem_alloc_info - if (mem_alloc_info == NULL) { + // Check for null pointer parameter: param_types + if (param_types == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = wasm_runtime_get_mem_alloc_info(mem_alloc_info); + wasm_func_get_param_types(func_inst, module_inst, param_types); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -get_package_type_checked(void *buf, uint32_t size) +wasm_func_get_result_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) { 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); + 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.package_type_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -218,39 +295,33 @@ get_package_type_checked(void *buf, uint32_t size) } static inline Result -wasm_runtime_get_file_package_type_checked(void *buf, uint32_t size) +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: buf - if (buf == NULL) { + // Check for null pointer parameter: result_types + if (result_types == NULL) { res.error_code = -1; return res; } // Execute the original function - package_type_t original_result = - wasm_runtime_get_file_package_type(buf, size); + wasm_func_get_result_types(func_inst, module_inst, result_types); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_get_module_package_type_checked(wasm_module_t module) +wasm_func_type_get_param_count_checked(wasm_func_type_t func_type) { Result res; // Execute the original function - package_type_t original_result = - wasm_runtime_get_module_package_type(module); + 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.package_type_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -259,20 +330,17 @@ wasm_runtime_get_module_package_type_checked(wasm_module_t module) } static inline Result -wasm_runtime_get_file_package_version_checked(void *buf, uint32_t size) +wasm_func_type_get_param_valkind_checked(wasm_func_type_t func_type, + uint32_t param_index) { 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); + 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.uint32_t_value = original_result; + res.value.wasm_valkind_t_value = original_result; } else { res.error_code = -2; @@ -281,11 +349,11 @@ wasm_runtime_get_file_package_version_checked(void *buf, uint32_t size) } static inline Result -wasm_runtime_get_module_package_version_checked(wasm_module_t module) +wasm_func_type_get_result_count_checked(wasm_func_type_t func_type) { Result res; // Execute the original function - uint32_t original_result = wasm_runtime_get_module_package_version(module); + 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; @@ -298,16 +366,17 @@ wasm_runtime_get_module_package_version_checked(wasm_module_t module) } static inline Result -wasm_runtime_get_current_package_version_checked(package_type_t package_type) +wasm_func_type_get_result_valkind_checked(wasm_func_type_t func_type, + uint32_t result_index) { Result res; // Execute the original function - uint32_t original_result = - wasm_runtime_get_current_package_version(package_type); + 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.uint32_t_value = original_result; + res.value.wasm_valkind_t_value = original_result; } else { res.error_code = -2; @@ -316,16 +385,11 @@ wasm_runtime_get_current_package_version_checked(package_type_t package_type) } static inline Result -wasm_runtime_is_xip_file_checked(void *buf, uint32_t size) +wasm_global_type_get_mutable_checked(wasm_global_type_t global_type) { 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); + _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; @@ -333,35 +397,29 @@ wasm_runtime_is_xip_file_checked(void *buf, uint32_t size) } static inline Result -wasm_runtime_set_module_reader_checked(module_reader reader, - module_destroyer destroyer) +wasm_global_type_get_valkind_checked(wasm_global_type_t global_type) { Result res; // Execute the original function - wasm_runtime_set_module_reader(reader, destroyer); + wasm_valkind_t original_result = wasm_global_type_get_valkind(global_type); // Assign return value and error code - res.error_code = 0; - return res; -} + 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_runtime_register_module_checked(void *module_name, wasm_module_t module, - void *error_buf, uint32_t error_buf_size) +wasm_memory_enlarge_checked(wasm_memory_inst_t memory_inst, + uint64_t inc_page_count) { 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); + _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; @@ -369,21 +427,26 @@ wasm_runtime_register_module_checked(void *module_name, wasm_module_t module, } static inline Result -wasm_runtime_find_module_registered_checked(void *module_name) +wasm_memory_get_base_address_checked(wasm_memory_inst_t memory_inst) { 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); + wasm_memory_get_base_address(memory_inst); // Assign return value and error code - if (original_result != NULL) { + 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.wasm_module_t_value = original_result; + res.value.uint64_t_value = original_result; } else { res.error_code = -2; @@ -392,27 +455,15 @@ wasm_runtime_find_module_registered_checked(void *module_name) } static inline Result -wasm_runtime_load_checked(void *buf, uint32_t size, void *error_buf, - uint32_t error_buf_size) +wasm_memory_get_cur_page_count_checked(wasm_memory_inst_t memory_inst) { 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); + uint64_t original_result = wasm_memory_get_cur_page_count(memory_inst); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_module_t_value = original_result; + res.value.uint64_t_value = original_result; } else { res.error_code = -2; @@ -421,32 +472,15 @@ wasm_runtime_load_checked(void *buf, uint32_t size, void *error_buf, } static inline Result -wasm_runtime_load_ex_checked(void *buf, uint32_t size, void *args, - void *error_buf, uint32_t error_buf_size) +wasm_memory_get_max_page_count_checked(wasm_memory_inst_t memory_inst) { 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); + uint64_t original_result = wasm_memory_get_max_page_count(memory_inst); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_module_t_value = original_result; + res.value.uint64_t_value = original_result; } else { res.error_code = -2; @@ -455,11 +489,11 @@ wasm_runtime_load_ex_checked(void *buf, uint32_t size, void *args, } static inline Result -wasm_runtime_resolve_symbols_checked(wasm_module_t module) +wasm_memory_get_shared_checked(wasm_memory_inst_t memory_inst) { Result res; // Execute the original function - _Bool original_result = wasm_runtime_resolve_symbols(module); + _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; @@ -467,23 +501,16 @@ wasm_runtime_resolve_symbols_checked(wasm_module_t module) } 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) +wasm_memory_type_get_init_page_count_checked(wasm_memory_type_t memory_type) { 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); + uint32_t original_result = + wasm_memory_type_get_init_page_count(memory_type); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_module_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -492,248 +519,224 @@ wasm_runtime_load_from_sections_checked(wasm_section_list_t section_list, } static inline Result -wasm_runtime_unload_checked(wasm_module_t module) +wasm_memory_type_get_max_page_count_checked(wasm_memory_type_t memory_type) { Result res; // Execute the original function - wasm_runtime_unload(module); + uint32_t original_result = wasm_memory_type_get_max_page_count(memory_type); // Assign return value and error code - res.error_code = 0; + 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_module_hash_checked(wasm_module_t module) +wasm_memory_type_get_shared_checked(wasm_memory_type_t memory_type) { Result res; // Execute the original function - wasm_runtime_get_module_hash(module); + _Bool original_result = wasm_memory_type_get_shared(memory_type); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; 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) +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_set_wasi_args_ex(module, dir_list, dir_count, map_dir_list, - map_dir_count, env, env_count, argv, argc, - stdinfd, stdoutfd, stderrfd); + 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_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) +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 - wasm_runtime_set_wasi_args(module, dir_list, dir_count, map_dir_list, - map_dir_count, env, env_count, argv, argc); + uint64_t original_result = + wasm_runtime_addr_native_to_app(module_inst, native_ptr); // Assign return value and error code - res.error_code = 0; + 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_set_wasi_addr_pool_checked(wasm_module_t module, void *addr_pool, - uint32_t addr_pool_size) +wasm_runtime_attach_shared_heap_checked(wasm_module_inst_t module_inst, + wasm_shared_heap_t shared_heap) { Result res; // Execute the original function - wasm_runtime_set_wasi_addr_pool(module, addr_pool, addr_pool_size); + _Bool original_result = + wasm_runtime_attach_shared_heap(module_inst, shared_heap); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; 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) +wasm_runtime_begin_blocking_op_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - wasm_runtime_set_wasi_ns_lookup_pool(module, ns_lookup_pool, - ns_lookup_pool_size); + _Bool original_result = wasm_runtime_begin_blocking_op(exec_env); // Assign return value and error code - res.error_code = 0; + 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) +wasm_runtime_call_indirect_checked(wasm_exec_env_t exec_env, + uint32_t element_index, uint32_t argc, + void *argv) { 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); + _Bool original_result = + wasm_runtime_call_indirect(exec_env, element_index, argc, argv); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_instantiate_ex_checked(wasm_module_t module, void *args, - void *error_buf, uint32_t error_buf_size) +wasm_runtime_call_wasm_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, uint32_t argc, + void *argv) { 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); + _Bool original_result = + wasm_runtime_call_wasm(exec_env, function, argc, argv); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_instantiation_args_create_checked(void *p) +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: p - if (p == NULL) { + // Check for null pointer parameter: args + if (args == 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 + _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_instantiation_args_destroy_checked(void *p) +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; - // Check for null pointer parameter: p - if (p == NULL) { - res.error_code = -1; - return res; - } + va_list args; // Execute the original function - wasm_runtime_instantiation_args_destroy(p); + 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 = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_instantiation_args_set_default_stack_size_checked(void *p, - uint32_t v) +wasm_runtime_chain_shared_heaps_checked(wasm_shared_heap_t head, + wasm_shared_heap_t body) { 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); + wasm_shared_heap_t original_result = + wasm_runtime_chain_shared_heaps(head, body); // Assign return value and error code - res.error_code = 0; + 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_instantiation_args_set_host_managed_heap_size_checked(void *p, - uint32_t v) +wasm_runtime_clear_exception_checked(wasm_module_inst_t module_inst) { 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); + wasm_runtime_clear_exception(module_inst); // 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) +wasm_runtime_create_context_key_checked(void *dtor) { Result res; - // Check for null pointer parameter: p - if (p == NULL) { + // Check for null pointer parameter: dtor + if (dtor == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_instantiation_args_set_max_memory_pages(p, v); + wasm_runtime_create_context_key(dtor); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_instantiate_ex2_checked(wasm_module_t module, void *args, - void *error_buf, uint32_t error_buf_size) +wasm_runtime_create_exec_env_checked(wasm_module_inst_t module_inst, + uint32_t stack_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); + 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_module_inst_t_value = original_result; + res.value.wasm_exec_env_t_value = original_result; } else { res.error_code = -2; @@ -742,29 +745,21 @@ wasm_runtime_instantiate_ex2_checked(wasm_module_t module, void *args, } 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_get_running_mode_checked(wasm_module_inst_t module_inst) +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 - RunningMode original_result = wasm_runtime_get_running_mode(module_inst); + wasm_shared_heap_t original_result = + wasm_runtime_create_shared_heap(init_args); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.RunningMode_value = original_result; + res.value.wasm_shared_heap_t_value = original_result; } else { res.error_code = -2; @@ -784,178 +779,130 @@ wasm_runtime_deinstantiate_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_get_module_checked(wasm_module_inst_t module_inst) +wasm_runtime_destroy_checked(void) { Result res; // Execute the original function - wasm_module_t original_result = wasm_runtime_get_module(module_inst); + wasm_runtime_destroy(); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_is_wasi_mode_checked(wasm_module_inst_t module_inst) +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 - _Bool original_result = wasm_runtime_is_wasi_mode(module_inst); + wasm_runtime_destroy_context_key(key); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_lookup_wasi_start_function_checked(wasm_module_inst_t module_inst) +wasm_runtime_destroy_exec_env_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - wasm_function_inst_t original_result = - wasm_runtime_lookup_wasi_start_function(module_inst); + wasm_runtime_destroy_exec_env(exec_env); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_get_wasi_exit_code_checked(wasm_module_inst_t module_inst) +wasm_runtime_destroy_spawned_exec_env_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - uint32_t original_result = wasm_runtime_get_wasi_exit_code(module_inst); + wasm_runtime_destroy_spawned_exec_env(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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_lookup_function_checked(wasm_module_inst_t module_inst, void *name) +wasm_runtime_destroy_thread_env_checked(void) { 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); + wasm_runtime_destroy_thread_env(); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_func_get_param_count_checked(wasm_function_inst_t func_inst, - wasm_module_inst_t module_inst) +wasm_runtime_detach_shared_heap_checked(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); + wasm_runtime_detach_shared_heap(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; - } + 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) +wasm_runtime_detect_native_stack_overflow_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - uint32_t original_result = - wasm_func_get_result_count(func_inst, module_inst); + _Bool original_result = wasm_runtime_detect_native_stack_overflow(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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; 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) +wasm_runtime_detect_native_stack_overflow_size_checked(wasm_exec_env_t exec_env, + uint32_t required_size) { 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); + _Bool original_result = + wasm_runtime_detect_native_stack_overflow_size(exec_env, required_size); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; 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) +wasm_runtime_dump_call_stack_checked(wasm_exec_env_t exec_env) { 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); + wasm_runtime_dump_call_stack(exec_env); // 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) +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 - wasm_exec_env_t original_result = - wasm_runtime_create_exec_env(module_inst, stack_size); + uint32_t original_result = + wasm_runtime_dump_call_stack_to_buf(exec_env, buf, len); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_exec_env_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -964,35 +911,40 @@ wasm_runtime_create_exec_env_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_destroy_exec_env_checked(wasm_exec_env_t exec_env) +wasm_runtime_dump_mem_consumption_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - wasm_runtime_destroy_exec_env(exec_env); + wasm_runtime_dump_mem_consumption(exec_env); // Assign return value and error code res.error_code = 0; 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) +wasm_runtime_dump_perf_profiling_checked(wasm_module_inst_t module_inst) { 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) { + // 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_copy_callstack( - exec_env, buffer, length, skip_n, error_buf, error_buf_size); + 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; @@ -1005,52 +957,46 @@ wasm_copy_callstack_checked(wasm_exec_env_t exec_env, void *buffer, } static inline Result -wasm_runtime_get_exec_env_singleton_checked(wasm_module_inst_t module_inst) +wasm_runtime_end_blocking_op_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - wasm_exec_env_t original_result = - wasm_runtime_get_exec_env_singleton(module_inst); + wasm_runtime_end_blocking_op(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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_start_debug_instance_with_port_checked(wasm_exec_env_t exec_env, - int32_t port) +wasm_runtime_enlarge_memory_checked(wasm_module_inst_t module_inst, + uint64_t inc_page_count) { Result res; // Execute the original function - uint32_t original_result = - wasm_runtime_start_debug_instance_with_port(exec_env, port); + _Bool original_result = + wasm_runtime_enlarge_memory(module_inst, inc_page_count); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_start_debug_instance_checked(wasm_exec_env_t exec_env) +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 - uint32_t original_result = wasm_runtime_start_debug_instance(exec_env); + wasm_module_t original_result = + wasm_runtime_find_module_registered(module_name); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.uint32_t_value = original_result; + res.value.wasm_module_t_value = original_result; } else { res.error_code = -2; @@ -1059,34 +1005,58 @@ wasm_runtime_start_debug_instance_checked(wasm_exec_env_t exec_env) } static inline Result -wasm_runtime_init_thread_env_checked(void) +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 - _Bool original_result = wasm_runtime_init_thread_env(); + wasm_runtime_free(ptr); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_destroy_thread_env_checked(void) +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 - wasm_runtime_destroy_thread_env(); + _Bool original_result = wasm_runtime_full_init(init_args); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_thread_env_inited_checked(void) +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_thread_env_inited(); + _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; @@ -1094,15 +1064,15 @@ wasm_runtime_thread_env_inited_checked(void) } static inline Result -wasm_runtime_get_module_inst_checked(wasm_exec_env_t exec_env) +wasm_runtime_get_call_stack_buf_size_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); + uint32_t original_result = wasm_runtime_get_call_stack_buf_size(exec_env); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_module_inst_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -1111,33 +1081,32 @@ wasm_runtime_get_module_inst_checked(wasm_exec_env_t exec_env) } static inline Result -wasm_runtime_set_module_inst_checked(wasm_exec_env_t exec_env, - wasm_module_inst_t module_inst) +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_set_module_inst(exec_env, module_inst); + wasm_runtime_get_context(inst, key); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_lookup_memory_checked(wasm_module_inst_t module_inst, void *name) +wasm_runtime_get_current_package_version_checked(package_type_t package_type) { 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); + uint32_t original_result = + wasm_runtime_get_current_package_version(package_type); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_memory_inst_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -1146,30 +1115,45 @@ wasm_runtime_lookup_memory_checked(wasm_module_inst_t module_inst, void *name) } static inline Result -wasm_runtime_get_default_memory_checked(wasm_module_inst_t module_inst) +wasm_runtime_get_custom_data_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); + wasm_runtime_get_custom_data(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; + 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; } - else { - res.error_code = -2; + // 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_memory_checked(wasm_module_inst_t module_inst, uint32_t index) +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_memory(module_inst, index); + wasm_runtime_get_default_memory(module_inst); // Assign return value and error code if (original_result != NULL) { res.error_code = 0; @@ -1182,32 +1166,27 @@ wasm_runtime_get_memory_checked(wasm_module_inst_t module_inst, uint32_t index) } static inline Result -wasm_memory_get_cur_page_count_checked(wasm_memory_inst_t memory_inst) +wasm_runtime_get_exception_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - uint64_t original_result = wasm_memory_get_cur_page_count(memory_inst); + wasm_runtime_get_exception(module_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; - } + res.error_code = 0; return res; } static inline Result -wasm_memory_get_max_page_count_checked(wasm_memory_inst_t memory_inst) +wasm_runtime_get_exec_env_singleton_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - uint64_t original_result = wasm_memory_get_max_page_count(memory_inst); + wasm_exec_env_t original_result = + wasm_runtime_get_exec_env_singleton(module_inst); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.uint64_t_value = original_result; + res.value.wasm_exec_env_t_value = original_result; } else { res.error_code = -2; @@ -1216,15 +1195,15 @@ wasm_memory_get_max_page_count_checked(wasm_memory_inst_t memory_inst) } static inline Result -wasm_memory_get_bytes_per_page_checked(wasm_memory_inst_t memory_inst) +wasm_runtime_get_export_count_checked(wasm_module_t module) { Result res; // Execute the original function - uint64_t original_result = wasm_memory_get_bytes_per_page(memory_inst); + 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.uint64_t_value = original_result; + res.value.int32_t_value = original_result; } else { res.error_code = -2; @@ -1233,11 +1212,23 @@ wasm_memory_get_bytes_per_page_checked(wasm_memory_inst_t memory_inst) } static inline Result -wasm_memory_get_shared_checked(wasm_memory_inst_t memory_inst) +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_memory_get_shared(memory_inst); + _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; @@ -1245,126 +1236,147 @@ wasm_memory_get_shared_checked(wasm_memory_inst_t memory_inst) } static inline Result -wasm_memory_get_base_address_checked(wasm_memory_inst_t memory_inst) +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 - wasm_memory_get_base_address(memory_inst); + _Bool original_result = + wasm_runtime_get_export_table_inst(module_inst, name, table_inst); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_memory_enlarge_checked(wasm_memory_inst_t memory_inst, - uint64_t inc_page_count) +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 - _Bool original_result = wasm_memory_enlarge(memory_inst, inc_page_count); + wasm_runtime_get_export_type(module, export_index, export_type); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; 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) +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 - _Bool original_result = - wasm_runtime_call_wasm(exec_env, function, argc, argv); + package_type_t original_result = + wasm_runtime_get_file_package_type(buf, size); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_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) +wasm_runtime_get_file_package_version_checked(void *buf, uint32_t size) { Result res; - // Check for null pointer parameter: args - if (args == NULL) { + // Check for null pointer parameter: buf + if (buf == 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); + uint32_t original_result = wasm_runtime_get_file_package_version(buf, size); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_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, ...) +wasm_runtime_get_function_attachment_checked(wasm_exec_env_t exec_env) { 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); + wasm_runtime_get_function_attachment(exec_env); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; 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) +wasm_runtime_get_import_count_checked(wasm_module_t module) { Result res; // Execute the original function - _Bool original_result = - wasm_runtime_call_indirect(exec_env, element_index, argc, argv); + int32_t original_result = wasm_runtime_get_import_count(module); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_application_execute_main_checked(wasm_module_inst_t module_inst, - int32_t argc, void *argv) +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 - _Bool original_result = - wasm_application_execute_main(module_inst, argc, argv); + wasm_runtime_get_import_type(module, import_index, import_type); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_application_execute_func_checked(wasm_module_inst_t module_inst, - void *name, int32_t argc, void *argv) +wasm_runtime_get_mem_alloc_info_checked(void *mem_alloc_info) { Result res; - // Check for null pointer parameter: name - if (name == NULL) { + // 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_application_execute_func(module_inst, name, argc, argv); + _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; @@ -1372,101 +1384,139 @@ wasm_application_execute_func_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_get_exception_checked(wasm_module_inst_t module_inst) +wasm_runtime_get_memory_checked(wasm_module_inst_t module_inst, uint32_t index) { Result res; // Execute the original function - wasm_runtime_get_exception(module_inst); + wasm_memory_inst_t original_result = + wasm_runtime_get_memory(module_inst, index); // Assign return value and error code - res.error_code = 0; + 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_set_exception_checked(wasm_module_inst_t module_inst, - void *exception) +wasm_runtime_get_module_checked(wasm_module_inst_t module_inst) { 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); + wasm_module_t original_result = wasm_runtime_get_module(module_inst); // Assign return value and error code - res.error_code = 0; + 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_clear_exception_checked(wasm_module_inst_t module_inst) +wasm_runtime_get_module_hash_checked(wasm_module_t module) { Result res; // Execute the original function - wasm_runtime_clear_exception(module_inst); + wasm_runtime_get_module_hash(module); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_terminate_checked(wasm_module_inst_t module_inst) +wasm_runtime_get_module_inst_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - wasm_runtime_terminate(module_inst); + wasm_module_inst_t original_result = wasm_runtime_get_module_inst(exec_env); // Assign return value and error code - res.error_code = 0; + 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_set_custom_data_checked(wasm_module_inst_t module_inst, - void *custom_data) +wasm_runtime_get_module_name_checked(wasm_module_t module) { 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); + wasm_runtime_get_module_name(module); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_get_custom_data_checked(wasm_module_inst_t module_inst) +wasm_runtime_get_module_package_type_checked(wasm_module_t module) { Result res; // Execute the original function - wasm_runtime_get_custom_data(module_inst); + package_type_t original_result = + wasm_runtime_get_module_package_type(module); // Assign return value and error code - res.error_code = 0; + 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_set_bounds_checks_checked(wasm_module_inst_t module_inst, - _Bool enable) +wasm_runtime_get_module_package_version_checked(wasm_module_t module) { Result res; // Execute the original function - wasm_runtime_set_bounds_checks(module_inst, enable); + uint32_t original_result = wasm_runtime_get_module_package_version(module); // Assign return value and error code - res.error_code = 0; + 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_is_bounds_checks_enabled_checked(wasm_module_inst_t module_inst) +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_is_bounds_checks_enabled(module_inst); + _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; @@ -1474,22 +1524,15 @@ wasm_runtime_is_bounds_checks_enabled_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_module_malloc_checked(wasm_module_inst_t module_inst, - uint64_t size, void *p_native_addr) +wasm_runtime_get_pgo_prof_data_size_checked(wasm_module_inst_t module_inst) { 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); + 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.uint64_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -1498,33 +1541,15 @@ wasm_runtime_module_malloc_checked(wasm_module_inst_t module_inst, } 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_dup_data_checked(wasm_module_inst_t module_inst, void *src, - uint64_t size) +wasm_runtime_get_running_mode_checked(wasm_module_inst_t module_inst) { 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); + 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.uint64_t_value = original_result; + res.value.RunningMode_value = original_result; } else { res.error_code = -2; @@ -1533,81 +1558,76 @@ wasm_runtime_module_dup_data_checked(wasm_module_inst_t module_inst, void *src, } static inline Result -wasm_runtime_validate_app_addr_checked(wasm_module_inst_t module_inst, - uint64_t app_offset, uint64_t size) +wasm_runtime_get_user_data_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - _Bool original_result = - wasm_runtime_validate_app_addr(module_inst, app_offset, size); + wasm_runtime_get_user_data(exec_env); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_validate_app_str_addr_checked(wasm_module_inst_t module_inst, - uint64_t app_str_offset) +wasm_runtime_get_version_checked(void *major, void *minor, void *patch) { 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) { + // 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 - _Bool original_result = - wasm_runtime_validate_native_addr(module_inst, native_ptr, size); + wasm_runtime_get_version(major, minor, patch); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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) +wasm_runtime_get_wasi_exit_code_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - wasm_runtime_addr_app_to_native(module_inst, app_offset); + uint32_t original_result = wasm_runtime_get_wasi_exit_code(module_inst); // Assign return value and error code - res.error_code = 0; + 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_addr_native_to_app_checked(wasm_module_inst_t module_inst, - void *native_ptr) +wasm_runtime_get_wasm_func_exec_time_checked(wasm_module_inst_t inst, + void *func_name) { Result res; - // Check for null pointer parameter: native_ptr - if (native_ptr == NULL) { + // Check for null pointer parameter: func_name + if (func_name == 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); + 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.uint64_t_value = original_result; + res.value.double_value = original_result; } else { res.error_code = -2; @@ -1616,25 +1636,11 @@ wasm_runtime_addr_native_to_app_checked(wasm_module_inst_t module_inst, } 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) +wasm_runtime_init_checked(void) { 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); + _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; @@ -1642,30 +1648,11 @@ wasm_runtime_get_app_addr_range_checked(wasm_module_inst_t module_inst, } 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) +wasm_runtime_init_thread_env_checked(void) { 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); + _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; @@ -1673,15 +1660,25 @@ wasm_runtime_get_native_addr_range_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_get_import_count_checked(wasm_module_t module) +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 - int32_t original_result = wasm_runtime_get_import_count(module); + 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 == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.int32_t_value = original_result; + res.value.wasm_module_inst_t_value = original_result; } else { res.error_code = -2; @@ -1690,32 +1687,56 @@ wasm_runtime_get_import_count_checked(wasm_module_t module) } static inline Result -wasm_runtime_get_import_type_checked(wasm_module_t module, int32_t import_index, - void *import_type) +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: import_type - if (import_type == NULL) { + // 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_runtime_get_import_type(module, import_index, import_type); + wasm_module_inst_t original_result = + wasm_runtime_instantiate_ex(module, args, error_buf, error_buf_size); // Assign return value and error code - res.error_code = 0; + 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_export_count_checked(wasm_module_t module) +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 - int32_t original_result = wasm_runtime_get_export_count(module); + 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 == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.int32_t_value = original_result; + res.value.wasm_module_inst_t_value = original_result; } else { res.error_code = -2; @@ -1724,117 +1745,118 @@ wasm_runtime_get_export_count_checked(wasm_module_t module) } static inline Result -wasm_runtime_get_export_type_checked(wasm_module_t module, int32_t export_index, - void *export_type) +wasm_runtime_instantiation_args_create_checked(void *p) { Result res; - // Check for null pointer parameter: export_type - if (export_type == NULL) { + // Check for null pointer parameter: p + if (p == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_get_export_type(module, export_index, export_type); + _Bool original_result = wasm_runtime_instantiation_args_create(p); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_func_type_get_param_count_checked(wasm_func_type_t func_type) +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 - uint32_t original_result = wasm_func_type_get_param_count(func_type); + wasm_runtime_instantiation_args_destroy(p); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_func_type_get_param_valkind_checked(wasm_func_type_t func_type, - uint32_t param_index) +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_valkind_t original_result = - wasm_func_type_get_param_valkind(func_type, param_index); + wasm_runtime_instantiation_args_set_default_stack_size(p, v); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_func_type_get_result_count_checked(wasm_func_type_t func_type) +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 - uint32_t original_result = wasm_func_type_get_result_count(func_type); + wasm_runtime_instantiation_args_set_host_managed_heap_size(p, v); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_func_type_get_result_valkind_checked(wasm_func_type_t func_type, - uint32_t result_index) +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_valkind_t original_result = - wasm_func_type_get_result_valkind(func_type, result_index); + wasm_runtime_instantiation_args_set_max_memory_pages(p, v); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_global_type_get_valkind_checked(wasm_global_type_t global_type) +wasm_runtime_is_bounds_checks_enabled_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - wasm_valkind_t original_result = wasm_global_type_get_valkind(global_type); + _Bool original_result = wasm_runtime_is_bounds_checks_enabled(module_inst); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_global_type_get_mutable_checked(wasm_global_type_t global_type) +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_global_type_get_mutable(global_type); + _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; @@ -1842,11 +1864,23 @@ wasm_global_type_get_mutable_checked(wasm_global_type_t global_type) } static inline Result -wasm_memory_type_get_shared_checked(wasm_memory_type_t memory_type) +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_memory_type_get_shared(memory_type); + _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; @@ -1854,63 +1888,53 @@ wasm_memory_type_get_shared_checked(wasm_memory_type_t memory_type) } static inline Result -wasm_memory_type_get_init_page_count_checked(wasm_memory_type_t memory_type) +wasm_runtime_is_running_mode_supported_checked(RunningMode running_mode) { Result res; // Execute the original function - uint32_t original_result = - wasm_memory_type_get_init_page_count(memory_type); + _Bool original_result = + wasm_runtime_is_running_mode_supported(running_mode); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_memory_type_get_max_page_count_checked(wasm_memory_type_t memory_type) +wasm_runtime_is_underlying_binary_freeable_checked(wasm_module_t module) { Result res; // Execute the original function - uint32_t original_result = wasm_memory_type_get_max_page_count(memory_type); + _Bool original_result = wasm_runtime_is_underlying_binary_freeable(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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_table_type_get_elem_kind_checked(wasm_table_type_t table_type) +wasm_runtime_is_wasi_mode_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - wasm_valkind_t original_result = wasm_table_type_get_elem_kind(table_type); + _Bool original_result = wasm_runtime_is_wasi_mode(module_inst); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_table_type_get_shared_checked(wasm_table_type_t table_type) +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_table_type_get_shared(table_type); + _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; @@ -1918,15 +1942,20 @@ wasm_table_type_get_shared_checked(wasm_table_type_t table_type) } static inline Result -wasm_table_type_get_init_size_checked(wasm_table_type_t table_type) +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 - uint32_t original_result = wasm_table_type_get_init_size(table_type); + 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.uint32_t_value = original_result; + res.value.int32_t_value = original_result; } else { res.error_code = -2; @@ -1935,15 +1964,27 @@ wasm_table_type_get_init_size_checked(wasm_table_type_t table_type) } static inline Result -wasm_table_type_get_max_size_checked(wasm_table_type_t table_type) +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 - uint32_t original_result = wasm_table_type_get_max_size(table_type); + wasm_module_t original_result = + wasm_runtime_load(buf, size, error_buf, error_buf_size); // Assign return value and error code - if (original_result == 0) { + if (original_result != NULL) { res.error_code = 0; - res.value.uint32_t_value = original_result; + res.value.wasm_module_t_value = original_result; } else { res.error_code = -2; @@ -1952,80 +1993,66 @@ wasm_table_type_get_max_size_checked(wasm_table_type_t table_type) } static inline Result -wasm_runtime_register_natives_checked(void *module_name, void *native_symbols, - uint32_t n_native_symbols) +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: module_name - if (module_name == NULL) { - res.error_code = -1; - return res; - } - // Check for null pointer parameter: native_symbols - if (native_symbols == NULL) { + // Check for null pointer parameter: buf + if (buf == 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) { + // Check for null pointer parameter: args + if (args == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: native_symbols - if (native_symbols == NULL) { + // 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_natives_raw( - module_name, native_symbols, n_native_symbols); + wasm_module_t original_result = + wasm_runtime_load_ex(buf, size, args, error_buf, error_buf_size); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_unregister_natives_checked(void *module_name, void *native_symbols) +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: module_name - if (module_name == NULL) { - res.error_code = -1; - return res; - } - // Check for null pointer parameter: native_symbols - if (native_symbols == NULL) { + // 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_unregister_natives(module_name, native_symbols); + 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 - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_export_global_inst_checked(wasm_module_inst_t module_inst, - void *name, void *global_inst) +wasm_runtime_lookup_function_checked(wasm_module_inst_t module_inst, void *name) { Result res; // Check for null pointer parameter: name @@ -2033,23 +2060,22 @@ wasm_runtime_get_export_global_inst_checked(wasm_module_inst_t module_inst, 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); + wasm_function_inst_t original_result = + wasm_runtime_lookup_function(module_inst, name); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_get_export_table_inst_checked(wasm_module_inst_t module_inst, - void *name, void *table_inst) +wasm_runtime_lookup_memory_checked(wasm_module_inst_t module_inst, void *name) { Result res; // Check for null pointer parameter: name @@ -2057,33 +2083,27 @@ wasm_runtime_get_export_table_inst_checked(wasm_module_inst_t module_inst, 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); + wasm_memory_inst_t original_result = + wasm_runtime_lookup_memory(module_inst, name); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_table_get_func_inst_checked(wasm_module_inst_t module_inst, - void *table_inst, uint32_t idx) +wasm_runtime_lookup_wasi_start_function_checked(wasm_module_inst_t module_inst) { 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); + wasm_runtime_lookup_wasi_start_function(module_inst); // Assign return value and error code if (original_result != NULL) { res.error_code = 0; @@ -2096,243 +2116,254 @@ wasm_table_get_func_inst_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_get_function_attachment_checked(wasm_exec_env_t exec_env) +wasm_runtime_malloc_checked(unsigned int size) { Result res; // Execute the original function - wasm_runtime_get_function_attachment(exec_env); + wasm_runtime_malloc(size); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_set_user_data_checked(wasm_exec_env_t exec_env, void *user_data) +wasm_runtime_module_dup_data_checked(wasm_module_inst_t module_inst, void *src, + uint64_t size) { Result res; - // Check for null pointer parameter: user_data - if (user_data == NULL) { + // Check for null pointer parameter: src + if (src == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_set_user_data(exec_env, user_data); + uint64_t original_result = + wasm_runtime_module_dup_data(module_inst, src, size); // Assign return value and error code - res.error_code = 0; + 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_get_user_data_checked(wasm_exec_env_t exec_env) +wasm_runtime_module_free_checked(wasm_module_inst_t module_inst, uint64_t ptr) { Result res; // Execute the original function - wasm_runtime_get_user_data(exec_env); + wasm_runtime_module_free(module_inst, ptr); // 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) +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: native_stack_boundary - if (native_stack_boundary == NULL) { + // Check for null pointer parameter: p_native_addr + if (p_native_addr == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_set_native_stack_boundary(exec_env, native_stack_boundary); + uint64_t original_result = + wasm_runtime_module_malloc(module_inst, size, p_native_addr); // Assign return value and error code - res.error_code = 0; + 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_set_instruction_count_limit_checked(wasm_exec_env_t exec_env, - int instruction_count) +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_set_instruction_count_limit(exec_env, instruction_count); + wasm_runtime_realloc(ptr, size); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_dump_mem_consumption_checked(wasm_exec_env_t exec_env) +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 - wasm_runtime_dump_mem_consumption(exec_env); + _Bool original_result = wasm_runtime_register_module( + module_name, module, error_buf, error_buf_size); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_dump_perf_profiling_checked(wasm_module_inst_t module_inst) +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 - wasm_runtime_dump_perf_profiling(module_inst); + _Bool original_result = wasm_runtime_register_natives( + module_name, native_symbols, n_native_symbols); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_sum_wasm_exec_time_checked(wasm_module_inst_t module_inst) +wasm_runtime_register_natives_raw_checked(void *module_name, + void *native_symbols, + uint32_t n_native_symbols) { 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; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; } - 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) { + // Check for null pointer parameter: native_symbols + if (native_symbols == NULL) { res.error_code = -1; return res; } // Execute the original function - double original_result = - wasm_runtime_get_wasm_func_exec_time(inst, func_name); + _Bool original_result = wasm_runtime_register_natives_raw( + module_name, native_symbols, n_native_symbols); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_set_max_thread_num_checked(uint32_t num) +wasm_runtime_resolve_symbols_checked(wasm_module_t module) { Result res; // Execute the original function - wasm_runtime_set_max_thread_num(num); + _Bool original_result = wasm_runtime_resolve_symbols(module); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_spawn_exec_env_checked(wasm_exec_env_t exec_env) +wasm_runtime_set_bounds_checks_checked(wasm_module_inst_t module_inst, + _Bool enable) { Result res; // Execute the original function - wasm_exec_env_t original_result = wasm_runtime_spawn_exec_env(exec_env); + wasm_runtime_set_bounds_checks(module_inst, enable); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_destroy_spawned_exec_env_checked(wasm_exec_env_t exec_env) +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_destroy_spawned_exec_env(exec_env); + wasm_runtime_set_context(inst, key, ctx); // Assign return value and error code res.error_code = 0; 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) +wasm_runtime_set_context_spread_checked(wasm_module_inst_t inst, void *key, + void *ctx) { Result res; - // Check for null pointer parameter: tid - if (tid == NULL) { + // Check for null pointer parameter: key + if (key == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: arg - if (arg == NULL) { + // Check for null pointer parameter: ctx + if (ctx == NULL) { res.error_code = -1; return res; } // Execute the original function - int32_t original_result = - wasm_runtime_spawn_thread(exec_env, tid, callback, arg); + wasm_runtime_set_context_spread(inst, key, ctx); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_join_thread_checked(wasm_thread_t tid, void *retval) +wasm_runtime_set_custom_data_checked(wasm_module_inst_t module_inst, + void *custom_data) { Result res; - // Check for null pointer parameter: retval - if (retval == NULL) { + // Check for null pointer parameter: custom_data + if (custom_data == NULL) { res.error_code = -1; return res; } // Execute the original function - int32_t original_result = wasm_runtime_join_thread(tid, retval); + wasm_runtime_set_custom_data(module_inst, custom_data); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_externref_obj2ref_checked(wasm_module_inst_t module_inst, void *extern_obj, - void *p_externref_idx) +wasm_runtime_set_default_running_mode_checked(RunningMode running_mode) { 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); + _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; @@ -2340,426 +2371,432 @@ wasm_externref_obj2ref_checked(wasm_module_inst_t module_inst, void *extern_obj, } static inline Result -wasm_externref_objdel_checked(wasm_module_inst_t module_inst, void *extern_obj) +wasm_runtime_set_enlarge_mem_error_callback_checked( + enlarge_memory_error_callback_t callback, void *user_data) { Result res; - // Check for null pointer parameter: extern_obj - if (extern_obj == NULL) { + // Check for null pointer parameter: user_data + if (user_data == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = wasm_externref_objdel(module_inst, extern_obj); + wasm_runtime_set_enlarge_mem_error_callback(callback, user_data); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_externref_set_cleanup_checked(wasm_module_inst_t module_inst, - void *extern_obj, void *extern_obj_cleanup) +wasm_runtime_set_exception_checked(wasm_module_inst_t module_inst, + void *exception) { 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) { + // Check for null pointer parameter: exception + if (exception == 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); + wasm_runtime_set_exception(module_inst, exception); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_externref_ref2obj_checked(uint32_t externref_idx, void *p_extern_obj) +wasm_runtime_set_instruction_count_limit_checked(wasm_exec_env_t exec_env, + int instruction_count) { 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); + wasm_runtime_set_instruction_count_limit(exec_env, instruction_count); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_externref_retain_checked(uint32_t externref_idx) +wasm_runtime_set_log_level_checked(log_level_t level) { Result res; // Execute the original function - _Bool original_result = wasm_externref_retain(externref_idx); + wasm_runtime_set_log_level(level); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_dump_call_stack_checked(wasm_exec_env_t exec_env) +wasm_runtime_set_max_thread_num_checked(uint32_t num) { Result res; // Execute the original function - wasm_runtime_dump_call_stack(exec_env); + wasm_runtime_set_max_thread_num(num); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_get_call_stack_buf_size_checked(wasm_exec_env_t exec_env) +wasm_runtime_set_module_inst_checked(wasm_exec_env_t exec_env, + wasm_module_inst_t module_inst) { Result res; // Execute the original function - uint32_t original_result = wasm_runtime_get_call_stack_buf_size(exec_env); + wasm_runtime_set_module_inst(exec_env, 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; - } + 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) +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: buf - if (buf == NULL) { + // 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 - uint32_t original_result = - wasm_runtime_dump_call_stack_to_buf(exec_env, buf, len); + _Bool original_result = + wasm_runtime_set_module_name(module, name, 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; - } + 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) +wasm_runtime_set_module_reader_checked(module_reader reader, + module_destroyer destroyer) { Result res; // Execute the original function - uint32_t original_result = wasm_runtime_get_pgo_prof_data_size(module_inst); + wasm_runtime_set_module_reader(reader, destroyer); // 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; - } + 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) +wasm_runtime_set_native_stack_boundary_checked(wasm_exec_env_t exec_env, + void *native_stack_boundary) { Result res; - // Check for null pointer parameter: buf - if (buf == NULL) { + // Check for null pointer parameter: native_stack_boundary + if (native_stack_boundary == 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); + wasm_runtime_set_native_stack_boundary(exec_env, native_stack_boundary); // 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; - } + res.error_code = 0; return res; } static inline Result -wasm_runtime_get_custom_section_checked(wasm_module_t module_comm, void *name, - void *len) +wasm_runtime_set_running_mode_checked(wasm_module_inst_t module_inst, + RunningMode running_mode) { 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) { + // 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_get_custom_section(module_comm, name, len); + 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_get_version_checked(void *major, void *minor, void *patch) +wasm_runtime_set_wasi_addr_pool_checked(wasm_module_t module, void *addr_pool, + uint32_t addr_pool_size) { 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); + 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_is_import_func_linked_checked(void *module_name, void *func_name) +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; - // 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); + 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 = original_result ? 0 : -2; - res.value._Bool_value = original_result; + res.error_code = 0; return res; } static inline Result -wasm_runtime_is_import_global_linked_checked(void *module_name, - void *global_name) +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; - // 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) { + // 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 - _Bool original_result = - wasm_runtime_is_import_global_linked(module_name, global_name); + uint64_t original_result = + wasm_runtime_shared_heap_malloc(module_inst, size, p_native_addr); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_enlarge_memory_checked(wasm_module_inst_t module_inst, - uint64_t inc_page_count) +wasm_runtime_spawn_exec_env_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - _Bool original_result = - wasm_runtime_enlarge_memory(module_inst, inc_page_count); + wasm_exec_env_t original_result = wasm_runtime_spawn_exec_env(exec_env); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_set_enlarge_mem_error_callback_checked( - enlarge_memory_error_callback_t callback, void *user_data) +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: user_data - if (user_data == NULL) { + // 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 - wasm_runtime_set_enlarge_mem_error_callback(callback, user_data); + int32_t original_result = + wasm_runtime_spawn_thread(exec_env, tid, callback, arg); // Assign return value and error code - res.error_code = 0; + 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_create_context_key_checked(void *dtor) +wasm_runtime_start_debug_instance_checked(wasm_exec_env_t exec_env) { 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); + uint32_t original_result = wasm_runtime_start_debug_instance(exec_env); // Assign return value and error code - res.error_code = 0; + 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_destroy_context_key_checked(void *key) +wasm_runtime_start_debug_instance_with_port_checked(wasm_exec_env_t exec_env, + int32_t port) { 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); + uint32_t original_result = + wasm_runtime_start_debug_instance_with_port(exec_env, port); // Assign return value and error code - res.error_code = 0; + 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_set_context_checked(wasm_module_inst_t inst, void *key, void *ctx) +wasm_runtime_sum_wasm_exec_time_checked(wasm_module_inst_t module_inst) { 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); + double original_result = wasm_runtime_sum_wasm_exec_time(module_inst); // Assign return value and error code - res.error_code = 0; + 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_set_context_spread_checked(wasm_module_inst_t inst, void *key, - void *ctx) +wasm_runtime_terminate_checked(wasm_module_inst_t module_inst) { 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); + wasm_runtime_terminate(module_inst); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_runtime_get_context_checked(wasm_module_inst_t inst, void *key) +wasm_runtime_thread_env_inited_checked(void) { 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); + _Bool original_result = wasm_runtime_thread_env_inited(); // Assign return value and error code - res.error_code = 0; + 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) +wasm_runtime_unchain_shared_heaps_checked(wasm_shared_heap_t head, + _Bool entire_chain) { Result res; // Execute the original function - _Bool original_result = wasm_runtime_begin_blocking_op(exec_env); + wasm_shared_heap_t original_result = + wasm_runtime_unchain_shared_heaps(head, entire_chain); // Assign return value and error code - res.error_code = original_result ? 0 : -2; - res.value._Bool_value = original_result; + 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_end_blocking_op_checked(wasm_exec_env_t exec_env) +wasm_runtime_unload_checked(wasm_module_t module) { Result res; // Execute the original function - wasm_runtime_end_blocking_op(exec_env); + wasm_runtime_unload(module); // 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) +wasm_runtime_unregister_natives_checked(void *module_name, void *native_symbols) { Result res; - // Check for null pointer parameter: name - if (name == NULL) { + // 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) { + // 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_set_module_name(module, name, error_buf, error_buf_size); + 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; @@ -2767,22 +2804,13 @@ wasm_runtime_set_module_name_checked(wasm_module_t module, void *name, } 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_detect_native_stack_overflow_checked(wasm_exec_env_t exec_env) +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_detect_native_stack_overflow(exec_env); + _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; @@ -2790,13 +2818,13 @@ wasm_runtime_detect_native_stack_overflow_checked(wasm_exec_env_t exec_env) } static inline Result -wasm_runtime_detect_native_stack_overflow_size_checked(wasm_exec_env_t exec_env, - uint32_t required_size) +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_detect_native_stack_overflow_size(exec_env, required_size); + 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; @@ -2804,11 +2832,18 @@ wasm_runtime_detect_native_stack_overflow_size_checked(wasm_exec_env_t exec_env, } static inline Result -wasm_runtime_is_underlying_binary_freeable_checked(wasm_module_t module) +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_is_underlying_binary_freeable(module); + _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; @@ -2816,21 +2851,22 @@ wasm_runtime_is_underlying_binary_freeable_checked(wasm_module_t module) } static inline Result -wasm_runtime_create_shared_heap_checked(void *init_args) +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: init_args - if (init_args == NULL) { + // Check for null pointer parameter: table_inst + if (table_inst == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_shared_heap_t original_result = - wasm_runtime_create_shared_heap(init_args); + 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_shared_heap_t_value = original_result; + res.value.wasm_function_inst_t_value = original_result; } else { res.error_code = -2; @@ -2839,17 +2875,15 @@ wasm_runtime_create_shared_heap_checked(void *init_args) } static inline Result -wasm_runtime_chain_shared_heaps_checked(wasm_shared_heap_t head, - wasm_shared_heap_t body) +wasm_table_type_get_elem_kind_checked(wasm_table_type_t table_type) { Result res; // Execute the original function - wasm_shared_heap_t original_result = - wasm_runtime_chain_shared_heaps(head, body); + wasm_valkind_t original_result = wasm_table_type_get_elem_kind(table_type); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_shared_heap_t_value = original_result; + res.value.wasm_valkind_t_value = original_result; } else { res.error_code = -2; @@ -2858,17 +2892,15 @@ wasm_runtime_chain_shared_heaps_checked(wasm_shared_heap_t head, } static inline Result -wasm_runtime_unchain_shared_heaps_checked(wasm_shared_heap_t head, - _Bool entire_chain) +wasm_table_type_get_init_size_checked(wasm_table_type_t table_type) { Result res; // Execute the original function - wasm_shared_heap_t original_result = - wasm_runtime_unchain_shared_heaps(head, entire_chain); + uint32_t original_result = wasm_table_type_get_init_size(table_type); // Assign return value and error code - if (original_result != NULL) { + if (original_result == 0) { res.error_code = 0; - res.value.wasm_shared_heap_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -2877,47 +2909,15 @@ wasm_runtime_unchain_shared_heaps_checked(wasm_shared_heap_t head, } 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_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_shared_heap_malloc_checked(wasm_module_inst_t module_inst, - uint64_t size, void *p_native_addr) +wasm_table_type_get_max_size_checked(wasm_table_type_t table_type) { 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); + 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.uint64_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -2926,14 +2926,14 @@ wasm_runtime_shared_heap_malloc_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_shared_heap_free_checked(wasm_module_inst_t module_inst, - uint64_t ptr) +wasm_table_type_get_shared_checked(wasm_table_type_t table_type) { Result res; // Execute the original function - wasm_runtime_shared_heap_free(module_inst, ptr); + _Bool original_result = wasm_table_type_get_shared(table_type); // Assign return value and error code - res.error_code = 0; + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } From 58a9bae9c6ddc2cef81ff776d565cfc1d1bf7449 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Mon, 10 Nov 2025 12:53:16 +0000 Subject: [PATCH 27/27] fix: exclude standard library functions from generated checked headers --- ci/generate_checked_functions.py | 21 ++++ core/iwasm/include/wasm_c_api_checked.h | 128 ------------------------ 2 files changed, 21 insertions(+), 128 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index faa8a275ea..28c04887b9 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -268,6 +268,27 @@ def generate_checked_headers(header_paths): 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 = { diff --git a/core/iwasm/include/wasm_c_api_checked.h b/core/iwasm/include/wasm_c_api_checked.h index 05a7582438..83e73a3199 100644 --- a/core/iwasm/include/wasm_c_api_checked.h +++ b/core/iwasm/include/wasm_c_api_checked.h @@ -130,27 +130,6 @@ __memcmpeq_checked(void *__s1, void *__s2, size_t __n) 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) { @@ -430,43 +409,6 @@ memcpy_checked(void *__dest, void *__src, size_t __n) return res; } -static inline Result -memmove_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 - memmove(__dest, __src, __n); - // Assign return value and error code - res.error_code = 0; - return res; -} - -static inline Result -memset_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 - memset(__s, __c, __n); - // Assign return value and error code - res.error_code = 0; - return res; -} - static inline Result rindex_checked(void *__s, int __c) { @@ -579,27 +521,6 @@ strcasecmp_l_checked(void *__s1, void *__s2, locale_t __loc) return res; } -static inline Result -strcat_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 - strcat(__dest, __src); - // Assign return value and error code - res.error_code = 0; - return res; -} - static inline Result strchr_checked(void *__s, int __c) { @@ -616,33 +537,6 @@ strchr_checked(void *__s, int __c) return res; } -static inline Result -strcmp_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 = strcmp(__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_checked(void *__s1, void *__s2) { @@ -805,28 +699,6 @@ strerror_r_checked(int __errnum, void *__buf, size_t __buflen) return res; } -static inline Result -strlen_checked(void *__s) -{ - Result res; - // Check for null pointer parameter: __s - if (__s == NULL) { - res.error_code = -1; - return res; - } - // Execute the original function - size_t original_result = strlen(__s); - // 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 strncasecmp_checked(void *__s1, void *__s2, size_t __n) {