summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-05-24 16:48:09 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-05-24 16:48:09 -0300
commit1e6918d553e0d76148f7de0af63fdce326e049b8 (patch)
tree0f20249f37a4d36b0c4b21e2dc629cb0ab722faa
parent681297187ec45268e872b26753c441586c12bdd8 (diff)
downloadlua-github-1e6918d553e0d76148f7de0af63fdce326e049b8.tar.gz
Details
- Removed unused (and trivial) definition LUA_UNSIGNEDBITS - Alignment structure in pack/unpack moved to a narrower scope
-rw-r--r--lstrlib.c17
-rw-r--r--luaconf.h4
2 files changed, 7 insertions, 14 deletions
diff --git a/lstrlib.c b/lstrlib.c
index 47e5b27a..74501f78 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1352,15 +1352,6 @@ static const union {
} 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 @@ static void initheader (lua_State *L, Header *h) {
** 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 @@ static KOption getoption (Header *h, const char **fmt, int *size) {
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 e64d2ee3..d42d14b7 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 */