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 083AD3857023 for ; Fri, 13 May 2022 10:09:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 083AD3857023 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 [10.130.0.193] (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9BxcNpzLn5ipTAUAA--.9510S3; Fri, 13 May 2022 18:09:56 +0800 (CST) Subject: Re: [PATCH] gdbsupport: Remove some unnecessary ifdef HAVE_POLL judgments To: Pedro Alves , gdb-patches@sourceware.org References: <20220513074905.21554-1-tangyouling@loongson.cn> <634dfd3e-dca9-3c5a-cf63-2a86ca23e40e@palves.net> From: Youling Tang Message-ID: <182b2afa-d1ac-510b-b454-f81a98a51598@loongson.cn> Date: Fri, 13 May 2022 18:09:55 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <634dfd3e-dca9-3c5a-cf63-2a86ca23e40e@palves.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf9BxcNpzLn5ipTAUAA--.9510S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Ww4fJw4rGFW5ZFW7XrW7twb_yoW8AFWxpr y3AayqgFW3W3W2kayvqF1rWayak34kA34xtr95X3y5CF98Jas5tF12vF15ZFy5WFykX342 qw42qa4DCrZ8Ja7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvIb7Iv0xC_tr1lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwV C2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Gr0_Cr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxk0xIA0c2IEe2xFo4CEbIxvr21l c2xSY4AK67AK6r4DMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I 0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWU XVWUAwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcV CY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv 67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf 9x07jFZXOUUUUU= X-CM-SenderInfo: 5wdqw5prxox03j6o00pqjv00gofq/ X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, 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 10:10:00 -0000 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 > 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.