* aarch64-linux-nat.c: Replace PIDGET with ptid_get_pid.
[deliverable/binutils-gdb.git] / gdb / common / ptid.c
CommitLineData
d26e3629
KY
1/* The ptid_t type and common functions operating on it.
2
28e7fd62 3 Copyright (C) 1986-2013 Free Software Foundation, Inc.
d26e3629
KY
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "ptid.h"
21
22/* Oft used ptids */
23ptid_t null_ptid = { 0, 0, 0 };
24ptid_t minus_one_ptid = { -1, 0, 0 };
25
26/* Create a ptid given the necessary PID, LWP, and TID components. */
27
28ptid_t
29ptid_build (int pid, long lwp, long tid)
30{
31 ptid_t ptid;
32
33 ptid.pid = pid;
34 ptid.lwp = lwp;
35 ptid.tid = tid;
36 return ptid;
37}
38
39/* Create a ptid from just a pid. */
40
41ptid_t
42pid_to_ptid (int pid)
43{
44 return ptid_build (pid, 0, 0);
45}
46
47/* Fetch the pid (process id) component from a ptid. */
48
49int
50ptid_get_pid (ptid_t ptid)
51{
52 return ptid.pid;
53}
54
55/* Fetch the lwp (lightweight process) component from a ptid. */
56
57long
58ptid_get_lwp (ptid_t ptid)
59{
60 return ptid.lwp;
61}
62
63/* Fetch the tid (thread id) component from a ptid. */
64
65long
66ptid_get_tid (ptid_t ptid)
67{
68 return ptid.tid;
69}
70
71/* ptid_equal() is used to test equality of two ptids. */
72
73int
74ptid_equal (ptid_t ptid1, ptid_t ptid2)
75{
76 return (ptid1.pid == ptid2.pid
77 && ptid1.lwp == ptid2.lwp
78 && ptid1.tid == ptid2.tid);
79}
80
81/* Returns true if PTID represents a process. */
82
83int
84ptid_is_pid (ptid_t ptid)
85{
dfd4cc63
LM
86 if (ptid_equal (minus_one_ptid, ptid)
87 || ptid_equal (null_ptid, ptid))
d26e3629
KY
88 return 0;
89
90 return (ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) == 0);
91}
dfd4cc63
LM
92
93/* Returns true if PTID represents a lwp. */
94
95int
96ptid_lwp_p (ptid_t ptid)
97{
98 if (ptid_equal (minus_one_ptid, ptid)
99 || ptid_equal (null_ptid, ptid))
100 return 0;
101
102 return (ptid_get_lwp (ptid) != 0);
103}
104
105/* Returns true if PTID represents a tid. */
106
107int
108ptid_tid_p (ptid_t ptid)
109{
110 if (ptid_equal (minus_one_ptid, ptid)
111 || ptid_equal (null_ptid, ptid))
112 return 0;
113
114 return (ptid_get_tid (ptid) != 0);
115}
This page took 0.219329 seconds and 4 git commands to generate.