aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/arch/mips32.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-10-27 11:35:09 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-10-30 09:52:14 +0100
commit2c06f143fa63394dbdfa07f3f9d00b24b7c902c5 (patch)
tree6c19c53230ab117d2bf82f64b64ea7e50962d1dc /validation/arch/mips32.c
parent0a35fa5b1ce9be51c0a2f557fdfe75fabdf58a23 (diff)
downloadsparse-dev-2c06f143fa63394dbdfa07f3f9d00b24b7c902c5.tar.gz
arch: add an option to specify the desired arch: --arch=<arch>
Sparse is universal in the sense that the same executable can be used for all architectures. For this, most arch-specific setting can be set with an option and the default values are taken from the host machine. This is working nicely for native targets. However, for cross- compilation, while seeming to work relatively well (thanks to the kernel build system using -m32/-m64 for all archs, for example) things can never work 100% correctly. For example, in the case an X86-64 host machine is used for an ARM target, the kernel build system will call sparse with -m32, Sparse will 'autodetect' the target arch as i386 (x86-64 + -m32) and will then predefine the macro __i386__. Most of the time this is not a problem (at least for the kernel) unless, of course, if the code contains something like: #ifdef __i386__ ... #elif __arm__ ... So, add an option --arch=<arch> to specify the target architecture. The native arch is still used if no such flag is given. Reported-by: Ben Dooks <ben.dooks@codethink.co.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/arch/mips32.c')
-rw-r--r--validation/arch/mips32.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/validation/arch/mips32.c b/validation/arch/mips32.c
new file mode 100644
index 00000000..339218b6
--- /dev/null
+++ b/validation/arch/mips32.c
@@ -0,0 +1,29 @@
+__mips__
+__mips
+__mips64__
+__i386__
+__x86_64__
+__LP64__
+__BYTE_ORDER__
+__SIZEOF_INT__
+__SIZEOF_LONG__
+__SIZE_TYPE__
+
+/*
+ * check-name: arch/mips32
+ * check-command: sparse --arch=mips32 -E $file
+ *
+ * check-output-start
+
+1
+32
+__mips64__
+__i386__
+__x86_64__
+__LP64__
+4321
+4
+4
+unsigned int
+ * check-output-end
+ */