File tree Expand file tree Collapse file tree 3 files changed +6
-29
lines changed
src/mono/sample/wasi/native Expand file tree Collapse file tree 3 files changed +6
-29
lines changed Original file line number Diff line number Diff line change @@ -17,24 +17,15 @@ public static int MyExport(int number)
17
17
[ DllImport ( "*" , EntryPoint = "UnmanagedFunc" ) ]
18
18
public static extern void MyImport ( ) ; // calls ManagedFunc aka MyExport
19
19
20
- [ DllImport ( "*" ) ]
21
- public static unsafe extern void ReferenceFuncPtr ( delegate * unmanaged< int , int > funcPtr ) ;
22
-
23
- static bool AlwaysFalse ( string [ ] args ) => false ;
24
-
25
20
public unsafe static int Main ( string [ ] args )
26
21
{
27
22
Console . WriteLine ( $ "main: { args . Length } ") ;
28
- MyImport ( ) ;
29
-
30
- if ( AlwaysFalse ( args ) )
31
- {
32
- // never called (would an error on wasm) and doesn't actually do anything
33
- // but required for wasm_native_to_interp_ftndesc initialization
34
- // the lookup happens before main when this is here
35
- ReferenceFuncPtr ( & MyExport ) ;
23
+ // workaround to force the interpreter to initialize wasm_native_to_interp_ftndesc for MyExport
24
+ if ( args . Length > 10000 ) {
25
+ ( ( IntPtr ) ( delegate * unmanaged< int , int > ) & MyExport ) . ToString ( ) ;
36
26
}
37
27
28
+ MyImport ( ) ;
38
29
return 0 ;
39
30
}
40
31
}
Original file line number Diff line number Diff line change 7
7
<WasmBuildNative >true</WasmBuildNative >
8
8
<WasmNativeStrip >false</WasmNativeStrip >
9
9
<IsBrowserWasmProject >false</IsBrowserWasmProject >
10
+ <WasmSingleFileBundle >true</WasmSingleFileBundle >
10
11
</PropertyGroup >
11
12
12
13
<ItemGroup >
Original file line number Diff line number Diff line change @@ -8,19 +8,4 @@ void UnmanagedFunc()
8
8
printf ("UnmanagedFunc calling ManagedFunc\n" );
9
9
ret = ManagedFunc (123 );
10
10
printf ("ManagedFunc returned %d\n" , ret );
11
- }
12
-
13
-
14
- #ifdef PARSING_FUNCTION_POINTERS_IS_SUPPORTED
15
- /*
16
- warning WASM0001: Could not get pinvoke, or callbacks for method 'Test::ReferenceFuncPtr' because 'Parsing function pointe
17
- r types in signatures is not supported.'
18
- warning WASM0001: Skipping pinvoke 'Test::ReferenceFuncPtr' because 'Parsing function pointer types in signatures is not s
19
- upported.'
20
- */
21
- typedef int (* ManagedFuncPtr )(int );
22
-
23
- void ReferenceFuncPtr (ManagedFuncPtr funcPtr ) {
24
- printf ("ReferenceFuncPtr %p\n" , funcPtr );
25
- }
26
- #endif
11
+ }
You can’t perform that action at this time.
0 commit comments