diff mbox series

remove unnecessary extern "C" blocks

Message ID 20230110084946.299480-1-pbonzini@redhat.com
State New
Headers show
Series remove unnecessary extern "C" blocks | expand

Commit Message

Paolo Bonzini Jan. 10, 2023, 8:49 a.m. UTC
A handful of header files in QEMU are wrapped with extern "C" blocks.
These are not necessary: there are C++ source files anymore in QEMU,
and even where there were some, they did not include most of these
files anyway.

Remove them for consistency.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/disas/dis-asm.h   | 8 --------
 include/qemu/bswap.h      | 8 --------
 include/qemu/envlist.h    | 8 --------
 include/qemu/rcu.h        | 8 --------
 include/qemu/rcu_queue.h  | 8 --------
 include/qemu/uri.h        | 7 -------
 include/sysemu/os-posix.h | 8 --------
 include/sysemu/os-win32.h | 8 --------
 8 files changed, 63 deletions(-)

Comments

Daniel P. Berrangé Jan. 10, 2023, 9:38 a.m. UTC | #1
On Tue, Jan 10, 2023 at 09:49:46AM +0100, Paolo Bonzini wrote:
> A handful of header files in QEMU are wrapped with extern "C" blocks.
> These are not necessary: there are C++ source files anymore in QEMU,

s/are/are no/

> and even where there were some, they did not include most of these
> files anyway.
> 
> Remove them for consistency.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
Peter Maydell Jan. 10, 2023, 10:53 a.m. UTC | #2
On Tue, 10 Jan 2023 at 09:33, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> A handful of header files in QEMU are wrapped with extern "C" blocks.
> These are not necessary: there are C++ source files anymore in QEMU,
> and even where there were some, they did not include most of these
> files anyway.

Any reason not to also take out the extern "C" block in osdep.h
and the uses of QEMU_EXTERN_C ?

thanks
-- PMM
Paolo Bonzini Jan. 11, 2023, 9:14 a.m. UTC | #3
On 1/10/23 11:53, Peter Maydell wrote:
> On Tue, 10 Jan 2023 at 09:33, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>> A handful of header files in QEMU are wrapped with extern "C" blocks.
>> These are not necessary: there are C++ source files anymore in QEMU,
>> and even where there were some, they did not include most of these
>> files anyway.
> 
> Any reason not to also take out the extern "C" block in osdep.h
> and the uses of QEMU_EXTERN_C ?

qemu/osdep.h is still included by the C++ sources in qga/vss-win32.

Paolo
Peter Maydell Jan. 12, 2023, 11:05 a.m. UTC | #4
On Wed, 11 Jan 2023 at 09:14, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 1/10/23 11:53, Peter Maydell wrote:
> > On Tue, 10 Jan 2023 at 09:33, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >>
> >> A handful of header files in QEMU are wrapped with extern "C" blocks.
> >> These are not necessary: there are C++ source files anymore in QEMU,
> >> and even where there were some, they did not include most of these
> >> files anyway.
> >
> > Any reason not to also take out the extern "C" block in osdep.h
> > and the uses of QEMU_EXTERN_C ?
>
> qemu/osdep.h is still included by the C++ sources in qga/vss-win32.

If anything C++ still includes osdep.h then you can't remove
the handling of this from os-win32.h and os-posix.h, because
those files are included from osdep.h.

thanks
-- PMM
David Woodhouse Jan. 12, 2023, 1:10 p.m. UTC | #5
On Tue, 2023-01-10 at 09:49 +0100, Paolo Bonzini wrote:
> A handful of header files in QEMU are wrapped with extern "C" blocks.
> These are not necessary: there are C++ source files anymore in QEMU,
> and even where there were some, they did not include most of these
> files anyway.
> 
> Remove them for consistency.


Are we allowed C++ in qemu?

