[PATCH v2 02/14] fix '__SIZE_TYPE__' for LLP64

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

 



size_t_ctype is set to uint, ulong or ullong, depending on
the architecture (ullong is only used for LLP64).

However, when emitting '__SIZE_TYPE__', it's only compared to ulong
or uint.

Fix this by using an small helper directly using the right
struct symbol * and using builtin_typename() to output the
right type. This way we're guaranteed that '__SIZE_TYPE__'
is kept coherent with the internal type: size_t_ctype.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 lib.c                                  | 17 +++++++----------
 validation/preprocessor/predef-llp64.c |  1 -
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/lib.c b/lib.c
index 5c2059f23..8136b3368 100644
--- a/lib.c
+++ b/lib.c
@@ -1176,6 +1176,12 @@ static void predefined_type_size(const char *name, const char *suffix, unsigned
 	predefined_width(name, bits);
 }
 
+static void predefined_type(const char *name, struct symbol *type)
+{
+	const char *typename = builtin_typename(type);
+	add_pre_buffer("#weak_define __%s_TYPE__ %s\n", name, typename);
+}
+
 static void predefined_macros(void)
 {
 	predefine("__CHECKER__", 0, "1");
@@ -1269,16 +1275,7 @@ static void create_builtin_stream(void)
 	// Temporary hack
 	add_pre_buffer("#define _Pragma(x)\n");
 
-	// gcc defines __SIZE_TYPE__ to be size_t.  For linux/i86 and
-	// solaris/sparc that is really "unsigned int" and for linux/x86_64
-	// it is "long unsigned int".  In either case we can probably
-	// get away with this.  We need the #weak_define as cgcc will define
-	// the right __SIZE_TYPE__.
-	if (size_t_ctype == &ulong_ctype)
-		add_pre_buffer("#weak_define __SIZE_TYPE__ long unsigned int\n");
-	else
-		add_pre_buffer("#weak_define __SIZE_TYPE__ unsigned int\n");
-
+	predefined_type("SIZE", size_t_ctype);
 
 	/* add the multiarch include directories, if any */
 	if (multiarch_dir && *multiarch_dir) {
diff --git a/validation/preprocessor/predef-llp64.c b/validation/preprocessor/predef-llp64.c
index a34b51b3a..0a758690c 100644
--- a/validation/preprocessor/predef-llp64.c
+++ b/validation/preprocessor/predef-llp64.c
@@ -3,7 +3,6 @@
 /*
  * check-name: predefined macros for LLP64
  * check-command: test-linearize -Wno-decl -msize-llp64 $file
- * check-known-to-fail
  * check-output-ignore
  *
  * check-output-contains: ret\\..*\\$0
-- 
2.19.0




[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