From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Sat, 06 Apr 2013 09:04:29 +0200 Subject: [U-Boot] [PATCH] crc32: Correct endianness of crc32 result In-Reply-To: <1365203470-9099-1-git-send-email-sjg@chromium.org> References: <1365203470-9099-1-git-send-email-sjg@chromium.org> Message-ID: <20130406070429.381092002D9@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Simon Glass, In message <1365203470-9099-1-git-send-email-sjg@chromium.org> you wrote: > When crc32 is handled by the hash library, it requires the data to be in > big-endian format, since it reads it byte-wise. Thus at present the 'crc32' > command reports incorrect data. For example, previously we might see: > +#ifdef USE_HOSTCC > + crc = htobe32(crc); > memcpy(output, &crc, sizeof(crc)); > +#else > + put_unaligned_be32(crc, output); > +#endif Why is this depending on USE_HOSTCC, and not on the endianess? And why do we need the #ifdef? Can we not always use htobe32() and put_unaligned_be32() ? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things." - Doug Gwyn