aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/bits/xopen_lim.h51
-rw-r--r--include/limits.h6
2 files changed, 45 insertions, 12 deletions
diff --git a/include/bits/xopen_lim.h b/include/bits/xopen_lim.h
index 823c801e48..e874dba73c 100644
--- a/include/bits/xopen_lim.h
+++ b/include/bits/xopen_lim.h
@@ -92,23 +92,54 @@
/* Number of bits in a word of type `int'. */
-#if INT_MAX == 32767
-# define WORD_BIT 16
-#else
-# if INT_MAX == 2147483647
-# define WORD_BIT 32
+#ifdef INT_MAX
+# if INT_MAX == 32767
+# define WORD_BIT 16
+# else
+# if INT_MAX == 2147483647
+# define WORD_BIT 32
+# else
+/* Safe assumption. */
+# define WORD_BIT 64
+# endif
+# endif
+#elif defined __INT_MAX__
+# if __INT_MAX__ == 32767
+# define WORD_BIT 16
# else
+# if __INT_MAX__ == 2147483647
+# define WORD_BIT 32
+# else
/* Safe assumption. */
-# define WORD_BIT 64
+# define WORD_BIT 64
+# endif
# endif
+#else
+# define WORD_BIT 32
#endif
/* Number of bits in a word of type `long int'. */
-#if LONG_MAX == 2147483647
-# define LONG_BIT 32
-#else
+#ifdef LONG_MAX
+# if LONG_MAX == 2147483647
+# define LONG_BIT 32
+# else
/* Safe assumption. */
-# define LONG_BIT 64
+# define LONG_BIT 64
+# endif
+#elif defined __LONG_MAX__
+# if __LONG_MAX__ == 2147483647
+# define LONG_BIT 32
+# else
+/* Safe assumption. */
+# define LONG_BIT 64
+# endif
+#else
+# include <bits/wordsize.h>
+# if __WORDSIZE == 64
+# define LONG_BIT 64
+# else
+# define LONG_BIT 32
+# endif
#endif
#endif /* bits/xopen_lim.h */
diff --git a/include/limits.h b/include/limits.h
index d0c3d613f5..0e8eb9c6b3 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -42,6 +42,8 @@
# ifndef _LIMITS_H
# define _LIMITS_H 1
+#include <bits/wordsize.h>
+
/* We don't have #include_next.
Define ANSI <limits.h> for standard 32-bit words. */
@@ -82,7 +84,7 @@
# define UINT_MAX 4294967295U
/* Minimum and maximum values a `signed long int' can hold. */
-# ifdef __alpha__
+# if __WORDSIZE == 64
# define LONG_MAX 9223372036854775807L
# else
# define LONG_MAX 2147483647L
@@ -90,7 +92,7 @@
# define LONG_MIN (-LONG_MAX - 1L)
/* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
-# ifdef __alpha__
+# if __WORDSIZE == 64
# define ULONG_MAX 18446744073709551615UL
# else
# define ULONG_MAX 4294967295UL