Skip to content

Commit

Permalink
osdep: Make os-win32.h and os-posix.h handle 'extern "C"' themselves
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
pm215 committed May 10, 2021
1 parent 4d4fbbe commit 5d251a4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/qemu/osdep.h
Expand Up @@ -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
Expand All @@ -143,6 +139,10 @@ extern "C" {
#include "sysemu/os-posix.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

#include "qemu/typedefs.h"

/*
Expand Down
8 changes: 8 additions & 0 deletions include/sysemu/os-posix.h
Expand Up @@ -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);
Expand Down Expand Up @@ -92,4 +96,8 @@ static inline void qemu_funlockfile(FILE *f)
funlockfile(f);
}

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions include/sysemu/os-win32.h
Expand Up @@ -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.
Expand Down Expand Up @@ -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

0 comments on commit 5d251a4

Please sign in to comment.