From patchwork Tue Sep 19 17:34:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 22962 Received: (qmail 102329 invoked by alias); 19 Sep 2017 17:35:10 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 102299 invoked by uid 89); 19 Sep 2017 17:35:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f173.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=dcBEgmvtQ6bqB96+W0EGI3N+Nkft72kTr4TOSNjwwRE=; b=nKZqn1CWQV3G4asgcsChK2gz39YqcpwADXolq/5AGwlzvhlxhPdOcCXPvOnmnz51fM 1MBMBMiSuv2D3fYadr5Wj2L5CP/ERIp2Mh97ECK7RYl/A1exM0fty15kbiYoYQdDP35/ jtpb9qv+f38tlQwDQojPuIqKzS9VDV9NyhIPXiicuVQ1dkAiSgloFrUzcJaeq+Hu6rh3 PL5oK4qE8n/Gh/+v2tfydE+3r6AqbaHCQcN/H0JzMkYMn+Sx8HjzKYYp+Eh3qTzuFSXL s791N62L7YYJtT0TVHMCqtPdBKqPNrV1rR2x8iiOm7dgmf4W57Ptg+rI5J0gaDLCkKHK Zwfw== X-Gm-Message-State: AHPjjUiyE2lSqvhsPsJuNwYqLg0OgDg9osDbTCn24dalAhO6z8QccFpp mCy88JvXB1UeM1uavkqLEFVIIVzWwQg= X-Google-Smtp-Source: AOwi7QCs6x6vk7HZmdR6bPLwVo64QcHgW0AhgS6Tj3eibZFuboQbDlVDiyCydFysBMqvxi+wOKoK7Q== X-Received: by 10.200.8.131 with SMTP id v3mr3110008qth.262.1505842504830; Tue, 19 Sep 2017 10:35:04 -0700 (PDT) Subject: Re: [PATCH 2/2] Use C11 _Alignas on scratch_buffer internal buffer To: Andreas Schwab Cc: Paul Eggert , Florian Weimer , libc-alpha@sourceware.org References: <1505745774-29303-1-git-send-email-adhemerval.zanella@linaro.org> <1505745774-29303-2-git-send-email-adhemerval.zanella@linaro.org> <0f162389-e84d-3168-35eb-f168484e87ee@cs.ucla.edu> <22a21507-adc7-3116-813e-0ee873e2a8f9@cs.ucla.edu> <30c017fe-fafe-d787-7d76-865223cef599@linaro.org> From: Adhemerval Zanella Message-ID: <0e2a0dfe-5a44-f365-9544-ee0fc2b0df63@linaro.org> Date: Tue, 19 Sep 2017 14:34:59 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: On 19/09/2017 10:29, Andreas Schwab wrote: > On Sep 19 2017, Adhemerval Zanella wrote: > >> diff --git a/include/scratch_buffer.h b/include/scratch_buffer.h >> index bb04662..0f49dd9 100644 >> --- a/include/scratch_buffer.h >> +++ b/include/scratch_buffer.h >> @@ -66,7 +66,7 @@ >> struct scratch_buffer { >> void *data; /* Pointer to the beginning of the scratch area. */ >> size_t length; /* Allocated space at the data pointer, in bytes. */ >> - max_align_t __space[(1023 + sizeof (max_align_t)) / sizeof (max_align_t)]; >> + union { max_align_t __a; char __c[1024]; } __space; > > If you make it an anonymous union you don't even need to change the rest > of the code. > > Andreas. > Something like below maybe? --- * include/scratch_buffer.h (scratch_buffer): Use an union instead of a max_align_t array for __space definition. --- diff --git a/include/scratch_buffer.h b/include/scratch_buffer.h index bb04662..cc394a7 100644 --- a/include/scratch_buffer.h +++ b/include/scratch_buffer.h @@ -66,7 +66,7 @@ struct scratch_buffer { void *data; /* Pointer to the beginning of the scratch area. */ size_t length; /* Allocated space at the data pointer, in bytes. */ - max_align_t __space[(1023 + sizeof (max_align_t)) / sizeof (max_align_t)]; + union { max_align_t __align; char __space[1024]; }; }; /* Initializes *BUFFER so that BUFFER->data points to BUFFER->__space