[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 32/54] tests/qtest: libqtest: Adapt global_qtest declaration f
From: |
Bin Meng |
Subject: |
[PATCH v3 32/54] tests/qtest: libqtest: Adapt global_qtest declaration for win32 |
Date: |
Sun, 25 Sep 2022 19:30:10 +0800 |
From: Xuzhou Cheng <xuzhou.cheng@windriver.com>
Commit dd2107497275 ("tests/libqtest: Use libqtest-single.h in tests that
require global_qtest")
moved global_qtest to libqtest-single.h, by declaring global_qtest
attribute to be common and weak.
This trick unfortunately does not work on Windows, and building
qtest test cases results in multiple definition errors of the weak
symbol global_qtest, as Windows PE does not have the concept of
the so-called weak symbol like ELF in the *nix world.
However Windows does provide a trick to declare a variable to be
a common symbol, via __declspec(selectany) [1]. It does not provide
the "strong override weak" effect but we don't need it in our use
case anyway. So let's use it for win32.
[1] https://docs.microsoft.com/en-us/cpp/cpp/selectany
Signed-off-by: Xuzhou Cheng <xuzhou.cheng@windriver.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
---
(no changes since v2)
Changes in v2:
- Use __declspec(selectany) for the common weak symbol on Windows
tests/qtest/libqtest-single.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/qtest/libqtest-single.h b/tests/qtest/libqtest-single.h
index 4e7d0ae1dc..851724cbcb 100644
--- a/tests/qtest/libqtest-single.h
+++ b/tests/qtest/libqtest-single.h
@@ -13,7 +13,11 @@
#include "libqtest.h"
+#ifndef _WIN32
QTestState *global_qtest __attribute__((common, weak));
+#else
+__declspec(selectany) QTestState *global_qtest;
+#endif
/**
* qtest_start:
--
2.34.1
- Re: [PATCH v3 11/54] tests/qtest: virtio_blk_fuzz: Avoid using hardcoded /tmp, (continued)
- [PATCH v3 28/54] tests/qtest: Skip running virtio-net-test cases that require socketpair() for win32, Bin Meng, 2022/09/25
- [PATCH v3 29/54] tests/qtest: Build test-filter-{mirror, redirector} cases for posix only, Bin Meng, 2022/09/25
- [PATCH v3 24/54] tests: vhost-user-bridge: Avoid using hardcoded /tmp, Bin Meng, 2022/09/25
- [PATCH v3 22/54] tests/unit: test-image-locking: Avoid using hardcoded /tmp, Bin Meng, 2022/09/25
- [PATCH v3 18/54] tests/qtest: vhost-user-test: Avoid using hardcoded /tmp, Bin Meng, 2022/09/25
- [PATCH v3 30/54] tests/qtest: qmp-test: Skip running test_qmp_oob for win32, Bin Meng, 2022/09/25
- [PATCH v3 32/54] tests/qtest: libqtest: Adapt global_qtest declaration for win32,
Bin Meng <=
- [PATCH v3 33/54] tests/qtest: Use send/recv for socket communication, Bin Meng, 2022/09/25
- [PATCH v3 34/54] tests/qtest: libqtest: Exclude the *_fds APIs for win32, Bin Meng, 2022/09/25
- [PATCH v3 36/54] tests/qtest: Support libqtest to build and run on Windows, Bin Meng, 2022/09/25
- [PATCH v3 42/54] chardev/char-file: Add FILE_SHARE_WRITE when opening the file for win32, Bin Meng, 2022/09/25
[PATCH v3 35/54] tests/qtest: libqtest: Install signal handler via signal(), Bin Meng, 2022/09/25