From patchwork Tue Jun 10 23:13:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 4332641 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3E18FBEEAA for ; Tue, 10 Jun 2014 23:14:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F4EF2012F for ; Tue, 10 Jun 2014 23:14:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03E6920295 for ; Tue, 10 Jun 2014 23:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752634AbaFJXNv (ORCPT ); Tue, 10 Jun 2014 19:13:51 -0400 Received: from terminus.zytor.com ([198.137.202.10]:38710 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751504AbaFJXNt (ORCPT ); Tue, 10 Jun 2014 19:13:49 -0400 Received: from tazenda.hos.anvin.org ([IPv6:2601:9:7280:900:e269:95ff:fe35:9f3c]) (authenticated bits=0) by mail.zytor.com (8.14.7/8.14.5) with ESMTP id s5ANDPuX008135 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 10 Jun 2014 16:13:25 -0700 Received: from tazenda.hos.anvin.org (localhost [127.0.0.1]) by tazenda.hos.anvin.org (8.14.8/8.14.5) with ESMTP id s5ANDKIS016836; Tue, 10 Jun 2014 16:13:20 -0700 Received: (from hpa@localhost) by tazenda.hos.anvin.org (8.14.8/8.14.8/Submit) id s5ANDKuq016835; Tue, 10 Jun 2014 16:13:20 -0700 From: "H. Peter Anvin" To: Sam Ravnborg , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org Cc: Andy Lutomirski , Andrew Morton , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" Subject: [PATCH RFC 02/10] tools: Create and an unaligned subdirectory Date: Tue, 10 Jun 2014 16:13:06 -0700 Message-Id: <1402441994-16780-3-git-send-email-hpa@zytor.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1402441994-16780-1-git-send-email-hpa@zytor.com> References: <1402441994-16780-1-git-send-email-hpa@zytor.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Create and create an unaligned subdirectory for specific implementations -- currently including the existing be_byteshift.h and le_byteshift.h. Signed-off-by: H. Peter Anvin --- arch/x86/boot/compressed/mkpiggy.c | 2 +- arch/x86/boot/tools/build.c | 2 +- arch/x86/tools/relocs.h | 2 +- scripts/sortextable.c | 3 +- tools/include/tools/be_byteshift.h | 52 ---------------------------- tools/include/tools/le_byteshift.h | 52 ---------------------------- tools/include/tools/unaligned.h | 2 ++ tools/include/tools/unaligned/be_byteshift.h | 52 ++++++++++++++++++++++++++++ tools/include/tools/unaligned/le_byteshift.h | 52 ++++++++++++++++++++++++++++ tools/usb/ffs-test.c | 2 +- 10 files changed, 111 insertions(+), 110 deletions(-) delete mode 100644 tools/include/tools/be_byteshift.h delete mode 100644 tools/include/tools/le_byteshift.h create mode 100644 tools/include/tools/unaligned.h create mode 100644 tools/include/tools/unaligned/be_byteshift.h create mode 100644 tools/include/tools/unaligned/le_byteshift.h diff --git a/arch/x86/boot/compressed/mkpiggy.c b/arch/x86/boot/compressed/mkpiggy.c index b669ab65bf6c..dc009d80dd34 100644 --- a/arch/x86/boot/compressed/mkpiggy.c +++ b/arch/x86/boot/compressed/mkpiggy.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include int main(int argc, char *argv[]) { diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index 1a2f2121cada..010892234f94 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include typedef unsigned char u8; typedef unsigned short u16; diff --git a/arch/x86/tools/relocs.h b/arch/x86/tools/relocs.h index f59590645b68..69ae4d2b121c 100644 --- a/arch/x86/tools/relocs.h +++ b/arch/x86/tools/relocs.h @@ -14,7 +14,7 @@ #define USE_BSD #include #include -#include +#include void die(char *fmt, ...); diff --git a/scripts/sortextable.c b/scripts/sortextable.c index cc49062acdee..a17a7dbd8dce 100644 --- a/scripts/sortextable.c +++ b/scripts/sortextable.c @@ -28,8 +28,7 @@ #include #include -#include -#include +#include #ifndef EM_ARCOMPACT #define EM_ARCOMPACT 93 diff --git a/tools/include/tools/be_byteshift.h b/tools/include/tools/be_byteshift.h deleted file mode 100644 index 9850c7df2667..000000000000 --- a/tools/include/tools/be_byteshift.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _TOOLS_BE_BYTESHIFT_H -#define _TOOLS_BE_BYTESHIFT_H - -#include - -static inline uint16_t get_unaligned_be16(const void *_p) -{ - const uint8_t *p = _p; - - return p[0] << 8 | p[1]; -} - -static inline uint32_t get_unaligned_be32(const void *_p) -{ - const uint8_t *p = _p; - - return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; -} - -static inline uint64_t get_unaligned_be64(const void *_p) -{ - const uint8_t *p = _p; - - return (uint64_t)get_unaligned_be32(p) << 32 | - get_unaligned_be32(p + 4); -} - -static inline void put_unaligned_be16(uint16_t val, void *_p) -{ - uint8_t *p = _p; - - *p++ = val >> 8; - *p++ = val; -} - -static inline void put_unaligned_be32(uint32_t val, void *_p) -{ - uint8_t *p = _p; - - put_unaligned_be16(val >> 16, p); - put_unaligned_be16(val, p + 2); -} - -static inline void put_unaligned_be64(uint64_t val, void *_p) -{ - uint8_t *p = _p; - - put_unaligned_be32(val >> 32, p); - put_unaligned_be32(val, p + 4); -} - -#endif /* _TOOLS_BE_BYTESHIFT_H */ diff --git a/tools/include/tools/le_byteshift.h b/tools/include/tools/le_byteshift.h deleted file mode 100644 index 819ba186ede5..000000000000 --- a/tools/include/tools/le_byteshift.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _TOOLS_LE_BYTESHIFT_H -#define _TOOLS_LE_BYTESHIFT_H - -#include - -static inline uint16_t get_unaligned_le16(const void *_p) -{ - const uint8_t *p = _p; - - return p[0] | p[1] << 8; -} - -static inline uint32_t get_unaligned_le32(const void *_p) -{ - const uint8_t *p = _p; - - return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; -} - -static inline uint64_t get_unaligned_le64(const void *_p) -{ - const uint8_t *p = _p; - - return (uint64_t)get_unaligned_le32(p + 4) << 32 | - get_unaligned_le32(p); -} - -static inline void put_unaligned_le16(uint16_t val, void *_p) -{ - uint8_t *p = _p; - - *p++ = val; - *p++ = val >> 8; -} - -static inline void put_unaligned_le32(uint32_t val, void *_p) -{ - uint8_t *p = _p; - - put_unaligned_le16(val, p); - put_unaligned_le16(val >> 16, p + 2); -} - -static inline void put_unaligned_le64(uint64_t val, void *_p) -{ - uint8_t *p = _p; - - put_unaligned_le32(val, p); - put_unaligned_le32(val >> 32, p + 4); -} - -#endif /* _TOOLS_LE_BYTESHIFT_H */ diff --git a/tools/include/tools/unaligned.h b/tools/include/tools/unaligned.h new file mode 100644 index 000000000000..f89c089b6148 --- /dev/null +++ b/tools/include/tools/unaligned.h @@ -0,0 +1,2 @@ +#include +#include diff --git a/tools/include/tools/unaligned/be_byteshift.h b/tools/include/tools/unaligned/be_byteshift.h new file mode 100644 index 000000000000..9850c7df2667 --- /dev/null +++ b/tools/include/tools/unaligned/be_byteshift.h @@ -0,0 +1,52 @@ +#ifndef _TOOLS_BE_BYTESHIFT_H +#define _TOOLS_BE_BYTESHIFT_H + +#include + +static inline uint16_t get_unaligned_be16(const void *_p) +{ + const uint8_t *p = _p; + + return p[0] << 8 | p[1]; +} + +static inline uint32_t get_unaligned_be32(const void *_p) +{ + const uint8_t *p = _p; + + return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; +} + +static inline uint64_t get_unaligned_be64(const void *_p) +{ + const uint8_t *p = _p; + + return (uint64_t)get_unaligned_be32(p) << 32 | + get_unaligned_be32(p + 4); +} + +static inline void put_unaligned_be16(uint16_t val, void *_p) +{ + uint8_t *p = _p; + + *p++ = val >> 8; + *p++ = val; +} + +static inline void put_unaligned_be32(uint32_t val, void *_p) +{ + uint8_t *p = _p; + + put_unaligned_be16(val >> 16, p); + put_unaligned_be16(val, p + 2); +} + +static inline void put_unaligned_be64(uint64_t val, void *_p) +{ + uint8_t *p = _p; + + put_unaligned_be32(val >> 32, p); + put_unaligned_be32(val, p + 4); +} + +#endif /* _TOOLS_BE_BYTESHIFT_H */ diff --git a/tools/include/tools/unaligned/le_byteshift.h b/tools/include/tools/unaligned/le_byteshift.h new file mode 100644 index 000000000000..819ba186ede5 --- /dev/null +++ b/tools/include/tools/unaligned/le_byteshift.h @@ -0,0 +1,52 @@ +#ifndef _TOOLS_LE_BYTESHIFT_H +#define _TOOLS_LE_BYTESHIFT_H + +#include + +static inline uint16_t get_unaligned_le16(const void *_p) +{ + const uint8_t *p = _p; + + return p[0] | p[1] << 8; +} + +static inline uint32_t get_unaligned_le32(const void *_p) +{ + const uint8_t *p = _p; + + return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; +} + +static inline uint64_t get_unaligned_le64(const void *_p) +{ + const uint8_t *p = _p; + + return (uint64_t)get_unaligned_le32(p + 4) << 32 | + get_unaligned_le32(p); +} + +static inline void put_unaligned_le16(uint16_t val, void *_p) +{ + uint8_t *p = _p; + + *p++ = val; + *p++ = val >> 8; +} + +static inline void put_unaligned_le32(uint32_t val, void *_p) +{ + uint8_t *p = _p; + + put_unaligned_le16(val, p); + put_unaligned_le16(val >> 16, p + 2); +} + +static inline void put_unaligned_le64(uint64_t val, void *_p) +{ + uint8_t *p = _p; + + put_unaligned_le32(val, p); + put_unaligned_le32(val >> 32, p + 4); +} + +#endif /* _TOOLS_LE_BYTESHIFT_H */ diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c index fe1e66b6ef40..39695d18b3e7 100644 --- a/tools/usb/ffs-test.c +++ b/tools/usb/ffs-test.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include "../../include/uapi/linux/usb/functionfs.h"