aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-24 15:06:12 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-24 15:06:12 -0300
commit2caecf1b3efdbee4e08888a04143421589d6143b (patch)
tree5eb37237e2440b1fb0b3750e5917d6d6d80a8be7
parentf399e6705fab15013ae468049c910577e1a9a5a1 (diff)
downloadlua-2caecf1b3efdbee4e08888a04143421589d6143b.tar.gz
lua-2caecf1b3efdbee4e08888a04143421589d6143b.tar.bz2
lua-2caecf1b3efdbee4e08888a04143421589d6143b.zip
type 'L_Umaxalign' replaced by macro 'LUAI_MAXALIGN', which is also added
to the auxlib buffer
-rw-r--r--lauxlib.c6
-rw-r--r--lauxlib.h7
-rw-r--r--llimits.h17
-rw-r--r--lobject.h6
-rw-r--r--ltests.c4
-rw-r--r--luaconf.h8
6 files changed, 21 insertions, 27 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 7b14ca4d..2d16c9ce 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.288 2016/12/04 20:17:24 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.289 2016/12/20 18:37:00 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -496,7 +496,7 @@ static void *newbox (lua_State *L, size_t newsize) {
496** check whether buffer is using a userdata on the stack as a temporary 496** check whether buffer is using a userdata on the stack as a temporary
497** buffer 497** buffer
498*/ 498*/
499#define buffonstack(B) ((B)->b != (B)->initb) 499#define buffonstack(B) ((B)->b != (B)->init.b)
500 500
501 501
502/* 502/*
@@ -568,7 +568,7 @@ LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
568 568
569LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { 569LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
570 B->L = L; 570 B->L = L;
571 B->b = B->initb; 571 B->b = B->init.b;
572 B->n = 0; 572 B->n = 0;
573 B->size = LUAL_BUFFERSIZE; 573 B->size = LUAL_BUFFERSIZE;
574} 574}
diff --git a/lauxlib.h b/lauxlib.h
index 1d65c975..8de19916 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.130 2016/12/04 20:17:24 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.131 2016/12/06 14:54:31 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -150,7 +150,10 @@ typedef struct luaL_Buffer {
150 size_t size; /* buffer size */ 150 size_t size; /* buffer size */
151 size_t n; /* number of characters in buffer */ 151 size_t n; /* number of characters in buffer */
152 lua_State *L; 152 lua_State *L;
153 char initb[LUAL_BUFFERSIZE]; /* initial buffer */ 153 union {
154 LUAI_MAXALIGN; /* ensure maximum alignment for buffer */
155 char b[LUAL_BUFFERSIZE]; /* initial buffer */
156 } init;
154} luaL_Buffer; 157} luaL_Buffer;
155 158
156 159
diff --git a/llimits.h b/llimits.h
index fa14dfc7..14940550 100644
--- a/llimits.h
+++ b/llimits.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llimits.h,v 1.140 2015/10/21 18:40:47 roberto Exp roberto $ 2** $Id: llimits.h,v 1.141 2015/11/19 19:16:22 roberto Exp roberto $
3** Limits, basic types, and some other 'installation-dependent' definitions 3** Limits, basic types, and some other 'installation-dependent' definitions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -60,21 +60,6 @@ typedef unsigned char lu_byte;
60 60
61 61
62 62
63/* type to ensure maximum alignment */
64#if defined(LUAI_USER_ALIGNMENT_T)
65typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
66#else
67typedef union {
68 lua_Number n;
69 double u;
70 void *s;
71 lua_Integer i;
72 long l;
73} L_Umaxalign;
74#endif
75
76
77
78/* types of 'usual argument conversions' for lua_Number and lua_Integer */ 63/* types of 'usual argument conversions' for lua_Number and lua_Integer */
79typedef LUAI_UACNUMBER l_uacNumber; 64typedef LUAI_UACNUMBER l_uacNumber;
80typedef LUAI_UACINT l_uacInt; 65typedef 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 @@
1/* 1/*
2** $Id: lobject.h,v 2.117 2016/08/01 19:51:24 roberto Exp roberto $ 2** $Id: lobject.h,v 2.118 2017/04/11 18:41:09 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -317,7 +317,7 @@ typedef struct TString {
317** Ensures that address after this type is always fully aligned. 317** Ensures that address after this type is always fully aligned.
318*/ 318*/
319typedef union UTString { 319typedef union UTString {
320 L_Umaxalign dummy; /* ensures maximum alignment for strings */ 320 LUAI_MAXALIGN; /* ensures maximum alignment for strings */
321 TString tsv; 321 TString tsv;
322} UTString; 322} UTString;
323 323
@@ -357,7 +357,7 @@ typedef struct Udata {
357** Ensures that address after this type is always fully aligned. 357** Ensures that address after this type is always fully aligned.
358*/ 358*/
359typedef union UUdata { 359typedef union UUdata {
360 L_Umaxalign dummy; /* ensures maximum alignment for 'local' udata */ 360 LUAI_MAXALIGN; /* ensures maximum alignment for 'local' udata */
361 Udata uv; 361 Udata uv;
362} UUdata; 362} UUdata;
363 363
diff --git a/ltests.c b/ltests.c
index 77f0163d..4ac2c702 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.214 2017/04/19 18:46:47 roberto Exp roberto $ 2** $Id: ltests.c,v 2.215 2017/04/24 16:59:26 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -81,7 +81,7 @@ static int tpanic (lua_State *L) {
81#define MARK 0x55 /* 01010101 (a nice pattern) */ 81#define MARK 0x55 /* 01010101 (a nice pattern) */
82 82
83typedef union Header { 83typedef union Header {
84 L_Umaxalign a; /* ensures maximum alignment for Header */ 84 LUAI_MAXALIGN;
85 struct { 85 struct {
86 size_t size; 86 size_t size;
87 int type; 87 int type;
diff --git a/luaconf.h b/luaconf.h
index 33ff3604..f7ac7160 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.259 2016/12/22 13:08:50 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.260 2017/04/19 16:34:35 roberto Exp roberto $
3** Configuration file for Lua 3** Configuration file for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -761,6 +761,12 @@
761#define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer))) 761#define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer)))
762#endif 762#endif
763 763
764/*
765@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure
766** "maximum" alignment for the other items in that union.
767*/
768#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l
769
764/* }================================================================== */ 770/* }================================================================== */
765 771
766 772