[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 23/23] plugins: Support C++
|
From: |
Akihiko Odaki |
|
Subject: |
[PATCH v9 23/23] plugins: Support C++ |
|
Date: |
Wed, 11 Oct 2023 16:03:09 +0900 |
Make qemu-plugin.h consumable for C++ platform.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
docs/devel/tcg-plugins.rst | 4 ++++
meson.build | 2 +-
include/qemu/qemu-plugin.h | 4 ++++
tests/plugin/cc.cc | 16 ++++++++++++++++
tests/plugin/meson.build | 5 +++++
tests/tcg/Makefile.target | 3 +--
6 files changed, 31 insertions(+), 3 deletions(-)
create mode 100644 tests/plugin/cc.cc
diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst
index c9f8b27590..984d8012e9 100644
--- a/docs/devel/tcg-plugins.rst
+++ b/docs/devel/tcg-plugins.rst
@@ -283,6 +283,10 @@ run::
160 1 0
135 1 0
+- contrib/plugins/cc.cc
+
+A pure test plugin to ensure that the plugin API is compatible with C++.
+
- contrib/plugins/hotblocks.c
The hotblocks plugin allows you to examine the where hot paths of
diff --git a/meson.build b/meson.build
index 9f4c4f2f1e..c289bb8948 100644
--- a/meson.build
+++ b/meson.build
@@ -20,7 +20,7 @@ config_host = keyval.load(meson.current_build_dir() /
'config-host.mak')
cc = meson.get_compiler('c')
all_languages = ['c']
-if targetos == 'windows' and add_languages('cpp', required: false, native:
false)
+if add_languages('cpp', required: false, native: false)
all_languages += ['cpp']
cxx = meson.get_compiler('cpp')
endif
diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
index 40aae8db68..55f514ca6c 100644
--- a/include/qemu/qemu-plugin.h
+++ b/include/qemu/qemu-plugin.h
@@ -16,6 +16,8 @@
#include <stdbool.h>
#include <stddef.h>
+G_BEGIN_DECLS
+
/*
* For best performance, build the plugin with -fvisibility=hidden so that
* QEMU_PLUGIN_LOCAL is implicit. Then, just mark qemu_plugin_install with
@@ -710,4 +712,6 @@ int qemu_plugin_find_register(unsigned int vcpu_index, int
file,
*/
int qemu_plugin_read_register(GByteArray *buf, int reg);
+G_END_DECLS
+
#endif /* QEMU_QEMU_PLUGIN_H */
diff --git a/tests/plugin/cc.cc b/tests/plugin/cc.cc
new file mode 100644
index 0000000000..297a7e4f3f
--- /dev/null
+++ b/tests/plugin/cc.cc
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include <qemu-plugin.h>
+
+extern "C" {
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
+ const qemu_info_t *info, int argc,
+ char **argv)
+{
+ return 0;
+}
+
+};
diff --git a/tests/plugin/meson.build b/tests/plugin/meson.build
index 322cafcdf6..fed14aa0c2 100644
--- a/tests/plugin/meson.build
+++ b/tests/plugin/meson.build
@@ -5,6 +5,11 @@ if get_option('plugins')
include_directories: '../../include/qemu',
dependencies: glib)
endforeach
+ if 'cpp' in all_languages
+ t += shared_module('cc', files('cc.cc'),
+ include_directories: '../../include/qemu',
+ dependencies: glib)
+ endif
endif
if t.length() > 0
alias_target('test-plugins', t)
diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target
index 462289f47c..66a20d0f2c 100644
--- a/tests/tcg/Makefile.target
+++ b/tests/tcg/Makefile.target
@@ -145,10 +145,9 @@ RUN_TESTS=$(patsubst %,run-%, $(TESTS))
# If plugins exist also include those in the tests
ifeq ($(CONFIG_PLUGIN),y)
-PLUGIN_SRC=$(SRC_PATH)/tests/plugin
PLUGIN_LIB=../../plugin
VPATH+=$(PLUGIN_LIB)
-PLUGINS=$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c)))
+PLUGINS=$(notdir $(wildcard $(PLUGIN_LIB)/*.so))
# We need to ensure expand the run-plugin-TEST-with-PLUGIN
# pre-requistes manually here as we can't use stems to handle it. We
--
2.42.0
- [PATCH v9 12/23] gdbstub: Change gdb_get_reg_cb and gdb_set_reg_cb, (continued)
- [PATCH v9 12/23] gdbstub: Change gdb_get_reg_cb and gdb_set_reg_cb, Akihiko Odaki, 2023/10/11
- [PATCH v9 14/23] gdbstub: Infer number of core registers from XML, Akihiko Odaki, 2023/10/11
- [PATCH v9 15/23] hw/core/cpu: Remove gdb_get_dynamic_xml member, Akihiko Odaki, 2023/10/11
- [PATCH v9 16/23] gdbstub: Add members to identify registers to GDBFeature, Akihiko Odaki, 2023/10/11
- [PATCH v9 18/23] cpu: Call plugin hooks only when ready, Akihiko Odaki, 2023/10/11
- [PATCH v9 19/23] plugins: Remove an extra parameter, Akihiko Odaki, 2023/10/11
- [PATCH v9 17/23] gdbstub: Expose functions to read registers, Akihiko Odaki, 2023/10/11
- [PATCH v9 20/23] plugins: Use different helpers when reading registers, Akihiko Odaki, 2023/10/11
- [PATCH v9 21/23] plugins: Allow to read registers, Akihiko Odaki, 2023/10/11
- [PATCH v9 22/23] contrib/plugins: Allow to log registers, Akihiko Odaki, 2023/10/11
- [PATCH v9 23/23] plugins: Support C++,
Akihiko Odaki <=