Details
- Removed unused (and trivial) definition LUA_UNSIGNEDBITS
- Alignment structure in pack/unpack moved to a narrower scope
diff --git a/lstrlib.c b/lstrlib.c
index 47e5b27..74501f7 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1352,15 +1352,6 @@
} nativeendian = {1};
-/* dummy structure to get native alignment requirements */
-struct cD {
- char c;
- union { double d; void *p; lua_Integer i; lua_Number n; } u;
-};
-
-#define MAXALIGN (offsetof(struct cD, u))
-
-
/*
** information to pack/unpack stuff
*/
@@ -1435,6 +1426,8 @@
** Read and classify next option. 'size' is filled with option's size.
*/
static KOption getoption (Header *h, const char **fmt, int *size) {
+ /* dummy structure to get native alignment requirements */
+ struct cD { char c; union { LUAI_MAXALIGN; } u; };
int opt = *((*fmt)++);
*size = 0; /* default */
switch (opt) {
@@ -1465,7 +1458,11 @@
case '<': h->islittle = 1; break;
case '>': h->islittle = 0; break;
case '=': h->islittle = nativeendian.little; break;
- case '!': h->maxalign = getnumlimit(h, fmt, MAXALIGN); break;
+ case '!': {
+ const int maxalign = offsetof(struct cD, u);
+ h->maxalign = getnumlimit(h, fmt, maxalign);
+ break;
+ }
default: luaL_error(h->L, "invalid format option '%c'", opt);
}
return Knop;
diff --git a/luaconf.h b/luaconf.h
index e64d2ee..d42d14b 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -485,7 +485,6 @@
@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
@@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED.
-@@ LUA_UNSIGNEDBITS is the number of bits in a LUA_UNSIGNED.
@@ lua_integer2str converts an integer to a string.
*/
@@ -506,9 +505,6 @@
#define LUA_UNSIGNED unsigned LUAI_UACINT
-#define LUA_UNSIGNEDBITS (sizeof(LUA_UNSIGNED) * CHAR_BIT)
-
-
/* now the variable definitions */
#if LUA_INT_TYPE == LUA_INT_INT /* { int */