public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Youling Tang <tangyouling@loongson.cn>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdbsupport: Remove some unnecessary ifdef HAVE_POLL judgments
Date: Fri, 13 May 2022 18:09:55 +0800	[thread overview]
Message-ID: <182b2afa-d1ac-510b-b454-f81a98a51598@loongson.cn> (raw)
In-Reply-To: <634dfd3e-dca9-3c5a-cf63-2a86ca23e40e@palves.net>

Hi, Pedro

On 05/13/2022 05:28 PM, Pedro Alves wrote:
> On 2022-05-13 08:49, Youling Tang wrote:
>> By searching event-loop.cc we found that there are only the following 2
>> places to assign values to use_poll,
>> $ grep -nr use_poll gdbsupport/event-loop.cc
>>    88:static unsigned char use_poll = USE_POLL;
>>    263:	use_poll = 0;
>>
>> This USE_POLL is defined as follows,
>>   #ifdef HAVE_POLL
>>   #define USE_POLL 1
>>   #else
>>   #define USE_POLL 0
>>   #endif
>>
>> So use_poll may be 1 only if HAVE_POLL is defined. Removed "ifdef
>> HAVE_POLL" judgment in use_poll control block.
>>
>> Signed-off-by: Youling Tang <tangyouling@loongson.cn>
> Maybe I'm missing something, but ISTM this can't possible work on hosts that don'
>   have poll at all.  Like e.g., mingw:
>
>   $ grep POLL *
>   config.h:/* #undef HAVE_POLL */
>   config.h:/* #undef HAVE_POLL_H */
>   config.h:/* #undef HAVE_SYS_POLL_H */
>
> Surely they'll fail to compile after the patch?
You are right my oversight.

But we can remove these internal_error handling, similar to the 
following modification:

  add_file_handler (int fd, handler_func *proc, gdb_client_data client_data,
                   std::string &&name, bool is_ui)
  {
-#ifdef HAVE_POLL
-  struct pollfd fds;
-#endif
-
    if (use_poll)
      {
  #ifdef HAVE_POLL
+      struct pollfd fds;
+
        /* Check to see if poll () is usable.  If not, we'll switch to
          use select.  This can happen on systems like
          m68k-motorola-sys, `poll' cannot be used to wait for `stdin'.
@@ -264,19 +263,13 @@ add_file_handler (int fd, handler_func *proc, 
gdb_client_data client_data,
        fds.events = POLLIN;
        if (poll (&fds, 1, 0) == 1 && (fds.revents & POLLNVAL))
         use_poll = 0;
-#else
-      internal_error (__FILE__, __LINE__,
-                     _("use_poll without HAVE_POLL"));
-#endif /* HAVE_POLL */
+#endif

Thanks,
Youling.


  reply	other threads:[~2022-05-13 10:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13  7:49 Youling Tang
2022-05-13  9:28 ` Pedro Alves
2022-05-13 10:09   ` Youling Tang [this message]
2022-05-13 10:21     ` Pedro Alves
2022-05-14  1:14       ` Youling Tang
2022-05-16  9:31         ` [PATCH] gdbsupport/even-loop.cc: simplify !HAVE_POLL paths Pedro Alves
2022-05-16 12:13           ` Youling Tang
2022-05-16 15:24           ` Tom Tromey
2022-05-16 19:01             ` [ob/pushed] Reindent gdbsupport/event-loop.cc:handle_file_event (Re: [PATCH] gdbsupport/even-loop.cc: simplify !HAVE_POLL paths) Pedro Alves

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=182b2afa-d1ac-510b-b454-f81a98a51598@loongson.cn \
    --to=tangyouling@loongson.cn \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).