aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
authorPierre Muller <muller@sourceware.org>2012-11-15 16:12:19 +0000
committerPierre Muller <muller@sourceware.org>2012-11-15 16:12:19 +0000
commit8bdce1ffdf65dc18332dfddb39482f6685cec85a (patch)
treebaf333dd105f99f14a4b4ebfca4f91e0a76eba29 /gdb/common
parent3a731e0fc7b80a274d4a34fed7ed41d6f35f1e51 (diff)
downloadgdb-8bdce1ffdf65dc18332dfddb39482f6685cec85a.zip
gdb-8bdce1ffdf65dc18332dfddb39482f6685cec85a.tar.gz
gdb-8bdce1ffdf65dc18332dfddb39482f6685cec85a.tar.bz2
2012-11-15 Pierre Muller <muller@sourceware.org>
ARI fixes: move gdb_wait and gdb_stat headers to common subdirectory. * gdb_stat.h: Delete. Moved to common directory. * common/gdb_stat.h: New file. * gdb_wait.h: Delete. Moved to common directory. * common/gdb_wait.h: New file. * Makefile.in (H_FILES_NO_SRC): Adapt to new header location. * contrib/ari/gdb_ari.sh (wait.h rule): Adapt to new gdb_wait.h location. (stat.h rule): Adapt to new gdb_stat.h location. * common/linux-osdata.c: Include "gdb_stat.h" header instead of <sys/stat.h> header. * common/linux-ptrace.c: Include "gdb_wait.h" header instead of <sys/wait.h> header. gdbserver ChangeLog entry: 2012-11-15 Pierre Muller <muller@sourceware.org> * configure.ac (AC_CHECK_HEADERS): Add wait.h header. * config.in: Regenerate. * configure: Regenerate. * linux-low.c: Use "gdb_stat.h" header instead of <sys/stat.h> header. Use "gdb_wait.h" header instead of <sys/wait.h> header. * lynx-low.c: Use "gdb_wait.h" header instead of <sys/wait.h> header. * remote-utils.c: Use "gdb_stat.h" header instead of <sys/stat.h> header. * server.c: Remove HAVE_WAIT_H conditional. Use "gdb_wait.h" header instead of <sys/wait.h> header. * spu-low.c: Use "gdb_wait.h" header instead of <sys/wait.h> header.
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/gdb_stat.h59
-rw-r--r--gdb/common/gdb_wait.h113
-rw-r--r--gdb/common/linux-osdata.c2
-rw-r--r--gdb/common/linux-ptrace.c2
4 files changed, 174 insertions, 2 deletions
diff --git a/gdb/common/gdb_stat.h b/gdb/common/gdb_stat.h
new file mode 100644
index 0000000..51e2e56
--- /dev/null
+++ b/gdb/common/gdb_stat.h
@@ -0,0 +1,59 @@
+/* Portable <sys/stat.h>
+ Copyright (C) 1995, 2007-2012 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#if !defined(GDB_STAT_H)
+#define GDB_STAT_H
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if !defined(S_ISBLK) && defined(S_IFBLK)
+#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+#endif
+#if !defined(S_ISCHR) && defined(S_IFCHR)
+#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+#endif
+#if !defined(S_ISDIR) && defined(S_IFDIR)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+#if !defined(S_ISREG) && defined(S_IFREG)
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#endif
+#if !defined(S_ISFIFO) && defined(S_IFIFO)
+#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+#endif
+#if !defined(S_ISLNK) && defined(S_IFLNK)
+#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+#endif
+#if !defined(S_ISSOCK) && defined(S_IFSOCK)
+#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+#endif
+#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
+#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
+#define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
+#endif
+#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
+#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
+#endif
+
+/* Microsoft C's stat.h doesn't define all the POSIX file modes. */
+#ifndef S_IROTH
+#define S_IROTH S_IREAD
+#endif
+
+#endif /* !defined(GDB_STAT_H) */
diff --git a/gdb/common/gdb_wait.h b/gdb/common/gdb_wait.h
new file mode 100644
index 0000000..1d02f37
--- /dev/null
+++ b/gdb/common/gdb_wait.h
@@ -0,0 +1,113 @@
+/* Standard wait macros.
+ Copyright (C) 2000, 2007-2012 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef GDB_WAIT_H
+#define GDB_WAIT_H
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h> /* POSIX */
+#else
+#ifdef HAVE_WAIT_H
+#include <wait.h> /* legacy */
+#endif
+#endif
+
+/* Define how to access the int that the wait system call stores.
+ This has been compatible in all Unix systems since time immemorial,
+ but various well-meaning people have defined various different
+ words for the same old bits in the same old int (sometimes claimed
+ to be a struct). We just know it's an int and we use these macros
+ to access the bits. */
+
+/* The following macros are defined equivalently to their definitions
+ in POSIX.1. We fail to define WNOHANG and WUNTRACED, which POSIX.1
+ <sys/wait.h> defines, since our code does not use waitpid() (but
+ NOTE exception for GNU/Linux below). We also fail to declare
+ wait() and waitpid(). */
+
+#ifndef WIFEXITED
+#define WIFEXITED(w) (((w)&0377) == 0)
+#endif
+
+#ifndef WIFSIGNALED
+#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0)
+#endif
+
+#ifndef WIFSTOPPED
+#ifdef IBM6000
+
+/* Unfortunately, the above comment (about being compatible in all Unix
+ systems) is not quite correct for AIX, sigh. And AIX 3.2 can generate
+ status words like 0x57c (sigtrap received after load), and gdb would
+ choke on it. */
+
+#define WIFSTOPPED(w) ((w)&0x40)
+
+#else
+#define WIFSTOPPED(w) (((w)&0377) == 0177)
+#endif
+#endif
+
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */
+#endif
+
+#ifndef WTERMSIG
+#define WTERMSIG(w) ((w) & 0177)
+#endif
+
+#ifndef WSTOPSIG
+#define WSTOPSIG WEXITSTATUS
+#endif
+
+/* These are not defined in POSIX, but are used by our programs. */
+
+#ifndef WSETEXIT
+# ifdef W_EXITCODE
+#define WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
+# else
+#define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
+# endif
+#endif
+
+#ifndef WSETSTOP
+# ifdef W_STOPCODE
+#define WSETSTOP(w,sig) ((w) = W_STOPCODE(sig))
+# else
+#define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8)))
+# endif
+#endif
+
+/* For native GNU/Linux we may use waitpid and the __WCLONE option.
+ <GRIPE> It is of course dangerous not to use the REAL header file...
+ </GRIPE>. */
+
+/* Bits in the third argument to `waitpid'. */
+#ifndef WNOHANG
+#define WNOHANG 1 /* Don't block waiting. */
+#endif
+
+#ifndef WUNTRACED
+#define WUNTRACED 2 /* Report status of stopped children. */
+#endif
+
+#ifndef __WCLONE
+#define __WCLONE 0x80000000 /* Wait for cloned process. */
+#endif
+
+#endif
diff --git a/gdb/common/linux-osdata.c b/gdb/common/linux-osdata.c
index 0b1c5ac..afe3e75 100644
--- a/gdb/common/linux-osdata.c
+++ b/gdb/common/linux-osdata.c
@@ -26,7 +26,6 @@
#include "linux-osdata.h"
#include <sys/types.h>
-#include <sys/stat.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
@@ -43,6 +42,7 @@
#include "buffer.h"
#include "gdb_assert.h"
#include "gdb_dirent.h"
+#include "gdb_stat.h"
/* Define PID_T to be a fixed size that is at least as large as pid_t,
so that reading pid values embedded in /proc works
diff --git a/gdb/common/linux-ptrace.c b/gdb/common/linux-ptrace.c
index ae17786..55ba766 100644
--- a/gdb/common/linux-ptrace.c
+++ b/gdb/common/linux-ptrace.c
@@ -27,6 +27,7 @@
#include "linux-procfs.h"
#include "buffer.h"
#include "gdb_assert.h"
+#include "gdb_wait.h"
/* Find all possible reasons we could fail to attach PID and append these
newline terminated reason strings to initialized BUFFER. '\0' termination
@@ -57,7 +58,6 @@ extern void (linux_ptrace_test_ret_to_nx_instr) (void);
#include <sys/reg.h>
#include <sys/mman.h>
#include <signal.h>
-#include <sys/wait.h>
#include <stdint.h>
#endif /* defined __i386__ || defined __x86_64__ */