[PATCH 1/3] teach sparse about -m{big,little}-endian

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux