* [PATCH] sim: fix compilation on mingw64
@ 2021-10-27 6:27 Orgad Shaneh
2021-10-27 9:33 ` Mike Frysinger
2021-10-28 9:07 ` Orgad Shaneh
0 siblings, 2 replies; 5+ messages in thread
From: Orgad Shaneh @ 2021-10-27 6:27 UTC (permalink / raw)
To: gdb-patches; +Cc: Orgad Shaneh
1. reorder includes in sim-utils.c.
sim/mips/sim-main.h defines UserMode, while there is a struct in winnt.h
which has UserMode as a member. So if sim-main.h is included before winnt.h,
compilation fails.
2. pre-include winsock2.h in ppc
registers.h defines CR, which is used as a member in winnt.h.
---
sim/common/sim-utils.c | 5 ++---
sim/ppc/defs.h | 3 +++
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
index 380afd0493f..8edd1c9dc0a 100644
--- a/sim/common/sim-utils.c
+++ b/sim/common/sim-utils.c
@@ -20,9 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
-#include "sim-main.h"
-#include "sim-assert.h"
-
#include <stdlib.h>
#include <time.h>
#include <sys/time.h> /* needed by sys/resource.h */
@@ -34,7 +31,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "libiberty.h"
#include "bfd.h"
+#include "sim-main.h"
#include "sim-utils.h"
+#include "sim-assert.h"
/* Allocate zero filled memory with xcalloc - xcalloc aborts if the
allocation fails. */
diff --git a/sim/ppc/defs.h b/sim/ppc/defs.h
index c37f8c60485..31932b8b34d 100644
--- a/sim/ppc/defs.h
+++ b/sim/ppc/defs.h
@@ -22,6 +22,9 @@
/* Include gnulib's various configure tests. */
#include "gnulib/config.h"
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
/* Reset macros that our config.h will provide. */
#undef PACKAGE
--
2.33.1.windows.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sim: fix compilation on mingw64
2021-10-27 6:27 [PATCH] sim: fix compilation on mingw64 Orgad Shaneh
@ 2021-10-27 9:33 ` Mike Frysinger
2021-10-28 9:07 ` Orgad Shaneh
1 sibling, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2021-10-27 9:33 UTC (permalink / raw)
To: Orgad Shaneh; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 843 bytes --]
On 27 Oct 2021 06:27, Orgad Shaneh via Gdb-patches wrote:
> 1. reorder includes in sim-utils.c.
>
> sim/mips/sim-main.h defines UserMode, while there is a struct in winnt.h
> which has UserMode as a member. So if sim-main.h is included before winnt.h,
> compilation fails.
this looks fine, and is the direction we've been taking code -- include the
standard headers first, then the sim-specific headers. we haven't gone back
through all the files and fixed the order since it (largely) hasn't been an
issue.
> 2. pre-include winsock2.h in ppc
>
> registers.h defines CR, which is used as a member in winnt.h.
defs.h has a very specific meaning/role in life: include config.h and that's
it. we don't want to stuff it full of other random headers.
instead, let's find a fix similar to your sim-utils.c change.
-mike
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] sim: fix compilation on mingw64
@ 2021-10-28 9:07 ` Orgad Shaneh
2021-10-29 5:23 ` Mike Frysinger
0 siblings, 1 reply; 5+ messages in thread
From: Orgad Shaneh @ 2021-10-28 9:07 UTC (permalink / raw)
To: gdb-patches; +Cc: Orgad Shaneh
...by reordering includes.
1. sim-utils.c
sim/mips/sim-main.h defines UserMode, while there is a struct in winnt.h
which has UserMode as a member. So if sim-main.h is included before winnt.h,
compilation fails.
2. ppc
registers.h defines CR, which is used as a member in winnt.h.
winsock2.h is included by sys/time.h, so sys/time.h has to be included
before registers.h.
---
sim/common/sim-utils.c | 5 ++---
sim/ppc/emul_netbsd.c | 6 ++++--
sim/ppc/emul_unix.c | 6 ++++--
sim/ppc/mon.c | 9 ++++++---
4 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
index 380afd0493f..88fd20e8876 100644
--- a/sim/common/sim-utils.c
+++ b/sim/common/sim-utils.c
@@ -20,9 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
-#include "sim-main.h"
-#include "sim-assert.h"
-
#include <stdlib.h>
#include <time.h>
#include <sys/time.h> /* needed by sys/resource.h */
@@ -34,6 +31,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "libiberty.h"
#include "bfd.h"
+#include "sim-main.h"
+#include "sim-assert.h"
#include "sim-utils.h"
/* Allocate zero filled memory with xcalloc - xcalloc aborts if the
diff --git a/sim/ppc/emul_netbsd.c b/sim/ppc/emul_netbsd.c
index a97fc3b6460..d1595c5985f 100644
--- a/sim/ppc/emul_netbsd.c
+++ b/sim/ppc/emul_netbsd.c
@@ -25,8 +25,7 @@
/* Note: this module is called via a table. There is no benefit in
making it inline */
-#include "emul_generic.h"
-#include "emul_netbsd.h"
+#include "defs.h"
#include <string.h>
#include <sys/types.h>
@@ -38,6 +37,9 @@
#include <sys/param.h>
#include <sys/time.h>
+#include "emul_generic.h"
+#include "emul_netbsd.h"
+
#ifdef HAVE_GETRUSAGE
#ifndef HAVE_SYS_RESOURCE_H
#undef HAVE_GETRUSAGE
diff --git a/sim/ppc/emul_unix.c b/sim/ppc/emul_unix.c
index cfcb4691247..191e26abd8e 100644
--- a/sim/ppc/emul_unix.c
+++ b/sim/ppc/emul_unix.c
@@ -25,8 +25,7 @@
/* Note: this module is called via a table. There is no benefit in
making it inline */
-#include "emul_generic.h"
-#include "emul_unix.h"
+#include "defs.h"
#include <string.h>
#ifdef HAVE_SYS_TYPES_H
@@ -124,6 +123,9 @@ int getrusage();
#include <stdlib.h>
#include <time.h>
+#include "emul_generic.h"
+#include "emul_unix.h"
+
#ifndef STATIC_INLINE_EMUL_UNIX
#define STATIC_INLINE_EMUL_UNIX STATIC_INLINE
#endif
diff --git a/sim/ppc/mon.c b/sim/ppc/mon.c
index 966f86c040e..4e29ec99879 100644
--- a/sim/ppc/mon.c
+++ b/sim/ppc/mon.c
@@ -21,9 +21,8 @@
#ifndef _MON_C_
#define _MON_C_
-#include "basics.h"
-#include "cpu.h"
-#include "mon.h"
+#include "defs.h"
+
#include <stdio.h>
#include <string.h>
@@ -42,6 +41,10 @@
int getrusage();
#endif
+#include "basics.h"
+#include "cpu.h"
+#include "mon.h"
+
#define MAX_BYTE_READWRITE 9
#define MAX_SHIFT_READWRITE 3
--
2.33.1.windows.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sim: fix compilation on mingw64
2021-10-28 9:07 ` Orgad Shaneh
@ 2021-10-29 5:23 ` Mike Frysinger
2021-10-29 5:37 ` Orgad Shaneh
0 siblings, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2021-10-29 5:23 UTC (permalink / raw)
To: Orgad Shaneh; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 547 bytes --]
On 28 Oct 2021 09:07, Orgad Shaneh via Gdb-patches wrote:
> ...by reordering includes.
>
> 1. sim-utils.c
>
> sim/mips/sim-main.h defines UserMode, while there is a struct in winnt.h
> which has UserMode as a member. So if sim-main.h is included before winnt.h,
> compilation fails.
>
> 2. ppc
>
> registers.h defines CR, which is used as a member in winnt.h.
>
> winsock2.h is included by sys/time.h, so sys/time.h has to be included
> before registers.h.
these changes lgtm, thanks!
if you need me to push, lmk.
-mike
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] sim: fix compilation on mingw64
2021-10-29 5:23 ` Mike Frysinger
@ 2021-10-29 5:37 ` Orgad Shaneh
0 siblings, 0 replies; 5+ messages in thread
From: Orgad Shaneh @ 2021-10-29 5:37 UTC (permalink / raw)
To: Orgad Shaneh, gdb-patches
בתאריך יום ו׳, 29 באוק׳ 2021, 8:23, מאת Mike Frysinger <vapier@gentoo.org>:
> On 28 Oct 2021 09:07, Orgad Shaneh via Gdb-patches wrote:
> > ...by reordering includes.
> >
> > 1. sim-utils.c
> >
> > sim/mips/sim-main.h defines UserMode, while there is a struct in winnt.h
> > which has UserMode as a member. So if sim-main.h is included before
> winnt.h,
> > compilation fails.
> >
> > 2. ppc
> >
> > registers.h defines CR, which is used as a member in winnt.h.
> >
> > winsock2.h is included by sys/time.h, so sys/time.h has to be included
> > before registers.h.
>
> these changes lgtm, thanks!
>
> if you need me to push, lmk.
> -mike
Please do.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-29 5:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 6:27 [PATCH] sim: fix compilation on mingw64 Orgad Shaneh
2021-10-27 9:33 ` Mike Frysinger
2021-10-28 9:07 ` Orgad Shaneh
2021-10-29 5:23 ` Mike Frysinger
2021-10-29 5:37 ` Orgad Shaneh
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 read-only IMAP folder(s) and NNTP newsgroup(s).