-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WASI] improve UCO sample and WBT (#106632)
- Loading branch information
1 parent
00553a8
commit 5d21506
Showing
9 changed files
with
99 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<linker> | ||
<!-- workaround for https://github.com/dotnet/runtime/issues/106627 --> | ||
<assembly fullname="Wasi.Native.Sample"> | ||
<type fullname="Sample.Test"> | ||
<method signature="System.Int32 MyExport(System.Int32)" /> | ||
</type> | ||
</assembly> | ||
</linker> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<linker> | ||
<!-- workaround for https://github.com/dotnet/runtime/issues/106627 --> | ||
<assembly fullname="Wasi.Native.Test"> | ||
<type fullname="Sample.Test"> | ||
<method signature="System.Int32 MyExport(System.Int32)" /> | ||
</type> | ||
</assembly> | ||
</linker> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Sample; | ||
|
||
public unsafe class Test | ||
{ | ||
[UnmanagedCallersOnly(EntryPoint = "ManagedFunc")] | ||
public static int MyExport(int number) | ||
{ | ||
// called from MyImport aka UnmanagedFunc | ||
Console.WriteLine($"MyExport({number}) -> 42"); | ||
return 42; | ||
} | ||
|
||
[DllImport("*", EntryPoint = "UnmanagedFunc")] | ||
public static extern void MyImport(); // calls ManagedFunc aka MyExport | ||
|
||
public unsafe static int Main(string[] args) | ||
{ | ||
Console.WriteLine($"main: {args.Length}"); | ||
MyImport(); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <stdio.h> | ||
|
||
int ManagedFunc(int number); | ||
|
||
void UnmanagedFunc() | ||
{ | ||
int ret = 0; | ||
printf("UnmanagedFunc calling ManagedFunc\n"); | ||
ret = ManagedFunc(123); | ||
printf("ManagedFunc returned %d\n", ret); | ||
} |