Fix elf64-ppc.c electric fence warning
[deliverable/binutils-gdb.git] / gdb / common / ptid.c
index e8d25c02d1895529b299156b189e1ac0a5e636e6..deaea6b30aa563e668a22d00ed1bfcba28d3d280 100644 (file)
@@ -1,6 +1,6 @@
 /* The ptid_t type and common functions operating on it.
 
-   Copyright (C) 1986-2013 Free Software Foundation, Inc.
+   Copyright (C) 1986-2015 Free Software Foundation, Inc.
    
    This file is part of GDB.
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include "common-defs.h"
 #include "ptid.h"
 
-/* Oft used ptids */
+/* See ptid.h for these.  */
+
 ptid_t null_ptid = { 0, 0, 0 };
 ptid_t minus_one_ptid = { -1, 0, 0 };
 
-/* Create a ptid given the necessary PID, LWP, and TID components.  */
+/* See ptid.h.  */
 
 ptid_t
 ptid_build (int pid, long lwp, long tid)
@@ -36,7 +38,7 @@ ptid_build (int pid, long lwp, long tid)
   return ptid;
 }
 
-/* Create a ptid from just a pid.  */
+/* See ptid.h.  */
 
 ptid_t
 pid_to_ptid (int pid)
@@ -44,7 +46,7 @@ pid_to_ptid (int pid)
   return ptid_build (pid, 0, 0);
 }
 
-/* Fetch the pid (process id) component from a ptid.  */
+/* See ptid.h.  */
 
 int
 ptid_get_pid (ptid_t ptid)
@@ -52,7 +54,7 @@ ptid_get_pid (ptid_t ptid)
   return ptid.pid;
 }
 
-/* Fetch the lwp (lightweight process) component from a ptid.  */
+/* See ptid.h.  */
 
 long
 ptid_get_lwp (ptid_t ptid)
@@ -60,7 +62,7 @@ ptid_get_lwp (ptid_t ptid)
   return ptid.lwp;
 }
 
-/* Fetch the tid (thread id) component from a ptid.  */
+/* See ptid.h.  */
 
 long
 ptid_get_tid (ptid_t ptid)
@@ -68,7 +70,7 @@ ptid_get_tid (ptid_t ptid)
   return ptid.tid;
 }
 
-/* ptid_equal() is used to test equality of two ptids.  */
+/* See ptid.h.  */
 
 int
 ptid_equal (ptid_t ptid1, ptid_t ptid2)
@@ -78,7 +80,7 @@ ptid_equal (ptid_t ptid1, ptid_t ptid2)
          && ptid1.tid == ptid2.tid);
 }
 
-/* Returns true if PTID represents a process.  */
+/* See ptid.h.  */
 
 int
 ptid_is_pid (ptid_t ptid)
@@ -90,7 +92,7 @@ ptid_is_pid (ptid_t ptid)
   return (ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) == 0);
 }
 
-/* Returns true if PTID represents a lwp.  */
+/* See ptid.h.  */
 
 int
 ptid_lwp_p (ptid_t ptid)
@@ -102,7 +104,7 @@ ptid_lwp_p (ptid_t ptid)
   return (ptid_get_lwp (ptid) != 0);
 }
 
-/* Returns true if PTID represents a tid.  */
+/* See ptid.h.  */
 
 int
 ptid_tid_p (ptid_t ptid)
@@ -113,3 +115,17 @@ ptid_tid_p (ptid_t ptid)
 
   return (ptid_get_tid (ptid) != 0);
 }
+
+int
+ptid_match (ptid_t ptid, ptid_t filter)
+{
+  if (ptid_equal (filter, minus_one_ptid))
+    return 1;
+  if (ptid_is_pid (filter)
+      && ptid_get_pid (ptid) == ptid_get_pid (filter))
+    return 1;
+  else if (ptid_equal (ptid, filter))
+    return 1;
+
+  return 0;
+}
This page took 0.026104 seconds and 4 git commands to generate.