Skip to content

Add Linux support for extensions#72

Open
logmanoriginal wants to merge 7 commits into
mainfrom
30-Extensions-LinuxSupport
Open

Add Linux support for extensions#72
logmanoriginal wants to merge 7 commits into
mainfrom
30-Extensions-LinuxSupport

Conversation

@logmanoriginal

Copy link
Copy Markdown
Owner

This pull request introduces a robust, cross-platform completion rendezvous mechanism for callback shims in the extensions library, 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_completion structure and related functions in lvssh2_extensions.c to provide explicit rendezvous between callback shims and LabVIEW handler VIs using C11 <threads.h> primitives. The handler VI must now call lvssh2_extensions_signal_completion to signal completion.

  • Updated all callback payload structures in lvssh2_extensions.h to include a completion field, and extended the API with lvssh2_extensions_signal_completion.

Build system and platform support:

  • Changed the C standard to C11 in CMakeLists.txt to ensure <threads.h> support, and linked against the appropriate threading library using find_package(Threads REQUIRED) and target_link_libraries.

  • Added a linker option for Linux builds to allow undefined symbols in shared libraries, addressing platform-specific linking requirements.

Minor changes:

  • Examples and integration tests updated for callbacks in Win32 (ws2_32.dll) and Linux (libc.so.6).
  • Conditional disable structures no longer exclude extensions for Linux (use LVSSH2_NO_EXTENSIONS=TRUE to turn it off again).
  • Uses Register For Events instead of Register Event Callback to ensure cross-platform compatibility.

Closes #30

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
@logmanoriginal logmanoriginal force-pushed the 30-Extensions-LinuxSupport branch 4 times, most recently from b0d4d7a to 1ca8ed7 Compare July 11, 2026 18:42
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
@logmanoriginal logmanoriginal force-pushed the 30-Extensions-LinuxSupport branch from 1ca8ed7 to aa80390 Compare July 11, 2026 19:05
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Register Event Callback Node is not supported on non-Windows platforms

1 participant