From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7752A383FD51 for ; Tue, 6 Dec 2022 16:36:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7752A383FD51 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670344579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3y9uc01I0lQpEADmWhGEjQaykAHDlEwvpKkiJMt+KG4=; b=V6DPdHQAdkDt+0gNI8KKGirbokJKLy3NBVMFnef7N+r5IQ9h5MQZAE4223QAy+bdwXxQkd lgIBjrrTQ0JrlV0y3yq7foktDcSgzXuWcnZKkOJdJztD3Qv+XBo8/vdtpvKW4nyzI/oHMq oQZoDn1GallE/NLoHD6fXXRKdVCPbUg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-626-iIaQ5WoGNTeDlnu5CgI50A-1; Tue, 06 Dec 2022 11:36:17 -0500 X-MC-Unique: iIaQ5WoGNTeDlnu5CgI50A-1 Received: by mail-wm1-f70.google.com with SMTP id v125-20020a1cac83000000b003cfa148576dso8660422wme.3 for ; Tue, 06 Dec 2022 08:36:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3y9uc01I0lQpEADmWhGEjQaykAHDlEwvpKkiJMt+KG4=; b=eRl5eoJoslAWrxyqgEsoIUMtvJVkpqHu9GvDjMp+y0cxx9NFjHm8Z/nBbTAxAnK71B 1XqbtiGYMtNqAvmzr/3zZ0S43zDZ6ciX4blHPY1EBxmFIMEk+SZpYaDwZfYJ31cFIohy mlyYRBSDB5/4inVZjdaJU7MKpm2LaN8wdqM4FS7u5o+5gQ2YF8QNCIqWMaeuhKG44TXx UNae+EVbyevMfgESYIySMjP5kRNJrKtcXl4dqDw9LjP//gk2iP4wSs0koKX3Ua5vu/E8 K+BzD772teKrnSenKfDZi3tf45aXV6wSdMV7gLypHbxA530cCc4jPG5lz9huC/j8Gw4S ZbqQ== X-Gm-Message-State: ANoB5pm+plt7ljPs5wbdUft63qmem3Bohy7WADEXCvBljHb1DNnpe733 p79xgVroJK6iYtz5B0/LQEHS25JnFE0vTSHWi6rZkRft/RCT1ZPSdMH5afmZUVEFkBrGQ3BH3jq fvfb+SFXs4FF2mH99TVUpqqGPQFjaAsBsPf1AiO3QfemQAJJG84lOJJaXodf3xSriRuel/WfETg == X-Received: by 2002:a05:6000:124d:b0:242:10a:6667 with SMTP id j13-20020a056000124d00b00242010a6667mr36375093wrx.39.1670344576606; Tue, 06 Dec 2022 08:36:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf4JUfUHxtcDT2QairwBMvCofbLLRJWlQvXeLKJQxq5s15+2Xe3oTGR9MD/hsEf3htT7uWaVUw== X-Received: by 2002:a05:6000:124d:b0:242:10a:6667 with SMTP id j13-20020a056000124d00b00242010a6667mr36375067wrx.39.1670344576219; Tue, 06 Dec 2022 08:36:16 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id t2-20020a5d42c2000000b002365b759b65sm17121750wrr.86.2022.12.06.08.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 08:36:15 -0800 (PST) From: Andrew Burgess To: Simon Marchi via Gdb-patches , gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH 03/12] gdbsupport: add type definitions for pid, lwp and tid In-Reply-To: <20221206135729.3937767-4-simon.marchi@efficios.com> References: <20221206135729.3937767-1-simon.marchi@efficios.com> <20221206135729.3937767-4-simon.marchi@efficios.com> Date: Tue, 06 Dec 2022 16:36:14 +0000 Message-ID: <874ju84hhd.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 List-Id: Simon Marchi via Gdb-patches writes: > A following patch will want to declare variables of the same time as typo: s/time/type/ > 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. Sounds good. Now we just need to slowly convert the rest of GDB to use these types :) LGTM. Thanks, Andrew > > 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. */ > -- > 2.38.1