I ask because we have a full single-tenant implementation of XenStore
lying around, designed to be VMM-internal... that just happens to be
written in C++.
Peter Maydell Jan. 12, 2023, 1:14 p.m. UTC | #6
On Thu, 12 Jan 2023 at 13:10, David Woodhouse <dwmw2@infradead.org> wrote:
>
> On Tue, 2023-01-10 at 09:49 +0100, Paolo Bonzini wrote:
> > A handful of header files in QEMU are wrapped with extern "C" blocks.
> > These are not necessary: there are C++ source files anymore in QEMU,
> > and even where there were some, they did not include most of these
> > files anyway.
> >
> > Remove them for consistency.

> Are we allowed C++ in qemu?

No; we've just managed to removed a couple of minor optional
things that we'd allowed in, and removed the configure/build
machinery for supporting having an optional C++ compiler.
The only remaining bit of C++ is the Windows guest agent.

thanks
-- PMM
Daniel P. Berrangé Jan. 12, 2023, 1:17 p.m. UTC | #7
On Thu, Jan 12, 2023 at 01:10:13PM +0000, David Woodhouse wrote:
> On Tue, 2023-01-10 at 09:49 +0100, Paolo Bonzini wrote:
> > A handful of header files in QEMU are wrapped with extern "C" blocks.
> > These are not necessary: there are C++ source files anymore in QEMU,
> > and even where there were some, they did not include most of these
> > files anyway.
> > 
> > Remove them for consistency.
> 
> 
> Are we allowed C++ in qemu?

Not any more, we've just made an effort to eliminate the last part
of QEMU emulator related code that was C++.  All that's left is
one part of the Windows installer for the guest agent.

> I ask because we have a full single-tenant implementation of XenStore
> lying around, designed to be VMM-internal... that just happens to be
> written in C++.

That's unfortunate :-(

With regards,
Daniel
Paolo Bonzini Jan. 13, 2023, 8:27 a.m. UTC | #8
On 1/12/23 12:05, Peter Maydell wrote:
> On Wed, 11 Jan 2023 at 09:14, Paolo Bonzini<pbonzini@redhat.com>  wrote:
>> On 1/10/23 11:53, Peter Maydell wrote:
>>> On Tue, 10 Jan 2023 at 09:33, Paolo Bonzini<pbonzini@redhat.com>  wrote:
>>>> A handful of header files in QEMU are wrapped with extern "C" blocks.
>>>> These are not necessary: there are C++ source files anymore in QEMU,
>>>> and even where there were some, they did not include most of these
>>>> files anyway.
>>> Any reason not to also take out the extern "C" block in osdep.h
>>> and the uses of QEMU_EXTERN_C ?
>> qemu/osdep.h is still included by the C++ sources in qga/vss-win32.
> If anything C++ still includes osdep.h then you can't remove
> the handling of this from os-win32.h and os-posix.h, because
> those files are included from osdep.h.

Oh, I was confused by them being in sysemu/.  I'll revert those two.

Paolo
diff mbox series

Patch

diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h
index 64247ecb11f4..32cda9ef14c5 100644
--- a/include/disas/dis-asm.h
+++ b/include/disas/dis-asm.h
@@ -11,10 +11,6 @@ 
 
 #include "qemu/bswap.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 typedef void *PTR;
 typedef uint64_t bfd_vma;
 typedef int64_t bfd_signed_vma;
