All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Christopher Li <sparse@chrisli.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 1/3] teach sparse about -m{big,little}-endian
Date: Tue, 20 Jun 2017 22:19:29 +0200	[thread overview]
Message-ID: <20170620201931.92864-2-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170620201931.92864-1-luc.vanoostenryck@gmail.com>

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 <luc.vanoostenryck@gmail.com>
---
 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);
-- 
2.13.0


  reply	other threads:[~2017-06-20 20:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20 20:19 [PATCH 0/3] teach sparse about endianness Luc Van Oostenryck
2017-06-20 20:19 ` Luc Van Oostenryck [this message]
2017-06-20 20:19 ` [PATCH 2/3] teach sparse about __{BIG,LITTLE}_ENDIAN__ Luc Van Oostenryck
2017-06-20 20:19 ` [PATCH 3/3] teach sparse about __BYTE_ORDER__ & __ORDER_{BIG,LITTLE}_ENDIAN__ Luc Van Oostenryck
2017-06-21  4:13 ` [PATCH 0/3] teach sparse about endianness Christopher Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170620201931.92864-2-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.