1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/* The ptid_t type and common functions operating on it.
Copyright (C) 1986-2014 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/>. */
#include "ptid.h"
/* See ptid.h for these. */
ptid_t null_ptid = { 0, 0, 0 };
ptid_t minus_one_ptid = { -1, 0, 0 };
/* See ptid.h. */
ptid_t
ptid_build (int pid, long lwp, long tid)
{
ptid_t ptid;
ptid.pid = pid;
ptid.lwp = lwp;
ptid.tid = tid;
return ptid;
}
/* See ptid.h. */
ptid_t
pid_to_ptid (int pid)
{
return ptid_build (pid, 0, 0);
}
/* See ptid.h. */
int
ptid_get_pid (ptid_t ptid)
{
return ptid.pid;
}
/* See ptid.h. */
long
ptid_get_lwp (ptid_t ptid)
{
return ptid.lwp;
}
/* See ptid.h. */
long
ptid_get_tid (ptid_t ptid)
{
return ptid.tid;
}
/* See ptid.h. */
int
ptid_equal (ptid_t ptid1, ptid_t ptid2)
{
return (ptid1.pid == ptid2.pid
&& ptid1.lwp == ptid2.lwp
&& ptid1.tid == ptid2.tid);
}
/* See ptid.h. */
int
ptid_is_pid (ptid_t ptid)
{
if (ptid_equal (minus_one_ptid, ptid)
|| ptid_equal (null_ptid, ptid))
return 0;
return (ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) == 0);
}
/* See ptid.h. */
int
ptid_lwp_p (ptid_t ptid)
{
if (ptid_equal (minus_one_ptid, ptid)
|| ptid_equal (null_ptid, ptid))
return 0;
return (ptid_get_lwp (ptid) != 0);
}
/* See ptid.h. */
int
ptid_tid_p (ptid_t ptid)
{
if (ptid_equal (minus_one_ptid, ptid)
|| ptid_equal (null_ptid, ptid))
return 0;
return (ptid_get_tid (ptid) != 0);
}
|