This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 14/13 v2] Move errno.h to common-defs.h
- From: Gary Benson <gbenson at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at redhat dot com>
- Date: Thu, 31 Jul 2014 09:55:11 +0100
- Subject: [PATCH 14/13 v2] Move errno.h to common-defs.h
- Authentication-results: sourceware.org; auth=none
- References: <87zjfqti57 dot fsf at fleche dot redhat dot com>
Tom Tromey wrote:
> >>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:
>
> Gary> This commit moves the inclusion of errno.h to common-defs.h
> Gary> and removes all other inclusions. Note that prior to this
> Gary> commit errno.h was included unconditionally in defs.h, whereas
> Gary> in common-defs.h it is protected by "#ifdef HAVE_ERRNO_H".
> Gary> This does not change the status quo, since presumably every
> Gary> platform on which GDB builds has errno.h.
>
> Gary> Is this ok to commit?
>
> Gary> * configure.ac (AC_CHECK_HEADERS): Add errno.h.
>
> If a header in common/, nat/, or target/ requires an autoconf
> define, then the check should be added to common/common.m4 and
> then the various configure scripts rebuilt.
>
> This way we ensure that gdb and gdbserver keep in sync. There
> were problems with this in the past.
>
> I think it's fine to unconditionally include errno.h. For one thing
> some files in gdb did this. Also I believe it is pulled into gnulib
> as a dependency of some other module; though you'd probably want to
> check this.
>
> If you go this route then I guess it would be nice to remove errno.h
> checks instead.
I'll move the check. There are some Windows CE workarounds for errno
in gdbserver that I don't really want to touch, so keeping the checks
keeps the effect of this change as minimal as possible.
Updated patch inlined below.
Thanks,
Gary
--
gdb/
2014-07-31 Gary Benson <gbenson@redhat.com>
* common/common.m4 (AC_CHECK_HEADERS): Add errno.h.
* configure: Regenerate.
* config.in: Likewise.
* common/common-defs.h: Include errno.h.
* defs.h: Do not include errno.h.
* ada-typeprint.c: Likewise.
* c-typeprint.c: Likewise.
* core-regset.c: Likewise.
* corefile.c: Likewise.
* corelow.c: Likewise.
* event-loop.c: Likewise.
* f-typeprint.c: Likewise.
* gnu-nat.c: Likewise.
* go32-nat.c: Likewise.
* i386gnu-nat.c: Likewise.
* m2-typeprint.c: Likewise.
* nat/linux-btrace.c: Likewise.
* p-typeprint.c: Likewise.
* procfs.c: Likewise.
* remote-sim.c: Likewise.
* rs6000-nat.c: Likewise.
* target.c: Likewise.
* typeprint.c: Likewise.
* ui-file.c: Likewise.
* valops.c: Likewise.
* valprint.c: Likewise.
gdb/gdbserver/
2014-07-31 Gary Benson <gbenson@redhat.com>
* configure.ac (AC_CHECK_HEADERS): Remove errno.h.
* configure: Regenerate.
* server.h: Do not include errno.h.
* event-loop.c: Likewise.
* hostio-errno.c: Likewise.
* linux-low.c: Likewise.
* remote-utils.c: Likewise.
* spu-low.c: Likewise.
* utils.c: Likewise.
---
gdb/ChangeLog | 29 +++++++++++++++++++++++++++++
gdb/ada-typeprint.c | 2 --
gdb/c-typeprint.c | 1 -
gdb/common/common-defs.h | 3 +++
gdb/common/common.m4 | 2 +-
gdb/config.in | 3 +++
gdb/configure | 2 +-
gdb/core-regset.c | 1 -
gdb/corefile.c | 1 -
gdb/corelow.c | 1 -
gdb/defs.h | 1 -
gdb/event-loop.c | 1 -
gdb/f-typeprint.c | 1 -
gdb/gdbserver/ChangeLog | 12 ++++++++++++
gdb/gdbserver/configure | 4 ++--
gdb/gdbserver/configure.ac | 2 +-
gdb/gdbserver/event-loop.c | 4 ----
gdb/gdbserver/hostio-errno.c | 1 -
gdb/gdbserver/linux-low.c | 1 -
gdb/gdbserver/remote-utils.c | 3 ---
gdb/gdbserver/server.h | 3 ---
gdb/gdbserver/spu-low.c | 1 -
gdb/gdbserver/utils.c | 3 ---
gdb/gnu-nat.c | 1 -
gdb/go32-nat.c | 1 -
gdb/i386gnu-nat.c | 1 -
gdb/m2-typeprint.c | 1 -
gdb/nat/linux-btrace.c | 1 -
gdb/p-typeprint.c | 1 -
gdb/procfs.c | 1 -
gdb/remote-sim.c | 1 -
gdb/rs6000-nat.c | 1 -
gdb/target.c | 1 -
gdb/typeprint.c | 1 -
gdb/ui-file.c | 2 --
gdb/valops.c | 1 -
gdb/valprint.c | 2 --
37 files changed, 52 insertions(+), 46 deletions(-)
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index a43ced7..305e39c 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -32,9 +32,7 @@
#include "c-lang.h"
#include "typeprint.h"
#include "ada-lang.h"
-
#include <ctype.h>
-#include <errno.h>
static int print_selected_record_field_types (struct type *, struct type *,
int, int,
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 5239505..374c90e 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -31,7 +31,6 @@
#include "typeprint.h"
#include "cp-abi.h"
#include "jv-lang.h"
-#include <errno.h>
#include "cp-support.h"
static void c_type_print_varspec_prefix (struct type *,
diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h
index 7c67846..964b006 100644
--- a/gdb/common/common-defs.h
+++ b/gdb/common/common-defs.h
@@ -32,6 +32,9 @@
#include <stdarg.h>
#include <stddef.h>
#include <string.h>
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
#include "ansidecl.h"
#include "libiberty.h"
#include "pathmax.h"
diff --git a/gdb/common/common.m4 b/gdb/common/common.m4
index 426df79..d6406ec 100644
--- a/gdb/common/common.m4
+++ b/gdb/common/common.m4
@@ -28,7 +28,7 @@ AC_DEFUN([GDB_AC_COMMON], [
AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl
sys/resource.h sys/socket.h sys/syscall.h dnl
sys/un.h sys/wait.h dnl
- thread_db.h wait.h)
+ thread_db.h wait.h errno.h)
AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair])
diff --git a/gdb/config.in b/gdb/config.in
index fb9b0cd..e592050 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -129,6 +129,9 @@
/* Define to 1 if you have the <elf_hp.h> header file. */
#undef HAVE_ELF_HP_H
+/* Define to 1 if you have the <errno.h> header file. */
+#undef HAVE_ERRNO_H
+
/* Define to 1 if your system has the etext variable. */
#undef HAVE_ETEXT
diff --git a/gdb/configure b/gdb/configure
index 809326a..caf970f 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -11003,7 +11003,7 @@ $as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h
fi
- for ac_header in linux/perf_event.h locale.h memory.h signal.h sys/resource.h sys/socket.h sys/syscall.h sys/un.h sys/wait.h thread_db.h wait.h
+ for ac_header in linux/perf_event.h locale.h memory.h signal.h sys/resource.h sys/socket.h sys/syscall.h sys/un.h sys/wait.h thread_db.h wait.h errno.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
diff --git a/gdb/core-regset.c b/gdb/core-regset.c
index 6edc8c5..bdcb72a 100644
--- a/gdb/core-regset.c
+++ b/gdb/core-regset.c
@@ -34,7 +34,6 @@
#include "regcache.h"
#include <fcntl.h>
-#include <errno.h>
#include <time.h>
#ifdef HAVE_SYS_PROCFS_H
#include <sys/procfs.h>
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 1eaecb5..2b5ed13 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
-#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include "inferior.h"
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 1c9a93d..b5958d6 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -19,7 +19,6 @@
#include "defs.h"
#include "arch-utils.h"
-#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#ifdef HAVE_SYS_FILE_H
diff --git a/gdb/defs.h b/gdb/defs.h
index 710298c..b7271a7 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -28,7 +28,6 @@
#include "common-defs.h"
#include <sys/types.h>
-#include <errno.h> /* System call error return status. */
#include <limits.h>
#include <stdint.h>
diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index cc2f837..e40187e 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -31,7 +31,6 @@
#endif
#include <sys/types.h>
-#include <errno.h>
#include <sys/time.h>
#include "exceptions.h"
#include "gdb_select.h"
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 534019a..7474051 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -30,7 +30,6 @@
#include "gdbcore.h"
#include "target.h"
#include "f-lang.h"
-#include <errno.h>
#if 0 /* Currently unused. */
static void f_type_print_args (struct type *, struct ui_file *);
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 5f8dcd2..b341a89 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -4904,7 +4904,7 @@ $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cach
cd "$ac_popdir"
-for ac_header in sgtty.h termio.h termios.h sys/reg.h string.h proc_service.h sys/procfs.h linux/elf.h errno.h fcntl.h signal.h sys/file.h malloc.h sys/ioctl.h netinet/in.h sys/socket.h netdb.h netinet/tcp.h arpa/inet.h
+for ac_header in sgtty.h termio.h termios.h sys/reg.h string.h proc_service.h sys/procfs.h linux/elf.h fcntl.h signal.h sys/file.h malloc.h sys/ioctl.h netinet/in.h sys/socket.h netdb.h netinet/tcp.h arpa/inet.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -5271,7 +5271,7 @@ $as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h
fi
- for ac_header in linux/perf_event.h locale.h memory.h signal.h sys/resource.h sys/socket.h sys/syscall.h sys/un.h sys/wait.h thread_db.h wait.h
+ for ac_header in linux/perf_event.h locale.h memory.h signal.h sys/resource.h sys/socket.h sys/syscall.h sys/un.h sys/wait.h thread_db.h wait.h errno.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 67866f8..8e5d74f 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -82,7 +82,7 @@ ACX_CONFIGURE_DIR(["../../libiberty"], ["build-libiberty-gdbserver"])
AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
proc_service.h sys/procfs.h linux/elf.h dnl
- errno.h fcntl.h signal.h sys/file.h malloc.h dnl
+ fcntl.h signal.h sys/file.h malloc.h dnl
sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
netinet/tcp.h arpa/inet.h)
AC_CHECK_FUNCS(pread pwrite pread64 readlink)
diff --git a/gdb/gdbserver/event-loop.c b/gdb/gdbserver/event-loop.c
index 1513b59..92c8db0 100644
--- a/gdb/gdbserver/event-loop.c
+++ b/gdb/gdbserver/event-loop.c
@@ -29,10 +29,6 @@
#include <io.h>
#endif
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-
#include <unistd.h>
typedef struct gdb_event gdb_event;
diff --git a/gdb/gdbserver/hostio-errno.c b/gdb/gdbserver/hostio-errno.c
index 8817096..f24b51f 100644
--- a/gdb/gdbserver/hostio-errno.c
+++ b/gdb/gdbserver/hostio-errno.c
@@ -22,7 +22,6 @@
on top of errno. */
#include "server.h"
-#include <errno.h>
#include "gdb/fileio.h"
static int
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 74289c0..f71a4de 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -31,7 +31,6 @@
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
-#include <errno.h>
#include <sys/syscall.h>
#include <sched.h>
#include <ctype.h>
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index f3ae393..327677a 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -56,9 +56,6 @@
#include <arpa/inet.h>
#endif
#include <sys/stat.h>
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
#if USE_WIN32API
#include <winsock2.h>
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h
index 1e2c3a1..db6ddde 100644
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -27,9 +27,6 @@
#include "version.h"
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
#include <setjmp.h>
#ifdef HAVE_ALLOCA_H
diff --git a/gdb/gdbserver/spu-low.c b/gdb/gdbserver/spu-low.c
index cb1ac0d..867f97b 100644
--- a/gdb/gdbserver/spu-low.c
+++ b/gdb/gdbserver/spu-low.c
@@ -24,7 +24,6 @@
#include <sys/ptrace.h>
#include <fcntl.h>
#include <unistd.h>
-#include <errno.h>
#include <sys/syscall.h>
#include "filestuff.h"
#include "hostio.h"
diff --git a/gdb/gdbserver/utils.c b/gdb/gdbserver/utils.c
index ec37a9b..b011637 100644
--- a/gdb/gdbserver/utils.c
+++ b/gdb/gdbserver/utils.c
@@ -17,9 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "server.h"
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
#ifdef IN_PROCESS_AGENT
# define PREFIX "ipa: "
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index d6658c7..c8164d6 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -23,7 +23,6 @@
#include "defs.h"
#include <ctype.h>
-#include <errno.h>
#include <limits.h>
#include <setjmp.h>
#include <signal.h>
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 75596a2..727f810 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -105,7 +105,6 @@
#include "inf-child.h"
#include <ctype.h>
-#include <errno.h>
#include <unistd.h>
#include <sys/utsname.h>
#include <io.h>
diff --git a/gdb/i386gnu-nat.c b/gdb/i386gnu-nat.c
index 94d2a0a..8fad871 100644
--- a/gdb/i386gnu-nat.c
+++ b/gdb/i386gnu-nat.c
@@ -22,7 +22,6 @@
#include "floatformat.h"
#include "regcache.h"
-#include <errno.h>
#include <mach.h>
#include <mach_error.h>
#include <mach/message.h>
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index 45bc093..72c107b 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -31,7 +31,6 @@
#include "c-lang.h"
#include "typeprint.h"
#include "cp-abi.h"
-#include <errno.h>
static void m2_print_bounds (struct type *type,
struct ui_file *stream, int show, int level,
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index 19e218e..f6fdbda 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -37,7 +37,6 @@
#if HAVE_LINUX_PERF_EVENT_H && defined(SYS_perf_event_open)
-#include <errno.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/mman.h>
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 6870cdf..b1e16f0 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -31,7 +31,6 @@
#include "p-lang.h"
#include "typeprint.h"
#include "gdb-demangle.h"
-#include <errno.h>
#include <ctype.h>
static void pascal_type_print_varspec_suffix (struct type *, struct ui_file *,
diff --git a/gdb/procfs.c b/gdb/procfs.c
index d93843a..3465bc5 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -42,7 +42,6 @@
#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h>
#endif
-#include <sys/errno.h>
#include "gdb_wait.h"
#include <signal.h>
#include <ctype.h>
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index e26a971..b8974e1 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -28,7 +28,6 @@
#include <fcntl.h>
#include <signal.h>
#include <setjmp.h>
-#include <errno.h>
#include "terminal.h"
#include "target.h"
#include "gdbcore.h"
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 4ba955c..1b09680 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -46,7 +46,6 @@
#include <signal.h>
#include <sys/ioctl.h>
#include <fcntl.h>
-#include <errno.h>
#include <a.out.h>
#include <sys/file.h>
diff --git a/gdb/target.c b/gdb/target.c
index ec1db3e..b784b05 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -20,7 +20,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
-#include <errno.h>
#include "target.h"
#include "target-dcache.h"
#include "gdbcmd.h"
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index e0b7c44..3d8620a 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -33,7 +33,6 @@
#include "typeprint.h"
#include "exceptions.h"
#include "valprint.h"
-#include <errno.h>
#include <ctype.h>
#include "cli/cli-utils.h"
#include "extension.h"
diff --git a/gdb/ui-file.c b/gdb/ui-file.c
index 767b55b..49607dc 100644
--- a/gdb/ui-file.c
+++ b/gdb/ui-file.c
@@ -25,8 +25,6 @@
#include "gdb_select.h"
#include "filestuff.h"
-#include <errno.h>
-
static ui_file_isatty_ftype null_file_isatty;
static ui_file_write_ftype null_file_write;
static ui_file_write_ftype null_file_write_async_safe;
diff --git a/gdb/valops.c b/gdb/valops.c
index 5ef763d..d9ce2f2 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -36,7 +36,6 @@
#include "cp-support.h"
#include "dfp.h"
#include "tracepoint.h"
-#include <errno.h>
#include "observer.h"
#include "objfiles.h"
#include "exceptions.h"
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 0ded6b7..d3ab267 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -37,8 +37,6 @@
#include "charset.h"
#include <ctype.h>
-#include <errno.h>
-
/* Maximum number of wchars returned from wchar_iterate. */
#define MAX_WCHARS 4
--
1.7.1