From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6463 invoked by alias); 22 Feb 2015 23:10:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 6453 invoked by uid 89); 22 Feb 2015 23:10:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: bin-vsp-out-04.atm.binero.net Received: from vsp-unauthed01.binero.net (HELO bin-vsp-out-04.atm.binero.net) (195.74.38.225) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 22 Feb 2015 23:10:47 +0000 X-Halon-ID: 06c8190f-bae8-11e4-9ec3-005056917c0c Authorized-sender: jiri@gaisler.se Received: from [192.168.9.20] (unknown [78.68.173.120]) by bin-vsp-out-04.atm.binero.net (Halon Mail Gateway) with ESMTPA for ; Mon, 23 Feb 2015 00:10:43 +0100 (CET) Message-ID: <54EA61F2.6080303@gaisler.se> Date: Sun, 22 Feb 2015 23:10:00 -0000 From: Jiri Gaisler User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: Re: [PATCH v2 10/22] sim/erc32: Switched emulated memory to host endian order. References: <1424385100-15397-1-git-send-email-jiri@gaisler.se> <1424385100-15397-11-git-send-email-jiri@gaisler.se> <20150222205132.GA31422@vapier> In-Reply-To: <20150222205132.GA31422@vapier> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Fx3p7vbJcJlOuLNEqFFvQoA77bA5edIrk" X-IsSubscribed: yes X-SW-Source: 2015-02/txt/msg00644.txt.bz2 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Fx3p7vbJcJlOuLNEqFFvQoA77bA5edIrk Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 1302 On 02/22/2015 09:51 PM, Mike Frysinger wrote: > On 19 Feb 2015 23:31, Jiri Gaisler wrote: >> + *((unsigned short *) &(mem[waddr])) =3D *data & 0x0ffff; >=20 > this violates strict aliasing. you can't cast the RHS side like this. i= t also=20 > violates alignment since the buffer is passed in as unsigned char *. I don't fully agree on this. *mem holds the pointer to romb or ramb, which are defined as unsigned char arrays. However, their definition is is preceded with an integer define: static uint32 mem_blockprot; /* RAM block write protection enabled */ static unsigned char romb[ROM_SZ]; static unsigned char ramb[RAM_END - RAM_START]; This means that romb and ramb are aligned on a 4-byte boundary on systems where this matters (SPARC, ARM). When casting to short, waddr is always aligned on 2, when casting to integer waddr is always aligned on 4. So the casting really works without getting an alignment error. Can I rather document this instead of using a slower memcpy()? In cpu simulation, performance is essential and every (host) instruction counts. >=20 > you should use memcpy() instead. on systems where unaligned access are O= K, gcc=20 > should optimize it down to a few load/stores anyways. memcpy() does have some overhead compared to a single store ... Jiri. --Fx3p7vbJcJlOuLNEqFFvQoA77bA5edIrk Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 884 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJU6mHyAAoJEIAIwBKmO2+bZqkQAMlEm9HHBVv/Cpt9ylxm+m9n rqBYxXUxbZIJX3taHtPajf7zsxUTdXRZkK4i14PnufHn8hXDsXbNsVYkThrXgA7q BJoaRjJCwlND/uTE5MzOxooR7Y20ffJ6Ts2PwePwJXiGOvfOG7K+JU0zIwNrDim1 5ukipe1NmNib3XOBnW3jqHQHHaHr1IzyGGW0GNaq0RuH4I2CSxQ55Tv5kEe9tJTt C475rxR4qPMW17sTuO2Sxtef0lRM7iWmwryKtTcWUeIXh6EZqSd+neTTWkbUqARw C9i5MgMcKZsrXAajPASL4YnwP1bwGtGj5GipSZVgVnpjh62vXqatFekBOuLKlKS6 MwABgNtcNx0rNIqR57JX9EhUi9IpGug9xhHGI+YCg8ek9oNVBd54PiS7rUvM9fgz TKhcIVfWWCGtnHt5uu5PWSCeffzzdMkSXYQr7C9G7CqxcSJadZU+AwdrkEH7fzq1 A7Kvs8bnP6Ha0nA9aYYjXY0pH4rgTYSggb1eTI48ugxgX8k+PRiD5JmuUuZuVFBY swjeGBknyuFdHRf0zSr/kO+eFesefNTvxzYfRQLwB1saCOrqIpyuotEt5UKLUKmJ qVvRWkXUVdxdY/xhngJeog40Nq+UyEGyMmP1163EqwfFiNEzUSstk4nkhi/yMFAU DN8A0EGBYBM5/RMMSZgl =/v7E -----END PGP SIGNATURE----- --Fx3p7vbJcJlOuLNEqFFvQoA77bA5edIrk--