Skip to content

Commit 8a6379b

Browse files
authored
Add wasm_runtime_get_module_package_type() and wasm_runtime_get_file_package_type() (#3600)
wasm_runtime_get_file_package_type() is the counterpart of get_file_package_type(). See discussion in #3595.
1 parent 8aba858 commit 8a6379b

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

core/iwasm/common/wasm_runtime_common.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,22 @@ get_package_type(const uint8 *buf, uint32 size)
871871
return Package_Type_Unknown;
872872
}
873873

874+
PackageType
875+
wasm_runtime_get_file_package_type(const uint8 *buf, uint32 size)
876+
{
877+
return get_package_type(buf, size);
878+
}
879+
880+
PackageType
881+
wasm_runtime_get_module_package_type(WASMModuleCommon *module)
882+
{
883+
if (!module) {
884+
return Package_Type_Unknown;
885+
}
886+
887+
return module->module_type;
888+
}
889+
874890
#if WASM_ENABLE_AOT != 0
875891
static uint8 *
876892
align_ptr(const uint8 *p, uint32 b)

core/iwasm/include/wasm_export.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,28 @@ wasm_runtime_get_mem_alloc_info(mem_alloc_info_t *mem_alloc_info);
422422
WASM_RUNTIME_API_EXTERN package_type_t
423423
get_package_type(const uint8_t *buf, uint32_t size);
424424

425+
/**
426+
* Get the package type of a buffer (same as get_package_type).
427+
*
428+
* @param buf the package buffer
429+
* @param size the package buffer size
430+
*
431+
* @return the package type, return Package_Type_Unknown if the type is unknown
432+
*/
433+
WASM_RUNTIME_API_EXTERN package_type_t
434+
wasm_runtime_get_file_package_type(const uint8_t *buf, uint32_t size);
435+
436+
/**
437+
* Get the package type of a module.
438+
*
439+
* @param module the module
440+
*
441+
* @return the package type, return Package_Type_Unknown if the type is
442+
* unknown
443+
*/
444+
WASM_RUNTIME_API_EXTERN package_type_t
445+
wasm_runtime_get_module_package_type(wasm_module_t module);
446+
425447
/**
426448
* Check whether a file is an AOT XIP (Execution In Place) file
427449
*

0 commit comments

Comments
 (0)