mirror of
				https://github.com/bytecodealliance/wasm-micro-runtime.git
				synced 2025-10-30 21:02:27 +00:00 
			
		
		
		
	 50b6474f54
			
		
	
	
		50b6474f54
		
			
		
	
	
	
	
		
			
			Refer to https://github.com/WebAssembly/WASI/blob/main/design/application-abi.md to check the WASI ABI compatibility: - Command (main module) may export _start function with signature "()" - Reactor (sub module) may export _initialize function with signature "()" - _start and _initialize can not be exported at the same time - Reactor cannot export _start function - Command and Reactor must export memory And - Rename module->is_wasi_module to module->import_wasi_api - Refactor wasm_loader_find_export() - Remove MULTI_MODULE related codes from mini_loader - Update multi-module samples - Fix a "use-after-free" issue. Since we reuse the memory instance of sub module, just to protect it from freeing an imported memory instance
		
			
				
	
	
		
			46 lines
		
	
	
		
			845 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			845 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include <cstdlib>
 | |
| #include <cstdio>
 | |
| #include <iostream>
 | |
| 
 | |
| static void
 | |
| bye_setup()
 | |
| {
 | |
|     std::cout << "mE " << __FUNCTION__ << std::endl;
 | |
| }
 | |
| 
 | |
| static void
 | |
| bye_func()
 | |
| {
 | |
|     std::cout << "mE " << __FUNCTION__ << std::endl;
 | |
| }
 | |
| 
 | |
| __attribute__((constructor)) void
 | |
| setup()
 | |
| {
 | |
|     std::cout << "mE " << __FUNCTION__ << std::endl;
 | |
|     if (std::atexit(bye_setup) != 0) {
 | |
|         std::perror("register an atexit handler failed");
 | |
|     }
 | |
| }
 | |
| 
 | |
| __attribute__((destructor)) void
 | |
| teardown()
 | |
| {
 | |
|     std::cout << "mE " << __FUNCTION__ << std::endl;
 | |
| }
 | |
| 
 | |
| __attribute__((export_name("func1"))) void
 | |
| func1()
 | |
| {
 | |
|     std::cout << "mE " << __FUNCTION__ << std::endl;
 | |
|     if (std::atexit(bye_func) != 0) {
 | |
|         std::perror("register an atexit handler failed");
 | |
|     }
 | |
| }
 | |
| 
 | |
| __attribute__((export_name("func2"))) void
 | |
| func2()
 | |
| {
 | |
|     std::cout << "mE " << __FUNCTION__ << std::endl;
 | |
| }
 |