GDB (API)
/home/stan/gdb/src/gdb/common/ptid.c
Go to the documentation of this file.
00001 /* The ptid_t type and common functions operating on it.
00002 
00003    Copyright (C) 1986-2013 Free Software Foundation, Inc.
00004    
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #include "ptid.h"
00021 
00022 /* See ptid.h for these.  */
00023 
00024 ptid_t null_ptid = { 0, 0, 0 };
00025 ptid_t minus_one_ptid = { -1, 0, 0 };
00026 
00027 /* See ptid.h.  */
00028 
00029 ptid_t
00030 ptid_build (int pid, long lwp, long tid)
00031 {
00032   ptid_t ptid;
00033 
00034   ptid.pid = pid;
00035   ptid.lwp = lwp;
00036   ptid.tid = tid;
00037   return ptid;
00038 }
00039 
00040 /* See ptid.h.  */
00041 
00042 ptid_t
00043 pid_to_ptid (int pid)
00044 {
00045   return ptid_build (pid, 0, 0);
00046 }
00047 
00048 /* See ptid.h.  */
00049 
00050 int
00051 ptid_get_pid (ptid_t ptid)
00052 {
00053   return ptid.pid;
00054 }
00055 
00056 /* See ptid.h.  */
00057 
00058 long
00059 ptid_get_lwp (ptid_t ptid)
00060 {
00061   return ptid.lwp;
00062 }
00063 
00064 /* See ptid.h.  */
00065 
00066 long
00067 ptid_get_tid (ptid_t ptid)
00068 {
00069   return ptid.tid;
00070 }
00071 
00072 /* See ptid.h.  */
00073 
00074 int
00075 ptid_equal (ptid_t ptid1, ptid_t ptid2)
00076 {
00077   return (ptid1.pid == ptid2.pid
00078           && ptid1.lwp == ptid2.lwp
00079           && ptid1.tid == ptid2.tid);
00080 }
00081 
00082 /* See ptid.h.  */
00083 
00084 int
00085 ptid_is_pid (ptid_t ptid)
00086 {
00087   if (ptid_equal (minus_one_ptid, ptid)
00088       || ptid_equal (null_ptid, ptid))
00089     return 0;
00090 
00091   return (ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) == 0);
00092 }
00093 
00094 /* See ptid.h.  */
00095 
00096 int
00097 ptid_lwp_p (ptid_t ptid)
00098 {
00099   if (ptid_equal (minus_one_ptid, ptid)
00100       || ptid_equal (null_ptid, ptid))
00101     return 0;
00102 
00103   return (ptid_get_lwp (ptid) != 0);
00104 }
00105 
00106 /* See ptid.h.  */
00107 
00108 int
00109 ptid_tid_p (ptid_t ptid)
00110 {
00111   if (ptid_equal (minus_one_ptid, ptid)
00112       || ptid_equal (null_ptid, ptid))
00113     return 0;
00114 
00115   return (ptid_get_tid (ptid) != 0);
00116 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines