From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 7C7823858C2D for ; Fri, 13 May 2022 07:49:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7C7823858C2D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from localhost.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9BxQNpxDX5iGAcUAA--.6788S2; Fri, 13 May 2022 15:49:05 +0800 (CST) From: Youling Tang To: gdb-patches@sourceware.org Subject: [PATCH] gdbsupport: Remove some unnecessary ifdef HAVE_POLL judgments Date: Fri, 13 May 2022 15:49:05 +0800 Message-Id: <20220513074905.21554-1-tangyouling@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf9BxQNpxDX5iGAcUAA--.6788S2 X-Coremail-Antispam: 1UD129KBjvJXoWxtrW7Kr1DZr15Xry8try3CFg_yoW7GFWDpa y3K3yq9r45G3Wjkay0qF18ua43C34kJ3sFgF9Yq3yrG34DJF9YyFWjkF15XFy5WF93Xa4f Zw4qqr98AFZxJw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUk2b7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4 vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xv F2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0Ex4A2jsIE14v26r4j6F 4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY02Avz4vE14v_GF4l42xK 82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGw C20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1j6r15MIIYrxkI7VAKI48J MIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMI IF0xvE42xK8VAvwI8IcIk0rVW3JVWrJr1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2 z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxUySoXUUUUU X-CM-SenderInfo: 5wdqw5prxox03j6o00pqjv00gofq/ X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 May 2022 07:49:10 -0000 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 --- gdbsupport/event-loop.cc | 61 +++++----------------------------------- 1 file changed, 7 insertions(+), 54 deletions(-) diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc index 385b45b2de1..0bdaa4e7d35 100644 --- a/gdbsupport/event-loop.cc +++ b/gdbsupport/event-loop.cc @@ -248,13 +248,10 @@ void 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,21 +261,10 @@ 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 */ } if (use_poll) - { -#ifdef HAVE_POLL - create_file_handler (fd, POLLIN, proc, client_data, std::move (name), + create_file_handler (fd, POLLIN, proc, client_data, std::move (name), is_ui); -#else - internal_error (__FILE__, __LINE__, - _("use_poll without HAVE_POLL")); -#endif - } else create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION, proc, client_data, std::move (name), is_ui); @@ -323,7 +309,6 @@ create_file_handler (int fd, int mask, handler_func * proc, if (use_poll) { -#ifdef HAVE_POLL gdb_notifier.num_fds++; if (gdb_notifier.poll_fds) gdb_notifier.poll_fds = @@ -336,10 +321,6 @@ create_file_handler (int fd, int mask, handler_func * proc, (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->fd = fd; (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->events = mask; (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->revents = 0; -#else - internal_error (__FILE__, __LINE__, - _("use_poll without HAVE_POLL")); -#endif /* HAVE_POLL */ } else { @@ -402,10 +383,6 @@ delete_file_handler (int fd) { file_handler *file_ptr, *prev_ptr = NULL; int i; -#ifdef HAVE_POLL - int j; - struct pollfd *new_poll_fds; -#endif /* Find the entry for the given file. */ @@ -421,7 +398,9 @@ delete_file_handler (int fd) if (use_poll) { -#ifdef HAVE_POLL + int j; + struct pollfd *new_poll_fds; + /* Create a new poll_fds array by copying every fd's information but the one we want to get rid of. */ @@ -442,10 +421,6 @@ delete_file_handler (int fd) xfree (gdb_notifier.poll_fds); gdb_notifier.poll_fds = new_poll_fds; gdb_notifier.num_fds--; -#else - internal_error (__FILE__, __LINE__, - _("use_poll without HAVE_POLL")); -#endif /* HAVE_POLL */ } else { @@ -510,9 +485,6 @@ static void handle_file_event (file_handler *file_ptr, int ready_mask) { int mask; -#ifdef HAVE_POLL - int error_mask; -#endif { { @@ -528,7 +500,7 @@ handle_file_event (file_handler *file_ptr, int ready_mask) if (use_poll) { -#ifdef HAVE_POLL + int error_mask; /* POLLHUP means EOF, but can be combined with POLLIN to signal more data to read. */ error_mask = POLLHUP | POLLERR | POLLNVAL; @@ -547,10 +519,6 @@ handle_file_event (file_handler *file_ptr, int ready_mask) } else file_ptr->error = 0; -#else - internal_error (__FILE__, __LINE__, - _("use_poll without HAVE_POLL")); -#endif /* HAVE_POLL */ } else { @@ -601,7 +569,6 @@ gdb_wait_for_event (int block) if (use_poll) { -#ifdef HAVE_POLL int timeout; if (block) @@ -616,10 +583,6 @@ gdb_wait_for_event (int block) signal. */ if (num_found == -1 && errno != EINTR) perror_with_name (("poll")); -#else - internal_error (__FILE__, __LINE__, - _("use_poll without HAVE_POLL")); -#endif /* HAVE_POLL */ } else { @@ -672,7 +635,6 @@ gdb_wait_for_event (int block) may change between invocations, but this is good enough. */ if (use_poll) { -#ifdef HAVE_POLL int i; int mask; @@ -699,10 +661,6 @@ gdb_wait_for_event (int block) mask = (gdb_notifier.poll_fds + i)->revents; handle_file_event (file_ptr, mask); return 1; -#else - internal_error (__FILE__, __LINE__, - _("use_poll without HAVE_POLL")); -#endif /* HAVE_POLL */ } else { @@ -858,12 +816,7 @@ update_wait_timeout (void) /* Update the timeout for select/ poll. */ if (use_poll) { -#ifdef HAVE_POLL gdb_notifier.poll_timeout = timeout.tv_sec * 1000; -#else - internal_error (__FILE__, __LINE__, - _("use_poll without HAVE_POLL")); -#endif /* HAVE_POLL */ } else { -- 2.20.1