From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102755 invoked by alias); 12 Sep 2017 14:37:54 -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 102744 invoked by uid 89); 12 Sep 2017 14:37:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy=Hx-languages-length:1430 X-HELO: relay1.mentorg.com Date: Tue, 12 Sep 2017 14:37:00 -0000 From: Joseph Myers To: Zack Weinberg CC: Florian Weimer , Rajalakshmi Srinivasaraghavan , GNU C Library Subject: Re: [PATCH] powerpc: Use aligned stores in memset In-Reply-To: Message-ID: References: <1503033107-20047-1-git-send-email-raji@linux.vnet.ibm.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-SW-Source: 2017-09/txt/msg00507.txt.bz2 On Tue, 12 Sep 2017, Zack Weinberg wrote: > On Tue, Sep 12, 2017 at 6:30 AM, Florian Weimer wrote: > > > > I could not find the manual which has the requirement that the mem* > > functions do not use unaligned accesses. Unless they are worded in a > > very peculiar way, right now, the GCC/glibc combination does not comply > > with a requirement that memset & Co. can be used for device memory access. > > mem* are required to behave as-if they access memory as an array of > unsigned char. Therefore it is valid to give them arbitrarily > (un)aligned pointers. The C abstract machine doesn't specifically > contemplate the possibility of a CPU that can do unaligned word reads > but maybe not to all memory addresses, but I would argue that if there > is such a CPU, then mem* are obliged to cope with it. Only if there is a way, within the standard, in which you might obtain a pointer to such memory. It is explicitly undefined in ISO C to access "an object defined with a volatile-qualified type through use of an lvalue with non-volatile-qualified type" (C11 6.7.3#6). Thus you can't use mem* functions on objects defined as volatile. I think device memory with special access requirements should be considered to be defined as volatile. (So any access from C code should use volatile-qualified lvalues.) -- Joseph S. Myers joseph@codesourcery.com