From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114477 invoked by alias); 18 Sep 2017 11:43:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 114463 invoked by uid 89); 18 Sep 2017 11:43:16 -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=H*r:sk:86.2017, H*M:c93e, C, c X-HELO: mail-qt0-f171.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=wAJWrVKHaC553I2kd9ai6+FyzrGnFqrsbaQrBscCZEI=; b=BPTZtaSCDDRmM+IbBUwBE+6XZvOBaPeIIhdVl3XeSzjZA23Fd3+7G5XtZUo0xrMKHc I4FObIFpOC2W1gDf5JhBmL+H9GYYu6P5hxBU/CeCRAPh9vCq/W5U3mlacmHMd+OecSDH b8pHmUgQyXjBo+txFwHWZzmhN/FNZMlCD+GBF9DnMnULfH+A2hQ3tZmBmCmtl6Orqjr6 UQrUwBUWOusy23HxE8YgaCfL1J/px43NC/PC54C9tgIxdJEmQtfkMsigSbn2OKihUR17 OoNfZa92ej/86XTWJUKl7z++OYS+pXHkLtAxdhTIXMZyv0+M1HgQVXXi/PdWWNOXgJ/K /Mgg== X-Gm-Message-State: AHPjjUha8C0sf84Zx/VQmrCqFE/kx8meblYx2Xf1Xov5oZkrxP1VF7NE ZBi5jwfabCcN/Ojw X-Google-Smtp-Source: AOwi7QAO7UW6VDvKM5NSYi0tJ0uRv2mR1u88WZhU/gr9i1ldNisDowh5zMcigvBmYGcKHUaze+yVyw== X-Received: by 10.237.33.33 with SMTP id 30mr4523717qtc.138.1505734992262; Mon, 18 Sep 2017 04:43:12 -0700 (PDT) Subject: Re: [PATCH 4/9] Sync scratch_buffer with gnulib To: Florian Weimer , libc-alpha@sourceware.org Cc: Paul Eggert References: <1504643122-14874-1-git-send-email-adhemerval.zanella@linaro.org> <1504643122-14874-5-git-send-email-adhemerval.zanella@linaro.org> <3e95c32d-2311-c791-1df2-5b1883486d0b@redhat.com> From: Adhemerval Zanella Message-ID: Date: Mon, 18 Sep 2017 11:43:00 -0000 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: <3e95c32d-2311-c791-1df2-5b1883486d0b@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2017-09/txt/msg00670.txt.bz2 On 18/09/2017 03:09, Florian Weimer wrote: > On 09/05/2017 10:25 PM, Adhemerval Zanella wrote: >> -  char __space[1024] >> -    __attribute__ ((aligned (__alignof__ (max_align_t)))); >> +  max_align_t __space[(1023 + sizeof (max_align_t)) / sizeof (max_align_t)]; > > This change needs a declaration from the GCC folks (probably from Richard Biener) that it does not break aliasing analysis.  The old code uses a GCC extension (writing to a char array changes its dynamic type); it is not valid C.  I don't know if the GCC extension also applies if the storage site is declared with a non-char type. > > Thanks, > Florian What about this below instead: --- diff --git a/include/scratch_buffer.h b/include/scratch_buffer.h index bb04662..f77e7da 100644 --- a/include/scratch_buffer.h +++ b/include/scratch_buffer.h @@ -60,13 +60,18 @@ #include #include #include +#include /* Scratch buffer. Must be initialized with scratch_buffer_init before its use. */ struct scratch_buffer { void *data; /* Pointer to the beginning of the scratch area. */ size_t length; /* Allocated space at the data pointer, in bytes. */ +#if __alignas_is_defined + _Alignas (max_align_t) char __space[1024]; +#else max_align_t __space[(1023 + sizeof (max_align_t)) / sizeof (max_align_t)]; +#endif }; /* Initializes *BUFFER so that BUFFER->data points to BUFFER->__space --- _Alignas/stdalign.h is supported since GCC 4.7 [1] (so it is safe to use on glibc without configure support) and gnulib have its own version which defines __alignas_is_defined depending on underlying compiler support. [1] https://gcc.gnu.org/wiki/C11Status