From patchwork Tue Jun 10 23:13:12 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: 4332651 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8D91F9F503 for ; Tue, 10 Jun 2014 23:14:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D3782012F for ; Tue, 10 Jun 2014 23:14:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7FF6620295 for ; Tue, 10 Jun 2014 23:14:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753143AbaFJXNw (ORCPT ); Tue, 10 Jun 2014 19:13:52 -0400 Received: from terminus.zytor.com ([198.137.202.10]:38709 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751758AbaFJXNt (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 s5ANDQ6x008150 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 10 Jun 2014 16:13:27 -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 s5ANDLrM016860; Tue, 10 Jun 2014 16:13:21 -0700 Received: (from hpa@localhost) by tazenda.hos.anvin.org (8.14.8/8.14.8/Submit) id s5ANDLdl016859; Tue, 10 Jun 2014 16:13:21 -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 08/10] tools: Move unaligned common infrastructure into Date: Tue, 10 Jun 2014 16:13:12 -0700 Message-Id: <1402441994-16780-9-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 Move common includes and infrastructure into . Signed-off-by: H. Peter Anvin --- tools/include/tools/unaligned.h | 34 ++++++++++++++++++++++++++++ tools/include/tools/unaligned/be_bswap.h | 2 -- tools/include/tools/unaligned/be_byteshift.h | 2 -- tools/include/tools/unaligned/be_direct.h | 2 -- tools/include/tools/unaligned/be_endian.h | 6 ----- tools/include/tools/unaligned/be_struct.h | 14 ------------ tools/include/tools/unaligned/le_bswap.h | 2 -- tools/include/tools/unaligned/le_byteshift.h | 2 -- tools/include/tools/unaligned/le_direct.h | 2 -- tools/include/tools/unaligned/le_endian.h | 6 ----- tools/include/tools/unaligned/le_struct.h | 12 ---------- 11 files changed, 34 insertions(+), 50 deletions(-) diff --git a/tools/include/tools/unaligned.h b/tools/include/tools/unaligned.h index f89c089b6148..a3d43989bd25 100644 --- a/tools/include/tools/unaligned.h +++ b/tools/include/tools/unaligned.h @@ -1,2 +1,36 @@ +#ifndef TOOLS_UNALIGNED_H +#define TOOLS_UNALIGNED_H + +#include + +#ifndef _BSD_SOURCE +# define _BSD_SOURCE 1 +#endif +#include + +#ifdef __GNUC__ + +struct _packed_u16_struct { + uint16_t v; +} __attribute__((packed)); + +struct _packed_u32_struct { + uint32_t v; +} __attribute__((packed)); + +struct _packed_u64_struct { + uint64_t v; +} __attribute__((packed)); + +#define TOOLS_UNALIGNED_GCC ((__GNUC__ << 16) + (__GNUC_MINOR__ << 8) + __GNUC_PATCHLEVEL__) + +#else + +#define TOOLS_UNALIGNED_GCC 0 + +#endif /* __GNUC__ */ + #include #include + +#endif /* TOOLS_UNALIGNED_H */ diff --git a/tools/include/tools/unaligned/be_bswap.h b/tools/include/tools/unaligned/be_bswap.h index 5e63da922d23..72855d3af5f2 100644 --- a/tools/include/tools/unaligned/be_bswap.h +++ b/tools/include/tools/unaligned/be_bswap.h @@ -1,8 +1,6 @@ #ifndef TOOLS_BE_BSWAP_H #define TOOLS_BE_BSWAP_H -#include - static inline uint16_t get_unaligned_be16(const void *_p) { return __builtin_bswap16(get_unaligned_le16(_p)); diff --git a/tools/include/tools/unaligned/be_byteshift.h b/tools/include/tools/unaligned/be_byteshift.h index 068a5a8b47b2..ee0ff62c63cc 100644 --- a/tools/include/tools/unaligned/be_byteshift.h +++ b/tools/include/tools/unaligned/be_byteshift.h @@ -1,8 +1,6 @@ #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; diff --git a/tools/include/tools/unaligned/be_direct.h b/tools/include/tools/unaligned/be_direct.h index 4f446856aa84..1ce1c4a94a01 100644 --- a/tools/include/tools/unaligned/be_direct.h +++ b/tools/include/tools/unaligned/be_direct.h @@ -1,8 +1,6 @@ #ifndef TOOLS_BE_DIRECT_H #define TOOLS_BE_DIRECT_H -#include - static inline uint16_t get_unaligned_be16(const void *_p) { const uint16_t *p = _p; diff --git a/tools/include/tools/unaligned/be_endian.h b/tools/include/tools/unaligned/be_endian.h index 52ee4a47e23c..bed93fd0c88b 100644 --- a/tools/include/tools/unaligned/be_endian.h +++ b/tools/include/tools/unaligned/be_endian.h @@ -1,12 +1,6 @@ #ifndef TOOLS_BE_ENDIAN_H #define TOOLS_BE_ENDIAN_H -#ifndef _BSD_SOURCE -# define _BSD_SOURCE 1 -#endif -#include -#include - static inline uint16_t get_unaligned_be16(const void *_p) { return be16toh(get_unaligned_le16(_p)); diff --git a/tools/include/tools/unaligned/be_struct.h b/tools/include/tools/unaligned/be_struct.h index 2543fee4acda..127ecfdc1ac0 100644 --- a/tools/include/tools/unaligned/be_struct.h +++ b/tools/include/tools/unaligned/be_struct.h @@ -1,20 +1,6 @@ #ifndef TOOLS_BE_STRUCT_H #define TOOLS_BE_STRUCT_H -#include - -struct _packed_u16_struct { - uint16_t v; -} __attribute__((packed)); - -struct _packed_u32_struct { - uint32_t v; -} __attribute__((packed)); - -struct _packed_u64_struct { - uint64_t v; -} __attribute__((packed)); - static inline uint16_t get_unaligned_be16(const void *_p) { const struct _packed_u16_struct *p = _p; diff --git a/tools/include/tools/unaligned/le_bswap.h b/tools/include/tools/unaligned/le_bswap.h index 199b42a7b862..f9717b7e072d 100644 --- a/tools/include/tools/unaligned/le_bswap.h +++ b/tools/include/tools/unaligned/le_bswap.h @@ -1,8 +1,6 @@ #ifndef TOOLS_LE_BSWAP_H #define TOOLS_LE_BSWAP_H -#include - static inline uint16_t get_unaligned_le16(const void *_p) { return __builtin_bswap16(get_unaligned_be16(_p)); diff --git a/tools/include/tools/unaligned/le_byteshift.h b/tools/include/tools/unaligned/le_byteshift.h index dfd5d42b9783..bf54188b5210 100644 --- a/tools/include/tools/unaligned/le_byteshift.h +++ b/tools/include/tools/unaligned/le_byteshift.h @@ -1,8 +1,6 @@ #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; diff --git a/tools/include/tools/unaligned/le_direct.h b/tools/include/tools/unaligned/le_direct.h index 17b773284edd..b599020be21f 100644 --- a/tools/include/tools/unaligned/le_direct.h +++ b/tools/include/tools/unaligned/le_direct.h @@ -1,8 +1,6 @@ #ifndef TOOLS_LE_DIRECT_H #define TOOLS_LE_DIRECT_H -#include - static inline uint16_t get_unaligned_le16(const void *_p) { const uint16_t *p = _p; diff --git a/tools/include/tools/unaligned/le_endian.h b/tools/include/tools/unaligned/le_endian.h index bc8c2d41be0e..a412af39eda9 100644 --- a/tools/include/tools/unaligned/le_endian.h +++ b/tools/include/tools/unaligned/le_endian.h @@ -1,12 +1,6 @@ #ifndef TOOLS_LE_ENDIAN_H #define TOOLS_LE_ENDIAN_H -#ifndef _BSD_SOURCE -# define _BSD_SOURCE 1 -#endif -#include -#include - static inline uint16_t get_unaligned_le16(const void *_p) { return le16toh(get_unaligned_be16(_p)); diff --git a/tools/include/tools/unaligned/le_struct.h b/tools/include/tools/unaligned/le_struct.h index f6f271a5824b..b1ac490dcb3f 100644 --- a/tools/include/tools/unaligned/le_struct.h +++ b/tools/include/tools/unaligned/le_struct.h @@ -3,18 +3,6 @@ #include -struct _packed_u16_struct { - uint16_t v; -} __attribute__((packed)); - -struct _packed_u32_struct { - uint32_t v; -} __attribute__((packed)); - -struct _packed_u64_struct { - uint64_t v; -} __attribute__((packed)); - static inline uint16_t get_unaligned_le16(const void *_p) { const struct _packed_u16_struct *p = _p;