From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by sourceware.org (Postfix) with ESMTPS id 52EBE385703F for ; Mon, 7 Jun 2021 22:20:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 52EBE385703F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f48.google.com with SMTP id e11so9107445wrg.3 for ; Mon, 07 Jun 2021 15:20:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=UfpiBZLmS86Im9MbIyQV9vI1PQg4WlV8dsjiDPvuCmk=; b=fRc+EjRYYKGMjgWbidRHEz9zoLfQDPyFPw4VCByKFEs1nIf70MJETCFJ+VuzUqi3Rn EDeWOCfpxVs5jGBy1UzTYgHxEdnYdVOsAmz43dyzGvAXgRZ/zjhZIs05GEGlCn1buTXJ mNZLhf4AElCQzMErhKvKR0V8WvYXDYd2zu5WTB5J+JPV4oIBi0de7i5r9UhtJTGKDoRE o2l6Cy/mpRaf6agJa0/EpRoV0X+BC0YaHp4lhUx+rfdAqM1mRxIIEzHlPXHaE8Dld0hE YDVX6dp3d1tujubm/mfLCqAnRtjHUWeSTa7NZGm8xjY/gXLMeTiL9zg/5Ldh8aAX5cB/ GVMg== X-Gm-Message-State: AOAM531cQP9SkIJ53LJ7raLw06EdkBDhXFI9c7yKuT1VKjJNxKXtL0kL nSl4kpXHFT09VXS2k/Wr+Kb4EXbjwA/HxA== X-Google-Smtp-Source: ABdhPJxnGgw95GlxQYp34DnEicy8JfOgKEQqABMmSn+Iljo5FDO8HIus7DcCF2NcMSPsOZVjW+9kmw== X-Received: by 2002:adf:f387:: with SMTP id m7mr13402560wro.86.1623104437820; Mon, 07 Jun 2021 15:20:37 -0700 (PDT) Received: from ?IPv6:2001:8a0:f932:6a00:46bc:d03b:7b3a:2227? ([2001:8a0:f932:6a00:46bc:d03b:7b3a:2227]) by smtp.gmail.com with ESMTPSA id t4sm17728426wru.53.2021.06.07.15.20.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Jun 2021 15:20:36 -0700 (PDT) Subject: Re: [PATCH 1/2] nat/amd64-linux-siginfo.c: Move align attribute from typedef to struct From: Pedro Alves To: John Baldwin , gdb-patches@sourceware.org References: <20210605001427.3597687-1-pedro@palves.net> <20210605001427.3597687-2-pedro@palves.net> <31bde046-a86f-9995-545d-a03737cf493b@FreeBSD.org> Message-ID: <00f901fb-b420-35e4-262f-65e4e3bacb3d@palves.net> Date: Mon, 7 Jun 2021 23:20:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <31bde046-a86f-9995-545d-a03737cf493b@FreeBSD.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, BODY_8BITS, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Mon, 07 Jun 2021 22:20:49 -0000 Hi John, On 2021-06-05 10:20 p.m., John Baldwin wrote: > On 6/4/21 5:14 PM, Pedro Alves wrote: >> diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c >> index e2d2db6e112..9ff9361487a 100644 >> --- a/gdb/nat/amd64-linux-siginfo.c >> +++ b/gdb/nat/amd64-linux-siginfo.c >> @@ -206,7 +206,7 @@ typedef struct compat_siginfo >>   /* For x32, clock_t in _sigchld is 64bit aligned at 4 bytes.  */ >>   typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t; >>   -typedef struct compat_x32_siginfo >> +typedef struct __attribute__ ((__aligned__ (8))) compat_x32_siginfo >>   { >>     int si_signo; >>     int si_errno; >> @@ -263,7 +263,7 @@ typedef struct compat_x32_siginfo >>         int _fd; >>       } _sigpoll; >>     } _sifields; >> -} compat_x32_siginfo_t __attribute__ ((__aligned__ (8))); >> +} compat_x32_siginfo_t; >>     /* To simplify usage of siginfo fields.  */ > > Looks good to me.  Note that alignas() is part of C++11, so you could > perhaps spell this a bit shorter as "alignas (8)" instead. > That sounded like a good idea at first, however, if we were to do that, I think we should do it to all __aligned__ attributes in the file. But note the one seen quoted above. Here again: typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t; We can't use alignas for that, because alignas doesn't work with typedefs. GCC: gdb/nat/amd64-linux-siginfo.c:207:14: error: attribute ignored [-Werror=attributes] 207 | typedef long alignas (4) compat_x32_clock_t; | ^~~~~~~ Clang: gdb/nat/amd64-linux-siginfo.c:207:14: error: 'alignas' attribute cannot be applied to types typedef long alignas (4) compat_x32_clock_t; ^ Clang attempt 2: gdb/nat/amd64-linux-siginfo.c:207:33: error: 'alignas' attribute only applies to variables, data members and tag types typedef long compat_x32_clock_t alignas (4); ^ See answer 4 here: https://stackoverflow.com/questions/15788947/where-can-i-use-alignas-in-c11 "These are the only places where the standard says an alignment-specifier (alignas(...)) may be applied. Note that this does not include typedef declarations nor alias-declarations." So for consistency I'm leaving the struct attribute as is too. I'm going to merge the patches now. Thanks, Pedro Alves