@@ -506,8 +502,4 @@  static inline bfd_vma bfd_getb16(const bfd_byte *addr)
 
 typedef bool bfd_boolean;
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif /* DISAS_DIS_ASM_H */
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 346d05f2aab3..eb8923b1fe07 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -15,10 +15,6 @@ 
 #define BSWAP_FROM_FALLBACKS
 #endif /* ! CONFIG_MACHINE_BSWAP_H */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #ifdef BSWAP_FROM_BYTESWAP
 static inline uint16_t bswap16(uint16_t x)
 {
@@ -448,8 +444,4 @@  DO_STN_LDN_P(be)
 #undef le_bswaps
 #undef be_bswaps
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif /* BSWAP_H */
diff --git a/include/qemu/envlist.h b/include/qemu/envlist.h
index b9addcc11f7d..6006dfae44c3 100644
--- a/include/qemu/envlist.h
+++ b/include/qemu/envlist.h
@@ -1,10 +1,6 @@ 
 #ifndef ENVLIST_H
 #define ENVLIST_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 typedef struct envlist envlist_t;
 
 envlist_t *envlist_create(void);
@@ -15,8 +11,4 @@  int envlist_parse_set(envlist_t *, const char *);
 int envlist_parse_unset(envlist_t *, const char *);
 char **envlist_to_environ(const envlist_t *, size_t *);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif /* ENVLIST_H */
diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h
index b063c6fde81d..313fc414bc2a 100644
--- a/include/qemu/rcu.h
+++ b/include/qemu/rcu.h
@@ -31,10 +31,6 @@ 
 #include "qemu/sys_membarrier.h"
 #include "qemu/coroutine-tls.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /*
  * Important !
  *
@@ -196,8 +192,4 @@  G_DEFINE_AUTOPTR_CLEANUP_FUNC(RCUReadAuto, rcu_read_auto_unlock)
 void rcu_add_force_rcu_notifier(Notifier *n);
 void rcu_remove_force_rcu_notifier(Notifier *n);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif /* QEMU_RCU_H */
diff --git a/include/qemu/rcu_queue.h b/include/qemu/rcu_queue.h
index 0e53ddd5305e..4e6298d47307 100644
--- a/include/qemu/rcu_queue.h
+++ b/include/qemu/rcu_queue.h
@@ -28,11 +28,6 @@ 
 #include "qemu/queue.h"
 #include "qemu/atomic.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
 /*
  * List access methods.
  */
@@ -311,7 +306,4 @@  extern "C" {
          (var) && ((next) = qatomic_rcu_read(&(var)->field.sle_next), 1); \
          (var) = (next))
 
-#ifdef __cplusplus
-}
-#endif
 #endif /* QEMU_RCU_QUEUE_H */
diff --git a/include/qemu/uri.h b/include/qemu/uri.h
index d201c61260de..db5218c39ec0 100644
--- a/include/qemu/uri.h
+++ b/include/qemu/uri.h
@@ -53,10 +53,6 @@ 
 #ifndef QEMU_URI_H
 #define QEMU_URI_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /**
  * URI:
  *
@@ -105,7 +101,4 @@  struct QueryParams *query_params_new (int init_alloc);
 extern QueryParams *query_params_parse (const char *query);
 extern void query_params_free (QueryParams *ps);
 
-#ifdef __cplusplus
-}
-#endif
 #endif /* QEMU_URI_H */
diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h
index 58de7c994d85..616d07790445 100644
--- a/include/sysemu/os-posix.h
+++ b/include/sysemu/os-posix.h
@@ -38,10 +38,6 @@ 
 #include <sys/sysmacros.h>
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 int os_parse_cmd_args(int index, const char *optarg);
 void os_set_line_buffering(void);
 void os_setup_early_signal_handling(void);
@@ -96,8 +92,4 @@  static inline void qemu_funlockfile(FILE *f)
     funlockfile(f);
 }
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif
diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index 5b38c7bd0451..ef3d1a1b181e 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -47,10 +47,6 @@  typedef struct sockaddr_un {
 #define SIO_AF_UNIX_GETPEERPID _WSAIOR(IOC_VENDOR, 256)
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #if defined(_WIN64)
 /* On w64, setjmp is implemented by _setjmp which needs a second parameter.
  * If this parameter is NULL, longjump does no stack unwinding.
@@ -221,8 +217,4 @@  ssize_t qemu_recv_wrap(int sockfd, void *buf, size_t len, int flags);
 ssize_t qemu_recvfrom_wrap(int sockfd, void *buf, size_t len, int flags,
                            struct sockaddr *addr, socklen_t *addrlen);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif