diff --git a/ldump.c b/ldump.c
index 54f96674..d8fca317 100644
--- a/ldump.c
+++ b/ldump.c
@@ -87,7 +87,7 @@ static void dumpByte (DumpState *D, int y) {
 ** size for 'dumpVarint' buffer: each byte can store up to 7 bits.
 ** (The "+6" rounds up the division.)
 */
-#define DIBS    ((sizeof(size_t) * CHAR_BIT + 6) / 7)
+#define DIBS    ((l_numbits(size_t) + 6) / 7)
 
 /*
 ** Dumps an unsigned integer using the MSB Varint encoding
diff --git a/lfunc.c b/lfunc.c
index c62a5d23..da7c6239 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -162,13 +162,8 @@ static void prepcallclosemth (lua_State *L, StkId level, TStatus status,
 }
 
 
-/*
-** Maximum value for deltas in 'tbclist', dependent on the type
-** of delta. (This macro assumes that an 'L' is in scope where it
-** is used.)
-*/
-#define MAXDELTA  \
-	((256ul << ((sizeof(L->stack.p->tbclist.delta) - 1) * 8)) - 1)
+/* Maximum value for deltas in 'tbclist' */
+#define MAXDELTA       USHRT_MAX
 
 
 /*
diff --git a/llimits.h b/llimits.h
index d206e9e1..710dc1b4 100644
--- a/llimits.h
+++ b/llimits.h
@@ -15,6 +15,8 @@
 #include "lua.h"
 
 
+#define l_numbits(t)	cast_int(sizeof(t) * CHAR_BIT)
+
 /*
 ** 'l_mem' is a signed integer big enough to count the total memory
 ** used by Lua.  (It is signed due to the use of debt in several
@@ -33,7 +35,7 @@ typedef unsigned long lu_mem;
 #endif				/* } */
 
 #define MAX_LMEM  \
-	cast(l_mem, (cast(lu_mem, 1) << (sizeof(l_mem) * 8 - 1)) - 1)
+	cast(l_mem, (cast(lu_mem, 1) << (l_numbits(l_mem) - 1)) - 1)
 
 
 /* chars used as small naturals (so that 'char' is reserved for characters) */
@@ -61,7 +63,7 @@ typedef lu_byte TStatus;
 ** floor of the log2 of the maximum signed value for integral type 't'.
 ** (That is, maximum 'n' such that '2^n' fits in the given signed type.)
 */
-#define log2maxs(t)	cast_int(sizeof(t) * 8 - 2)
+#define log2maxs(t)	(l_numbits(t) - 2)
 
 
 /*
diff --git a/ltable.c b/ltable.c
index 8df9a4fb..0b3ec176 100644
--- a/ltable.c
+++ b/ltable.c
@@ -67,7 +67,7 @@ typedef union {
 ** MAXABITS is the largest integer such that 2^MAXABITS fits in an
 ** unsigned int.
 */
-#define MAXABITS	cast_int(sizeof(int) * CHAR_BIT - 1)
+#define MAXABITS	(l_numbits(int) - 1)
 
 
 /*
diff --git a/ltests.h b/ltests.h
index af5641ba..34205167 100644
--- a/ltests.h
+++ b/ltests.h
@@ -142,9 +142,6 @@ LUA_API void *debug_realloc (void *ud, void *block,
 #define STRCACHE_N	23
 #define STRCACHE_M	5
 
-#undef LUAI_USER_ALIGNMENT_T
-#define LUAI_USER_ALIGNMENT_T   union { char b[sizeof(void*) * 8]; }
-
 
 /*
 ** This one is not compatible with tests for opcode optimizations,
diff --git a/lvm.c b/lvm.c
index f14397d4..e2c36ef5 100644
--- a/lvm.c
+++ b/lvm.c
@@ -774,7 +774,7 @@ lua_Number luaV_modf (lua_State *L, lua_Number m, lua_Number n) {
 
 
 /* number of bits in an integer */
-#define NBITS	cast_int(sizeof(lua_Integer) * CHAR_BIT)
+#define NBITS	l_numbits(lua_Integer)
 
 
 /*