diff mbox series

[v3,4/6] plugin: define QEMU_PLUGIN_API_IMPLEMENTATION first

Message ID 20201001163429.1348-5-luoyonggang@gmail.com
State New
Headers show
Series Enable plugin support on msys2/mingw | expand

Commit Message

罗勇刚(Yonggang Luo) Oct. 1, 2020, 4:34 p.m. UTC
This is used to distinguish from the qemu and plugin in
header qemu-plugin.h

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 plugins/api.c  | 1 +
 plugins/core.c | 1 +
 2 files changed, 2 insertions(+)

Comments

Alex Bennée Oct. 5, 2020, 10:44 a.m. UTC | #1
Yonggang Luo <luoyonggang@gmail.com> writes:

> This is used to distinguish from the qemu and plugin in

> header qemu-plugin.h

>

> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>

> ---

>  plugins/api.c  | 1 +

>  plugins/core.c | 1 +

>  2 files changed, 2 insertions(+)

>

> diff --git a/plugins/api.c b/plugins/api.c

> index bbdc5a4eb4..f16922ca8b 100644

> --- a/plugins/api.c

> +++ b/plugins/api.c

> @@ -35,6 +35,7 @@

>   */

>  

>  #include "qemu/osdep.h"

> +#define QEMU_PLUGIN_API_IMPLEMENTATION

>  #include "qemu/plugin.h"


This doesn't do anything in this patch. You should split the special
handling in the plugin header and combine it in this patch. Also I'm not
quite sure of the logic you are trying to achieve later on:

  #if !defined(QEMU_PLUGIN_API_IMPLEMENTATION)
  #if defined(QEMU_PLUGIN_IMPLEMENTATION)
  #define QEMU_PLUGIN_EXTERN
  #else
  #define QEMU_PLUGIN_EXTERN extern
  #endif

It seems to me you could get away with only one symbol - ideally just
defined in plugins/api.c so you don't need to churn the plugins with
changes, e.g.

  #ifdef QEMU_PLUGIN_API_IMPLEMENTATION
  #define QEMU_PLUGIN_EXTERN
  #else
  #define QEMU_PLUGIN_EXTERN extern
  #endif

But I'd still like to have a better answer as to why we need the extern?
Is this a limitation of the mingw compiler or some windows special?

>  #include "cpu.h"

>  #include "sysemu/sysemu.h"

> diff --git a/plugins/core.c b/plugins/core.c

> index 51bfc94787..7a79ea4179 100644

> --- a/plugins/core.c

> +++ b/plugins/core.c

> @@ -12,6 +12,7 @@

>   * SPDX-License-Identifier: GPL-2.0-or-later

>   */

>  #include "qemu/osdep.h"

> +#define QEMU_PLUGIN_API_IMPLEMENTATION

>  #include "qemu/error-report.h"

>  #include "qemu/config-file.h"

>  #include "qapi/error.h"


I don't think we include qemu/plugin.h from this file although it does
raise the question of what happens when other parts of QEMU include the
internal qemu/plugins.h header.

-- 
Alex Bennée
罗勇刚(Yonggang Luo) Oct. 5, 2020, 3:58 p.m. UTC | #2
Hi, I split this out just for easier review, so the lines changed in api.c
and core.c
equales to the number of function exported, anyway

On Mon, Oct 5, 2020 at 6:44 PM Alex Bennée <alex.bennee@linaro.org> wrote:
>

>

> Yonggang Luo <luoyonggang@gmail.com> writes:

>

> > This is used to distinguish from the qemu and plugin in

> > header qemu-plugin.h

> >

> > Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>

> > ---

> >  plugins/api.c  | 1 +

> >  plugins/core.c | 1 +

> >  2 files changed, 2 insertions(+)

> >

> > diff --git a/plugins/api.c b/plugins/api.c

> > index bbdc5a4eb4..f16922ca8b 100644

> > --- a/plugins/api.c

> > +++ b/plugins/api.c

> > @@ -35,6 +35,7 @@

> >   */

> >

> >  #include "qemu/osdep.h"

> > +#define QEMU_PLUGIN_API_IMPLEMENTATION

> >  #include "qemu/plugin.h"

>

> This doesn't do anything in this patch. You should split the special

> handling in the plugin header and combine it in this patch. Also I'm not

> quite sure of the logic you are trying to achieve later on:

>

>   #if !defined(QEMU_PLUGIN_API_IMPLEMENTATION)

>   #if defined(QEMU_PLUGIN_IMPLEMENTATION)

>   #define QEMU_PLUGIN_EXTERN

>   #else

>   #define QEMU_PLUGIN_EXTERN extern

>   #endif

>

> It seems to me you could get away with only one symbol - ideally just

> defined in plugins/api.c so you don't need to churn the plugins with

> changes, e.g.

>

>   #ifdef QEMU_PLUGIN_API_IMPLEMENTATION

>   #define QEMU_PLUGIN_EXTERN

>   #else

>   #define QEMU_PLUGIN_EXTERN extern

>   #endif

>

> But I'd still like to have a better answer as to why we need the extern?

> Is this a limitation of the mingw compiler or some windows special?

>

> >  #include "cpu.h"

> >  #include "sysemu/sysemu.h"

> > diff --git a/plugins/core.c b/plugins/core.c

> > index 51bfc94787..7a79ea4179 100644

> > --- a/plugins/core.c

> > +++ b/plugins/core.c

> > @@ -12,6 +12,7 @@

> >   * SPDX-License-Identifier: GPL-2.0-or-later

> >   */

> >  #include "qemu/osdep.h"

