From patchwork Fri Oct 24 21:39:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 403238 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 320A814007D for ; Mon, 27 Oct 2014 02:26:55 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0A925A793C; Sun, 26 Oct 2014 16:25:42 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t9RWqFgt+LuR; Sun, 26 Oct 2014 16:25:41 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C9FA9A793E; Sun, 26 Oct 2014 16:23:59 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3DFC14B629 for ; Fri, 24 Oct 2014 23:39:24 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cMcYGRBsv1W4 for ; Fri, 24 Oct 2014 23:39:24 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from cyclops.biessmann.org (cyclops.biessmann.org [134.0.25.77]) by theia.denx.de (Postfix) with ESMTP id 1F8D24B628 for ; Fri, 24 Oct 2014 23:39:24 +0200 (CEST) Received: from localhost (er.biessmann.org [80.81.14.92]) by cyclops.biessmann.org (Postfix) with ESMTPSA id 886A2B6262; Fri, 24 Oct 2014 23:39:23 +0200 (CEST) From: andreas.devel@googlemail.com To: u-boot@lists.denx.de Date: Fri, 24 Oct 2014 23:39:10 +0200 Message-Id: <1414186751-3061-2-git-send-email-andreas.devel@googlemail.com> X-Mailer: git-send-email 1.9.3 (Apple Git-50) In-Reply-To: <1414186751-3061-1-git-send-email-andreas.devel@googlemail.com> References: <1414186751-3061-1-git-send-email-andreas.devel@googlemail.com> MIME-Version: 1.0 Cc: Marek Vasut , Pavel Machek Subject: [U-Boot] [PATCH 1/2] tools/socfpgaimage.c: fix build on darwin X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Andreas Bießmann socfpgaimage utilizes htole32 and friends, unfortunately these functions are not available on darwin. Fix it by using the cpu_to_le32 and friends defined in compiler.h as other parts in mkimage do. This patch fixes the following error: ---8<--- HOSTCC tools/socfpgaimage.o tools/socfpgaimage.c:77:22: warning: implicit declaration of function 'htole32' is invalid in C99 [-Wimplicit-function-declaration] header.validation = htole32(VALIDATION_WORD); ^ tools/socfpgaimage.c:80:22: warning: implicit declaration of function 'htole16' is invalid in C99 [-Wimplicit-function-declaration] header.length_u32 = htole16(length_bytes/4); ^ tools/socfpgaimage.c:95:6: warning: implicit declaration of function 'le32toh' is invalid in C99 [-Wimplicit-function-declaration] if (le32toh(header.validation) != VALIDATION_WORD) ^ tools/socfpgaimage.c:97:6: warning: implicit declaration of function 'le16toh' is invalid in C99 [-Wimplicit-function-declaration] if (le16toh(header.checksum) != hdr_checksum(&header)) ^ 4 warnings generated. ... HOSTLD tools/dumpimage Undefined symbols for architecture x86_64: "_htole16", referenced from: _socfpgaimage_set_header in socfpgaimage.o "_htole32", referenced from: _socfpgaimage_set_header in socfpgaimage.o "_le16toh", referenced from: _verify_buffer in socfpgaimage.o "_le32toh", referenced from: _verify_buffer in socfpgaimage.o ld: symbol(s) not found for architecture x86_64 --->8--- Signed-off-by: Andreas Bießmann Acked-by: Marek Vasut --- tools/socfpgaimage.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/socfpgaimage.c b/tools/socfpgaimage.c index 396d8a5..917873e 100644 --- a/tools/socfpgaimage.c +++ b/tools/socfpgaimage.c @@ -74,12 +74,12 @@ static uint16_t hdr_checksum(struct socfpga_header *header) static void build_header(uint8_t *buf, uint8_t version, uint8_t flags, uint16_t length_bytes) { - header.validation = htole32(VALIDATION_WORD); + header.validation = cpu_to_le32(VALIDATION_WORD); header.version = version; header.flags = flags; - header.length_u32 = htole16(length_bytes/4); + header.length_u32 = cpu_to_le16(length_bytes/4); header.zero = 0; - header.checksum = htole16(hdr_checksum(&header)); + header.checksum = cpu_to_le16(hdr_checksum(&header)); memcpy(buf, &header, sizeof(header)); } @@ -92,12 +92,12 @@ static int verify_header(const uint8_t *buf) { memcpy(&header, buf, sizeof(header)); - if (le32toh(header.validation) != VALIDATION_WORD) + if (le32_to_cpu(header.validation) != VALIDATION_WORD) return -1; - if (le16toh(header.checksum) != hdr_checksum(&header)) + if (le16_to_cpu(header.checksum) != hdr_checksum(&header)) return -1; - return le16toh(header.length_u32) * 4; + return le16_to_cpu(header.length_u32) * 4; } /* Sign the buffer and return the signed buffer size */ @@ -116,7 +116,7 @@ static int sign_buffer(uint8_t *buf, /* Calculate and apply the CRC */ calc_crc = ~pbl_crc32(0, (char *)buf, len); - *((uint32_t *)(buf + len)) = htole32(calc_crc); + *((uint32_t *)(buf + len)) = cpu_to_le32(calc_crc); if (!pad_64k) return len + 4; @@ -150,7 +150,7 @@ static int verify_buffer(const uint8_t *buf) calc_crc = ~pbl_crc32(0, (const char *)buf, len); - buf_crc = le32toh(*((uint32_t *)(buf + len))); + buf_crc = le32_to_cpu(*((uint32_t *)(buf + len))); if (buf_crc != calc_crc) { fprintf(stderr, "CRC32 does not match (%08x != %08x)\n",