From patchwork Fri Feb 27 08:53:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 5335 Received: (qmail 29593 invoked by alias); 27 Feb 2015 08:53:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 29573 invoked by uid 89); 27 Feb 2015 08:53:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 27 Feb 2015 08:53:53 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A13ADD3177; Fri, 27 Feb 2015 03:53:51 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id U0K67tBeHP0v; Fri, 27 Feb 2015 03:53:51 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 6322FD3176; Fri, 27 Feb 2015 03:53:51 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id A830C40EAD; Fri, 27 Feb 2015 09:53:48 +0100 (CET) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Mark Wielaard Subject: [RFA/commit] Remove use of stdbool.h in GDB sources. Date: Fri, 27 Feb 2015 09:53:46 +0100 Message-Id: <1425027226-23546-1-git-send-email-brobecker@adacore.com> Hello, Using type bool from stdbool unfortunately causes problems trying to build GDB on AiX and Solaris: In file included from ../../src/gdb/utils.h:24:0, from ../../src/gdb/defs.h:707, from ../../src/gdb/utils.c:20: /[...]/curses.h:96:14: error: two or more data types in declaration specifiers typedef char bool; ^ make[2]: *** [utils.o] Error 1 In theory, the problem is in the system's curses.h which, in both cases, do something similar. On Solaris: #if !defined(__cplusplus) && !defined(_BOOL) typedef char bool; #endif /* !defined(__cplusplus) && !defined(_BOOL) */ On AiX: #if !defined(__cplusplus) || (defined(__IBMCPP__) &&(__IBMCPP__<400)) #ifndef _BOOL #define _BOOL typedef int bool; #endif #endif You can reproduce the same problem by trying to compile: % cat toto.c #include #include % gcc -c toto.c In file included from toto.c:1:0: /[...]/curses.h:159:13: error: two or more data types in declaration specifiers typedef int bool; ^ This specific issue wouldn't occur if we included curses.h before including stdbool.h, and I looked at that just to be complete. Here is a small schematic representation of the include logic: * utils.c: -> defs.h -> utils.h -> stdbool.h -> gdb_curses.h -> curses.h Because defs.h should always be first on the list, it means that stdbool.h will always necessarily be included ahead of curses.h. But, thinking beyond this very specific issue, it shows that using stdbool.h is going to cause problems on these systems until either GCC fixes those includes in a way that makes them work (not really an option in the short term); or we switch to C++. In the meantime, I think the path of least resistance is to revert the use of stdbool.h, and use integers, the way we've done up until now. The benefits of using type "bool" are modest, IMO, so not a great loss, and a temporary one. gdb/ChangeLog: * utils.h: Remove #include. (producer_is_gcc): Change return type to "int". * utils.c (producer_is_gcc): Change return type to int. Return 1 instead of true, and 0 instead of false. Adjust function documentation accordingly. I will push this patch in the next few days, unless there are objections. Thanks, diff --git a/gdb/utils.c b/gdb/utils.c index 3ce5814..4f9f4f0 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3269,11 +3269,11 @@ producer_is_gcc_ge_4 (const char *producer) return minor; } -/* Returns true if the given PRODUCER string is GCC and sets the MAJOR - and MINOR versions when not NULL. Returns false if the given PRODUCER +/* Returns nonzero if the given PRODUCER string is GCC and sets the MAJOR + and MINOR versions when not NULL. Returns zero if the given PRODUCER is NULL or it isn't GCC. */ -bool +int producer_is_gcc (const char *producer, int *major, int *minor) { const char *cs; @@ -3299,11 +3299,11 @@ producer_is_gcc (const char *producer, int *major, int *minor) if (*cs && isspace (*cs)) cs++; if (sscanf (cs, "%d.%d", major, minor) == 2) - return true; + return 1; } /* Not recognized as GCC. */ - return false; + return 0; } /* Helper for make_cleanup_free_char_ptr_vec. */ diff --git a/gdb/utils.h b/gdb/utils.h index d8afa79..b8e1aff 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -21,8 +21,6 @@ #ifndef UTILS_H #define UTILS_H -#include - #include "exceptions.h" extern void initialize_utils (void); @@ -304,7 +302,7 @@ extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout); #endif extern int producer_is_gcc_ge_4 (const char *producer); -extern bool producer_is_gcc (const char *producer, int *major, int *minor); +extern int producer_is_gcc (const char *producer, int *major, int *minor); extern int myread (int, char *, int);