> > +#define QEMU_PLUGIN_API_IMPLEMENTATION

> >  #include "qemu/error-report.h"

> >  #include "qemu/config-file.h"

> >  #include "qapi/error.h"

>

> I don't think we include qemu/plugin.h from this file although it does

> raise the question of what happens when other parts of QEMU include the

> internal qemu/plugins.h header.

>

> --

> Alex Bennée




--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
<div dir="ltr">Hi, I split this out just for easier review, so the lines changed in api.c and core.c<div>equales to the number of function exported, anyway<br><br>On Mon, Oct 5, 2020 at 6:44 PM Alex Bennée &lt;<a href="mailto:alex.bennee@linaro.org">alex.bennee@linaro.org</a>&gt; wrote:<br>&gt;<br>&gt;<br>&gt; Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt; writes:<br>&gt;<br>&gt; &gt; This is used to distinguish from the qemu and plugin in<br>&gt; &gt; header qemu-plugin.h<br>&gt; &gt;<br>&gt; &gt; Signed-off-by: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;<br>&gt; &gt; ---<br>&gt; &gt;  plugins/api.c  | 1 +<br>&gt; &gt;  plugins/core.c | 1 +<br>&gt; &gt;  2 files changed, 2 insertions(+)<br>&gt; &gt;<br>&gt; &gt; diff --git a/plugins/api.c b/plugins/api.c<br>&gt; &gt; index bbdc5a4eb4..f16922ca8b 100644<br>&gt; &gt; --- a/plugins/api.c<br>&gt; &gt; +++ b/plugins/api.c<br>&gt; &gt; @@ -35,6 +35,7 @@<br>&gt; &gt;   */<br>&gt; &gt; <br>&gt; &gt;  #include &quot;qemu/osdep.h&quot;<br>&gt; &gt; +#define QEMU_PLUGIN_API_IMPLEMENTATION<br>&gt; &gt;  #include &quot;qemu/plugin.h&quot;<br>&gt;<br>&gt; This doesn&#39;t do anything in this patch. You should split the special<br>&gt; handling in the plugin header and combine it in this patch. Also I&#39;m not<br>&gt; quite sure of the logic you are trying to achieve later on:<br>&gt;<br>&gt;   #if !defined(QEMU_PLUGIN_API_IMPLEMENTATION)<br>&gt;   #if defined(QEMU_PLUGIN_IMPLEMENTATION)<br>&gt;   #define QEMU_PLUGIN_EXTERN<br>&gt;   #else<br>&gt;   #define QEMU_PLUGIN_EXTERN extern<br>&gt;   #endif<br>&gt;<br>&gt; It seems to me you could get away with only one symbol - ideally just<br>&gt; defined in plugins/api.c so you don&#39;t need to churn the plugins with<br>&gt; changes, e.g.<br>&gt;<br>&gt;   #ifdef QEMU_PLUGIN_API_IMPLEMENTATION<br>&gt;   #define QEMU_PLUGIN_EXTERN<br>&gt;   #else<br>&gt;   #define QEMU_PLUGIN_EXTERN extern<br>&gt;   #endif<br>&gt;<br>&gt; But I&#39;d still like to have a better answer as to why we need the extern?<br>&gt; Is this a limitation of the mingw compiler or some windows special?<br>&gt;<br>&gt; &gt;  #include &quot;cpu.h&quot;<br>&gt; &gt;  #include &quot;sysemu/sysemu.h&quot;<br>&gt; &gt; diff --git a/plugins/core.c b/plugins/core.c<br>&gt; &gt; index 51bfc94787..7a79ea4179 100644<br>&gt; &gt; --- a/plugins/core.c<br>&gt; &gt; +++ b/plugins/core.c<br>&gt; &gt; @@ -12,6 +12,7 @@<br>&gt; &gt;   * SPDX-License-Identifier: GPL-2.0-or-later<br>&gt; &gt;   */<br>&gt; &gt;  #include &quot;qemu/osdep.h&quot;<br>&gt; &gt; +#define QEMU_PLUGIN_API_IMPLEMENTATION<br>&gt; &gt;  #include &quot;qemu/error-report.h&quot;<br>&gt; &gt;  #include &quot;qemu/config-file.h&quot;<br>&gt; &gt;  #include &quot;qapi/error.h&quot;<br>&gt;<br>&gt; I don&#39;t think we include qemu/plugin.h from this file although it does<br>&gt; raise the question of what happens when other parts of QEMU include the<br>&gt; internal qemu/plugins.h header.<br>&gt;<br>&gt; --<br>&gt; Alex Bennée<br><br><br><br>--<br>         此致<br>礼<br>罗勇刚<br>Yours<br>    sincerely,<br>Yonggang Luo</div></div>
diff mbox series

Patch

diff --git a/plugins/api.c b/plugins/api.c
index bbdc5a4eb4..f16922ca8b 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -35,6 +35,7 @@ 
  */
 
 #include "qemu/osdep.h"
+#define QEMU_PLUGIN_API_IMPLEMENTATION
 #include "qemu/plugin.h"
 #include "cpu.h"
 #include "sysemu/sysemu.h"
diff --git a/plugins/core.c b/plugins/core.c
index 51bfc94787..7a79ea4179 100644
--- a/plugins/core.c
+++ b/plugins/core.c
@@ -12,6 +12,7 @@ 
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 #include "qemu/osdep.h"
+#define QEMU_PLUGIN_API_IMPLEMENTATION
 #include "qemu/error-report.h"
 #include "qemu/config-file.h"
 #include "qapi/error.h"