Add Linux support for extensions#72
Open
logmanoriginal wants to merge 7 commits into
Open
Conversation
Event callbacks, when using Register Event Callback, are blocking. However, Register Event Callback is intended only for .NET and ActiveX events, and not supported on non-Windows platforms. This change introduces a completion signal, which ensures that the C code waits until the callback VI signals completion. This is carefully constructed to support the existing use case (completion signaled while blocked) and for later conversion from Register Event Callback to Register For Events (completion signaled by callback VI). On the LabVIEW side, this adds a new completion pointer to the input args, which is then passed to `lvssh2_extensions_signal_completion` to signal when the callback VI is completed. Completion is signaled seamlessly, so that the caller does not need to worry about synchronization. This avoids breaking changes. Note, however, that the updated implementation still uses Register Event Callback and therefore does not support non-Windows platforms. Please also note that the implementation makes use of C11 threads, which are not supported on macOS. Since macOS is currently not a supported platform, this is acceptable. Co-authored by AI
b0d4d7a to
1ca8ed7
Compare
This replaces all occurrences of Register Callback VI with the non-blocking Register For Event, using event structures to handle the callback. Callback handlers are refactored into async VIs that run indefinitely or until the stop event is raised. Callback event refnums are completely eliminated and replaced by stop event refnums. Places where Diagram Disable Structures had conditions for non-Windows platforms are removed, so that Linux can now also use the extension library.
On Linux, the extensions library must not explicitly link to liblv.so because it is dynamically linked when the library is loaded. This appears to be common for shared objects. Co-authored by AI
Change function prototypes to match man pages. [1]: https://www.man7.org/linux/man-pages/man2/recv.2.html [2]: https://www.man7.org/linux/man-pages/man2/send.2.html
1ca8ed7 to
aa80390
Compare
The extensions library, when compiled in debug mode, requires vcruntime140_threadsd.dll, which is not placed in PATH but in a directory managed by Visual Studio. To avoid hard dependencies on those paths, we statically link the runtime via /MTd. This fixes broken builds because lvssh2_extensions.dll could not be loaded.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a robust, cross-platform completion rendezvous mechanism for callback shims in the
extensionslibrary, ensuring correct synchronization between C callbacks and LabVIEW handler VIs. It replaces the previous reliance on synchronous behavior with explicit signaling using C11<threads.h>, improving reliability and portability. The CMake configuration is updated accordingly, and relevant payload structures and APIs are extended to support this mechanism.Callback synchronization and C11 threading:
Introduced a
lvssh2_completionstructure and related functions inlvssh2_extensions.cto provide explicit rendezvous between callback shims and LabVIEW handler VIs using C11<threads.h>primitives. The handler VI must now calllvssh2_extensions_signal_completionto signal completion.Updated all callback payload structures in
lvssh2_extensions.hto include acompletionfield, and extended the API withlvssh2_extensions_signal_completion.Build system and platform support:
Changed the C standard to C11 in
CMakeLists.txtto ensure<threads.h>support, and linked against the appropriate threading library usingfind_package(Threads REQUIRED)andtarget_link_libraries.Added a linker option for Linux builds to allow undefined symbols in shared libraries, addressing platform-specific linking requirements.
Minor changes:
ws2_32.dll) and Linux (libc.so.6).LVSSH2_NO_EXTENSIONS=TRUEto turn it off again).Register For Eventsinstead ofRegister Event Callbackto ensure cross-platform compatibility.Closes #30