[RFA] Remove some unnecessary declarations and configury

Message ID 20180722153641.27167-1-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey July 22, 2018, 3:36 p.m. UTC
  configure checks for declarations of free, malloc, and realloc; but
the results are only used in a single spot: utils.c.  I think these
checks are long since obsolete, so this patch removes them.

Grepping the entire tree for these HAVE_DECL_ symbols, the only uses
of possible interest to gdb come from bfd/sysdep.h; but this is not
(nor should be) included by gdb.  (And furthermore I think the code
there is probably also obsolete.)

ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* utils.c (malloc, realloc, free): Don't declare.
	* configure, config.in: Rebuild.
	* configure.ac: Don't check for declarations of free, malloc, or
	realloc.
---
 gdb/ChangeLog    |  7 +++++++
 gdb/config.in    | 12 ------------
 gdb/configure    | 30 ------------------------------
 gdb/configure.ac |  2 +-
 gdb/utils.c      | 10 ----------
 5 files changed, 8 insertions(+), 53 deletions(-)
  

Comments

Simon Marchi July 23, 2018, 5:32 p.m. UTC | #1
On 2018-07-22 11:36 AM, Tom Tromey wrote:
> configure checks for declarations of free, malloc, and realloc; but
> the results are only used in a single spot: utils.c.  I think these
> checks are long since obsolete, so this patch removes them.
> 
> Grepping the entire tree for these HAVE_DECL_ symbols, the only uses
> of possible interest to gdb come from bfd/sysdep.h; but this is not
> (nor should be) included by gdb.  (And furthermore I think the code
> there is probably also obsolete.)

I'm really not an expert of old arcane systems, but I don't think any
platform we support today needs this.

Simon
  
Simon Marchi July 24, 2018, 1:57 p.m. UTC | #2
On 2018-07-23 01:32 PM, Simon Marchi wrote:
> On 2018-07-22 11:36 AM, Tom Tromey wrote:
>> configure checks for declarations of free, malloc, and realloc; but
>> the results are only used in a single spot: utils.c.  I think these
>> checks are long since obsolete, so this patch removes them.
>>
>> Grepping the entire tree for these HAVE_DECL_ symbols, the only uses
>> of possible interest to gdb come from bfd/sysdep.h; but this is not
>> (nor should be) included by gdb.  (And furthermore I think the code
>> there is probably also obsolete.)
> 
> I'm really not an expert of old arcane systems, but I don't think any
> platform we support today needs this.
> 
> Simon
> 

I should clarify that this patch LGTM.

Thanks,

Simon
  

Patch

diff --git a/gdb/config.in b/gdb/config.in
index 527290296ec..01acda124b9 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -102,26 +102,14 @@ 
 /* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
 #undef HAVE_DECL_FFS
 
-/* Define to 1 if you have the declaration of `free', and to 0 if you don't.
-   */
-#undef HAVE_DECL_FREE
-
 /* Define to 1 if you have the declaration of `getthrds', and to 0 if you
    don't. */
 #undef HAVE_DECL_GETTHRDS
 
-/* Define to 1 if you have the declaration of `malloc', and to 0 if you don't.
-   */
-#undef HAVE_DECL_MALLOC
-
 /* Define to 1 if you have the declaration of `ptrace', and to 0 if you don't.
    */
 #undef HAVE_DECL_PTRACE
 
-/* Define to 1 if you have the declaration of `realloc', and to 0 if you
-   don't. */
-#undef HAVE_DECL_REALLOC
-
 /* Define to 1 if you have the declaration of `snprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_SNPRINTF
diff --git a/gdb/configure b/gdb/configure
index 3f0a22073d0..91d2a7fb80a 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -12394,36 +12394,6 @@  _ACEOF
 
 
 
-ac_fn_c_check_decl "$LINENO" "free" "ac_cv_have_decl_free" "$ac_includes_default"
-if test "x$ac_cv_have_decl_free" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_FREE $ac_have_decl
-_ACEOF
-ac_fn_c_check_decl "$LINENO" "malloc" "ac_cv_have_decl_malloc" "$ac_includes_default"
-if test "x$ac_cv_have_decl_malloc" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_MALLOC $ac_have_decl
-_ACEOF
-ac_fn_c_check_decl "$LINENO" "realloc" "ac_cv_have_decl_realloc" "$ac_includes_default"
-if test "x$ac_cv_have_decl_realloc" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_REALLOC $ac_have_decl
-_ACEOF
 ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
 if test "x$ac_cv_have_decl_snprintf" = xyes; then :
   ac_have_decl=1
diff --git a/gdb/configure.ac b/gdb/configure.ac
index dfd38a730f4..13bc5f9a8f2 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1317,7 +1317,7 @@  AC_CHECK_HEADERS(term.h, [], [],
 
 libiberty_INIT
 
-AC_CHECK_DECLS([free, malloc, realloc, snprintf])
+AC_CHECK_DECLS([snprintf])
 AM_LC_MESSAGES
 
 # ----------------------- #
diff --git a/gdb/utils.c b/gdb/utils.c
index bfcb45bc950..7a8c80c64ed 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -72,16 +72,6 @@ 
 #include <algorithm>
 #include "common/pathstuff.h"
 
-#if !HAVE_DECL_MALLOC
-extern PTR malloc ();		/* ARI: PTR */
-#endif
-#if !HAVE_DECL_REALLOC
-extern PTR realloc ();		/* ARI: PTR */
-#endif
-#if !HAVE_DECL_FREE
-extern void free ();
-#endif
-
 void (*deprecated_error_begin_hook) (void);
 
 /* Prototypes for local functions */