gdbsupport/event-loop.cc: simplify !HAVE_POLL paths
authorPedro Alves <pedro@palves.net>
Mon, 16 May 2022 09:11:15 +0000 (10:11 +0100)
committerPedro Alves <pedro@palves.net>
Mon, 16 May 2022 18:54:20 +0000 (19:54 +0100)
commit36a5b3705352f228cdd14a7f9d5e85177fad034c
treeb1f4da15c5794bcc10204d1482a766730528476f
parente90601a4f1af82ff5350797ddc54e24efd731535
gdbsupport/event-loop.cc: simplify !HAVE_POLL paths

gdbsupport/event-loop.cc throughout handles the case of use_poll being
true on a system where HAVE_POLL is not defined, by calling
internal_error if that situation ever happens.

Simplify this by moving the "use_poll" global itself under HAVE_POLL,
so that it's way more unlikely to ever end up in such a situation.
Then, move the code that checks the value of use_poll under HAVE_POLL
too, and remove the internal_error calls.  Like, from:

    if (use_poll)
      {
  #ifdef HAVE_POLL
        // poll code
  #else
      internal_error (....);
  #endif /* HAVE_POLL */
      }
    else
      {
// select code
      }

to

  #ifdef HAVE_POLL
    if (use_poll)
      {
        // poll code
      }
    else
  #endif /* HAVE_POLL */
      {
// select code
      }

While at it, make use_poll be a bool.  The current code is using
unsigned char most probably to save space, but I don't think it really
matters here.

Co-Authored-By: Youling Tang <tangyouling@loongson.cn>
Change-Id: I0dd74fdd4d393ccd057906df4cd75e8e83c1cdb4
gdbsupport/event-loop.cc