mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-08 08:33:13 +00:00
The ptid_t contructors, accessors and predicates are documented in
_three_ places, and each place uses a different wording.
E.g, the descriptions in the .c file of the new ptid_lwp_p, ptid_tid_p
weren't updated in the final revision like the descriptions in the .h
file were. Clearly, switching to a style that has a single central
description avoids such issues.
Worse, some of the existing descriptions are plain wrong, such as:
/* Attempt to find and return an existing ptid with the given PID, LWP,
and TID components. If none exists, create a new one and return
that. */
ptid_t ptid_build (int pid, long lwp, long tid);
The function does nothing that complicated. It's just a simple
constructor.
So this gets rid of all the unnecessary descriptions, leaving only the
ones near the function declarations in the header file, and
fixes/clarifies those that remain.
gdb/
2013-10-04 Pedro Alves <palves@redhat.com>
* common/ptid.c (null_ptid, minus_one_ptid, ptid_build)
(pid_to_ptid, ptid_get_pid, ptid_get_lwp, ptid_get_tid)
(ptid_equal, ptid_is_pid, ptid_lwp_p, ptid_tid_p): Replace
describing comments with references to ptid.h.
* common/ptid.h: Remove intro description of constructors,
accessors and predicates.
(struct ptid): Reformat.
(minus_one_ptid, ptid_build, pid_to_ptid, ptid_get_pid)
(ptid_get_lwp, ptid_get_tid, ptid_equal, ptid_is_pid): Change
describing comments.
117 lines
2.1 KiB
C
117 lines
2.1 KiB
C
/* The ptid_t type and common functions operating on it.
|
|
|
|
Copyright (C) 1986-2013 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);
|
|
}
|