just predefine stdc inttypes
[m6w6/ext-psi] / src / token.h
index cf9423fba8320d573e870cd1f848fffc11bbf6dd..643864662d82bb5f54eeabb34d3dad71e220d5ee 100644 (file)
@@ -49,9 +49,53 @@ static inline size_t psi_offset_padding(size_t diff, size_t alignment) {
 
 #define PSI_T_CAST                     PSI_T_EQUALS
 #define PSI_T_POINTER          PSI_T_ASTERISK
-#define PSI_T_LONG_DOUBLE      (PSI_T_DOUBLE << 16)
-#define PSI_T_BSLASH           (PSI_T_SLASH << 16)
+
 #define PSI_T_WHITESPACE       -PSI_T_NO_WHITESPACE
+#define PSI_T_BSLASH           -PSI_T_SLASH
+#define PSI_T_LONG_DOUBLE      -PSI_T_DOUBLE
+
+#if SIZEOF_CHAR == SIZEOF_INT8_T
+# define PSI_T_INT8 PSI_T_CHAR
+# define PSI_T_UINT8 -PSI_T_CHAR
+# define ALIGNOF_INT8_T ALIGNOF_CHAR
+# define ALIGNOF_UINT8_T ALIGNOF_CHAR
+#else
+# error SIZEOF_CHAR != 8
+#endif
+#if SIZEOF_SHORT == SIZEOF_INT16_T
+# define PSI_T_INT16 PSI_T_SHORT
+# define PSI_T_UINT16 -PSI_T_SHORT
+# define ALIGNOF_INT16_T ALIGNOF_SHORT
+# define ALIGNOF_UINT16_T ALIGNOF_SHORT
+#else
+# error SIZEOF_SHORT != 16
+#endif
+#if SIZEOF_INT == SIZEOF_INT32_T
+# define PSI_T_INT32 PSI_T_INT
+# define PSI_T_UINT32 -PSI_T_INT
+# define ALIGNOF_INT32_T ALIGNOF_INT
+# define ALIGNOF_UINT32_T ALIGNOF_INT
+#elif SIZEOF_LONG == SIZEOF_INT32_T
+# define PSI_T_INT32 PSI_T_LONG
+# define PSI_T_UINT32 -PSI_T_LONG
+# define ALIGNOF_INT32_T ALIGNOF_LONG
+# define ALIGNOF_UINT32_T ALIGNOF_LONG
+#else
+# error SIZEOF_INT != 32 and SIZEOF_LONG != 32
+#endif
+#if SIZEOF_LONG == SIZEOF_INT64_T
+# define PSI_T_INT64 PSI_T_LONG
+# define PSI_T_UINT64 -PSI_T_LONG
+# define ALIGNOF_INT64_T ALIGNOF_LONG
+# define ALIGNOF_UINT64_T ALIGNOF_LONG
+# elif HAVE_LONG_LONG_INT && SIZEOF_LONG_LONG_INT == SIZEOF_INT64_T
+# define PSI_T_INT64 (PSI_T_LONG << 16)
+# define PSI_T_UINT64 -(PSI_T_LONG << 16)
+# define ALIGNOF_INT64_T ALIGNOF_LONG_LONG
+# define ALIGNOF_UINT64_T ALIGNOF_LONG_LONG
+#else
+# error SIZEOF_LONG != 64 and SIZEOF_LONG_LONG != 64
+#endif
 
 typedef int token_t;