deleted file mode 100644
@@ -1,16 +0,0 @@
-#define TEST_BIT(X, T) if (__ ## X ## _BIT__ != 8 * sizeof(T)) return 1
-
-int test(void)
-{
- TEST_BIT(CHAR, char);
-
- return 0;
-}
-
-/*
- * check-name: predefined __<type>_BIT__
- * check-command: test-linearize -Wno-decl $file
- * check-output-ignore
- *
- * check-output-contains: ret\\..*\\$0
- */
new file mode 100644
@@ -0,0 +1,10 @@
+#include "predef.c"
+
+/*
+ * 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
+ */
new file mode 100644
@@ -0,0 +1,9 @@
+#include "predef.c"
+
+/*
+ * check-name: predefined macros for LP32
+ * check-command: test-linearize -Wno-decl -m32 $file
+ * check-output-ignore
+ *
+ * check-output-contains: ret\\..*\\$0
+ */
new file mode 100644
@@ -0,0 +1,9 @@
+#include "predef.c"
+
+/*
+ * check-name: predefined macros for LP64
+ * check-command: test-linearize -Wno-decl -m64 $file
+ * check-output-ignore
+ *
+ * check-output-contains: ret\\..*\\$0
+ */
deleted file mode 100644
@@ -1,18 +0,0 @@
-#define TEST_MAX(X, Z) if (X != ((~ Z) >> 1)) return 1
-
-int test_max(void)
-{
- TEST_MAX(__INT_MAX__, 0U);
- TEST_MAX(__LONG_MAX__, 0UL);
- TEST_MAX(__LONG_LONG_MAX__, 0ULL);
-
- return 0;
-}
-
-/*
- * check-name: predefined __<type>_MAX__
- * check-command: test-linearize -Wno-decl $file
- * check-output-ignore
- *
- * check-output-contains: ret\\..*\\$0
- */
deleted file mode 100644
@@ -1,25 +0,0 @@
-#define TEST(X, T) if (__SIZEOF_ ## X ## __ != sizeof(T)) return 1
-
-int test_sizeof(void)
-{
- TEST(SHORT, short);
- TEST(INT, int);
- TEST(LONG, long);
- TEST(LONG_LONG, long long);
- TEST(INT128, __int128);
- TEST(SIZE_T, __SIZE_TYPE__);
- TEST(POINTER, void*);
- TEST(FLOAT, float);
- TEST(DOUBLE, double);
- TEST(LONG_DOUBLE, long double);
-
- return 0;
-}
-
-/*
- * check-name: predefined __SIZEOF_<type>__
- * check-command: test-linearize -Wno-decl $file
- * check-output-ignore
- *
- * check-output-contains: ret\\..*\\$0
- */
new file mode 100644
@@ -0,0 +1,42 @@
+#define BITS(T) (sizeof(T) * 8)
+#define SIGN_BIT(T) (1ULL << (BITS(T) - 1))
+#define SMASK(T) (SIGN_BIT(T) - 1)
+#define UMASK(T) (SIGN_BIT(T) | SMASK(T))
+
+int test(void);
+int test(void)
+{
+#define TEST_BIT(X, T) if (__ ## X ## _BIT__ != BITS(T)) return 1
+ TEST_BIT(CHAR, char);
+
+#define TEST_MAX(X, M) if (__ ## X ## _MAX__ != M) return 1
+#define TEST_SMAX(X, T) TEST_MAX(X, SMASK(T))
+#define TEST_UMAX(X, T) TEST_MAX(X, UMASK(T))
+ TEST_SMAX(SCHAR, signed char);
+ TEST_SMAX(SHRT, short);
+ TEST_SMAX(INT, int);
+ TEST_SMAX(LONG, long);
+ TEST_SMAX(LONG_LONG, long long);
+
+#define TEST_SIZEOF(X, T) if (__SIZEOF_ ## X ## __ != sizeof(T)) return 1
+ TEST_SIZEOF(SHORT, short);
+ TEST_SIZEOF(INT, int);
+ TEST_SIZEOF(LONG, long);
+ TEST_SIZEOF(LONG_LONG, long long);
+ TEST_SIZEOF(INT128, __int128);
+ TEST_SIZEOF(SIZE_T, __SIZE_TYPE__);
+ TEST_SIZEOF(POINTER, void*);
+ TEST_SIZEOF(FLOAT, float);
+ TEST_SIZEOF(DOUBLE, double);
+ TEST_SIZEOF(LONG_DOUBLE, long double);
+
+ return 0;
+}
+
+/*
+ * check-name: predefined macros: __SIZEOF_<type>__, ...
+ * check-command: test-linearize -Wno-decl $file
+ * check-output-ignore
+ *
+ * check-output-contains: ret\\..*\\$0
+ */
Now these tests should succeed and be meaningful on all archs. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- validation/preprocessor/predef-char-bit.c | 16 --------- validation/preprocessor/predef-llp64.c | 10 ++++++ validation/preprocessor/predef-lp32.c | 9 +++++ validation/preprocessor/predef-lp64.c | 9 +++++ validation/preprocessor/predef-max.c | 18 ---------- validation/preprocessor/predef-sizeof.c | 25 -------------- validation/preprocessor/predef.c | 42 +++++++++++++++++++++++ 7 files changed, 70 insertions(+), 59 deletions(-) delete mode 100644 validation/preprocessor/predef-char-bit.c create mode 100644 validation/preprocessor/predef-llp64.c create mode 100644 validation/preprocessor/predef-lp32.c create mode 100644 validation/preprocessor/predef-lp64.c delete mode 100644 validation/preprocessor/predef-max.c delete mode 100644 validation/preprocessor/predef-sizeof.c create mode 100644 validation/preprocessor/predef.c