[PATCH 03/11] allow optional "_T" suffix to __SIZEOF_XXX__

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

 



This allows to be more generic.
---
 lib.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib.c b/lib.c
index 8136b3368..db33e58b2 100644
--- a/lib.c
+++ b/lib.c
@@ -1144,11 +1144,11 @@ static char **handle_switch(char *arg, char **next)
 	return next;
 }
 
-static void predefined_sizeof(const char *name, unsigned bits)
+static void predefined_sizeof(const char *name, const char *suffix, unsigned bits)
 {
 	char buf[32];
 
-	snprintf(buf, sizeof(buf), "__SIZEOF_%s__", name);
+	snprintf(buf, sizeof(buf), "__SIZEOF_%s%s__", name, suffix);
 	predefine(buf, 1, "%d", bits/8);
 }
 
@@ -1172,7 +1172,7 @@ static void predefined_max(const char *name, const char *suffix, unsigned bits)
 static void predefined_type_size(const char *name, const char *suffix, unsigned bits)
 {
 	predefined_max(name, suffix, bits);
-	predefined_sizeof(name, bits);
+	predefined_sizeof(name, "", bits);
 	predefined_width(name, bits);
 }
 
@@ -1223,12 +1223,12 @@ static void predefined_macros(void)
 		break;
 	}
 
-	predefined_sizeof("SHORT", bits_in_short);
+	predefined_sizeof("SHORT", "", bits_in_short);
 	predefined_max("SHRT", "", bits_in_short);
 	predefined_width("SHRT",   bits_in_short);
 	predefined_max("SCHAR", "", bits_in_char);
 	predefined_width("SCHAR",   bits_in_char);
-	predefined_sizeof("WCHAR_T",bits_in_wchar);
+	predefined_sizeof("WCHAR", "_T", bits_in_wchar);
 	predefined_max("WCHAR", "", bits_in_wchar);
 	predefined_width("WCHAR",   bits_in_wchar);
 	predefine("__CHAR_BIT__", 1, "%d", bits_in_char);
@@ -1237,17 +1237,17 @@ static void predefined_macros(void)
 	predefined_type_size("LONG", "L", bits_in_long);
 	predefined_type_size("LONG_LONG", "LL", bits_in_longlong);
 
-	predefined_sizeof("INT128", 128);
+	predefined_sizeof("INT128", "", 128);
 
-	predefined_sizeof("SIZE_T", bits_in_pointer);
+	predefined_sizeof("SIZE", "_T", bits_in_pointer);
 	predefined_width( "SIZE",   bits_in_pointer);
-	predefined_sizeof("PTRDIFF_T", bits_in_pointer);
+	predefined_sizeof("PTRDIFF", "_T", bits_in_pointer);
 	predefined_width( "PTRDIFF",   bits_in_pointer);
-	predefined_sizeof("POINTER", bits_in_pointer);
+	predefined_sizeof("POINTER", "", bits_in_pointer);
 
-	predefined_sizeof("FLOAT", bits_in_float);
-	predefined_sizeof("DOUBLE", bits_in_double);
-	predefined_sizeof("LONG_DOUBLE", bits_in_longdouble);
+	predefined_sizeof("FLOAT", "", bits_in_float);
+	predefined_sizeof("DOUBLE", "", bits_in_double);
+	predefined_sizeof("LONG_DOUBLE", "", bits_in_longdouble);
 
 	predefine("__ORDER_LITTLE_ENDIAN__", 1, "1234");
 	predefine("__ORDER_BIG_ENDIAN__", 1, "4321");
-- 
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