qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: [PATCH for-6.0? 4/6] osdep: Make os-win32.h and os-posix.h handle 'extern "C"' themselves
Date: Fri, 16 Apr 2021 14:55:41 +0100	[thread overview]
Message-ID: <20210416135543.20382-5-peter.maydell@linaro.org> (raw)
In-Reply-To: <20210416135543.20382-1-peter.maydell@linaro.org>

Both os-win32.h and os-posix.h include system header files. Instead
of having osdep.h include them inside its 'extern "C"' block, make
these headers handle that themselves, so that we don't include the
system headers inside 'extern "C"'.

This doesn't fix any current problems, but it's conceptually the
right way to handle system headers.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/osdep.h      | 8 ++++----
 include/sysemu/os-posix.h | 8 ++++++++
 include/sysemu/os-win32.h | 8 ++++++++
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index cb2a07e472e..4c6f2390be4 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -131,10 +131,6 @@ QEMU_EXTERN_C int daemon(int, int);
  */
 #include "glib-compat.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #ifdef _WIN32
 #include "sysemu/os-win32.h"
 #endif
@@ -143,6 +139,10 @@ extern "C" {
 #include "sysemu/os-posix.h"
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "qemu/typedefs.h"
 
 /*
diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h
index 629c8c648b7..2edf33658a4 100644
--- a/include/sysemu/os-posix.h
+++ b/include/sysemu/os-posix.h
@@ -38,6 +38,10 @@
 #include <sys/sysmacros.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void os_set_line_buffering(void);
 void os_set_proc_name(const char *s);
 void os_setup_signal_handling(void);
@@ -92,4 +96,8 @@ 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 5346d51e890..43f569b5c21 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -30,6 +30,10 @@
 #include <windows.h>
 #include <ws2tcpip.h>
 
+#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.
@@ -194,4 +198,8 @@ 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
-- 
2.20.1



  parent reply	other threads:[~2021-04-16 13:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 13:55 [PATCH for-6.0? 0/6] extern "C" overhaul for C++ files Peter Maydell
2021-04-16 13:55 ` [PATCH for-6.0? 1/6] osdep: include glib-compat.h before other QEMU headers Peter Maydell
2021-04-16 17:16   ` Richard Henderson
2021-04-16 13:55 ` [PATCH for-6.0? 2/6] osdep: protect qemu/osdep.h with extern "C" Peter Maydell
2021-04-16 17:17   ` Richard Henderson
2021-04-16 13:55 ` [PATCH for-6.0? 3/6] include/qemu/osdep.h: Move system includes to top Peter Maydell
2021-04-16 17:17   ` Richard Henderson
2021-04-16 13:55 ` Peter Maydell [this message]
2021-04-16 16:25   ` [PATCH for-6.0? 4/6] osdep: Make os-win32.h and os-posix.h handle 'extern "C"' themselves Paolo Bonzini
2021-04-16 16:25     ` Peter Maydell
2021-04-16 17:17   ` Richard Henderson
2021-04-16 13:55 ` [PATCH for-6.0? 5/6] include/qemu/bswap.h: Handle being included outside extern "C" block Peter Maydell
2021-04-16 17:18   ` Richard Henderson
2021-04-16 13:55 ` [PATCH for-6.0? 6/6] include/disas/dis-asm.h: Handle being included outside 'extern "C"' Peter Maydell
2021-04-16 17:18   ` Richard Henderson
2021-04-16 14:03 ` [PATCH for-6.0? 0/6] extern "C" overhaul for C++ files no-reply
2021-04-16 14:56 ` Philippe Mathieu-Daudé
2021-04-16 16:28 ` Paolo Bonzini
2021-04-16 17:07   ` Peter Maydell
2021-04-16 18:31     ` Paolo Bonzini
2021-05-04 10:43 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210416135543.20382-5-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=berrange@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).