summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2018-03-14 21:03:10 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2018-03-14 21:03:10 +0100
commitbbb3f79baf0e013bbde52f676c9653cfbce3c28e (patch)
treeb8a331ae942ef3545b1e6837a92f34d86979f82e
parent1f33067f6e2231724a285bae8b7f9b6f4f308006 (diff)
Factor out check for size of int, long and pointer.
-rw-r--r--src/driver/predefs.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/driver/predefs.c b/src/driver/predefs.c
index b0deef2..2e93079 100644
--- a/src/driver/predefs.c
+++ b/src/driver/predefs.c
@@ -258,6 +258,14 @@ static void define_float_properties(const char *prefix,
add_define_prop_fmt("__%s_HAS_QUIET_NAN__", prefix, "1");
}
+static bool is_ILP(unsigned const size_int, unsigned const size_long, unsigned const size_pointer)
+{
+ return
+ get_atomic_type_size(ATOMIC_TYPE_INT) == size_int &&
+ get_atomic_type_size(ATOMIC_TYPE_LONG) == size_long &&
+ get_ctype_size(type_void_ptr) == size_pointer;
+}
+
void add_predefined_macros(void)
{
add_define("__STDC__", "1", true);
@@ -317,14 +325,10 @@ void add_predefined_macros(void)
add_define("__FINITE_MATH_ONLY__", "0", false);
- if (get_atomic_type_size(ATOMIC_TYPE_LONG) == 8
- && get_ctype_size(type_void_ptr) == 8
- && get_atomic_type_size(ATOMIC_TYPE_INT) == 4) {
+ if (is_ILP(4, 8, 8)) {
add_define("_LP64", "1", false);
add_define("__LP64__", "1", false);
- } else if (get_atomic_type_size(ATOMIC_TYPE_LONG) == 4
- && get_ctype_size(type_void_ptr) == 4
- && get_atomic_type_size(ATOMIC_TYPE_INT) == 4) {
+ } else if (is_ILP(4, 4, 4)) {
add_define("_ILP32", "1", false);
add_define("__ILP32__", "1", false);
}