diff --git a/lauxlib.c b/lauxlib.c index 7b14ca4d..2d16c9ce 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.288 2016/12/04 20:17:24 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.289 2016/12/20 18:37:00 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -496,7 +496,7 @@ static void *newbox (lua_State *L, size_t newsize) { ** check whether buffer is using a userdata on the stack as a temporary ** buffer */ -#define buffonstack(B) ((B)->b != (B)->initb) +#define buffonstack(B) ((B)->b != (B)->init.b) /* @@ -568,7 +568,7 @@ LUALIB_API void luaL_addvalue (luaL_Buffer *B) { LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { B->L = L; - B->b = B->initb; + B->b = B->init.b; B->n = 0; B->size = LUAL_BUFFERSIZE; } diff --git a/lauxlib.h b/lauxlib.h index 1d65c975..8de19916 100644 --- a/lauxlib.h +++ b/lauxlib.h @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.h,v 1.130 2016/12/04 20:17:24 roberto Exp roberto $ +** $Id: lauxlib.h,v 1.131 2016/12/06 14:54:31 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -150,7 +150,10 @@ typedef struct luaL_Buffer { size_t size; /* buffer size */ size_t n; /* number of characters in buffer */ lua_State *L; - char initb[LUAL_BUFFERSIZE]; /* initial buffer */ + union { + LUAI_MAXALIGN; /* ensure maximum alignment for buffer */ + char b[LUAL_BUFFERSIZE]; /* initial buffer */ + } init; } luaL_Buffer; diff --git a/llimits.h b/llimits.h index fa14dfc7..14940550 100644 --- a/llimits.h +++ b/llimits.h @@ -1,5 +1,5 @@ /* -** $Id: llimits.h,v 1.140 2015/10/21 18:40:47 roberto Exp roberto $ +** $Id: llimits.h,v 1.141 2015/11/19 19:16:22 roberto Exp roberto $ ** Limits, basic types, and some other 'installation-dependent' definitions ** See Copyright Notice in lua.h */ @@ -60,21 +60,6 @@ typedef unsigned char lu_byte; -/* type to ensure maximum alignment */ -#if defined(LUAI_USER_ALIGNMENT_T) -typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; -#else -typedef union { - lua_Number n; - double u; - void *s; - lua_Integer i; - long l; -} L_Umaxalign; -#endif - - - /* types of 'usual argument conversions' for lua_Number and lua_Integer */ typedef LUAI_UACNUMBER l_uacNumber; typedef LUAI_UACINT l_uacInt; diff --git a/lobject.h b/lobject.h index 7c521ba2..c8f9adb3 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.117 2016/08/01 19:51:24 roberto Exp roberto $ +** $Id: lobject.h,v 2.118 2017/04/11 18:41:09 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -317,7 +317,7 @@ typedef struct TString { ** Ensures that address after this type is always fully aligned. */ typedef union UTString { - L_Umaxalign dummy; /* ensures maximum alignment for strings */ + LUAI_MAXALIGN; /* ensures maximum alignment for strings */ TString tsv; } UTString; @@ -357,7 +357,7 @@ typedef struct Udata { ** Ensures that address after this type is always fully aligned. */ typedef union UUdata { - L_Umaxalign dummy; /* ensures maximum alignment for 'local' udata */ + LUAI_MAXALIGN; /* ensures maximum alignment for 'local' udata */ Udata uv; } UUdata; diff --git a/ltests.c b/ltests.c index 77f0163d..4ac2c702 100644 --- a/ltests.c +++ b/ltests.c @@ -1,5 +1,5 @@ /* -** $Id: ltests.c,v 2.214 2017/04/19 18:46:47 roberto Exp roberto $ +** $Id: ltests.c,v 2.215 2017/04/24 16:59:26 roberto Exp roberto $ ** Internal Module for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -81,7 +81,7 @@ static int tpanic (lua_State *L) { #define MARK 0x55 /* 01010101 (a nice pattern) */ typedef union Header { - L_Umaxalign a; /* ensures maximum alignment for Header */ + LUAI_MAXALIGN; struct { size_t size; int type; diff --git a/luaconf.h b/luaconf.h index 33ff3604..f7ac7160 100644 --- a/luaconf.h +++ b/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.259 2016/12/22 13:08:50 roberto Exp roberto $ +** $Id: luaconf.h,v 1.260 2017/04/19 16:34:35 roberto Exp roberto $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -761,6 +761,12 @@ #define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer))) #endif +/* +@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure +** "maximum" alignment for the other items in that union. +*/ +#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l + /* }================================================================== */