-
Notifications
You must be signed in to change notification settings - Fork 9
Update wpiutil and ntcore native imports and native-backed structs #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ namespace WPIUtil.Natives; | |
|
|
||
| public static partial class SynchronizationNative | ||
| { | ||
| [LibraryImport("wpiutil", EntryPoint = "WPI_CreateEvent")] | ||
| [LibraryImport("wpiutil", EntryPoint = "WPI_MakeEvent")] | ||
| [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] | ||
| public static partial WpiEventHandle CreateEvent([MarshalAs(UnmanagedType.I4)] bool manualReset, [MarshalAs(UnmanagedType.I4)] bool initialState); | ||
|
|
||
|
|
@@ -23,7 +23,7 @@ public static partial class SynchronizationNative | |
| [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] | ||
| public static partial void ResetEvent(WpiEventHandle handle); | ||
|
|
||
| [LibraryImport("wpiutil", EntryPoint = "WPI_CreateSemaphore")] | ||
| [LibraryImport("wpiutil", EntryPoint = "WPI_MakeSemaphore")] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When code calls Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, you're using out of date information here. |
||
| [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] | ||
| public static partial WpiSemaphoreHandle CreateSemaphore(int initialCount, int maximumCount); | ||
|
|
||
|
|
@@ -33,17 +33,17 @@ public static partial class SynchronizationNative | |
|
|
||
| [LibraryImport("wpiutil", EntryPoint = "WPI_ReleaseSemaphore")] | ||
| [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] | ||
| [return: MarshalAs(UnmanagedType.U4)] | ||
| [return: MarshalAs(UnmanagedType.I4)] | ||
| public static unsafe partial bool ReleaseSemaphore(WpiSemaphoreHandle handle, int releaseCount, out int prevCount); | ||
|
|
||
| [LibraryImport("wpiutil", EntryPoint = "WPI_WaitForObject")] | ||
| [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] | ||
| [return: MarshalAs(UnmanagedType.U4)] | ||
| [return: MarshalAs(UnmanagedType.I4)] | ||
| public static partial bool WaitForObject(int handle); | ||
|
|
||
| [LibraryImport("wpiutil", EntryPoint = "WPI_WaitForObjectTimeout")] | ||
| [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] | ||
| [return: MarshalAs(UnmanagedType.U4)] | ||
| [return: MarshalAs(UnmanagedType.I4)] | ||
| public static unsafe partial bool WaitForObjectTimeout(int handle, double timeout, [MarshalAs(UnmanagedType.I4)] out bool timedOut); | ||
|
|
||
| [LibraryImport("wpiutil", EntryPoint = "WPI_WaitForObjects")] | ||
|
|
@@ -64,7 +64,7 @@ public static unsafe ReadOnlySpan<int> WaitForObjects(ReadOnlySpan<int> handles, | |
| [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] | ||
| public static unsafe partial int WaitForObjectsTimeout(ReadOnlySpan<int> handles, int handlesCount, Span<int> signaled, double timeout, [MarshalAs(UnmanagedType.I4)] out bool timedOut); | ||
|
|
||
| [LibraryImport("wpiutil", EntryPoint = "WPI_CreateSemaphore")] | ||
| [LibraryImport("wpiutil", EntryPoint = "WPI_CreateSignalObject")] | ||
| [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] | ||
| public static partial void CreateSignalObject(int handle, [MarshalAs(UnmanagedType.I4)] bool manualReset, [MarshalAs(UnmanagedType.I4)] bool InitialState); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When code calls
SynchronizationNative.CreateEvent, this import now asks the loader forWPI_MakeEvent, but the wpiutil C API still exports the C entry point asWPI_CreateEvent(theMakeEventname is only the C++ wrapper name). This will throwEntryPointNotFoundExceptionat runtime for any path that creates an event, so the entry point should remainWPI_CreateEvent.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're using out of date information here. The entry point has changed in wpilib.