Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp490412yba; Fri, 12 Apr 2019 07:37:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3YAkLqKTTo/w/f6jhTDUjeBYvjwpQuU+ED+rIRAZort+1R4+EAzy4c2GG4sYW0j0wJ9o2 X-Received: by 2002:a65:6108:: with SMTP id z8mr53795634pgu.106.1555079820193; Fri, 12 Apr 2019 07:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555079820; cv=none; d=google.com; s=arc-20160816; b=swEg5Vg4RJs5idXpo8ow/yR/1jw0Js7stFMnYrxJxhv3+qQSpnrA2cKBbizYFTpVPS uoDlIZQx8y5jJQhzffFFUbbbWmtud0Z/DROCxUP0QsLYmBgvSXl66mC2ki7hjED8f5t3 yywOoQqZXwM3sRDQgIt75TzoP1U1T/vAmj+S87oyoG5/lKtK9SrNSd/MFEHlwzJ+uryC DdhlHYozkQ4qGna9KGzCQpphJAxvMlapJqk9m6S5bj9qawferM7cX7LoUti7qZrmJNJ4 u6WeONpTMaKXz+BeZTGRC/e5Q97pRiFW83qFC7jGM3BJ4RWAZ+29hgub5x3xOPAih98N M/Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=WX6iybjkfSLlj5DKZHfXMiYqnwkNSI8RrI8E3WQ+jdA=; b=zx6X5dlRfU4aL7WjzZ0g7jwW37kMYs0OdWb+i5kBsXh2K3+ml1hYRIRkunj1+33jZD UHDLJymfU+pVYaXWb9vujlDXrOqHt3y2BubdmAAMqGSDBF4SQUN6Y4OLMVmuGPkOo1wn Ayxx4TaJO02OeHOCSyot1Ls7pua1upITxRpAZyBkqryHo6gzaIINIeS2EXjY5pv74qT8 JWUaGzHpzEESTd3HXcJAqbHrF6f3gIQxff42s9zoXbESAQVMzkE79VCJh2x87V15dYR8 KZys9blpML1ilFlim3VQE7Y0Sk1lvAte/DHffPYeLyzE5d2B4HzYhnwZq16ubAuu9Hv4 BB4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gi0j1M3S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z13si36414397pgp.376.2019.04.12.07.36.43; Fri, 12 Apr 2019 07:37:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gi0j1M3S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726911AbfDLOgF (ORCPT + 99 others); Fri, 12 Apr 2019 10:36:05 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36394 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbfDLOgE (ORCPT ); Fri, 12 Apr 2019 10:36:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WX6iybjkfSLlj5DKZHfXMiYqnwkNSI8RrI8E3WQ+jdA=; b=gi0j1M3Sp46bU0SZU6OEYUFGj a/7A4gIdXabgKMIuy0HISd7zgTpmLRdakrXssA/mr23qUHf08Fcef3viSAfgJDTVO3d3MzbnT/IKo +hLNO5REhOWeVxhl0kcyGKXLQ12p0PH1c1cBzbQ2xHs+zzZXSBrr63cJZ77LO+ZG4Pb/PoRYqC/8z bYgDTsI86KHRlHjym3+uBb9aBJpLPjBKG+u8ST1ehYuHAxO6vx7MtZQweofexmbGt164k5/CMB+GE EsTPnBD68FiyJmiokO8ohTnW/R1azxOMQJ5ZPNXT+Wn5aKox4LALq1/0tg8DlsB+XhSR/sgqyAX6a Xu3biwdMA==; Received: from 089144214194.atnat0023.highway.a1.net ([89.144.214.194] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hExHd-00078b-Ux; Fri, 12 Apr 2019 14:36:02 +0000 From: Christoph Hellwig To: torvalds@linux-foundation.org, akpm@linux-foundation.org Cc: arnd@arndb.de, linux-arch@vger.kernel.org, mick@ics.forth.gr, linux-kernel@vger.kernel.org Subject: [PATCH, RFC] byteorder: sanity check toolchain vs kernel endianess Date: Fri, 12 Apr 2019 16:35:38 +0200 Message-Id: <20190412143538.11780-1-hch@lst.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When removing some dead big endian checks in the RISC-V code Nick suggested that we should have some generic sanity checks. I don't think we should have thos inside the RISC-V code, but maybe it might make sense to have these in the generic byteorder headers. Note that these are UAPI headers and some compilers might not actually define __BYTE_ORDER__, so we first check that it actually exists. Suggested-by: Nick Kossifidis Signed-off-by: Christoph Hellwig --- include/uapi/linux/byteorder/big_endian.h | 4 ++++ include/uapi/linux/byteorder/little_endian.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/include/uapi/linux/byteorder/big_endian.h b/include/uapi/linux/byteorder/big_endian.h index 2199adc6a6c2..34a5864526d2 100644 --- a/include/uapi/linux/byteorder/big_endian.h +++ b/include/uapi/linux/byteorder/big_endian.h @@ -2,6 +2,10 @@ #ifndef _UAPI_LINUX_BYTEORDER_BIG_ENDIAN_H #define _UAPI_LINUX_BYTEORDER_BIG_ENDIAN_H +#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ +#error "Unsupported endianess, check your toolchain" +#endif + #ifndef __BIG_ENDIAN #define __BIG_ENDIAN 4321 #endif diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h index 601c904fd5cd..0cdf3583e19f 100644 --- a/include/uapi/linux/byteorder/little_endian.h +++ b/include/uapi/linux/byteorder/little_endian.h @@ -2,6 +2,10 @@ #ifndef _UAPI_LINUX_BYTEORDER_LITTLE_ENDIAN_H #define _UAPI_LINUX_BYTEORDER_LITTLE_ENDIAN_H +#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ +#error "Unsupported endianess, check your toolchain" +#endif + #ifndef __LITTLE_ENDIAN #define __LITTLE_ENDIAN 1234 #endif -- 2.20.1