From patchwork Tue Jun 20 20:19:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9800179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 220FA6038C for ; Tue, 20 Jun 2017 20:19:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 177101FF12 for ; Tue, 20 Jun 2017 20:19:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C051283DA; Tue, 20 Jun 2017 20:19:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90B2826861 for ; Tue, 20 Jun 2017 20:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751090AbdFTUTj (ORCPT ); Tue, 20 Jun 2017 16:19:39 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:33498 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751118AbdFTUTi (ORCPT ); Tue, 20 Jun 2017 16:19:38 -0400 Received: by mail-wr0-f196.google.com with SMTP id x23so20344736wrb.0 for ; Tue, 20 Jun 2017 13:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fhKfQe6ROPGePFHSuug1h+9TjZhubL2wePu+QMZIqQA=; b=htQJ0wgxh9/0pVNKqebCbHTeFG0jUsuB6XubO9YOspPXJHlJ6rUCH7DEiB8KikTykP j+pRWnwCKG5JjvisurDuOZTpEFA6X5JjHjFekZ+Hs1F8GxZy9rfHvwzSRJSvHSh/H4tA IqgoYQx12uiIFMQBaUaGBpOMCj7BknqNu4DppTYngHf0LcGo8LI37k6Uhno59IEi5XDt r7YVTTfNrC4MxeA7H2KUC46kgzOoVRCkJEalAxGD3BvkXSiNWna9LCLKHUTHFeczGc03 cYfwQhYiVx8P94im96FPU2P66tjTE02kV3NSR6R29CsOaP2ZUbyiKmaOfTOUrbjSHpOT hvbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fhKfQe6ROPGePFHSuug1h+9TjZhubL2wePu+QMZIqQA=; b=BLtdKthP8sZAK0wMRma4XuS19x0+yPYBdOEXexOInh8sT2QHjTc7nupohFIiJRqic1 8k1ZVUXZAv9cbInl3EWmFE+oPsNCyI3/PkJFVXtbbd4qloZeOEhfYPH3rK9dCK/6Ej1T rX9jRwEI7j5Dvw7TAZWJt9DcLuViSBoZSy0CJGftNXQwYSrs+IH2j2yCmjJ138nJWCqr exnO1yz5xuAW+Xi8IXCQc4dwgb+77c7tLOZ2y5/sysW2Qo+eh6dNwipVLb9YFeNPlznw O2zZzL9RB00AukWTiHYJw5kz2+WQwJYBWU0frL+R98KPFUgMBizo1vEdoYI0Gh3+GiP+ 698Q== X-Gm-Message-State: AKS2vOxa3LYDIN5TjqDgA7gWJUm1f3GOlmBCarySJvlG5AKktIMn6dsX aIs3i9b709F7rkqifCg= X-Received: by 10.80.216.10 with SMTP id o10mr22617341edj.81.1497989977118; Tue, 20 Jun 2017 13:19:37 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:837:f300:4131:d708:a975:bd4c]) by smtp.gmail.com with ESMTPSA id r28sm8047501edd.33.2017.06.20.13.19.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jun 2017 13:19:36 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [PATCH 1/3] teach sparse about -m{big,little}-endian Date: Tue, 20 Jun 2017 22:19:29 +0200 Message-Id: <20170620201931.92864-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170620201931.92864-1-luc.vanoostenryck@gmail.com> References: <20170620201931.92864-1-luc.vanoostenryck@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some macros, structures definitions, ... depends on the endianness and thus checking them with sparse demands that sparse is endian-aware. Give this information to sparse with two flags: -mbig-endian/-mlittle-endian, and by default use the endianness of the platform used to compile sparse. Signed-off-by: Luc Van Oostenryck --- lib.c | 15 ++++++++++++++- lib.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib.c b/lib.c index eac84ee3f..a22635ecc 100644 --- a/lib.c +++ b/lib.c @@ -282,6 +282,14 @@ static enum { STANDARD_C89, int arch_m64 = ARCH_M64_DEFAULT; int arch_msize_long = 0; +#ifdef __BIG_ENDIAN__ +#define ARCH_BIG_ENDIAN 1 +#else +#define ARCH_BIG_ENDIAN 0 +#endif +int arch_big_endian = ARCH_BIG_ENDIAN; + + #define CMDLINE_INCLUDE 20 static int cmdline_include_nr = 0; static char *cmdline_include[CMDLINE_INCLUDE]; @@ -410,8 +418,13 @@ static char **handle_switch_m(char *arg, char **next) arch_m64 = ARCH_LLP64; } else if (!strcmp(arg, "msize-long")) { arch_msize_long = 1; - } else if (!strcmp(arg, "multiarch-dir")) + } else if (!strcmp(arg, "multiarch-dir")) { return handle_multiarch_dir(arg, next); + } else if (!strcmp(arg, "mbig-endian")) { + arch_big_endian = 1; + } else if (!strcmp(arg, "mlittle-endian")) { + arch_big_endian = 0; + } return next; } diff --git a/lib.h b/lib.h index e09f47f12..3f8d3615a 100644 --- a/lib.h +++ b/lib.h @@ -150,6 +150,7 @@ extern int fdump_linearize; extern unsigned long long fmemcpy_max_count; extern int arch_m64; +extern int arch_big_endian; extern void declare_builtin_functions(void); extern void create_builtin_stream(void);