[14/13] Move errno.h to common-defs.h
Commit Message
Hi all,
An addendum to my previous series...
This commit moves the inclusion of errno.h to common-defs.h and
removes all other inclusions. Note that prior to this commit errno.h
was included unconditionally in defs.h, whereas in common-defs.h it is
protected by "#ifdef HAVE_ERRNO_H". This does not change the status
quo, since presumably every platform on which GDB builds has errno.h.
Is this ok to commit?
Thanks,
Gary
--
gdb/
2014-07-30 Gary Benson <gbenson@redhat.com>
* configure.ac (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-30 Gary Benson <gbenson@redhat.com>
* 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/config.in | 3 +++
gdb/configure | 2 +-
gdb/configure.ac | 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 | 10 ++++++++++
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 --
35 files changed, 47 insertions(+), 43 deletions(-)
Comments
>>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:
Gary> This commit moves the inclusion of errno.h to common-defs.h and
Gary> removes all other inclusions. Note that prior to this commit errno.h
Gary> was included unconditionally in defs.h, whereas in common-defs.h it is
Gary> protected by "#ifdef HAVE_ERRNO_H". This does not change the status
Gary> quo, since presumably every 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.
Tom
On 07/31/2014 02:46 AM, Tom Tromey wrote:
>>>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:
>
> Gary> This commit moves the inclusion of errno.h to common-defs.h and
> Gary> removes all other inclusions. Note that prior to this commit errno.h
> Gary> was included unconditionally in defs.h, whereas in common-defs.h it is
> Gary> protected by "#ifdef HAVE_ERRNO_H". This does not change the status
> Gary> quo, since presumably every 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.
That's actually not a good justification. We should always check the
history of why the check is on the gdb or gdbserver side. That's
because the set of hosts/ports supported by either side is not a strict
superset of the other side.
The checks for HAVE_ERRNO_H on the gdbserver side were added for the
Windows CE port (as git blame/log will show -- 68070c10). There's no native
gdb Windows CE, so it didn't need that. That said, the CE port is broken
for other (similar) reasons. E.g., the CE port predated use of both libiberty
and gnulib in gdbserver, and libiberty unconditionally includes errno.h as
well, for example. I don't think we should completely nuke the port because
most of the arch abstractions in the Windows target side are needed for
Windows (NT) on ARM anyway, but it's super fine with me to not have it prevent
modernization of the core code base. (If someone were to fix the port, she
just somehow come up with an errno.h replacement and make it available to
all of the build, including libiberty, which doesn't use gnulib.)
> Also I believe it is pulled into gnulib as
> a dependency of some other module; though you'd probably want to check
> this.
Yeah, I think so.
>
> If you go this route then I guess it would be nice to remove errno.h
> checks instead.
Let's do that.
@@ -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,
@@ -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 *,
@@ -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"
@@ -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
@@ -9417,7 +9417,7 @@ for ac_header in nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \
sys/reg.h sys/debugreg.h sys/select.h sys/syscall.h \
termios.h termio.h \
sgtty.h elf_hp.h \
- dlfcn.h
+ dlfcn.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"
@@ -1274,7 +1274,7 @@ AC_CHECK_HEADERS([nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \
sys/reg.h sys/debugreg.h sys/select.h sys/syscall.h \
termios.h termio.h \
sgtty.h elf_hp.h \
- dlfcn.h])
+ dlfcn.h errno.h])
AC_CHECK_HEADERS(sys/proc.h, [], [],
[#if HAVE_SYS_PARAM_H
# include <sys/param.h>
@@ -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>
@@ -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"
@@ -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
@@ -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>
@@ -31,7 +31,6 @@
#endif
#include <sys/types.h>
-#include <errno.h>
#include <sys/time.h>
#include "exceptions.h"
#include "gdb_select.h"
@@ -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 *);
@@ -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;
@@ -22,7 +22,6 @@
on top of errno. */
#include "server.h"
-#include <errno.h>
#include "gdb/fileio.h"
static int
@@ -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>
@@ -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>
@@ -27,9 +27,6 @@
#include "version.h"
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
#include <setjmp.h>
#ifdef HAVE_ALLOCA_H
@@ -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"
@@ -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: "
@@ -23,7 +23,6 @@
#include "defs.h"
#include <ctype.h>
-#include <errno.h>
#include <limits.h>
#include <setjmp.h>
#include <signal.h>
@@ -105,7 +105,6 @@
#include "inf-child.h"
#include <ctype.h>
-#include <errno.h>
#include <unistd.h>
#include <sys/utsname.h>
#include <io.h>
@@ -22,7 +22,6 @@
#include "floatformat.h"
#include "regcache.h"
-#include <errno.h>
#include <mach.h>
#include <mach_error.h>
#include <mach/message.h>
@@ -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,
@@ -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>
@@ -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 *,
@@ -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>
@@ -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"
@@ -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>
@@ -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"
@@ -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"
@@ -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;
@@ -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"
@@ -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