mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-09 22:08:56 +08:00
test(windows-shim): stub g_px4_session_id and align errno_map linkage
The runtime shim references g_px4_session_id, an interlocked LONG defined in platforms/posix/src/px4/windows/runtime/init.cpp. The test_windows_shim_runtime binary does not link init.cpp because doing so drags the entire process bootstrap path; without the symbol the test failed at link time with an unresolved external. Provide a local definition with C++ linkage that mirrors the runtime contract (the original is also C++-linkage in init.cpp, no extern "C"; matching avoids a name-mangling mismatch at link). Same translation unit had three forward declarations of errno_map helpers (px4_win_error_to_errno, px4_wsa_error_to_errno, px4_hstrerror_text) wrapped in extern "C", but the implementations in errno_map.cpp are C++- linkage. Drop the extern "C" so the linker resolves to the mangled names that errno_map.cpp actually exports. Add the missing <io.h>, <fcntl.h>, and <sys/stat.h> includes that the runtime tests rely on for _open / _close / _read / _write declarations under MSVC's CRT. Signed-off-by: Nuno Marques <n.marques21@hotmail.com>
This commit is contained in:
@@ -58,7 +58,18 @@
|
|||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
/* The runtime shim references g_px4_session_id (defined in
|
||||||
|
* platforms/posix/src/px4/windows/runtime/init.cpp). This test binary
|
||||||
|
* does not link init.cpp because pulling it in drags the entire process
|
||||||
|
* bootstrap. Provide a local definition that mirrors the runtime
|
||||||
|
* contract. The original is C++-linkage (no extern "C") in init.cpp so
|
||||||
|
* we match that here exactly. */
|
||||||
|
volatile LONG g_px4_session_id = 0;
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <io.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
@@ -70,10 +81,12 @@
|
|||||||
|
|
||||||
/* errno_map prototypes -- declared in px4_windows_internal.h but the
|
/* errno_map prototypes -- declared in px4_windows_internal.h but the
|
||||||
* tests don't include that header (it pulls in the entire winsock+win32
|
* tests don't include that header (it pulls in the entire winsock+win32
|
||||||
* stack via the shim umbrella). Forward-declare just what we need. */
|
* stack via the shim umbrella). Forward-declare just what we need. The
|
||||||
extern "C" int px4_win_error_to_errno(DWORD err);
|
* originals are C++-linkage in errno_map.cpp; matching the linkage
|
||||||
extern "C" int px4_wsa_error_to_errno(int err);
|
* exactly here keeps name mangling aligned. */
|
||||||
extern "C" const char *px4_hstrerror_text(int err);
|
int px4_win_error_to_errno(DWORD err);
|
||||||
|
int px4_wsa_error_to_errno(int err);
|
||||||
|
const char *px4_hstrerror_text(int err);
|
||||||
|
|
||||||
/* errno_map ------------------------------------------------------------ */
|
/* errno_map ------------------------------------------------------------ */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user