@@ -68,6 +68,14 @@ pub fn generate_import_list(
6868 ( HOST . clone ( ) , EXPECT . clone ( ) )
6969}
7070
71+ cfg_if:: cfg_if! {
72+ if #[ cfg( all( target_arch = "wasm32" , target_os = "unknown" ) ) ] {
73+ fn get_allocator( caller: & mut Caller <' _, ( ) >) -> Option <Extern > { get_allocator( & mut caller) }
74+ } else {
75+ fn get_allocator( caller: & mut Caller <' _, ( ) >) -> Option <Extern > { caller. get_export( "proxy_on_memory_allocate" ) }
76+ }
77+ }
78+
7179fn get_hostfunc (
7280 store : & mut Store < ( ) > ,
7381 _abi_version : AbiVersion ,
@@ -674,7 +682,7 @@ fn get_hostfunc(
674682 }
675683 } ;
676684
677- let malloc = match caller . get_export ( "malloc" ) {
685+ let malloc = match get_allocator ( & mut caller ) {
678686 Some ( Extern :: Func ( func) ) => func,
679687 _ => {
680688 println ! (
@@ -812,7 +820,7 @@ fn get_hostfunc(
812820 }
813821 } ;
814822
815- let malloc = match caller . get_export ( "malloc" ) {
823+ let malloc = match get_allocator ( & mut caller ) {
816824 Some ( Extern :: Func ( func) ) => func,
817825 _ => {
818826 println ! (
@@ -1120,7 +1128,7 @@ fn get_hostfunc(
11201128 }
11211129 } ;
11221130
1123- let malloc = match caller . get_export ( "malloc" ) {
1131+ let malloc = match get_allocator ( & mut caller ) {
11241132 Some ( Extern :: Func ( func) ) => func,
11251133 _ => {
11261134 println ! ( "Error: proxy_get_buffer_bytes cannot get export \" malloc\" " ) ;
@@ -1684,6 +1692,43 @@ fn get_hostfunc(
16841692 }
16851693
16861694 /* ---------------------------------- System ---------------------------------- */
1695+ "clock_time_get" => Some ( Func :: wrap (
1696+ store,
1697+ |mut _caller : Caller < ' _ , ( ) > , _clock_id : i32 , _precision : i64 , _time : i32 | -> i32 {
1698+ Status :: Ok as i32
1699+ } ,
1700+ ) ) ,
1701+
1702+ "random_get" => Some ( Func :: wrap (
1703+ store,
1704+ |mut _caller : Caller < ' _ , ( ) > , _buf : i32 , _buf_len : i32 | -> i32 { Status :: Ok as i32 } ,
1705+ ) ) ,
1706+
1707+ "fd_write" => Some ( Func :: wrap (
1708+ store,
1709+ |mut _caller : Caller < ' _ , ( ) > ,
1710+ _param1 : i32 ,
1711+ _param2 : i32 ,
1712+ _param3 : i32 ,
1713+ _param4 : i32 |
1714+ -> i32 { Status :: Ok as i32 } ,
1715+ ) ) ,
1716+
1717+ "environ_get" => Some ( Func :: wrap (
1718+ store,
1719+ |mut _caller : Caller < ' _ , ( ) > , _param1 : i32 , _param2 : i32 | -> i32 { Status :: Ok as i32 } ,
1720+ ) ) ,
1721+
1722+ "environ_sizes_get" => Some ( Func :: wrap (
1723+ store,
1724+ |mut _caller : Caller < ' _ , ( ) > , _param1 : i32 , _param2 : i32 | -> i32 { Status :: Ok as i32 } ,
1725+ ) ) ,
1726+
1727+ "proc_exit" => Some ( Func :: wrap (
1728+ store,
1729+ |mut _caller : Caller < ' _ , ( ) > , _param1 : i32 | -> ( ) { ( ) } ,
1730+ ) ) ,
1731+
16871732 "proxy_set_effective_context" => {
16881733 Some ( Func :: wrap (
16891734 store,
0 commit comments