A few changes in tests about number of bits in integers

- The preprocessor must work with at least 'long', and therefore must
do shifts of up to 31 bits correctly.
- Whenever possible, use unsigned types in shifts.
diff --git a/llimits.h b/llimits.h
index 950e7e6..2b52c83 100644
--- a/llimits.h
+++ b/llimits.h
@@ -15,10 +15,6 @@
 #include "lua.h"
 
 
-/* minimum number of bits in an integer */
-#define LUAI_BITSINT	(LUAI_IS32INT ? 32 : 16)
-
-
 /*
 ** 'lu_mem' and 'l_mem' are unsigned/signed integers big enough to count
 ** the total memory used by Lua (in bytes). Usually, 'size_t' and
diff --git a/lmathlib.c b/lmathlib.c
index e3ccc3e..3454c41 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -266,7 +266,7 @@
 
 /* try to find an integer type with at least 64 bits */
 
-#if (LONG_MAX >> 31 >> 31) >= 1
+#if (ULONG_MAX >> 31 >> 31) >= 3
 
 /* 'long' has at least 64 bits */
 #define Rand64		unsigned long
@@ -276,7 +276,7 @@
 /* there is a 'long long' type (which must have at least 64 bits) */
 #define Rand64		unsigned long long
 
-#elif (LUA_MAXINTEGER >> 31 >> 31) >= 1
+#elif (LUA_MAXINTEGER >> 30 >> 30) >= 7
 
 /* 'lua_Integer' has at least 64 bits */
 #define Rand64		lua_Unsigned
@@ -347,7 +347,7 @@
 #else	/* no 'Rand64'   }{ */
 
 /* get an integer with at least 32 bits */
-#if (INT_MAX >> 30) >= 1
+#if LUAI_IS32INT
 typedef unsigned int lu_int32;
 #else
 typedef unsigned long lu_int32;
@@ -538,7 +538,7 @@
     lim |= (lim >> 4);
     lim |= (lim >> 8);
     lim |= (lim >> 16);
-#if (LUA_MAXINTEGER >> 30 >> 1) > 0
+#if (LUA_MAXINTEGER >> 30) >= 3
     lim |= (lim >> 32);  /* integer type has more than 32 bits */
 #endif
   }
diff --git a/lopcodes.h b/lopcodes.h
index bbdd689..a314dcd 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -57,12 +57,18 @@
 
 #define POS_sJ		POS_A
 
+
 /*
 ** limits for opcode arguments.
-** we use (signed) int to manipulate most arguments,
-** so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
+** we use (signed) 'int' to manipulate most arguments,
+** so they must fit in ints.
 */
-#if SIZE_Bx < LUAI_BITSINT-1
+
+/* Check whether type 'int' has at least 'b' bits ('b' < 32) */
+#define L_INTHASBITS(b)		((UINT_MAX >> ((b) - 1)) >= 1)
+
+
+#if L_INTHASBITS(SIZE_Bx)
 #define MAXARG_Bx	((1<<SIZE_Bx)-1)
 #else
 #define MAXARG_Bx	MAX_INT
@@ -71,13 +77,13 @@
 #define OFFSET_sBx	(MAXARG_Bx>>1)         /* 'sBx' is signed */
 
 
-#if SIZE_Ax < LUAI_BITSINT-1
+#if L_INTHASBITS(SIZE_Ax)
 #define MAXARG_Ax	((1<<SIZE_Ax)-1)
 #else
 #define MAXARG_Ax	MAX_INT
 #endif
 
-#if SIZE_sJ < LUAI_BITSINT-1
+#if L_INTHASBITS(SIZE_sJ)
 #define MAXARG_sJ	((1 << SIZE_sJ) - 1)
 #else
 #define MAXARG_sJ	MAX_INT
diff --git a/ltable.c b/ltable.c
index 628c640..d8ff3d8 100644
--- a/ltable.c
+++ b/ltable.c
@@ -214,8 +214,8 @@
     size |= (size >> 4);
     size |= (size >> 8);
     size |= (size >> 16);
-#if (INT_MAX >> 30 >> 1) > 0
-    size |= (size >> 32);  /* int has more than 32 bits */
+#if (UINT_MAX >> 30) > 3
+    size |= (size >> 32);  /* unsigned int has more than 32 bits */
 #endif
     size++;
     lua_assert(ispow2(size) && size/2 < t->alimit && t->alimit < size);
diff --git a/luaconf.h b/luaconf.h
index 4647ba1..e6271b8 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -87,9 +87,8 @@
 
 /*
 @@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits.
-** (the use of two shifts avoids undefined shifts)
 */
-#define LUAI_IS32INT	(((UINT_MAX >> 15) >> 15) >= 3)
+#define LUAI_IS32INT	((UINT_MAX >> 30) >= 3)
 
 /* }================================================================== */
 
diff --git a/lutf8lib.c b/lutf8lib.c
index 9786b60..b4b787e 100644
--- a/lutf8lib.c
+++ b/lutf8lib.c
@@ -28,7 +28,7 @@
 /*
 ** Integer type for decoded UTF-8 values; MAXUTF needs 31 bits.
 */
-#if ((UINT_MAX >> 15) >> 15) >= 1
+#if (UINT_MAX >> 30) >= 1
 typedef	unsigned int utfint;
 #else
 typedef unsigned long utfint;