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 000000000..65b8a9739 --- /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 65b8a9739..e06791006 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -14,10 +14,6 @@ typedef struct { } 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 e06791006..c90145686 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 c90145686..f35a271ee 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 f35a271ee..5310822e6 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 5310822e6..bc6383285 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -2,11 +2,6 @@ from pycparser import c_parser, c_ast, parse_file 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 bc6383285..3fbdb6fb0 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 3fbdb6fb0..7a1937f9a 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 7a1937f9a..3fbdb6fb0 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 3fbdb6fb0..572d94646 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 572d94646..f682fd676 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -2,10 +2,78 @@ from pycparser import c_parser, c_ast, parse_file 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 generate_checked_function(func): +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 + + 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 f682fd676..ac5ef524e 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_typedef(typedefs, type_name): 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_typedef(typedefs, 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 + 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 ac5ef524e..630c0b86a 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 000000000..e3015b9c0 --- /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 000000000..4db49fa47 --- /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 000000000..2ad7bb6af --- /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 000000000..22a63b9b1 --- /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 | 156 +++++++++++++++++-------------- 1 file changed, 84 insertions(+), 72 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 630c0b86a..fc24a03a2 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") + 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)=", - ], - ) - - # 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", + # 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) - f.write("#endif // WASM_EXPORT_CHECKED_H\n") + # 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") 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 fc24a03a2..781006def 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_typedef(typedefs, 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 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 781006def..c3a618e61 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -29,23 +29,73 @@ Output: 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 +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)} - 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 +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 - return typedefs + +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") + + 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") def resolve_typedef(typedefs, type_name): @@ -97,6 +147,7 @@ def resolve_typedef(typedefs, 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 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 + cpp_args=CPP_ARGS, + ) - RESULT_STRUCT = RESULT_STRUCT.replace( - "// Add other types as needed", - f" {return_type} {return_type}_value;\n // Add other types as needed", - ) + typedefs = extract_typedefs(ast) + functions = [ + node + for node in ast.ext + if isinstance(node, c_ast.Decl) and isinstance(node.type, c_ast.FuncDecl) + ] - # 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") + return_types = { + " ".join(func.type.type.type.names) + for func in functions + if isinstance(func.type.type, c_ast.TypeDecl) + } - # 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") + result_struct = generate_result_struct(return_types) + write_checked_header(output_path, result_struct, functions, typedefs) - # 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") +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 c3a618e61..f1744b34c 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -57,6 +57,13 @@ RESULT_STRUCT_TEMPLATE = """ } 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 f1744b34c..8b2b579ae 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 8b2b579ae..51df56a0f 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -52,7 +52,7 @@ RESULT_STRUCT_TEMPLATE = """ 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 e3015b9c0..d1ea8c6e4 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 4db49fa47..5546bd2f3 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 22a63b9b1..6603dfc59 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 51df56a0f..4243202ed 100644 --- a/ci/generate_checked_functions.py +++ b/ci/generate_checked_functions.py @@ -7,8 +7,11 @@ Usage: 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 @@ Description: 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 9a9023ee2..cb27919e0 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 000000000..158343817 --- /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 000000000..698876458 --- /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 000000000..7dfab1152 --- /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 000000000..4c584de14 --- /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 000000000..e3f936201 --- /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 000000000..b6aa24b74 --- /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 000000000..2a8b2fea2 --- /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 | 230 +- core/iwasm/include/gc_export_checked.h | 6122 +++++++-------- core/iwasm/include/wasm_c_api_checked.h | 8590 +++++++++++----------- core/iwasm/include/wasm_export_checked.h | 4334 +++++------ 5 files changed, 9640 insertions(+), 9638 deletions(-) diff --git a/ci/generate_checked_functions.py b/ci/generate_checked_functions.py index 4243202ed..faa8a275e 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 7dfab1152..03c2dc9d1 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; @@ -44,6 +44,60 @@ aot_call_stack_features_init_default_checked(void *features) return res; } +static inline Result +aot_compile_wasm_checked(aot_comp_context_t comp_ctx) +{ + Result res; + // Execute the original function + _Bool original_result = aot_compile_wasm(comp_ctx); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +aot_compiler_destroy_checked(void) +{ + Result res; + // Execute the original function + aot_compiler_destroy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +aot_compiler_init_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = aot_compiler_init(); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +aot_create_comp_context_checked(aot_comp_data_t comp_data, + aot_comp_option_t option) +{ + Result res; + // Execute the original function + aot_comp_context_t original_result = + aot_create_comp_context(comp_data, option); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.aot_comp_context_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + static inline Result aot_create_comp_data_checked(void *wasm_module, void *target_arch, _Bool gc_enabled) @@ -74,58 +128,21 @@ aot_create_comp_data_checked(void *wasm_module, void *target_arch, } static inline Result -aot_destroy_comp_data_checked(aot_comp_data_t comp_data) +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_comp_data(comp_data); + aot_destroy_aot_file(aot_file); // 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) { @@ -138,62 +155,31 @@ aot_destroy_comp_context_checked(aot_comp_context_t comp_ctx) } static inline Result -aot_compile_wasm_checked(aot_comp_context_t comp_ctx) +aot_destroy_comp_data_checked(aot_comp_data_t comp_data) { 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); + 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,36 +256,22 @@ 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; - 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; + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; } - // Execute the original function - aot_destroy_aot_file(aot_file); - // Assign return value and error code - res.error_code = 0; return res; } @@ -331,4 +303,32 @@ aot_get_plt_table_size_checked(void) return res; } +static inline Result +aot_obj_data_create_checked(aot_comp_context_t comp_ctx) +{ + Result res; + // Execute the original function + aot_obj_data_t original_result = aot_obj_data_create(comp_ctx); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.aot_obj_data_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +aot_obj_data_destroy_checked(aot_obj_data_t obj_data) +{ + Result res; + // Execute the original function + aot_obj_data_destroy(obj_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + #endif // AOT_EXPORT_CHECKED_H diff --git a/core/iwasm/include/gc_export_checked.h b/core/iwasm/include/gc_export_checked.h index 4c584de14..47b651bd2 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 { - 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; + RunningMode RunningMode_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; + package_type_t package_type_t_value; uint32_t uint32_t_value; + uint64_t uint64_t_value; wasm_anyref_obj_t wasm_anyref_obj_t_value; + wasm_array_obj_t wasm_array_obj_t_value; + wasm_defined_type_t wasm_defined_type_t_value; + wasm_exec_env_t wasm_exec_env_t_value; + wasm_externref_obj_t wasm_externref_obj_t_value; + wasm_func_obj_t wasm_func_obj_t_value; + wasm_func_type_t wasm_func_type_t_value; + wasm_function_inst_t wasm_function_inst_t_value; + wasm_i31_obj_t wasm_i31_obj_t_value; + wasm_memory_inst_t wasm_memory_inst_t_value; + wasm_module_inst_t wasm_module_inst_t_value; + wasm_module_t wasm_module_t_value; + wasm_obj_t wasm_obj_t_value; + wasm_ref_type_t wasm_ref_type_t_value; + wasm_shared_heap_t wasm_shared_heap_t_value; + wasm_struct_obj_t wasm_struct_obj_t_value; + wasm_valkind_t wasm_valkind_t_value; // Add other types as needed } value; } Result; @@ -69,142 +69,6 @@ get_base_lib_export_apis_checked(void *p_base_lib_apis) 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) { @@ -227,6 +91,2068 @@ get_package_type_checked(void *buf, uint32_t size) return res; } +static inline Result +wasm_anyref_obj_get_value_checked(wasm_anyref_obj_t anyref_obj) +{ + Result res; + // Execute the original function + wasm_anyref_obj_get_value(anyref_obj); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_anyref_obj_new_checked(wasm_exec_env_t exec_env, void *host_obj) +{ + Result res; + // Check for null pointer parameter: host_obj + if (host_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_anyref_obj_t original_result = wasm_anyref_obj_new(exec_env, host_obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_anyref_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_application_execute_func_checked(wasm_module_inst_t module_inst, + void *name, int32_t argc, void *argv) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_application_execute_func(module_inst, name, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_application_execute_main_checked(wasm_module_inst_t module_inst, + int32_t argc, void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_application_execute_main(module_inst, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_array_obj_copy_checked(wasm_array_obj_t dst_obj, uint32_t dst_idx, + wasm_array_obj_t src_obj, uint32_t src_idx, + uint32_t len) +{ + Result res; + // Execute the original function + wasm_array_obj_copy(dst_obj, dst_idx, src_obj, src_idx, len); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_array_obj_elem_addr_checked(wasm_array_obj_t array_obj, uint32_t elem_idx) +{ + Result res; + // Execute the original function + wasm_array_obj_elem_addr(array_obj, elem_idx); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_array_obj_first_elem_addr_checked(wasm_array_obj_t array_obj) +{ + Result res; + // Execute the original function + wasm_array_obj_first_elem_addr(array_obj); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_array_obj_get_elem_checked(wasm_array_obj_t array_obj, uint32_t elem_idx, + _Bool sign_extend, void *value) +{ + Result res; + // Check for null pointer parameter: value + if (value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_array_obj_get_elem(array_obj, elem_idx, sign_extend, value); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_array_obj_length_checked(wasm_array_obj_t array_obj) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_array_obj_length(array_obj); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_array_obj_new_with_type_checked(wasm_exec_env_t exec_env, + wasm_array_type_t type, uint32_t length, + void *init_value) +{ + Result res; + // Check for null pointer parameter: init_value + if (init_value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_array_obj_t original_result = + wasm_array_obj_new_with_type(exec_env, type, length, init_value); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_array_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_array_obj_new_with_typeidx_checked(wasm_exec_env_t exec_env, + uint32_t type_idx, uint32_t length, + void *init_value) +{ + Result res; + // Check for null pointer parameter: init_value + if (init_value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_array_obj_t original_result = + wasm_array_obj_new_with_typeidx(exec_env, type_idx, length, init_value); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_array_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_array_obj_set_elem_checked(wasm_array_obj_t array_obj, uint32_t elem_idx, + void *value) +{ + Result res; + // Check for null pointer parameter: value + if (value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_array_obj_set_elem(array_obj, elem_idx, value); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_array_type_get_elem_type_checked(wasm_array_type_t array_type, + void *p_is_mutable) +{ + Result res; + // Check for null pointer parameter: p_is_mutable + if (p_is_mutable == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_type_t original_result = + wasm_array_type_get_elem_type(array_type, p_is_mutable); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_ref_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_copy_callstack_checked(wasm_exec_env_t exec_env, void *buffer, + uint32_t length, uint32_t skip_n, void *error_buf, + uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: buffer + if (buffer == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = wasm_copy_callstack( + exec_env, buffer, length, skip_n, error_buf, error_buf_size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_defined_type_equal_checked(wasm_defined_type_t def_type1, + wasm_defined_type_t def_type2, + wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_defined_type_equal(def_type1, def_type2, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_defined_type_is_array_type_checked(wasm_defined_type_t def_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_defined_type_is_array_type(def_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_defined_type_is_func_type_checked(wasm_defined_type_t def_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_defined_type_is_func_type(def_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_defined_type_is_struct_type_checked(wasm_defined_type_t def_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_defined_type_is_struct_type(def_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_defined_type_is_subtype_of_checked(wasm_defined_type_t def_type1, + wasm_defined_type_t def_type2, + wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_defined_type_is_subtype_of(def_type1, def_type2, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_obj2ref_checked(wasm_module_inst_t module_inst, void *extern_obj, + void *p_externref_idx) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_externref_idx + if (p_externref_idx == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_externref_obj2ref(module_inst, extern_obj, p_externref_idx); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_obj_get_value_checked(wasm_externref_obj_t externref_obj) +{ + Result res; + // Execute the original function + wasm_externref_obj_get_value(externref_obj); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externref_obj_new_checked(wasm_exec_env_t exec_env, void *host_obj) +{ + Result res; + // Check for null pointer parameter: host_obj + if (host_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externref_obj_t original_result = + wasm_externref_obj_new(exec_env, host_obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_externref_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_externref_obj_to_internal_obj_checked(wasm_externref_obj_t externref_obj) +{ + Result res; + // Execute the original function + wasm_obj_t original_result = + wasm_externref_obj_to_internal_obj(externref_obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_externref_objdel_checked(wasm_module_inst_t module_inst, void *extern_obj) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_externref_objdel(module_inst, extern_obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_ref2obj_checked(uint32_t externref_idx, void *p_extern_obj) +{ + Result res; + // Check for null pointer parameter: p_extern_obj + if (p_extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_externref_ref2obj(externref_idx, p_extern_obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_retain_checked(uint32_t externref_idx) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_externref_retain(externref_idx); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_set_cleanup_checked(wasm_module_inst_t module_inst, + void *extern_obj, void *extern_obj_cleanup) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: extern_obj_cleanup + if (extern_obj_cleanup == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_externref_set_cleanup(module_inst, extern_obj, extern_obj_cleanup); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_func_get_param_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_func_get_param_count(func_inst, module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_get_param_types_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst, + void *param_types) +{ + Result res; + // Check for null pointer parameter: param_types + if (param_types == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_get_param_types(func_inst, module_inst, param_types); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_get_result_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_func_get_result_count(func_inst, module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_get_result_types_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst, + void *result_types) +{ + Result res; + // Check for null pointer parameter: result_types + if (result_types == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_get_result_types(func_inst, module_inst, result_types); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_obj_get_func_idx_bound_checked(wasm_func_obj_t func_obj) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_func_obj_get_func_idx_bound(func_obj); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_obj_get_func_type_checked(wasm_func_obj_t func_obj) +{ + Result res; + // Execute the original function + wasm_func_type_t original_result = wasm_func_obj_get_func_type(func_obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_func_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_obj_new_with_type_checked(wasm_exec_env_t exec_env, + wasm_func_type_t type, + uint32_t func_idx_bound) +{ + Result res; + // Execute the original function + wasm_func_obj_t original_result = + wasm_func_obj_new_with_type(exec_env, type, func_idx_bound); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_func_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_obj_new_with_typeidx_checked(wasm_exec_env_t exec_env, + uint32_t type_idx, + uint32_t func_idx_bound) +{ + Result res; + // Execute the original function + wasm_func_obj_t original_result = + wasm_func_obj_new_with_typeidx(exec_env, type_idx, func_idx_bound); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_func_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_param_count_checked(wasm_func_type_t func_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_func_type_get_param_count(func_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_param_type_checked(wasm_func_type_t func_type, + uint32_t param_idx) +{ + Result res; + // Execute the original function + wasm_ref_type_t original_result = + wasm_func_type_get_param_type(func_type, param_idx); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_ref_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_param_valkind_checked(wasm_func_type_t func_type, + uint32_t param_index) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = + wasm_func_type_get_param_valkind(func_type, param_index); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_result_count_checked(wasm_func_type_t func_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_func_type_get_result_count(func_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_result_type_checked(wasm_func_type_t func_type, + uint32_t result_idx) +{ + Result res; + // Execute the original function + wasm_ref_type_t original_result = + wasm_func_type_get_result_type(func_type, result_idx); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_ref_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_result_valkind_checked(wasm_func_type_t func_type, + uint32_t result_index) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = + wasm_func_type_get_result_valkind(func_type, result_index); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_get_defined_type_checked(wasm_module_t module, uint32_t index) +{ + Result res; + // Execute the original function + wasm_defined_type_t original_result = wasm_get_defined_type(module, index); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_defined_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_get_defined_type_count_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_get_defined_type_count(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_global_type_get_mutable_checked(wasm_global_type_t global_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_global_type_get_mutable(global_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_global_type_get_valkind_checked(wasm_global_type_t global_type) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = wasm_global_type_get_valkind(global_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_i31_obj_get_value_checked(wasm_i31_obj_t i31_obj, _Bool sign_extend) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_i31_obj_get_value(i31_obj, sign_extend); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_i31_obj_new_checked(uint32_t i31_value) +{ + Result res; + // Execute the original function + wasm_i31_obj_t original_result = wasm_i31_obj_new(i31_value); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_i31_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_internal_obj_to_externref_obj_checked(wasm_exec_env_t exec_env, + wasm_obj_t internal_obj) +{ + Result res; + // Execute the original function + wasm_externref_obj_t original_result = + wasm_internal_obj_to_externref_obj(exec_env, internal_obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_externref_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_enlarge_checked(wasm_memory_inst_t memory_inst, + uint64_t inc_page_count) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_enlarge(memory_inst, inc_page_count); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_get_base_address_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + wasm_memory_get_base_address(memory_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_get_bytes_per_page_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_bytes_per_page(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_cur_page_count_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_cur_page_count(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_max_page_count_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_max_page_count(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_shared_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_get_shared(memory_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_type_get_init_page_count_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_memory_type_get_init_page_count(memory_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_type_get_max_page_count_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_memory_type_get_max_page_count(memory_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_type_get_shared_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_type_get_shared(memory_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_get_defined_type_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + wasm_defined_type_t original_result = wasm_obj_get_defined_type(obj); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_defined_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_obj_get_defined_type_idx_checked(wasm_module_t module, wasm_obj_t obj) +{ + Result res; + // Execute the original function + int32_t original_result = wasm_obj_get_defined_type_idx(module, obj); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_obj_is_anyref_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_anyref_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_array_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_array_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_eq_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_eq_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_externref_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_externref_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_func_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_func_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_i31_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_i31_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_instance_of_defined_type_checked(wasm_obj_t obj, + wasm_defined_type_t defined_type, + wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_obj_is_instance_of_defined_type(obj, defined_type, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_instance_of_ref_type_checked(wasm_obj_t obj, void *ref_type) +{ + Result res; + // Check for null pointer parameter: ref_type + if (ref_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_obj_is_instance_of_ref_type(obj, ref_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_instance_of_type_idx_checked(wasm_obj_t obj, uint32_t type_idx, + wasm_module_t module) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_obj_is_instance_of_type_idx(obj, type_idx, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_internal_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_internal_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_is_struct_obj_checked(wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_obj_is_struct_obj(obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_set_gc_finalizer_checked(wasm_exec_env_t exec_env, wasm_obj_t obj, + wasm_obj_finalizer_t cb, void *data) +{ + Result res; + // Check for null pointer parameter: data + if (data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_obj_set_gc_finalizer(exec_env, obj, cb, data); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_obj_unset_gc_finalizer_checked(wasm_exec_env_t exec_env, void *obj) +{ + Result res; + // Check for null pointer parameter: obj + if (obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_obj_unset_gc_finalizer(exec_env, obj); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_type_equal_checked(void *ref_type1, void *ref_type2, + wasm_module_t module) +{ + Result res; + // Check for null pointer parameter: ref_type1 + if (ref_type1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: ref_type2 + if (ref_type2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_ref_type_equal(ref_type1, ref_type2, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_ref_type_is_subtype_of_checked(void *ref_type1, void *ref_type2, + wasm_module_t module) +{ + Result res; + // Check for null pointer parameter: ref_type1 + if (ref_type1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: ref_type2 + if (ref_type2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_ref_type_is_subtype_of(ref_type1, ref_type2, module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_ref_type_set_heap_type_checked(void *ref_type, _Bool nullable, + int32_t heap_type) +{ + Result res; + // Check for null pointer parameter: ref_type + if (ref_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_type_set_heap_type(ref_type, nullable, heap_type); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_type_set_type_idx_checked(void *ref_type, _Bool nullable, + int32_t type_idx) +{ + Result res; + // Check for null pointer parameter: ref_type + if (ref_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_type_set_type_idx(ref_type, nullable, type_idx); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_addr_app_to_native_checked(wasm_module_inst_t module_inst, + uint64_t app_offset) +{ + Result res; + // Execute the original function + wasm_runtime_addr_app_to_native(module_inst, app_offset); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_addr_native_to_app_checked(wasm_module_inst_t module_inst, + void *native_ptr) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint64_t original_result = + wasm_runtime_addr_native_to_app(module_inst, native_ptr); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_attach_shared_heap_checked(wasm_module_inst_t module_inst, + wasm_shared_heap_t shared_heap) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_attach_shared_heap(module_inst, shared_heap); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_begin_blocking_op_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_begin_blocking_op(exec_env); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_func_ref_checked(wasm_exec_env_t exec_env, + wasm_func_obj_t func_obj, uint32_t argc, + void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_call_func_ref(exec_env, func_obj, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_func_ref_a_checked(wasm_exec_env_t exec_env, + wasm_func_obj_t func_obj, + uint32_t num_results, void *results, + uint32_t num_args, void *args) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_call_func_ref_a( + exec_env, func_obj, num_results, results, num_args, args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_func_ref_v_checked(wasm_exec_env_t exec_env, + wasm_func_obj_t func_obj, + uint32_t num_results, void *results, + uint32_t num_args, ...) +{ + Result res; + va_list args; + // Execute the original function + va_start(args, num_args); + _Bool original_result = wasm_runtime_call_func_ref_v( + exec_env, func_obj, num_results, results, num_args, args); + va_end(args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_indirect_checked(wasm_exec_env_t exec_env, + uint32_t element_index, uint32_t argc, + void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_call_indirect(exec_env, element_index, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, uint32_t argc, + void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_call_wasm(exec_env, function, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_a_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, + uint32_t num_results, void *results, + uint32_t num_args, void *args) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_call_wasm_a( + exec_env, function, num_results, results, num_args, args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_v_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, + uint32_t num_results, void *results, + uint32_t num_args, ...) +{ + Result res; + va_list args; + // Execute the original function + va_start(args, num_args); + _Bool original_result = wasm_runtime_call_wasm_v( + exec_env, function, num_results, results, num_args, args); + va_end(args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_chain_shared_heaps_checked(wasm_shared_heap_t head, + wasm_shared_heap_t body) +{ + Result res; + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_chain_shared_heaps(head, body); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_clear_exception_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_clear_exception(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_create_context_key_checked(void *dtor) +{ + Result res; + // Check for null pointer parameter: dtor + if (dtor == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_create_context_key(dtor); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_create_exec_env_checked(wasm_module_inst_t module_inst, + uint32_t stack_size) +{ + Result res; + // Execute the original function + wasm_exec_env_t original_result = + wasm_runtime_create_exec_env(module_inst, stack_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_exec_env_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_create_shared_heap_checked(void *init_args) +{ + Result res; + // Check for null pointer parameter: init_args + if (init_args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_create_shared_heap(init_args); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_deinstantiate_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_deinstantiate(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_checked(void) +{ + Result res; + // Execute the original function + wasm_runtime_destroy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_context_key_checked(void *key) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_destroy_context_key(key); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_exec_env_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_exec_env(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_spawned_exec_env_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_spawned_exec_env(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_thread_env_checked(void) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_thread_env(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_detach_shared_heap_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_detach_shared_heap(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_detect_native_stack_overflow_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_detect_native_stack_overflow(exec_env); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_detect_native_stack_overflow_size_checked(wasm_exec_env_t exec_env, + uint32_t required_size) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_detect_native_stack_overflow_size(exec_env, required_size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_dump_call_stack_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_dump_call_stack(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_call_stack_to_buf_checked(wasm_exec_env_t exec_env, void *buf, + uint32_t len) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = + wasm_runtime_dump_call_stack_to_buf(exec_env, buf, len); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_dump_mem_consumption_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_dump_mem_consumption(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_perf_profiling_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_dump_perf_profiling(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_pgo_prof_data_to_buf_checked(wasm_module_inst_t module_inst, + void *buf, uint32_t len) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = + wasm_runtime_dump_pgo_prof_data_to_buf(module_inst, buf, len); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_end_blocking_op_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_end_blocking_op(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_enlarge_memory_checked(wasm_module_inst_t module_inst, + uint64_t inc_page_count) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_enlarge_memory(module_inst, inc_page_count); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_find_module_registered_checked(void *module_name) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = + wasm_runtime_find_module_registered(module_name); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_free_checked(void *ptr) +{ + Result res; + // Check for null pointer parameter: ptr + if (ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_free(ptr); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_full_init_checked(void *init_args) +{ + Result res; + // Check for null pointer parameter: init_args + if (init_args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_full_init(init_args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_app_addr_range_checked(wasm_module_inst_t module_inst, + uint64_t app_offset, + void *p_app_start_offset, + void *p_app_end_offset) +{ + Result res; + // Check for null pointer parameter: p_app_start_offset + if (p_app_start_offset == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_app_end_offset + if (p_app_end_offset == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_app_addr_range( + module_inst, app_offset, p_app_start_offset, p_app_end_offset); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_call_stack_buf_size_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_call_stack_buf_size(exec_env); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_context_checked(wasm_module_inst_t inst, void *key) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_context(inst, key); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_cur_local_obj_ref_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_get_cur_local_obj_ref(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_current_package_version_checked(package_type_t package_type) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_runtime_get_current_package_version(package_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_custom_data_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_get_custom_data(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_custom_section_checked(wasm_module_t module_comm, void *name, + void *len) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: len + if (len == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_custom_section(module_comm, name, len); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_default_memory_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_memory_inst_t original_result = + wasm_runtime_get_default_memory(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_memory_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_exception_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_get_exception(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_exec_env_singleton_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_exec_env_t original_result = + wasm_runtime_get_exec_env_singleton(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_exec_env_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_export_count_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + int32_t original_result = wasm_runtime_get_export_count(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_export_global_inst_checked(wasm_module_inst_t module_inst, + void *name, void *global_inst) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: global_inst + if (global_inst == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_get_export_global_inst(module_inst, name, global_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_export_table_inst_checked(wasm_module_inst_t module_inst, + void *name, void *table_inst) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: table_inst + if (table_inst == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_get_export_table_inst(module_inst, name, table_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_export_type_checked(wasm_module_t module, int32_t export_index, + void *export_type) +{ + Result res; + // Check for null pointer parameter: export_type + if (export_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_export_type(module, export_index, export_type); + // Assign return value and error code + res.error_code = 0; + return res; +} + static inline Result wasm_runtime_get_file_package_type_checked(void *buf, uint32_t size) { @@ -250,24 +2176,6 @@ wasm_runtime_get_file_package_type_checked(void *buf, uint32_t size) 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) { @@ -290,6 +2198,160 @@ wasm_runtime_get_file_package_version_checked(void *buf, uint32_t size) return res; } +static inline Result +wasm_runtime_get_function_attachment_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_get_function_attachment(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_import_count_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + int32_t original_result = wasm_runtime_get_import_count(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_import_type_checked(wasm_module_t module, int32_t import_index, + void *import_type) +{ + Result res; + // Check for null pointer parameter: import_type + if (import_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_import_type(module, import_index, import_type); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_mem_alloc_info_checked(void *mem_alloc_info) +{ + Result res; + // Check for null pointer parameter: mem_alloc_info + if (mem_alloc_info == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_mem_alloc_info(mem_alloc_info); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_memory_checked(wasm_module_inst_t module_inst, uint32_t index) +{ + Result res; + // Execute the original function + wasm_memory_inst_t original_result = + wasm_runtime_get_memory(module_inst, index); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_memory_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_module_t original_result = wasm_runtime_get_module(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_hash_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_get_module_hash(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_module_inst_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_module_inst_t original_result = wasm_runtime_get_module_inst(exec_env); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_name_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_get_module_name(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_module_package_type_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + package_type_t original_result = + wasm_runtime_get_module_package_type(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.package_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + static inline Result wasm_runtime_get_module_package_version_checked(wasm_module_t module) { @@ -308,12 +2370,42 @@ 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_runtime_get_native_addr_range_checked(wasm_module_inst_t module_inst, + void *native_ptr, + void *p_native_start_addr, + void *p_native_end_addr) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_native_start_addr + if (p_native_start_addr == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_native_end_addr + if (p_native_end_addr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_native_addr_range( + module_inst, native_ptr, p_native_start_addr, p_native_end_addr); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_pgo_prof_data_size_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - uint32_t original_result = - wasm_runtime_get_current_package_version(package_type); + 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; @@ -326,16 +2418,106 @@ 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_runtime_get_running_mode_checked(wasm_module_inst_t module_inst) { Result res; - // Check for null pointer parameter: buf - if (buf == NULL) { + // Execute the original function + RunningMode original_result = wasm_runtime_get_running_mode(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.RunningMode_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_user_data_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_get_user_data(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_version_checked(void *major, void *minor, void *patch) +{ + Result res; + // Check for null pointer parameter: major + if (major == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: minor + if (minor == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: patch + if (patch == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = wasm_runtime_is_xip_file(buf, size); + wasm_runtime_get_version(major, minor, patch); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_wasi_exit_code_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_wasi_exit_code(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_wasm_func_exec_time_checked(wasm_module_inst_t inst, + void *func_name) +{ + Result res; + // Check for null pointer parameter: func_name + if (func_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + double original_result = + wasm_runtime_get_wasm_func_exec_time(inst, func_name); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.double_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_init_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_init(); // Assign return value and error code res.error_code = original_result ? 0 : -2; res.value._Bool_value = original_result; @@ -343,245 +2525,17 @@ 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_runtime_init_thread_env_checked(void) { 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); + _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_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, @@ -638,6 +2592,35 @@ wasm_runtime_instantiate_ex_checked(wasm_module_t module, void *args, return res; } +static inline Result +wasm_runtime_instantiate_ex2_checked(wasm_module_t module, void *args, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_inst_t original_result = + wasm_runtime_instantiate_ex2(module, args, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + static inline Result wasm_runtime_instantiation_args_create_checked(void *p) { @@ -723,42 +2706,11 @@ wasm_runtime_instantiation_args_set_max_memory_pages_checked(void *p, } 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) +wasm_runtime_is_bounds_checks_enabled_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - _Bool original_result = - wasm_runtime_set_running_mode(module_inst, running_mode); + _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; @@ -766,47 +2718,74 @@ wasm_runtime_set_running_mode_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_get_running_mode_checked(wasm_module_inst_t module_inst) +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 - RunningMode original_result = wasm_runtime_get_running_mode(module_inst); + _Bool original_result = + wasm_runtime_is_import_func_linked(module_name, func_name); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_deinstantiate_checked(wasm_module_inst_t module_inst) +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 - wasm_runtime_deinstantiate(module_inst); + _Bool original_result = + wasm_runtime_is_import_global_linked(module_name, global_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_runtime_get_module_checked(wasm_module_inst_t module_inst) +wasm_runtime_is_running_mode_supported_checked(RunningMode running_mode) { Result res; // Execute the original function - wasm_module_t original_result = wasm_runtime_get_module(module_inst); + _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_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_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; } @@ -823,16 +2802,37 @@ wasm_runtime_is_wasi_mode_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_lookup_wasi_start_function_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_function_inst_t original_result = - wasm_runtime_lookup_wasi_start_function(module_inst); + _Bool original_result = wasm_runtime_is_xip_file(buf, size); // 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_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.wasm_function_inst_t_value = original_result; + res.value.int32_t_value = original_result; } else { res.error_code = -2; @@ -841,15 +2841,86 @@ 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_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_runtime_get_wasi_exit_code(module_inst); + 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; + } + return res; +} + +static inline Result +wasm_runtime_load_ex_checked(void *buf, uint32_t size, void *args, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = + wasm_runtime_load_ex(buf, size, args, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_load_from_sections_checked(wasm_section_list_t section_list, + _Bool is_aot, void *error_buf, + uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = wasm_runtime_load_from_sections( + section_list, is_aot, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; } else { res.error_code = -2; @@ -880,258 +2951,6 @@ wasm_runtime_lookup_function_checked(wasm_module_inst_t module_inst, void *name) 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) { @@ -1156,16 +2975,16 @@ 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_lookup_wasi_start_function_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_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_memory_inst_t_value = original_result; + res.value.wasm_function_inst_t_value = original_result; } else { res.error_code = -2; @@ -1174,345 +2993,11 @@ 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_runtime_malloc_checked(unsigned int size) { 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); + wasm_runtime_malloc(size); // Assign return value and error code res.error_code = 0; return res; @@ -1543,77 +3028,29 @@ 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_module_free_checked(wasm_module_inst_t module_inst, uint64_t ptr) { 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); + wasm_runtime_module_free(module_inst, ptr); // 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) +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_ptr - if (native_ptr == NULL) { + // 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_addr_native_to_app(module_inst, native_ptr); + wasm_runtime_module_malloc(module_inst, size, p_native_addr); // Assign return value and error code if (original_result == 0) { res.error_code = 0; @@ -1626,25 +3063,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_pin_object_checked(wasm_exec_env_t exec_env, wasm_obj_t obj) { 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_pin_object(exec_env, obj); // Assign return value and error code res.error_code = original_result ? 0 : -2; res.value._Bool_value = original_result; @@ -1652,315 +3075,84 @@ 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) -{ - 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) +wasm_runtime_pop_local_obj_ref_checked(wasm_exec_env_t exec_env) { 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); + 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_get_export_count_checked(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 - 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); + 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_func_type_get_param_count_checked(wasm_func_type_t func_type) +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 - uint32_t original_result = wasm_func_type_get_param_count(func_type); + wasm_runtime_push_local_obj_ref(exec_env, local_obj_ref); // 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_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_valkind_t original_result = - wasm_func_type_get_param_valkind(func_type, param_index); + wasm_runtime_realloc(ptr, size); // 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_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 - 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); + _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_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) @@ -2011,22 +3203,11 @@ wasm_runtime_register_natives_raw_checked(void *module_name, } static inline Result -wasm_runtime_unregister_natives_checked(void *module_name, void *native_symbols) +wasm_runtime_resolve_symbols_checked(wasm_module_t module) { 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); + _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; @@ -2034,637 +3215,12 @@ wasm_runtime_unregister_natives_checked(void *module_name, void *native_symbols) } 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) +wasm_runtime_set_bounds_checks_checked(wasm_module_inst_t module_inst, + _Bool enable) { 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); + wasm_runtime_set_bounds_checks(module_inst, enable); // Assign return value and error code res.error_code = 0; return res; @@ -2714,27 +3270,28 @@ wasm_runtime_set_context_spread_checked(wasm_module_inst_t inst, void *key, } static inline Result -wasm_runtime_get_context_checked(wasm_module_inst_t inst, void *key) +wasm_runtime_set_custom_data_checked(wasm_module_inst_t module_inst, + void *custom_data) { Result res; - // Check for null pointer parameter: key - if (key == NULL) { + // Check for null pointer parameter: custom_data + if (custom_data == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_get_context(inst, key); + 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_begin_blocking_op_checked(wasm_exec_env_t exec_env) +wasm_runtime_set_default_running_mode_checked(RunningMode running_mode) { Result res; // Execute the original function - _Bool original_result = wasm_runtime_begin_blocking_op(exec_env); + _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; @@ -2742,11 +3299,80 @@ 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_set_enlarge_mem_error_callback_checked( + enlarge_memory_error_callback_t callback, void *user_data) +{ + Result res; + // Check for null pointer parameter: user_data + if (user_data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_enlarge_mem_error_callback(callback, user_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_exception_checked(wasm_module_inst_t module_inst, + void *exception) +{ + Result res; + // Check for null pointer parameter: exception + if (exception == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_exception(module_inst, exception); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_instruction_count_limit_checked(wasm_exec_env_t exec_env, + int instruction_count) { Result res; // Execute the original function - wasm_runtime_end_blocking_op(exec_env); + wasm_runtime_set_instruction_count_limit(exec_env, instruction_count); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_log_level_checked(log_level_t level) +{ + Result res; + // Execute the original function + wasm_runtime_set_log_level(level); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_max_thread_num_checked(uint32_t num) +{ + Result res; + // Execute the original function + wasm_runtime_set_max_thread_num(num); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_module_inst_checked(wasm_exec_env_t exec_env, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_set_module_inst(exec_env, module_inst); // Assign return value and error code res.error_code = 0; return res; @@ -2777,123 +3403,42 @@ 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) +wasm_runtime_set_module_reader_checked(module_reader reader, + module_destroyer destroyer) { Result res; // Execute the original function - wasm_runtime_get_module_name(module); + wasm_runtime_set_module_reader(reader, destroyer); // 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_set_native_stack_boundary_checked(wasm_exec_env_t exec_env, + void *native_stack_boundary) { 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) { + // Check for null pointer parameter: native_stack_boundary + if (native_stack_boundary == 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_runtime_set_native_stack_boundary(exec_env, native_stack_boundary); // 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 = 0; 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) +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_attach_shared_heap(module_inst, shared_heap); + 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; @@ -2901,11 +3446,87 @@ 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_set_user_data_checked(wasm_exec_env_t exec_env, void *user_data) +{ + Result res; + // Check for null pointer parameter: user_data + if (user_data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_user_data(exec_env, user_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_addr_pool_checked(wasm_module_t module, void *addr_pool, + uint32_t addr_pool_size) { Result res; // Execute the original function - wasm_runtime_detach_shared_heap(module_inst); + wasm_runtime_set_wasi_addr_pool(module, addr_pool, addr_pool_size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_args_checked(wasm_module_t module, void *dir_list, + uint32_t dir_count, void *map_dir_list, + uint32_t map_dir_count, void *env, + uint32_t env_count, void *argv, int argc) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_args(module, dir_list, dir_count, map_dir_list, + map_dir_count, env, env_count, argv, argc); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_args_ex_checked(wasm_module_t module, void *dir_list, + uint32_t dir_count, void *map_dir_list, + uint32_t map_dir_count, void *env, + uint32_t env_count, void *argv, int argc, + int64_t stdinfd, int64_t stdoutfd, + int64_t stderrfd) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_args_ex(module, dir_list, dir_count, map_dir_list, + map_dir_count, env, env_count, argv, argc, + stdinfd, stdoutfd, stderrfd); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_ns_lookup_pool_checked(wasm_module_t module, + void *ns_lookup_pool, + uint32_t ns_lookup_pool_size) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_ns_lookup_pool(module, ns_lookup_pool, + ns_lookup_pool_size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_shared_heap_free_checked(wasm_module_inst_t module_inst, + uint64_t ptr) +{ + Result res; + // Execute the original function + wasm_runtime_shared_heap_free(module_inst, ptr); // Assign return value and error code res.error_code = 0; return res; @@ -2936,44 +3557,15 @@ 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_runtime_spawn_exec_env_checked(wasm_exec_env_t exec_env) { 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); + 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_defined_type_t_value = original_result; + res.value.wasm_exec_env_t_value = original_result; } else { res.error_code = -2; @@ -2982,28 +3574,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_spawn_thread_checked(wasm_exec_env_t exec_env, void *tid, + wasm_thread_callback_t callback, void *arg) { 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; + // Check for null pointer parameter: tid + if (tid == NULL) { + res.error_code = -1; + return res; } - else { - res.error_code = -2; + // Check for null pointer parameter: arg + if (arg == NULL) { + res.error_code = -1; + return res; } - 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); + 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; @@ -3016,53 +3603,15 @@ 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_start_debug_instance_checked(wasm_exec_env_t exec_env) { 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); + 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.wasm_ref_type_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -3071,17 +3620,17 @@ 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_start_debug_instance_with_port_checked(wasm_exec_env_t exec_env, + int32_t port) { Result res; // Execute the original function - wasm_ref_type_t original_result = - wasm_func_type_get_result_type(func_type, result_idx); + 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.wasm_ref_type_t_value = original_result; + res.value.uint32_t_value = original_result; } else { res.error_code = -2; @@ -3089,6 +3638,247 @@ wasm_func_type_get_result_type_checked(wasm_func_type_t func_type, return res; } +static inline Result +wasm_runtime_sum_wasm_exec_time_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + double original_result = wasm_runtime_sum_wasm_exec_time(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.double_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_terminate_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_terminate(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_thread_env_inited_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_thread_env_inited(); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_unchain_shared_heaps_checked(wasm_shared_heap_t head, + _Bool entire_chain) +{ + Result res; + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_unchain_shared_heaps(head, entire_chain); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_unload_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_unload(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_unpin_object_checked(wasm_exec_env_t exec_env, wasm_obj_t obj) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_unpin_object(exec_env, obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_unregister_natives_checked(void *module_name, void *native_symbols) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: native_symbols + if (native_symbols == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_unregister_natives(module_name, native_symbols); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_app_addr_checked(wasm_module_inst_t module_inst, + uint64_t app_offset, uint64_t size) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_validate_app_addr(module_inst, app_offset, size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_app_str_addr_checked(wasm_module_inst_t module_inst, + uint64_t app_str_offset) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_validate_app_str_addr(module_inst, app_str_offset); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_native_addr_checked(wasm_module_inst_t module_inst, + void *native_ptr, uint64_t size) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_validate_native_addr(module_inst, native_ptr, size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_struct_obj_get_field_checked(wasm_struct_obj_t obj, uint32_t field_idx, + _Bool sign_extend, void *value) +{ + Result res; + // Check for null pointer parameter: value + if (value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_struct_obj_get_field(obj, field_idx, sign_extend, value); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_struct_obj_get_field_count_checked(wasm_struct_obj_t obj) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_struct_obj_get_field_count(obj); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_struct_obj_new_with_type_checked(wasm_exec_env_t exec_env, + wasm_struct_type_t type) +{ + Result res; + // Execute the original function + wasm_struct_obj_t original_result = + wasm_struct_obj_new_with_type(exec_env, type); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_struct_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_struct_obj_new_with_typeidx_checked(wasm_exec_env_t exec_env, + uint32_t type_idx) +{ + Result res; + // Execute the original function + wasm_struct_obj_t original_result = + wasm_struct_obj_new_with_typeidx(exec_env, type_idx); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_struct_obj_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_struct_obj_set_field_checked(wasm_struct_obj_t obj, uint32_t field_idx, + void *value) +{ + Result res; + // Check for null pointer parameter: value + if (value == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_struct_obj_set_field(obj, field_idx, value); + // Assign return value and error code + res.error_code = 0; + return res; +} + static inline Result wasm_struct_type_get_field_count_checked(wasm_struct_type_t struct_type) { @@ -3131,22 +3921,39 @@ wasm_struct_type_get_field_type_checked(wasm_struct_type_t struct_type, } static inline Result -wasm_array_type_get_elem_type_checked(wasm_array_type_t array_type, - void *p_is_mutable) +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: p_is_mutable - if (p_is_mutable == NULL) { + // Check for null pointer parameter: table_inst + if (table_inst == 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); + wasm_function_inst_t original_result = + wasm_table_get_func_inst(module_inst, table_inst, idx); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_function_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_elem_kind_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = wasm_table_type_get_elem_kind(table_type); // Assign return value and error code if (original_result == 0) { res.error_code = 0; - res.value.wasm_ref_type_t_value = original_result; + res.value.wasm_valkind_t_value = original_result; } else { res.error_code = -2; @@ -3155,194 +3962,11 @@ wasm_array_type_get_elem_type_checked(wasm_array_type_t array_type, } 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_table_type_get_init_size_checked(wasm_table_type_t table_type) { 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); + 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; @@ -3355,108 +3979,11 @@ wasm_struct_obj_get_field_count_checked(wasm_struct_obj_t obj) } 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) +wasm_table_type_get_max_size_checked(wasm_table_type_t table_type) { 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); + 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; @@ -3469,542 +3996,15 @@ wasm_array_obj_length_checked(wasm_array_obj_t array_obj) } static inline Result -wasm_array_obj_first_elem_addr_checked(wasm_array_obj_t array_obj) +wasm_table_type_get_shared_checked(wasm_table_type_t table_type) { 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); + _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_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/wasm_c_api_checked.h b/core/iwasm/include/wasm_c_api_checked.h index b6aa24b74..05a758243 100644 --- a/core/iwasm/include/wasm_c_api_checked.h +++ b/core/iwasm/include/wasm_c_api_checked.h @@ -19,126 +19,90 @@ 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) +__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 - memcpy(__dest, __src, __n); + __assert(__assertion, __file, __line); // 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_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; + } + // Check for null pointer parameter: __function + if (__function == NULL) { res.error_code = -1; return res; } // Execute the original function - memmove(__dest, __src, __n); + __assert_fail(__assertion, __file, __line, __function); // 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_perror_fail_checked(int __errnum, void *__file, unsigned int __line, + void *__function) { Result res; - // Check for null pointer parameter: __dest - if (__dest == NULL) { + // Check for null pointer parameter: __file + if (__file == NULL) { res.error_code = -1; return res; } - // Check for null pointer parameter: __src - if (__src == NULL) { + // Check for null pointer parameter: __function + if (__function == NULL) { res.error_code = -1; return res; } // Execute the original function - memccpy(__dest, __src, __c, __n); + __assert_perror_fail(__errnum, __file, __line, __function); // 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) { @@ -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,392 +166,7 @@ strncpy_checked(void *__dest, void *__src, size_t __n) 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); + __stpncpy(__dest, __src, __n); // Assign return value and error code res.error_code = 0; return res; @@ -635,120 +198,6 @@ __strtok_r_checked(void *__s, void *__delim, void *__save_ptr) 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) { @@ -814,7 +263,7 @@ bzero_checked(void *__s, size_t __n) } static inline Result -index_checked(void *__s, int __c) +explicit_bzero_checked(void *__s, size_t __n) { Result res; // Check for null pointer parameter: __s @@ -823,23 +272,7 @@ index_checked(void *__s, int __c) 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); + explicit_bzero(__s, __n); // Assign return value and error code res.error_code = 0; return res; @@ -896,6 +329,202 @@ ffsll_checked(long long int __ll) return res; } +static inline Result +index_checked(void *__s, int __c) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + index(__s, __c); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +memccpy_checked(void *__dest, void *__src, int __c, size_t __n) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + memccpy(__dest, __src, __c, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +memchr_checked(void *__s, int __c, size_t __n) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + memchr(__s, __c, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +memcmp_checked(void *__s1, void *__s2, size_t __n) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = memcmp(__s1, __s2, __n); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +memcpy_checked(void *__dest, void *__src, size_t __n) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + memcpy(__dest, __src, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +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) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + rindex(__s, __c); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +stpcpy_checked(void *__dest, void *__src) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + stpcpy(__dest, __src); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +stpncpy_checked(void *__dest, void *__src, size_t __n) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + stpncpy(__dest, __src, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + static inline Result strcasecmp_checked(void *__s1, void *__s2) { @@ -923,33 +552,6 @@ strcasecmp_checked(void *__s1, void *__s2) 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) { @@ -977,6 +579,281 @@ 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) +{ + 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 +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) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strcoll(__s1, __s2); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strcoll_l_checked(void *__s1, void *__s2, locale_t __l) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strcoll_l(__s1, __s2, __l); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strcpy_checked(void *__dest, void *__src) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strcpy(__dest, __src); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strcspn_checked(void *__s, void *__reject) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __reject + if (__reject == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = strcspn(__s, __reject); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strdup_checked(void *__s) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strdup(__s); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strerror_checked(int __errnum) +{ + Result res; + // Execute the original function + strerror(__errnum); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strerror_l_checked(int __errnum, locale_t __l) +{ + Result res; + // Execute the original function + strerror_l(__errnum, __l); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strerror_r_checked(int __errnum, void *__buf, size_t __buflen) +{ + Result res; + // Check for null pointer parameter: __buf + if (__buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strerror_r(__errnum, __buf, __buflen); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +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) +{ + Result res; + // Check for null pointer parameter: __s1 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strncasecmp(__s1, __s2, __n); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + static inline Result strncasecmp_l_checked(void *__s1, void *__s2, size_t __n, locale_t __loc) { @@ -1005,7 +882,135 @@ strncasecmp_l_checked(void *__s1, void *__s2, size_t __n, locale_t __loc) } static inline Result -explicit_bzero_checked(void *__s, 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 + if (__s1 == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __s2 + if (__s2 == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int original_result = strncmp(__s1, __s2, __n); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strncpy_checked(void *__dest, void *__src, size_t __n) +{ + Result res; + // Check for null pointer parameter: __dest + if (__dest == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __src + if (__src == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strncpy(__dest, __src, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strndup_checked(void *__string, size_t __n) +{ + Result res; + // Check for null pointer parameter: __string + if (__string == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strndup(__string, __n); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strnlen_checked(void *__string, size_t __maxlen) +{ + Result res; + // Check for null pointer parameter: __string + if (__string == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = strnlen(__string, __maxlen); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strpbrk_checked(void *__s, void *__accept) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __accept + if (__accept == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strpbrk(__s, __accept); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strrchr_checked(void *__s, int __c) { Result res; // Check for null pointer parameter: __s @@ -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,7 +1058,102 @@ 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: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __accept + if (__accept == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = strspn(__s, __accept); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +strstr_checked(void *__haystack, void *__needle) +{ + Result res; + // Check for null pointer parameter: __haystack + if (__haystack == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __needle + if (__needle == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strstr(__haystack, __needle); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strtok_checked(void *__s, void *__delim) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __delim + if (__delim == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strtok(__s, __delim); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strtok_r_checked(void *__s, void *__delim, void *__save_ptr) +{ + Result res; + // Check for null pointer parameter: __s + if (__s == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __delim + if (__delim == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: __save_ptr + if (__save_ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + strtok_r(__s, __delim, __save_ptr); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +strxfrm_checked(void *__dest, void *__src, size_t __n) { Result res; // Check for null pointer parameter: __dest @@ -1067,14 +1167,20 @@ __stpcpy_checked(void *__dest, void *__src) return res; } // Execute the original function - __stpcpy(__dest, __src); + 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 -stpcpy_checked(void *__dest, void *__src) +strxfrm_l_checked(void *__dest, void *__src, size_t __n, locale_t __l) { Result res; // Check for null pointer parameter: __dest @@ -1088,169 +1194,15 @@ stpcpy_checked(void *__dest, void *__src) return res; } // Execute the original function - stpcpy(__dest, __src); + size_t original_result = strxfrm_l(__dest, __src, __n, __l); // 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; + 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 - __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; } @@ -1291,6 +1243,54 @@ wasm_byte_vec_delete_checked(void *) return res; } +static inline Result +wasm_byte_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_byte_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_byte_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_byte_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_byte_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_byte_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + static inline Result wasm_config_delete_checked(void *) { @@ -1318,6 +1318,22 @@ wasm_config_new_checked(void) return res; } +static inline Result +wasm_config_set_linux_perf_opt_checked(void *, _Bool) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_config_set_linux_perf_opt(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + static inline Result wasm_config_set_mem_alloc_opt_checked(void *, mem_alloc_type_t, void *) { @@ -1339,22 +1355,6 @@ wasm_config_set_mem_alloc_opt_checked(void *, mem_alloc_type_t, void *) 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) { @@ -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,1425 +1440,12 @@ 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 *) -{ - 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 *) { @@ -2892,48 +1463,53 @@ wasm_exporttype_delete_checked(void *) } static inline Result -wasm_exporttype_vec_new_empty_checked(void *out) +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_exporttype_vec_new_empty(out); + wasm_exporttype_name(); // 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_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; + } + // 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_exporttype_new(, ); // 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_exporttype_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(out, , ); + wasm_exporttype_type(); // Assign return value and error code res.error_code = 0; return res; @@ -2977,113 +1553,7 @@ wasm_exporttype_vec_delete_checked(void *) } 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) +wasm_exporttype_vec_new_checked(void *out, size_t, void *) { Result res; // Check for null pointer parameter: out @@ -3092,14 +1562,14 @@ wasm_val_vec_new_empty_checked(void *out) return res; } // Execute the original function - wasm_val_vec_new_empty(out); + wasm_exporttype_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_exporttype_vec_new_empty_checked(void *out) { Result res; // Check for null pointer parameter: out @@ -3108,14 +1578,14 @@ wasm_val_vec_new_uninitialized_checked(void *out, size_t) return res; } // Execute the original function - wasm_val_vec_new_uninitialized(out, ); + wasm_exporttype_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_exporttype_vec_new_uninitialized_checked(void *out, size_t) { Result res; // Check for null pointer parameter: out @@ -3124,35 +1594,14 @@ wasm_val_vec_new_checked(void *out, size_t, void *) return res; } // Execute the original function - wasm_val_vec_new(out, , ); + wasm_exporttype_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 *) -{ - 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 *) +wasm_extern_as_func_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3161,14 +1610,14 @@ wasm_val_vec_delete_checked(void *) return res; } // Execute the original function - wasm_val_vec_delete(); + wasm_extern_as_func(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_delete_checked(void *) +wasm_extern_as_func_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3177,14 +1626,14 @@ wasm_ref_delete_checked(void *) return res; } // Execute the original function - wasm_ref_delete(); + wasm_extern_as_func_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_copy_checked(void *) +wasm_extern_as_global_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3193,14 +1642,212 @@ wasm_ref_copy_checked(void *) return res; } // Execute the original function - wasm_ref_copy(); + wasm_extern_as_global(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_same_checked(void *, void *) +wasm_extern_as_global_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_global_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_memory_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_memory(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_memory_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_memory_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_table_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_table(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_as_table_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_as_table_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_kind_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externkind_t original_result = wasm_extern_kind(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_externkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_extern_new_empty_checked(void *, wasm_externkind_t) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_new_empty(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -3214,7 +1861,7 @@ wasm_ref_same_checked(void *, void *) return res; } // Execute the original function - _Bool original_result = wasm_ref_same(, ); + _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; @@ -3222,23 +1869,7 @@ wasm_ref_same_checked(void *, void *) } 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 *) +wasm_extern_set_host_info_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -3252,14 +1883,14 @@ wasm_ref_set_host_info_checked(void *, void *) return res; } // Execute the original function - wasm_ref_set_host_info(, ); + wasm_extern_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 *) +wasm_extern_set_host_info_with_finalizer_checked(void *, void *, void *) { Result res; // Check for null pointer parameter: None @@ -3278,14 +1909,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_extern_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 *) +wasm_extern_type_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3294,62 +1925,14 @@ wasm_frame_delete_checked(void *) return res; } // Execute the original function - wasm_frame_delete(); + wasm_extern_type(); // 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 *) +wasm_extern_vec_copy_checked(void *out, void *) { Result res; // Check for null pointer parameter: out @@ -3363,14 +1946,14 @@ wasm_frame_vec_copy_checked(void *out, void *) return res; } // Execute the original function - wasm_frame_vec_copy(out, ); + wasm_extern_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_frame_vec_delete_checked(void *) +wasm_extern_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3379,14 +1962,62 @@ wasm_frame_vec_delete_checked(void *) return res; } // Execute the original function - wasm_frame_vec_delete(); + wasm_extern_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_frame_copy_checked(void *) +wasm_extern_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_extern_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_extern_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_functype_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3395,14 +2026,14 @@ wasm_frame_copy_checked(void *) return res; } // Execute the original function - wasm_frame_copy(); + wasm_externtype_as_functype(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_frame_instance_checked(void *) +wasm_externtype_as_functype_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3411,14 +2042,14 @@ wasm_frame_instance_checked(void *) return res; } // Execute the original function - wasm_frame_instance(); + wasm_externtype_as_functype_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_frame_func_index_checked(void *) +wasm_externtype_as_globaltype_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3427,11 +2058,139 @@ wasm_frame_func_index_checked(void *) return res; } // Execute the original function - uint32_t original_result = wasm_frame_func_index(); + wasm_externtype_as_globaltype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_globaltype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_globaltype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_memorytype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_memorytype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_memorytype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_memorytype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_tabletype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_tabletype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_as_tabletype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_as_tabletype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_kind_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externkind_t original_result = wasm_externtype_kind(); // Assign return value and error code if (original_result == 0) { res.error_code = 0; - res.value.uint32_t_value = original_result; + res.value.wasm_externkind_t_value = original_result; } else { res.error_code = -2; @@ -3440,67 +2199,28 @@ wasm_frame_func_index_checked(void *) } static inline Result -wasm_frame_func_offset_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 - 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(); + wasm_externtype_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_trap_copy_checked(void *) +wasm_externtype_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3509,235 +2229,103 @@ wasm_trap_copy_checked(void *) return res; } // Execute the original function - wasm_trap_copy(); + wasm_externtype_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_trap_same_checked(void *, void *) +wasm_externtype_vec_new_checked(void *out, size_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 - _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); + wasm_externtype_vec_new(out, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_trap_origin_checked(void *) +wasm_externtype_vec_new_empty_checked(void *out) { 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); + wasm_externtype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_externtype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_externtype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_copy(); // Assign return value and error code res.error_code = 0; return res; @@ -3760,7 +2348,7 @@ wasm_foreign_delete_checked(void *) } static inline Result -wasm_foreign_copy_checked(void *) +wasm_foreign_get_host_info_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3769,7 +2357,23 @@ wasm_foreign_copy_checked(void *) return res; } // Execute the original function - wasm_foreign_copy(); + wasm_foreign_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_foreign_new_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_foreign_new(); // Assign return value and error code res.error_code = 0; return res; @@ -3797,22 +2401,6 @@ wasm_foreign_same_checked(void *, void *) 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 *) { @@ -3861,7 +2449,7 @@ wasm_foreign_set_host_info_with_finalizer_checked(void *, void *, void *) } static inline Result -wasm_foreign_as_ref_checked(void *) +wasm_frame_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3870,14 +2458,14 @@ wasm_foreign_as_ref_checked(void *) return res; } // Execute the original function - wasm_foreign_as_ref(); + wasm_frame_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_foreign_checked(void *) +wasm_frame_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3886,14 +2474,14 @@ wasm_ref_as_foreign_checked(void *) return res; } // Execute the original function - wasm_ref_as_foreign(); + wasm_frame_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_foreign_as_ref_const_checked(void *) +wasm_frame_func_index_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3902,14 +2490,58 @@ wasm_foreign_as_ref_const_checked(void *) return res; } // Execute the original function - wasm_foreign_as_ref_const(); + uint32_t original_result = wasm_frame_func_index(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_frame_func_offset_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = wasm_frame_func_offset(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_frame_instance_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_frame_instance(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_ref_as_foreign_const_checked(void *) +wasm_frame_module_offset_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3918,14 +2550,41 @@ wasm_ref_as_foreign_const_checked(void *) return res; } // Execute the original function - wasm_ref_as_foreign_const(); + size_t original_result = wasm_frame_module_offset(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_frame_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_frame_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_foreign_new_checked(void *) +wasm_frame_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -3934,162 +2593,62 @@ wasm_foreign_new_checked(void *) return res; } // Execute the original function - wasm_foreign_new(); + wasm_frame_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_module_new_checked(void *, void *binary) +wasm_frame_vec_new_checked(void *out, size_t, void *) { 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); + wasm_frame_vec_new(out, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_module_exports_checked(void *, void *out) +wasm_frame_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: out if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_module_exports(, out); + wasm_frame_vec_new_empty(out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_module_serialize_checked(void *, void *out) +wasm_frame_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: out if (out == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_module_serialize(, out); + wasm_frame_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_module_deserialize_checked(void *, void *) +wasm_func_as_extern_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4097,20 +2656,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_func_as_extern(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_module_share_checked(void *) +wasm_func_as_extern_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4119,216 +2673,7 @@ wasm_module_share_checked(void *) 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(, , ); + wasm_func_as_extern_const(); // Assign return value and error code res.error_code = 0; return res; @@ -4350,22 +2695,6 @@ wasm_func_as_ref_checked(void *) 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 *) { @@ -4383,7 +2712,33 @@ wasm_func_as_ref_const_checked(void *) } static inline Result -wasm_ref_as_func_const_checked(void *) +wasm_func_call_checked(void *, void *args, void *results) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: results + if (results == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_call(, args, results); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4392,7 +2747,39 @@ wasm_ref_as_func_const_checked(void *) return res; } // Execute the original function - wasm_ref_as_func_const(); + wasm_func_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_get_host_info(); // Assign return value and error code res.error_code = 0; return res; @@ -4452,22 +2839,6 @@ wasm_func_new_with_env_checked(void *, void *type, 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 *) { @@ -4513,7 +2884,7 @@ wasm_func_result_arity_checked(void *) } static inline Result -wasm_func_call_checked(void *, void *args, void *results) +wasm_func_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -4521,8 +2892,152 @@ wasm_func_call_checked(void *, void *args, void *results) res.error_code = -1; return res; } - // Check for null pointer parameter: args - if (args == NULL) { + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_func_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_func_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_type_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_type(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_as_externtype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_as_externtype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_as_externtype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_as_externtype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_new_checked(void *params, void *results) +{ + Result res; + // Check for null pointer parameter: params + if (params == NULL) { res.error_code = -1; return res; } @@ -4532,7 +3047,204 @@ wasm_func_call_checked(void *, void *args, void *results) return res; } // Execute the original function - wasm_func_call(, args, results); + wasm_functype_new(params, results); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_params_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_params(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_results_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_results(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_functype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_functype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_as_extern_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_as_extern(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_as_extern_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_as_extern_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_copy(); // Assign return value and error code res.error_code = 0; return res; @@ -4555,7 +3267,28 @@ wasm_global_delete_checked(void *) } static inline Result -wasm_global_copy_checked(void *) +wasm_global_get_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_get(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_get_host_info_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4564,7 +3297,33 @@ wasm_global_copy_checked(void *) return res; } // Execute the original function - wasm_global_copy(); + wasm_global_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_global_new_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_global_new(, , ); // Assign return value and error code res.error_code = 0; return res; @@ -4593,7 +3352,7 @@ wasm_global_same_checked(void *, void *) } static inline Result -wasm_global_get_host_info_checked(void *) +wasm_global_set_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -4601,8 +3360,13 @@ wasm_global_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_global_get_host_info(); + wasm_global_set(, ); // Assign return value and error code res.error_code = 0; return res; @@ -4655,96 +3419,6 @@ wasm_global_set_host_info_with_finalizer_checked(void *, void *, void *) 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 *) { @@ -4762,7 +3436,7 @@ wasm_global_type_checked(void *) } static inline Result -wasm_global_get_checked(void *, void *out) +wasm_globaltype_as_externtype_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4770,20 +3444,15 @@ wasm_global_get_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_global_get(, out); + wasm_globaltype_as_externtype(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_set_checked(void *, void *) +wasm_globaltype_as_externtype_const_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4791,20 +3460,15 @@ wasm_global_set_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_global_set(, ); + wasm_globaltype_as_externtype_const(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_delete_checked(void *) +wasm_globaltype_content_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4813,14 +3477,14 @@ wasm_table_delete_checked(void *) return res; } // Execute the original function - wasm_table_delete(); + wasm_globaltype_content(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_copy_checked(void *) +wasm_globaltype_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4829,36 +3493,14 @@ wasm_table_copy_checked(void *) return res; } // Execute the original function - wasm_table_copy(); + wasm_globaltype_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 *) +wasm_globaltype_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4867,61 +3509,14 @@ wasm_table_get_host_info_checked(void *) return res; } // Execute the original function - wasm_table_get_host_info(); + wasm_globaltype_delete(); // 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 *) +wasm_globaltype_mutability_checked(void *) { Result res; // Check for null pointer parameter: None @@ -4930,155 +3525,11 @@ wasm_table_as_ref_checked(void *) 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(); + 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_table_size_t_value = original_result; + res.value.wasm_mutability_t_value = original_result; } else { res.error_code = -2; @@ -5087,29 +3538,7 @@ wasm_table_size_checked(void *) } 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 *) +wasm_globaltype_new_checked(void *, wasm_mutability_t) { Result res; // Check for null pointer parameter: None @@ -5118,522 +3547,14 @@ wasm_memory_delete_checked(void *) return res; } // Execute the original function - wasm_memory_delete(); + wasm_globaltype_new(, ); // 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 *) +wasm_globaltype_vec_copy_checked(void *out, void *) { Result res; // Check for null pointer parameter: out @@ -5647,14 +3568,14 @@ wasm_extern_vec_copy_checked(void *out, void *) return res; } // Execute the original function - wasm_extern_vec_copy(out, ); + wasm_globaltype_vec_copy(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_vec_delete_checked(void *) +wasm_globaltype_vec_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5663,84 +3584,62 @@ wasm_extern_vec_delete_checked(void *) return res; } // Execute the original function - wasm_extern_vec_delete(); + wasm_globaltype_vec_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_kind_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_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(); + wasm_globaltype_vec_new(out, , ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_func_as_extern_checked(void *) +wasm_globaltype_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_func_as_extern(); + wasm_globaltype_vec_new_empty(out); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_global_as_extern_checked(void *) +wasm_globaltype_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_global_as_extern(); + wasm_globaltype_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_table_as_extern_checked(void *) +wasm_importtype_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5749,14 +3648,14 @@ wasm_table_as_extern_checked(void *) return res; } // Execute the original function - wasm_table_as_extern(); + wasm_importtype_copy(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_memory_as_extern_checked(void *) +wasm_importtype_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5765,14 +3664,14 @@ wasm_memory_as_extern_checked(void *) return res; } // Execute the original function - wasm_memory_as_extern(); + wasm_importtype_delete(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_extern_as_func_checked(void *) +wasm_importtype_is_linked_checked(void *) { Result res; // Check for null pointer parameter: None @@ -5781,236 +3680,7 @@ wasm_extern_as_func_checked(void *) 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(, ); + _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; @@ -6018,7 +3688,7 @@ wasm_instance_same_checked(void *, void *) } static inline Result -wasm_instance_get_host_info_checked(void *) +wasm_importtype_module_checked(void *) { Result res; // Check for null pointer parameter: None @@ -6027,14 +3697,14 @@ wasm_instance_get_host_info_checked(void *) return res; } // Execute the original function - wasm_instance_get_host_info(); + wasm_importtype_module(); // Assign return value and error code res.error_code = 0; return res; } static inline Result -wasm_instance_set_host_info_checked(void *, void *) +wasm_importtype_name_checked(void *) { Result res; // Check for null pointer parameter: None @@ -6042,29 +3712,24 @@ wasm_instance_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_instance_set_host_info(, ); + wasm_importtype_name(); // 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_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: None - if (None == NULL) { + // Check for null pointer parameter: name + if (name == NULL) { res.error_code = -1; return res; } @@ -6074,7 +3739,108 @@ wasm_instance_set_host_info_with_finalizer_checked(void *, void *, void *) return res; } // Execute the original function - wasm_instance_set_host_info_with_finalizer(, , ); + wasm_importtype_new(module, name, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_type_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_type(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_importtype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_importtype_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; @@ -6096,22 +3862,6 @@ wasm_instance_as_ref_checked(void *) 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 *) { @@ -6129,7 +3879,7 @@ wasm_instance_as_ref_const_checked(void *) } static inline Result -wasm_ref_as_instance_const_checked(void *) +wasm_instance_copy_checked(void *) { Result res; // Check for null pointer parameter: None @@ -6138,12 +3888,92 @@ wasm_ref_as_instance_const_checked(void *) return res; } // Execute the original function - wasm_ref_as_instance_const(); + wasm_instance_copy(); // Assign return value and error code res.error_code = 0; return res; } +static inline Result +wasm_instance_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_exports_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_exports(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_get_wasm_func_exec_time_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + double original_result = wasm_instance_get_wasm_func_exec_time(, ); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.double_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + static inline Result wasm_instance_new_checked(void *, void *, void *imports, void *trap) { @@ -6245,7 +4075,7 @@ wasm_instance_new_with_args_ex_checked(void *, void *, void *imports, } static inline Result -wasm_instance_exports_checked(void *, void *out) +wasm_instance_same_checked(void *, void *) { Result res; // Check for null pointer parameter: None @@ -6253,13 +4083,61 @@ wasm_instance_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; } // Execute the original function - wasm_instance_exports(, out); + _Bool original_result = wasm_instance_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_instance_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_instance_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_instance_set_host_info_with_finalizer(, , ); // Assign return value and error code res.error_code = 0; return res; @@ -6288,7 +4166,7 @@ wasm_instance_sum_wasm_exec_time_checked(void *) } static inline Result -wasm_instance_get_wasm_func_exec_time_checked(void *, void *) +wasm_memory_as_extern_checked(void *) { Result res; // Check for null pointer parameter: None @@ -6296,17 +4174,108 @@ wasm_instance_get_wasm_func_exec_time_checked(void *, void *) res.error_code = -1; return res; } + // Execute the original function + wasm_memory_as_extern(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_as_extern_const_checked(void *) +{ + Result res; // Check for null pointer parameter: None if (None == NULL) { res.error_code = -1; return res; } // Execute the original function - double original_result = wasm_instance_get_wasm_func_exec_time(, ); + wasm_memory_as_extern_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_data_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_data(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_data_size_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + size_t original_result = wasm_memory_data_size(); // Assign return value and error code if (original_result == 0) { res.error_code = 0; - res.value.double_value = original_result; + res.value.size_t_value = original_result; } else { res.error_code = -2; @@ -6315,7 +4284,7 @@ wasm_instance_get_wasm_func_exec_time_checked(void *, void *) } static inline Result -wasm_extern_new_empty_checked(void *, wasm_externkind_t) +wasm_memory_delete_checked(void *) { Result res; // Check for null pointer parameter: None @@ -6324,7 +4293,2038 @@ wasm_extern_new_empty_checked(void *, wasm_externkind_t) return res; } // Execute the original function - wasm_extern_new_empty(, ); + wasm_memory_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_grow_checked(void *, wasm_memory_pages_t delta) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_memory_grow(, delta); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_new_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_new(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_memory_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_size_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_pages_t original_result = wasm_memory_size(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_memory_pages_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_type_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memory_type(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_as_externtype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_as_externtype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_as_externtype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_as_externtype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_limits_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_limits(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_new_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_new(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memorytype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_memorytype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_deserialize_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_deserialize(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_exports_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_exports(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_get_name_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_get_name(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_imports_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_imports(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_is_underlying_binary_freeable_checked(void *module) +{ + Result res; + // Check for null pointer parameter: module + if (module == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_module_is_underlying_binary_freeable(module); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_module_new_checked(void *, void *binary) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: binary + if (binary == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_new(, binary); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_new_ex_checked(void *, void *binary, void *args) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: binary + if (binary == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_new_ex(, binary, args); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_obtain_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_obtain(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_serialize_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_serialize(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_set_name_checked(void *, void *name) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_module_set_name(, name); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_module_share_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_share(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_module_validate_checked(void *, void *binary) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: binary + if (binary == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_module_validate(, binary); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_ref_as_extern_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_extern(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_extern_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_extern_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_foreign_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_foreign(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_foreign_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_foreign_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_func_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_func(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_func_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_func_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_global_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_global(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_global_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_global_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_instance_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_instance(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_instance_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_instance_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_memory_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_memory(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_memory_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_memory_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_table_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_table(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_table_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_table_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_trap_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_trap(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_as_trap_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_as_trap_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_ref_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_ref_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_ref_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_ref_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_shared_module_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_shared_module_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_store_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_store_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_store_new_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_store_new(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_as_extern_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_as_extern(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_as_extern_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_as_extern_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_get_checked(void *, wasm_table_size_t index) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_get(, index); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_grow_checked(void *, wasm_table_size_t delta, void *init) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: init + if (init == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_table_grow(, delta, init); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_table_new_checked(void *, void *, void *init) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: init + if (init == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_new(, , init); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_table_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_table_set_checked(void *, wasm_table_size_t index, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_table_set(, index, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_table_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_table_size_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_size_t original_result = wasm_table_size(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_table_size_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_table_type(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_as_externtype_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_as_externtype(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_as_externtype_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_as_externtype_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_element_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_element(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_limits_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_limits(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_new_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_new(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_tabletype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_tabletype_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_as_ref_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_as_ref(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_as_ref_const_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_as_ref_const(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_get_host_info_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_get_host_info(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_message_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_message(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_new_checked(void *store, void *) +{ + Result res; + // Check for null pointer parameter: store + if (store == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_new(store, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_origin_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_origin(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_same_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_trap_same(, ); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_trap_set_host_info_checked(void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_set_host_info(, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_set_host_info_with_finalizer_checked(void *, void *, void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_set_host_info_with_finalizer(, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_trap_trace_checked(void *, void *out) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_trap_trace(, out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_delete_checked(void *v) +{ + Result res; + // Check for null pointer parameter: v + if (v == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_delete(v); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_val_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_val_vec_new_uninitialized(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_copy_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_copy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_kind_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valkind_t original_result = wasm_valtype_kind(); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_valtype_new_checked(wasm_valkind_t) +{ + Result res; + // Execute the original function + wasm_valtype_new(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_vec_copy_checked(void *out, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_vec_copy(out, ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_vec_delete_checked(void *) +{ + Result res; + // Check for null pointer parameter: None + if (None == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_vec_delete(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_vec_new_checked(void *out, size_t, void *) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_vec_new(out, , ); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_vec_new_empty_checked(void *out) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_vec_new_empty(out); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_valtype_vec_new_uninitialized_checked(void *out, size_t) +{ + Result res; + // Check for null pointer parameter: out + if (out == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_valtype_vec_new_uninitialized(out, ); // Assign return value and error code res.error_code = 0; return res; diff --git a/core/iwasm/include/wasm_export_checked.h b/core/iwasm/include/wasm_export_checked.h index 2a8b2fea2..c7610079e 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; - 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; + package_type_t package_type_t_value; + uint32_t uint32_t_value; + uint64_t uint64_t_value; + wasm_exec_env_t wasm_exec_env_t_value; + wasm_function_inst_t wasm_function_inst_t_value; + wasm_memory_inst_t wasm_memory_inst_t_value; wasm_module_inst_t wasm_module_inst_t_value; + wasm_module_t wasm_module_t_value; + wasm_shared_heap_t wasm_shared_heap_t_value; + wasm_valkind_t wasm_valkind_t_value; // Add other types as needed } value; } Result; @@ -59,142 +59,6 @@ get_base_lib_export_apis_checked(void *p_base_lib_apis) 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) { @@ -217,6 +81,1201 @@ get_package_type_checked(void *buf, uint32_t size) return res; } +static inline Result +wasm_application_execute_func_checked(wasm_module_inst_t module_inst, + void *name, int32_t argc, void *argv) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_application_execute_func(module_inst, name, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_application_execute_main_checked(wasm_module_inst_t module_inst, + int32_t argc, void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_application_execute_main(module_inst, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_copy_callstack_checked(wasm_exec_env_t exec_env, void *buffer, + uint32_t length, uint32_t skip_n, void *error_buf, + uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: buffer + if (buffer == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = wasm_copy_callstack( + exec_env, buffer, length, skip_n, error_buf, error_buf_size); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_externref_obj2ref_checked(wasm_module_inst_t module_inst, void *extern_obj, + void *p_externref_idx) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_externref_idx + if (p_externref_idx == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_externref_obj2ref(module_inst, extern_obj, p_externref_idx); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_objdel_checked(wasm_module_inst_t module_inst, void *extern_obj) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_externref_objdel(module_inst, extern_obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_ref2obj_checked(uint32_t externref_idx, void *p_extern_obj) +{ + Result res; + // Check for null pointer parameter: p_extern_obj + if (p_extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_externref_ref2obj(externref_idx, p_extern_obj); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_retain_checked(uint32_t externref_idx) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_externref_retain(externref_idx); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_externref_set_cleanup_checked(wasm_module_inst_t module_inst, + void *extern_obj, void *extern_obj_cleanup) +{ + Result res; + // Check for null pointer parameter: extern_obj + if (extern_obj == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: extern_obj_cleanup + if (extern_obj_cleanup == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_externref_set_cleanup(module_inst, extern_obj, extern_obj_cleanup); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_func_get_param_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_func_get_param_count(func_inst, module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_get_param_types_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst, + void *param_types) +{ + Result res; + // Check for null pointer parameter: param_types + if (param_types == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_get_param_types(func_inst, module_inst, param_types); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_get_result_count_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_func_get_result_count(func_inst, module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_get_result_types_checked(wasm_function_inst_t func_inst, + wasm_module_inst_t module_inst, + void *result_types) +{ + Result res; + // Check for null pointer parameter: result_types + if (result_types == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_func_get_result_types(func_inst, module_inst, result_types); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_func_type_get_param_count_checked(wasm_func_type_t func_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_func_type_get_param_count(func_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_param_valkind_checked(wasm_func_type_t func_type, + uint32_t param_index) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = + wasm_func_type_get_param_valkind(func_type, param_index); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_result_count_checked(wasm_func_type_t func_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_func_type_get_result_count(func_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_func_type_get_result_valkind_checked(wasm_func_type_t func_type, + uint32_t result_index) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = + wasm_func_type_get_result_valkind(func_type, result_index); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_global_type_get_mutable_checked(wasm_global_type_t global_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_global_type_get_mutable(global_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_global_type_get_valkind_checked(wasm_global_type_t global_type) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = wasm_global_type_get_valkind(global_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_enlarge_checked(wasm_memory_inst_t memory_inst, + uint64_t inc_page_count) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_enlarge(memory_inst, inc_page_count); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_get_base_address_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + wasm_memory_get_base_address(memory_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_memory_get_bytes_per_page_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_bytes_per_page(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_cur_page_count_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_cur_page_count(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_max_page_count_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + uint64_t original_result = wasm_memory_get_max_page_count(memory_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_get_shared_checked(wasm_memory_inst_t memory_inst) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_get_shared(memory_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_memory_type_get_init_page_count_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_memory_type_get_init_page_count(memory_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_type_get_max_page_count_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_memory_type_get_max_page_count(memory_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_memory_type_get_shared_checked(wasm_memory_type_t memory_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_memory_type_get_shared(memory_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_addr_app_to_native_checked(wasm_module_inst_t module_inst, + uint64_t app_offset) +{ + Result res; + // Execute the original function + wasm_runtime_addr_app_to_native(module_inst, app_offset); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_addr_native_to_app_checked(wasm_module_inst_t module_inst, + void *native_ptr) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint64_t original_result = + wasm_runtime_addr_native_to_app(module_inst, native_ptr); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint64_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_attach_shared_heap_checked(wasm_module_inst_t module_inst, + wasm_shared_heap_t shared_heap) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_attach_shared_heap(module_inst, shared_heap); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_begin_blocking_op_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_begin_blocking_op(exec_env); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_indirect_checked(wasm_exec_env_t exec_env, + uint32_t element_index, uint32_t argc, + void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_call_indirect(exec_env, element_index, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, uint32_t argc, + void *argv) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_call_wasm(exec_env, function, argc, argv); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_a_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, + uint32_t num_results, void *results, + uint32_t num_args, void *args) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_call_wasm_a( + exec_env, function, num_results, results, num_args, args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_call_wasm_v_checked(wasm_exec_env_t exec_env, + wasm_function_inst_t function, + uint32_t num_results, void *results, + uint32_t num_args, ...) +{ + Result res; + va_list args; + // Execute the original function + va_start(args, num_args); + _Bool original_result = wasm_runtime_call_wasm_v( + exec_env, function, num_results, results, num_args, args); + va_end(args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_chain_shared_heaps_checked(wasm_shared_heap_t head, + wasm_shared_heap_t body) +{ + Result res; + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_chain_shared_heaps(head, body); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_clear_exception_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_clear_exception(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_create_context_key_checked(void *dtor) +{ + Result res; + // Check for null pointer parameter: dtor + if (dtor == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_create_context_key(dtor); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_create_exec_env_checked(wasm_module_inst_t module_inst, + uint32_t stack_size) +{ + Result res; + // Execute the original function + wasm_exec_env_t original_result = + wasm_runtime_create_exec_env(module_inst, stack_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_exec_env_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_create_shared_heap_checked(void *init_args) +{ + Result res; + // Check for null pointer parameter: init_args + if (init_args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_create_shared_heap(init_args); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_deinstantiate_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_deinstantiate(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_checked(void) +{ + Result res; + // Execute the original function + wasm_runtime_destroy(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_context_key_checked(void *key) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_destroy_context_key(key); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_exec_env_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_exec_env(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_spawned_exec_env_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_spawned_exec_env(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_destroy_thread_env_checked(void) +{ + Result res; + // Execute the original function + wasm_runtime_destroy_thread_env(); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_detach_shared_heap_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_detach_shared_heap(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_detect_native_stack_overflow_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_detect_native_stack_overflow(exec_env); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_detect_native_stack_overflow_size_checked(wasm_exec_env_t exec_env, + uint32_t required_size) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_detect_native_stack_overflow_size(exec_env, required_size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_dump_call_stack_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_dump_call_stack(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_call_stack_to_buf_checked(wasm_exec_env_t exec_env, void *buf, + uint32_t len) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = + wasm_runtime_dump_call_stack_to_buf(exec_env, buf, len); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_dump_mem_consumption_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_dump_mem_consumption(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_perf_profiling_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_dump_perf_profiling(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_dump_pgo_prof_data_to_buf_checked(wasm_module_inst_t module_inst, + void *buf, uint32_t len) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + uint32_t original_result = + wasm_runtime_dump_pgo_prof_data_to_buf(module_inst, buf, len); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_end_blocking_op_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_end_blocking_op(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_enlarge_memory_checked(wasm_module_inst_t module_inst, + uint64_t inc_page_count) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_enlarge_memory(module_inst, inc_page_count); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_find_module_registered_checked(void *module_name) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = + wasm_runtime_find_module_registered(module_name); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_free_checked(void *ptr) +{ + Result res; + // Check for null pointer parameter: ptr + if (ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_free(ptr); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_full_init_checked(void *init_args) +{ + Result res; + // Check for null pointer parameter: init_args + if (init_args == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_full_init(init_args); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_app_addr_range_checked(wasm_module_inst_t module_inst, + uint64_t app_offset, + void *p_app_start_offset, + void *p_app_end_offset) +{ + Result res; + // Check for null pointer parameter: p_app_start_offset + if (p_app_start_offset == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_app_end_offset + if (p_app_end_offset == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_app_addr_range( + module_inst, app_offset, p_app_start_offset, p_app_end_offset); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_call_stack_buf_size_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_call_stack_buf_size(exec_env); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_context_checked(wasm_module_inst_t inst, void *key) +{ + Result res; + // Check for null pointer parameter: key + if (key == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_context(inst, key); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_current_package_version_checked(package_type_t package_type) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_runtime_get_current_package_version(package_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_custom_data_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_get_custom_data(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_custom_section_checked(wasm_module_t module_comm, void *name, + void *len) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: len + if (len == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_custom_section(module_comm, name, len); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_default_memory_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_memory_inst_t original_result = + wasm_runtime_get_default_memory(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_memory_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_exception_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_get_exception(module_inst); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_exec_env_singleton_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_exec_env_t original_result = + wasm_runtime_get_exec_env_singleton(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_exec_env_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_export_count_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + int32_t original_result = wasm_runtime_get_export_count(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_export_global_inst_checked(wasm_module_inst_t module_inst, + void *name, void *global_inst) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: global_inst + if (global_inst == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_get_export_global_inst(module_inst, name, global_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_export_table_inst_checked(wasm_module_inst_t module_inst, + void *name, void *table_inst) +{ + Result res; + // Check for null pointer parameter: name + if (name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: table_inst + if (table_inst == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_get_export_table_inst(module_inst, name, table_inst); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_export_type_checked(wasm_module_t module, int32_t export_index, + void *export_type) +{ + Result res; + // Check for null pointer parameter: export_type + if (export_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_export_type(module, export_index, export_type); + // Assign return value and error code + res.error_code = 0; + return res; +} + static inline Result wasm_runtime_get_file_package_type_checked(void *buf, uint32_t size) { @@ -240,24 +1299,6 @@ wasm_runtime_get_file_package_type_checked(void *buf, uint32_t size) 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) { @@ -280,6 +1321,160 @@ wasm_runtime_get_file_package_version_checked(void *buf, uint32_t size) return res; } +static inline Result +wasm_runtime_get_function_attachment_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_get_function_attachment(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_import_count_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + int32_t original_result = wasm_runtime_get_import_count(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_import_type_checked(wasm_module_t module, int32_t import_index, + void *import_type) +{ + Result res; + // Check for null pointer parameter: import_type + if (import_type == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_get_import_type(module, import_index, import_type); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_mem_alloc_info_checked(void *mem_alloc_info) +{ + Result res; + // Check for null pointer parameter: mem_alloc_info + if (mem_alloc_info == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_mem_alloc_info(mem_alloc_info); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_memory_checked(wasm_module_inst_t module_inst, uint32_t index) +{ + Result res; + // Execute the original function + wasm_memory_inst_t original_result = + wasm_runtime_get_memory(module_inst, index); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_memory_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_module_t original_result = wasm_runtime_get_module(module_inst); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_hash_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_get_module_hash(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_module_inst_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_module_inst_t original_result = wasm_runtime_get_module_inst(exec_env); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_module_name_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_get_module_name(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_module_package_type_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + package_type_t original_result = + wasm_runtime_get_module_package_type(module); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.package_type_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + static inline Result wasm_runtime_get_module_package_version_checked(wasm_module_t module) { @@ -298,12 +1493,42 @@ 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_runtime_get_native_addr_range_checked(wasm_module_inst_t module_inst, + void *native_ptr, + void *p_native_start_addr, + void *p_native_end_addr) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_native_start_addr + if (p_native_start_addr == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: p_native_end_addr + if (p_native_end_addr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = wasm_runtime_get_native_addr_range( + module_inst, native_ptr, p_native_start_addr, p_native_end_addr); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_get_pgo_prof_data_size_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - uint32_t original_result = - wasm_runtime_get_current_package_version(package_type); + 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; @@ -316,16 +1541,106 @@ 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_runtime_get_running_mode_checked(wasm_module_inst_t module_inst) { Result res; - // Check for null pointer parameter: buf - if (buf == NULL) { + // Execute the original function + RunningMode original_result = wasm_runtime_get_running_mode(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.RunningMode_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_user_data_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + wasm_runtime_get_user_data(exec_env); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_version_checked(void *major, void *minor, void *patch) +{ + Result res; + // Check for null pointer parameter: major + if (major == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: minor + if (minor == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: patch + if (patch == NULL) { res.error_code = -1; return res; } // Execute the original function - _Bool original_result = wasm_runtime_is_xip_file(buf, size); + wasm_runtime_get_version(major, minor, patch); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_get_wasi_exit_code_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_get_wasi_exit_code(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_get_wasm_func_exec_time_checked(wasm_module_inst_t inst, + void *func_name) +{ + Result res; + // Check for null pointer parameter: func_name + if (func_name == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + double original_result = + wasm_runtime_get_wasm_func_exec_time(inst, func_name); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.double_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_init_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_init(); // Assign return value and error code res.error_code = original_result ? 0 : -2; res.value._Bool_value = original_result; @@ -333,245 +1648,17 @@ 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_runtime_init_thread_env_checked(void) { 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); + _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_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, @@ -628,6 +1715,35 @@ wasm_runtime_instantiate_ex_checked(wasm_module_t module, void *args, return res; } +static inline Result +wasm_runtime_instantiate_ex2_checked(wasm_module_t module, void *args, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_inst_t original_result = + wasm_runtime_instantiate_ex2(module, args, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + static inline Result wasm_runtime_instantiation_args_create_checked(void *p) { @@ -713,42 +1829,11 @@ wasm_runtime_instantiation_args_set_max_memory_pages_checked(void *p, } 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) +wasm_runtime_is_bounds_checks_enabled_checked(wasm_module_inst_t module_inst) { Result res; // Execute the original function - _Bool original_result = - wasm_runtime_set_running_mode(module_inst, running_mode); + _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; @@ -756,47 +1841,74 @@ wasm_runtime_set_running_mode_checked(wasm_module_inst_t module_inst, } static inline Result -wasm_runtime_get_running_mode_checked(wasm_module_inst_t module_inst) +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 - RunningMode original_result = wasm_runtime_get_running_mode(module_inst); + _Bool original_result = + wasm_runtime_is_import_func_linked(module_name, func_name); // 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; - } + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; return res; } static inline Result -wasm_runtime_deinstantiate_checked(wasm_module_inst_t module_inst) +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 - wasm_runtime_deinstantiate(module_inst); + _Bool original_result = + wasm_runtime_is_import_global_linked(module_name, global_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_runtime_get_module_checked(wasm_module_inst_t module_inst) +wasm_runtime_is_running_mode_supported_checked(RunningMode running_mode) { Result res; // Execute the original function - wasm_module_t original_result = wasm_runtime_get_module(module_inst); + _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_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_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; } @@ -813,16 +1925,37 @@ wasm_runtime_is_wasi_mode_checked(wasm_module_inst_t module_inst) } static inline Result -wasm_runtime_lookup_wasi_start_function_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_function_inst_t original_result = - wasm_runtime_lookup_wasi_start_function(module_inst); + _Bool original_result = wasm_runtime_is_xip_file(buf, size); // 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_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.wasm_function_inst_t_value = original_result; + res.value.int32_t_value = original_result; } else { res.error_code = -2; @@ -831,15 +1964,86 @@ 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_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_runtime_get_wasi_exit_code(module_inst); + 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; + } + return res; +} + +static inline Result +wasm_runtime_load_ex_checked(void *buf, uint32_t size, void *args, + void *error_buf, uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: buf + if (buf == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: args + if (args == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = + wasm_runtime_load_ex(buf, size, args, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_load_from_sections_checked(wasm_section_list_t section_list, + _Bool is_aot, void *error_buf, + uint32_t error_buf_size) +{ + Result res; + // Check for null pointer parameter: error_buf + if (error_buf == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_module_t original_result = wasm_runtime_load_from_sections( + section_list, is_aot, error_buf, error_buf_size); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_module_t_value = original_result; } else { res.error_code = -2; @@ -870,258 +2074,6 @@ wasm_runtime_lookup_function_checked(wasm_module_inst_t module_inst, void *name) 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) { @@ -1146,16 +2098,16 @@ 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_lookup_wasi_start_function_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_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_memory_inst_t_value = original_result; + res.value.wasm_function_inst_t_value = original_result; } else { res.error_code = -2; @@ -1164,345 +2116,11 @@ 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_runtime_malloc_checked(unsigned int size) { 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); + wasm_runtime_malloc(size); // Assign return value and error code res.error_code = 0; return res; @@ -1533,77 +2151,29 @@ 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_module_free_checked(wasm_module_inst_t module_inst, uint64_t ptr) { 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); + wasm_runtime_module_free(module_inst, ptr); // 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) +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_ptr - if (native_ptr == NULL) { + // 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_addr_native_to_app(module_inst, native_ptr); + wasm_runtime_module_malloc(module_inst, size, p_native_addr); // Assign return value and error code if (original_result == 0) { res.error_code = 0; @@ -1616,341 +2186,45 @@ 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_realloc_checked(void *ptr, unsigned int size) { 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) { + // Check for null pointer parameter: ptr + if (ptr == 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); + wasm_runtime_realloc(ptr, size); // 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) +wasm_runtime_register_module_checked(void *module_name, wasm_module_t module, + void *error_buf, uint32_t error_buf_size) { 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; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; } - 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) { + // Check for null pointer parameter: error_buf + if (error_buf == 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); + _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_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) @@ -2001,22 +2275,11 @@ wasm_runtime_register_natives_raw_checked(void *module_name, } static inline Result -wasm_runtime_unregister_natives_checked(void *module_name, void *native_symbols) +wasm_runtime_resolve_symbols_checked(wasm_module_t module) { 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); + _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; @@ -2024,637 +2287,12 @@ wasm_runtime_unregister_natives_checked(void *module_name, void *native_symbols) } 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) +wasm_runtime_set_bounds_checks_checked(wasm_module_inst_t module_inst, + _Bool enable) { 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); + wasm_runtime_set_bounds_checks(module_inst, enable); // Assign return value and error code res.error_code = 0; return res; @@ -2704,27 +2342,28 @@ wasm_runtime_set_context_spread_checked(wasm_module_inst_t inst, void *key, } static inline Result -wasm_runtime_get_context_checked(wasm_module_inst_t inst, void *key) +wasm_runtime_set_custom_data_checked(wasm_module_inst_t module_inst, + void *custom_data) { Result res; - // Check for null pointer parameter: key - if (key == NULL) { + // Check for null pointer parameter: custom_data + if (custom_data == NULL) { res.error_code = -1; return res; } // Execute the original function - wasm_runtime_get_context(inst, key); + 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_begin_blocking_op_checked(wasm_exec_env_t exec_env) +wasm_runtime_set_default_running_mode_checked(RunningMode running_mode) { Result res; // Execute the original function - _Bool original_result = wasm_runtime_begin_blocking_op(exec_env); + _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; @@ -2732,11 +2371,80 @@ 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_set_enlarge_mem_error_callback_checked( + enlarge_memory_error_callback_t callback, void *user_data) +{ + Result res; + // Check for null pointer parameter: user_data + if (user_data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_enlarge_mem_error_callback(callback, user_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_exception_checked(wasm_module_inst_t module_inst, + void *exception) +{ + Result res; + // Check for null pointer parameter: exception + if (exception == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_exception(module_inst, exception); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_instruction_count_limit_checked(wasm_exec_env_t exec_env, + int instruction_count) { Result res; // Execute the original function - wasm_runtime_end_blocking_op(exec_env); + wasm_runtime_set_instruction_count_limit(exec_env, instruction_count); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_log_level_checked(log_level_t level) +{ + Result res; + // Execute the original function + wasm_runtime_set_log_level(level); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_max_thread_num_checked(uint32_t num) +{ + Result res; + // Execute the original function + wasm_runtime_set_max_thread_num(num); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_module_inst_checked(wasm_exec_env_t exec_env, + wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_set_module_inst(exec_env, module_inst); // Assign return value and error code res.error_code = 0; return res; @@ -2767,123 +2475,42 @@ 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) +wasm_runtime_set_module_reader_checked(module_reader reader, + module_destroyer destroyer) { Result res; // Execute the original function - wasm_runtime_get_module_name(module); + wasm_runtime_set_module_reader(reader, destroyer); // 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_set_native_stack_boundary_checked(wasm_exec_env_t exec_env, + void *native_stack_boundary) { 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) { + // Check for null pointer parameter: native_stack_boundary + if (native_stack_boundary == 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_runtime_set_native_stack_boundary(exec_env, native_stack_boundary); // 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 = 0; 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) +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_attach_shared_heap(module_inst, shared_heap); + 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; @@ -2891,11 +2518,87 @@ 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_set_user_data_checked(wasm_exec_env_t exec_env, void *user_data) +{ + Result res; + // Check for null pointer parameter: user_data + if (user_data == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_runtime_set_user_data(exec_env, user_data); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_addr_pool_checked(wasm_module_t module, void *addr_pool, + uint32_t addr_pool_size) { Result res; // Execute the original function - wasm_runtime_detach_shared_heap(module_inst); + wasm_runtime_set_wasi_addr_pool(module, addr_pool, addr_pool_size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_args_checked(wasm_module_t module, void *dir_list, + uint32_t dir_count, void *map_dir_list, + uint32_t map_dir_count, void *env, + uint32_t env_count, void *argv, int argc) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_args(module, dir_list, dir_count, map_dir_list, + map_dir_count, env, env_count, argv, argc); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_args_ex_checked(wasm_module_t module, void *dir_list, + uint32_t dir_count, void *map_dir_list, + uint32_t map_dir_count, void *env, + uint32_t env_count, void *argv, int argc, + int64_t stdinfd, int64_t stdoutfd, + int64_t stderrfd) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_args_ex(module, dir_list, dir_count, map_dir_list, + map_dir_count, env, env_count, argv, argc, + stdinfd, stdoutfd, stderrfd); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_set_wasi_ns_lookup_pool_checked(wasm_module_t module, + void *ns_lookup_pool, + uint32_t ns_lookup_pool_size) +{ + Result res; + // Execute the original function + wasm_runtime_set_wasi_ns_lookup_pool(module, ns_lookup_pool, + ns_lookup_pool_size); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_shared_heap_free_checked(wasm_module_inst_t module_inst, + uint64_t ptr) +{ + Result res; + // Execute the original function + wasm_runtime_shared_heap_free(module_inst, ptr); // Assign return value and error code res.error_code = 0; return res; @@ -2926,15 +2629,312 @@ 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_runtime_spawn_exec_env_checked(wasm_exec_env_t exec_env) { Result res; // Execute the original function - wasm_runtime_shared_heap_free(module_inst, ptr); + wasm_exec_env_t original_result = wasm_runtime_spawn_exec_env(exec_env); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_exec_env_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_spawn_thread_checked(wasm_exec_env_t exec_env, void *tid, + wasm_thread_callback_t callback, void *arg) +{ + Result res; + // Check for null pointer parameter: tid + if (tid == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: arg + if (arg == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + int32_t original_result = + wasm_runtime_spawn_thread(exec_env, tid, callback, arg); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.int32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_start_debug_instance_checked(wasm_exec_env_t exec_env) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_runtime_start_debug_instance(exec_env); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_start_debug_instance_with_port_checked(wasm_exec_env_t exec_env, + int32_t port) +{ + Result res; + // Execute the original function + uint32_t original_result = + wasm_runtime_start_debug_instance_with_port(exec_env, port); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_sum_wasm_exec_time_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + double original_result = wasm_runtime_sum_wasm_exec_time(module_inst); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.double_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_terminate_checked(wasm_module_inst_t module_inst) +{ + Result res; + // Execute the original function + wasm_runtime_terminate(module_inst); // Assign return value and error code res.error_code = 0; return res; } +static inline Result +wasm_runtime_thread_env_inited_checked(void) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_runtime_thread_env_inited(); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_unchain_shared_heaps_checked(wasm_shared_heap_t head, + _Bool entire_chain) +{ + Result res; + // Execute the original function + wasm_shared_heap_t original_result = + wasm_runtime_unchain_shared_heaps(head, entire_chain); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_shared_heap_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_runtime_unload_checked(wasm_module_t module) +{ + Result res; + // Execute the original function + wasm_runtime_unload(module); + // Assign return value and error code + res.error_code = 0; + return res; +} + +static inline Result +wasm_runtime_unregister_natives_checked(void *module_name, void *native_symbols) +{ + Result res; + // Check for null pointer parameter: module_name + if (module_name == NULL) { + res.error_code = -1; + return res; + } + // Check for null pointer parameter: native_symbols + if (native_symbols == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_unregister_natives(module_name, native_symbols); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_app_addr_checked(wasm_module_inst_t module_inst, + uint64_t app_offset, uint64_t size) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_validate_app_addr(module_inst, app_offset, size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_app_str_addr_checked(wasm_module_inst_t module_inst, + uint64_t app_str_offset) +{ + Result res; + // Execute the original function + _Bool original_result = + wasm_runtime_validate_app_str_addr(module_inst, app_str_offset); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_runtime_validate_native_addr_checked(wasm_module_inst_t module_inst, + void *native_ptr, uint64_t size) +{ + Result res; + // Check for null pointer parameter: native_ptr + if (native_ptr == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + _Bool original_result = + wasm_runtime_validate_native_addr(module_inst, native_ptr, size); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + +static inline Result +wasm_table_get_func_inst_checked(wasm_module_inst_t module_inst, + void *table_inst, uint32_t idx) +{ + Result res; + // Check for null pointer parameter: table_inst + if (table_inst == NULL) { + res.error_code = -1; + return res; + } + // Execute the original function + wasm_function_inst_t original_result = + wasm_table_get_func_inst(module_inst, table_inst, idx); + // Assign return value and error code + if (original_result != NULL) { + res.error_code = 0; + res.value.wasm_function_inst_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_elem_kind_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + wasm_valkind_t original_result = wasm_table_type_get_elem_kind(table_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.wasm_valkind_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_init_size_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_table_type_get_init_size(table_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_max_size_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + uint32_t original_result = wasm_table_type_get_max_size(table_type); + // Assign return value and error code + if (original_result == 0) { + res.error_code = 0; + res.value.uint32_t_value = original_result; + } + else { + res.error_code = -2; + } + return res; +} + +static inline Result +wasm_table_type_get_shared_checked(wasm_table_type_t table_type) +{ + Result res; + // Execute the original function + _Bool original_result = wasm_table_type_get_shared(table_type); + // Assign return value and error code + res.error_code = original_result ? 0 : -2; + res.value._Bool_value = original_result; + return res; +} + #endif // WASM_EXPORT_CHECKED_H 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 faa8a275e..28c04887b 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 05a758243..83e73a319 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) {