diff options
| -rw-r--r-- | lstrlib.c | 17 | ||||
| -rw-r--r-- | luaconf.h | 4 |
2 files changed, 7 insertions, 14 deletions
| @@ -1352,15 +1352,6 @@ static const union { | |||
| 1352 | } nativeendian = {1}; | 1352 | } nativeendian = {1}; |
| 1353 | 1353 | ||
| 1354 | 1354 | ||
| 1355 | /* dummy structure to get native alignment requirements */ | ||
| 1356 | struct cD { | ||
| 1357 | char c; | ||
| 1358 | union { double d; void *p; lua_Integer i; lua_Number n; } u; | ||
| 1359 | }; | ||
| 1360 | |||
| 1361 | #define MAXALIGN (offsetof(struct cD, u)) | ||
| 1362 | |||
| 1363 | |||
| 1364 | /* | 1355 | /* |
| 1365 | ** information to pack/unpack stuff | 1356 | ** information to pack/unpack stuff |
| 1366 | */ | 1357 | */ |
| @@ -1435,6 +1426,8 @@ static void initheader (lua_State *L, Header *h) { | |||
| 1435 | ** Read and classify next option. 'size' is filled with option's size. | 1426 | ** Read and classify next option. 'size' is filled with option's size. |
| 1436 | */ | 1427 | */ |
| 1437 | static KOption getoption (Header *h, const char **fmt, int *size) { | 1428 | static KOption getoption (Header *h, const char **fmt, int *size) { |
| 1429 | /* dummy structure to get native alignment requirements */ | ||
| 1430 | struct cD { char c; union { LUAI_MAXALIGN; } u; }; | ||
| 1438 | int opt = *((*fmt)++); | 1431 | int opt = *((*fmt)++); |
| 1439 | *size = 0; /* default */ | 1432 | *size = 0; /* default */ |
| 1440 | switch (opt) { | 1433 | switch (opt) { |
| @@ -1465,7 +1458,11 @@ static KOption getoption (Header *h, const char **fmt, int *size) { | |||
| 1465 | case '<': h->islittle = 1; break; | 1458 | case '<': h->islittle = 1; break; |
| 1466 | case '>': h->islittle = 0; break; | 1459 | case '>': h->islittle = 0; break; |
| 1467 | case '=': h->islittle = nativeendian.little; break; | 1460 | case '=': h->islittle = nativeendian.little; break; |
| 1468 | case '!': h->maxalign = getnumlimit(h, fmt, MAXALIGN); break; | 1461 | case '!': { |
| 1462 | const int maxalign = offsetof(struct cD, u); | ||
| 1463 | h->maxalign = getnumlimit(h, fmt, maxalign); | ||
| 1464 | break; | ||
| 1465 | } | ||
| 1469 | default: luaL_error(h->L, "invalid format option '%c'", opt); | 1466 | default: luaL_error(h->L, "invalid format option '%c'", opt); |
| 1470 | } | 1467 | } |
| 1471 | return Knop; | 1468 | return Knop; |
| @@ -485,7 +485,6 @@ | |||
| 485 | @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. | 485 | @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. |
| 486 | @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. | 486 | @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. |
| 487 | @@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED. | 487 | @@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED. |
| 488 | @@ LUA_UNSIGNEDBITS is the number of bits in a LUA_UNSIGNED. | ||
| 489 | @@ lua_integer2str converts an integer to a string. | 488 | @@ lua_integer2str converts an integer to a string. |
| 490 | */ | 489 | */ |
| 491 | 490 | ||
| @@ -506,9 +505,6 @@ | |||
| 506 | #define LUA_UNSIGNED unsigned LUAI_UACINT | 505 | #define LUA_UNSIGNED unsigned LUAI_UACINT |
| 507 | 506 | ||
| 508 | 507 | ||
| 509 | #define LUA_UNSIGNEDBITS (sizeof(LUA_UNSIGNED) * CHAR_BIT) | ||
| 510 | |||
| 511 | |||
| 512 | /* now the variable definitions */ | 508 | /* now the variable definitions */ |
| 513 | 509 | ||
| 514 | #if LUA_INT_TYPE == LUA_INT_INT /* { int */ | 510 | #if LUA_INT_TYPE == LUA_INT_INT /* { int */ |
