From patchwork Tue Dec 6 13:57:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 61553 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E9685383FD54 for ; Tue, 6 Dec 2022 13:59:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9685383FD54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670335142; bh=d1wteO8K83b7lrIf+lumjMcchCNjUbBUYBOeRaQlpXg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=OvvP3rG+z6OP+jaaIsg5QmG11lkY5e+5tAn4nWPkSd2GCL0OfvmypsOZgLgXdQknr VHGo8D9tspck4p+7195adZZ520ypXF/1BY7gSn1TKoN+8GsukRP/1fWy3hBd+KGLTk WQ8vSKrdmf5ngmkHyhx6A/+Z6wtvNMxh0pmyuEgw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 1807A3864A2F for ; Tue, 6 Dec 2022 13:57:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1807A3864A2F X-ASG-Debug-ID: 1670335052-0c856e762a1bad0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id RMMUA10xZLDmXlVj (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Tue, 06 Dec 2022 08:57:32 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 3F76C441D65; Tue, 6 Dec 2022 08:57:32 -0500 (EST) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 03/12] gdbsupport: add type definitions for pid, lwp and tid Date: Tue, 6 Dec 2022 08:57:20 -0500 X-ASG-Orig-Subj: [PATCH 03/12] gdbsupport: add type definitions for pid, lwp and tid Message-Id: <20221206135729.3937767-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206135729.3937767-1-simon.marchi@efficios.com> References: <20221206135729.3937767-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1670335052 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2481 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.102644 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" A following patch will want to declare variables of the same time as some ptid_t components. To make that easy (and avoid harcoding those types everywhere), define some type definitions in the ptid_t struct for each of them. Use them throughout ptid.h. I initially used pid_t, lwp_t and tid_t, but there is the risk of some system defining the pid_t type using a macro instead of a typedef, which would break things. So, use the _type suffix instead. Change-Id: I820b0bea9dafcb4914f1c9ba4bb96b5c666c8dec --- gdbsupport/ptid.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h index d66cd988459..6dcab984b99 100644 --- a/gdbsupport/ptid.h +++ b/gdbsupport/ptid.h @@ -39,6 +39,10 @@ class ptid_t { public: + using pid_type = int; + using lwp_type = long; + using tid_type = ULONGEST; + /* Must have a trivial defaulted default constructor so that the type remains POD. */ ptid_t () noexcept = default; @@ -48,13 +52,13 @@ class ptid_t A ptid with only a PID (LWP and TID equal to zero) is usually used to represent a whole process, including all its lwps/threads. */ - explicit constexpr ptid_t (int pid, long lwp = 0, ULONGEST tid = 0) + explicit constexpr ptid_t (pid_type pid, lwp_type lwp = 0, tid_type tid = 0) : m_pid (pid), m_lwp (lwp), m_tid (tid) {} /* Fetch the pid (process id) component from the ptid. */ - constexpr int pid () const + constexpr pid_type pid () const { return m_pid; } /* Return true if the ptid's lwp member is non-zero. */ @@ -64,7 +68,7 @@ class ptid_t /* Fetch the lwp (lightweight process) component from the ptid. */ - constexpr long lwp () const + constexpr lwp_type lwp () const { return m_lwp; } /* Return true if the ptid's tid member is non-zero. */ @@ -74,7 +78,7 @@ class ptid_t /* Fetch the tid (thread id) component from a ptid. */ - constexpr ULONGEST tid () const + constexpr tid_type tid () const { return m_tid; } /* Return true if the ptid represents a whole process, including all its @@ -144,13 +148,13 @@ class ptid_t private: /* Process id. */ - int m_pid; + pid_type m_pid; /* Lightweight process id. */ - long m_lwp; + lwp_type m_lwp; /* Thread id. */ - ULONGEST m_tid; + tid_type m_tid; }; /* Functor to hash a ptid. */