Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix ARM simulator build on Windows
Date: Thu, 9 Dec 2021 21:25:08 -0500	[thread overview]
Message-ID: <YbK6hNgrG0bSKo71@vapier> (raw)
In-Reply-To: <20211209140212.3980587-1-tromey@adacore.com>

[-- Attachment #1: Type: text/plain, Size: 1768 bytes --]

On 09 Dec 2021 07:02, Tom Tromey wrote:
> For a Windows-hosted build with arm-elf as the target, the sim build
> fails like:

what is your --host ?  guessing it's a mingw toolchain.

> [...]sim-io.c:214:29: error: 'struct host_callback_struct' has no member named 'open'
> 
> The recent header reorganization seems to have caused this, because
> now 'open' is redefined by the gnulib fcntl.h.

yeah, i think that's why it started breaking.

> The fix is simple: remove the undef of 'open' from sim-io.c.

mmm, not that simple.  the error you're seeing is because the open macro
rewrote the host_callback_struct structure.  and then we tried to use it,
but they no longer matched.

include/sim/callback.h:
struct host_callback_struct {
  int (*open) (host_callback *, const char*, int mode);

common/sim-io.c:
int sim_io_open (SIM_DESC sd, const char *name, int flags)
{ 
  return STATE_CALLBACK (sd)->open (STATE_CALLBACK (sd), name, flags);
}

i'm not keen on relying on open being defined to a simple symbol name and thus
it will continue to compile.  if it's defined to something more complicated, i
imagine it will still fail to compile.
#define open(args...) _foo_open(1234, ## args)

so i think it's better to move the undef between the system includes and the
local sim includes so it's undone for the header & source.  this file doesn't
use actual open() call, so should be fine.
-mike

--- a/sim/common/sim-io.c
+++ b/sim/common/sim-io.c
@@ -33,12 +33,12 @@
 #include <unistd.h>
 #endif
 
+#undef open
+
 #include "sim-main.h"
 #include "sim-io.h"
 #include "sim/callback.h"
 
-#undef open
-
 /* Define the rate at which the simulator should poll the host
    for a quit. */
 #ifndef POLL_QUIT_INTERVAL

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-12-10  2:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 14:02 Tom Tromey via Gdb-patches
2021-12-10  2:25 ` Mike Frysinger via Gdb-patches [this message]
2021-12-16 14:58   ` Tom Tromey via Gdb-patches

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=YbK6hNgrG0bSKo71@vapier \
    --to=gdb-patches@sourceware.org \
    --cc=tromey@adacore.com \
    --cc=vapier@gentoo.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