diff mbox series

[v3,16/19] add predefined macros for [u]int64_t

Message ID 20181214001536.6259-17-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series predefined macros for intmax_t/intptr_t/... | expand

Commit Message

Luc Van Oostenryck Dec. 14, 2018, 12:15 a.m. UTC
All LP32 archs use [u]llong and all LP64 use [u]long for these
but Darwin which seems to always use [u]llong.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 lib.c                            | 8 ++++++++
 target.c                         | 6 ++++++
 target.h                         | 2 ++
 validation/preprocessor/predef.c | 2 ++
 4 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/lib.c b/lib.c
index cd427e078..f9015ef35 100644
--- a/lib.c
+++ b/lib.c
@@ -471,9 +471,13 @@  static void handle_arch_m64_finalize(void)
 		max_int_alignment = 8;
 		predefine("__ILP32__", 1, "1");
 		predefine("_ILP32", 1, "1");
+		int64_ctype = &llong_ctype;
+		uint64_ctype = &ullong_ctype;
 		goto case_x86_64;
 	case ARCH_LP32:
 		/* default values */
+		int64_ctype = &llong_ctype;
+		uint64_ctype = &ullong_ctype;
 		intmax_ctype = &llong_ctype;
 		uintmax_ctype = &ullong_ctype;
 		return;
@@ -492,6 +496,8 @@  static void handle_arch_m64_finalize(void)
 		max_int_alignment = 8;
 		size_t_ctype = &ullong_ctype;
 		ssize_t_ctype = &llong_ctype;
+		int64_ctype = &llong_ctype;
+		uint64_ctype = &ullong_ctype;
 		predefine("__LLP64__", 1, "1");
 		goto case_64bit_common;
 	case_64bit_common:
@@ -1245,6 +1251,8 @@  static void predefined_macros(void)
 	predefined_ctype("UINT8",     &uchar_ctype, PTYPE_MAX|PTYPE_TYPE);
 	predefined_ctype("INT16",     &short_ctype, PTYPE_MAX|PTYPE_TYPE);
 	predefined_ctype("UINT16",   &ushort_ctype, PTYPE_MAX|PTYPE_TYPE);
+	predefined_ctype("INT64",      int64_ctype, PTYPE_MAX|PTYPE_TYPE);
+	predefined_ctype("UINT64",    uint64_ctype, PTYPE_MAX|PTYPE_TYPE);
 
 	predefined_sizeof("INT128", "", 128);
 
diff --git a/target.c b/target.c
index 313288258..fe3756f80 100644
--- a/target.c
+++ b/target.c
@@ -8,6 +8,8 @@  struct symbol *size_t_ctype = &uint_ctype;
 struct symbol *ssize_t_ctype = &int_ctype;
 struct symbol *intmax_ctype = &llong_ctype;
 struct symbol *uintmax_ctype = &ullong_ctype;
+struct symbol *int64_ctype = &long_ctype;
+struct symbol *uint64_ctype = &ulong_ctype;
 struct symbol *wchar_ctype = &int_ctype;
 struct symbol *wint_ctype = &uint_ctype;
 
@@ -75,4 +77,8 @@  void init_target(void)
 #if defined(__FreeBSD__) || defined(__APPLE__)
 	wint_ctype = &int_ctype;
 #endif
+#if defined(__APPLE__)
+	int64_ctype = &llong_ctype;
+	uint64_ctype = &ullong_ctype;
+#endif
 }
diff --git a/target.h b/target.h
index d764d4182..7b1d96498 100644
--- a/target.h
+++ b/target.h
@@ -5,6 +5,8 @@  extern struct symbol *size_t_ctype;
 extern struct symbol *ssize_t_ctype;
 extern struct symbol *intmax_ctype;
 extern struct symbol *uintmax_ctype;
+extern struct symbol *int64_ctype;
+extern struct symbol *uint64_ctype;
 extern struct symbol *wchar_ctype;
 extern struct symbol *wint_ctype;
 
diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c
index 7a7b575a3..f00a471fc 100644
--- a/validation/preprocessor/predef.c
+++ b/validation/preprocessor/predef.c
@@ -21,6 +21,8 @@  int test(void)
 	TEST_MAX(UINT8,  0xffU);
 	TEST_MAX( INT16, 0x7fff);
 	TEST_MAX(UINT16, 0xffffU);
+	TEST_MAX( INT64, 0x7fffffffffffffffLL);
+	TEST_MAX(UINT64, 0xffffffffffffffffULL);
 	TEST_SMAX(INTMAX, __INTMAX_TYPE__);
 	TEST_UMAX(UINTMAX, __UINTMAX_TYPE__);
 	TEST_SMAX(INTPTR, __INTPTR_TYPE__);