replace convert_int_to_ascii with bin2hex
[deliverable/binutils-gdb.git] / gdb / common / ptid.c
CommitLineData
d26e3629
KY
1/* The ptid_t type and common functions operating on it.
2
ecd75fc8 3 Copyright (C) 1986-2014 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
9a2c3737
PA
22/* See ptid.h for these. */
23
d26e3629
KY
24ptid_t null_ptid = { 0, 0, 0 };
25ptid_t minus_one_ptid = { -1, 0, 0 };
26
9a2c3737 27/* See ptid.h. */
d26e3629
KY
28
29ptid_t
30ptid_build (int pid, long lwp, long tid)
31{
32 ptid_t ptid;
33
34 ptid.pid = pid;
35 ptid.lwp = lwp;
36 ptid.tid = tid;
37 return ptid;
38}
39
9a2c3737 40/* See ptid.h. */
d26e3629
KY
41
42ptid_t
43pid_to_ptid (int pid)
44{
45 return ptid_build (pid, 0, 0);
46}
47
9a2c3737 48/* See ptid.h. */
d26e3629
KY
49
50int
51ptid_get_pid (ptid_t ptid)
52{
53 return ptid.pid;
54}
55
9a2c3737 56/* See ptid.h. */
d26e3629
KY
57
58long
59ptid_get_lwp (ptid_t ptid)
60{
61 return ptid.lwp;
62}
63
9a2c3737 64/* See ptid.h. */
d26e3629
KY
65
66long
67ptid_get_tid (ptid_t ptid)
68{
69 return ptid.tid;
70}
71
9a2c3737 72/* See ptid.h. */
d26e3629
KY
73
74int
75ptid_equal (ptid_t ptid1, ptid_t ptid2)
76{
77 return (ptid1.pid == ptid2.pid
78 && ptid1.lwp == ptid2.lwp
79 && ptid1.tid == ptid2.tid);
80}
81
9a2c3737 82/* See ptid.h. */
d26e3629
KY
83
84int
85ptid_is_pid (ptid_t ptid)
86{
dfd4cc63
LM
87 if (ptid_equal (minus_one_ptid, ptid)
88 || ptid_equal (null_ptid, ptid))
d26e3629
KY
89 return 0;
90
91 return (ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) == 0);
92}
dfd4cc63 93
9a2c3737 94/* See ptid.h. */
dfd4cc63
LM
95
96int
97ptid_lwp_p (ptid_t ptid)
98{
99 if (ptid_equal (minus_one_ptid, ptid)
100 || ptid_equal (null_ptid, ptid))
101 return 0;
102
103 return (ptid_get_lwp (ptid) != 0);
104}
105
9a2c3737 106/* See ptid.h. */
dfd4cc63
LM
107
108int
109ptid_tid_p (ptid_t ptid)
110{
111 if (ptid_equal (minus_one_ptid, ptid)
112 || ptid_equal (null_ptid, ptid))
113 return 0;
114
115 return (ptid_get_tid (ptid) != 0);
116}
This page took 0.297125 seconds and 4 git commands to generate.