Commit bf3463d0 authored by zeroday's avatar zeroday
Browse files

Merge pull request #75 from nodemcu/dev095

Dev095
parents 0a3702f8 729603fa
This diff is collapsed.
......@@ -16,7 +16,7 @@
#undef LREGISTER
#if (MIN_OPT_LEVEL > 0) && (LUA_OPTIMIZE_MEMORY >= MIN_OPT_LEVEL)
#define LUA_REG_TYPE luaR_entry
#define LUA_REG_TYPE luaR_entry ICACHE_RODATA_ATTR
#define LSTRKEY LRO_STRKEY
#define LNUMKEY LRO_NUMKEY
#define LNILKEY LRO_NILKEY
......
......@@ -16,7 +16,7 @@
extern const luaR_table lua_rotable[];
/* Find a global "read only table" in the constant lua_rotable array */
void* ICACHE_FLASH_ATTR luaR_findglobal(const char *name, unsigned len) {
void* luaR_findglobal(const char *name, unsigned len) {
unsigned i;
if (c_strlen(name) > LUA_MAX_ROTABLE_NAME)
......@@ -29,7 +29,7 @@ void* ICACHE_FLASH_ATTR luaR_findglobal(const char *name, unsigned len) {
}
/* Find an entry in a rotable and return it */
static const TValue* ICACHE_FLASH_ATTR luaR_auxfind(const luaR_entry *pentry, const char *strkey, luaR_numkey numkey, unsigned *ppos) {
static const TValue* luaR_auxfind(const luaR_entry *pentry, const char *strkey, luaR_numkey numkey, unsigned *ppos) {
const TValue *res = NULL;
unsigned i = 0;
......@@ -48,7 +48,7 @@ static const TValue* ICACHE_FLASH_ATTR luaR_auxfind(const luaR_entry *pentry, co
return res;
}
int ICACHE_FLASH_ATTR luaR_findfunction(lua_State *L, const luaR_entry *ptable) {
int luaR_findfunction(lua_State *L, const luaR_entry *ptable) {
const TValue *res = NULL;
const char *key = luaL_checkstring(L, 2);
......@@ -64,12 +64,12 @@ int ICACHE_FLASH_ATTR luaR_findfunction(lua_State *L, const luaR_entry *ptable)
/* Find an entry in a rotable and return its type
If "strkey" is not NULL, the function will look for a string key,
otherwise it will look for a number key */
const TValue* ICACHE_FLASH_ATTR luaR_findentry(void *data, const char *strkey, luaR_numkey numkey, unsigned *ppos) {
const TValue* luaR_findentry(void *data, const char *strkey, luaR_numkey numkey, unsigned *ppos) {
return luaR_auxfind((const luaR_entry*)data, strkey, numkey, ppos);
}
/* Find the metatable of a given table */
void* ICACHE_FLASH_ATTR luaR_getmeta(void *data) {
void* luaR_getmeta(void *data) {
#ifdef LUA_META_ROTABLES
const TValue *res = luaR_auxfind((const luaR_entry*)data, "__metatable", 0, NULL);
return res && ttisrotable(res) ? rvalue(res) : NULL;
......@@ -78,7 +78,7 @@ void* ICACHE_FLASH_ATTR luaR_getmeta(void *data) {
#endif
}
static void ICACHE_FLASH_ATTR luaR_next_helper(lua_State *L, const luaR_entry *pentries, int pos, TValue *key, TValue *val) {
static void luaR_next_helper(lua_State *L, const luaR_entry *pentries, int pos, TValue *key, TValue *val) {
setnilvalue(key);
setnilvalue(val);
if (pentries[pos].key.type != LUA_TNIL) {
......@@ -91,7 +91,7 @@ static void ICACHE_FLASH_ATTR luaR_next_helper(lua_State *L, const luaR_entry *p
}
}
/* next (used for iteration) */
void ICACHE_FLASH_ATTR luaR_next(lua_State *L, void *data, TValue *key, TValue *val) {
void luaR_next(lua_State *L, void *data, TValue *key, TValue *val) {
const luaR_entry* pentries = (const luaR_entry*)data;
char strkey[LUA_MAX_ROTABLE_NAME + 1], *pstrkey = NULL;
luaR_numkey numkey = 0;
......@@ -115,7 +115,7 @@ void ICACHE_FLASH_ATTR luaR_next(lua_State *L, void *data, TValue *key, TValue *
}
/* Convert a Lua string to a C string */
void ICACHE_FLASH_ATTR luaR_getcstr(char *dest, const TString *src, size_t maxsize) {
void luaR_getcstr(char *dest, const TString *src, size_t maxsize) {
if (src->tsv.len+1 > maxsize)
dest[0] = '\0';
else {
......@@ -129,7 +129,7 @@ void ICACHE_FLASH_ATTR luaR_getcstr(char *dest, const TString *src, size_t maxsi
#include "compiler.h"
int ICACHE_FLASH_ATTR luaR_isrotable(void *p) {
int luaR_isrotable(void *p) {
return RODATA_START_ADDRESS <= (char*)p && (char*)p <= RODATA_END_ADDRESS;
}
#endif
......@@ -38,7 +38,7 @@ typedef struct LG {
static void ICACHE_FLASH_ATTR stack_init (lua_State *L1, lua_State *L) {
static void stack_init (lua_State *L1, lua_State *L) {
/* initialize CallInfo array */
L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo);
L1->ci = L1->base_ci;
......@@ -57,7 +57,7 @@ static void ICACHE_FLASH_ATTR stack_init (lua_State *L1, lua_State *L) {
}
static void ICACHE_FLASH_ATTR freestack (lua_State *L, lua_State *L1) {
static void freestack (lua_State *L, lua_State *L1) {
luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
luaM_freearray(L, L1->stack, L1->stacksize, TValue);
}
......@@ -66,7 +66,7 @@ static void ICACHE_FLASH_ATTR freestack (lua_State *L, lua_State *L1) {
/*
** open parts that may cause memory-allocation errors
*/
static void ICACHE_FLASH_ATTR f_luaopen (lua_State *L, void *ud) {
static void f_luaopen (lua_State *L, void *ud) {
global_State *g = G(L);
UNUSED(ud);
stack_init(L, L); /* init stack */
......@@ -80,7 +80,7 @@ static void ICACHE_FLASH_ATTR f_luaopen (lua_State *L, void *ud) {
}
static void ICACHE_FLASH_ATTR preinit_state (lua_State *L, global_State *g) {
static void preinit_state (lua_State *L, global_State *g) {
G(L) = g;
L->stack = NULL;
L->stacksize = 0;
......@@ -101,7 +101,7 @@ static void ICACHE_FLASH_ATTR preinit_state (lua_State *L, global_State *g) {
}
static void ICACHE_FLASH_ATTR close_state (lua_State *L) {
static void close_state (lua_State *L) {
global_State *g = G(L);
luaF_close(L, L->stack); /* close all upvalues for this thread */
luaC_freeall(L); /* collect all objects */
......@@ -115,7 +115,7 @@ static void ICACHE_FLASH_ATTR close_state (lua_State *L) {
}
lua_State *ICACHE_FLASH_ATTR luaE_newthread (lua_State *L) {
lua_State *luaE_newthread (lua_State *L) {
lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
luaC_link(L, obj2gco(L1), LUA_TTHREAD);
setthvalue(L, L->top, L1); /* put thread on stack */
......@@ -133,7 +133,7 @@ lua_State *ICACHE_FLASH_ATTR luaE_newthread (lua_State *L) {
}
void ICACHE_FLASH_ATTR luaE_freethread (lua_State *L, lua_State *L1) {
void luaE_freethread (lua_State *L, lua_State *L1) {
luaF_close(L1, L1->stack); /* close all upvalues for this thread */
lua_assert(L1->openupval == NULL);
luai_userstatefree(L1);
......@@ -142,7 +142,7 @@ void ICACHE_FLASH_ATTR luaE_freethread (lua_State *L, lua_State *L1) {
}
LUA_API lua_State *ICACHE_FLASH_ATTR lua_newstate (lua_Alloc f, void *ud) {
LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
int i;
lua_State *L;
global_State *g;
......@@ -205,7 +205,7 @@ LUA_API lua_State *ICACHE_FLASH_ATTR lua_newstate (lua_Alloc f, void *ud) {
}
static void ICACHE_FLASH_ATTR callallgcTM (lua_State *L, void *ud) {
static void callallgcTM (lua_State *L, void *ud) {
UNUSED(ud);
luaC_callGCTM(L); /* call GC metamethods for all udata */
}
......@@ -214,15 +214,15 @@ static void ICACHE_FLASH_ATTR callallgcTM (lua_State *L, void *ud) {
extern lua_State *luaL_newstate (void);
static lua_State *lua_crtstate;
lua_State *ICACHE_FLASH_ATTR lua_open(void) {
lua_State *lua_open(void) {
lua_crtstate = luaL_newstate();
return lua_crtstate;
}
lua_State *ICACHE_FLASH_ATTR lua_getstate(void) {
lua_State *lua_getstate(void) {
return lua_crtstate;
}
LUA_API void ICACHE_FLASH_ATTR lua_close (lua_State *L) {
LUA_API void lua_close (lua_State *L) {
#ifndef LUA_CROSS_COMPILER
lua_sethook( L, NULL, 0, 0 );
lua_crtstate = NULL;
......
......@@ -20,7 +20,7 @@
#define LUAS_READONLY_STRING 1
#define LUAS_REGULAR_STRING 0
void ICACHE_FLASH_ATTR luaS_resize (lua_State *L, int newsize) {
void luaS_resize (lua_State *L, int newsize) {
stringtable *tb;
int i;
tb = &G(L)->strt;
......@@ -51,7 +51,7 @@ void ICACHE_FLASH_ATTR luaS_resize (lua_State *L, int newsize) {
unset_resizing_strings_gc(L);
}
static TString *ICACHE_FLASH_ATTR newlstr (lua_State *L, const char *str, size_t l,
static TString *newlstr (lua_State *L, const char *str, size_t l,
unsigned int h, int readonly) {
TString *ts;
stringtable *tb;
......@@ -80,7 +80,7 @@ static TString *ICACHE_FLASH_ATTR newlstr (lua_State *L, const char *str, size_t
}
static TString *ICACHE_FLASH_ATTR luaS_newlstr_helper (lua_State *L, const char *str, size_t l, int readonly) {
static TString *luaS_newlstr_helper (lua_State *L, const char *str, size_t l, int readonly) {
GCObject *o;
unsigned int h = cast(unsigned int, l); /* seed */
size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
......@@ -100,7 +100,7 @@ static TString *ICACHE_FLASH_ATTR luaS_newlstr_helper (lua_State *L, const char
return newlstr(L, str, l, h, readonly); /* not found */
}
static int ICACHE_FLASH_ATTR lua_is_ptr_in_ro_area(const char *p) {
static int lua_is_ptr_in_ro_area(const char *p) {
#ifdef LUA_CROSS_COMPILER
return 0;
#else
......@@ -111,7 +111,7 @@ static int ICACHE_FLASH_ATTR lua_is_ptr_in_ro_area(const char *p) {
#endif
}
TString *ICACHE_FLASH_ATTR luaS_newlstr (lua_State *L, const char *str, size_t l) {
TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
// If the pointer is in a read-only memory and the string is at least 4 chars in length,
// create it as a read-only string instead
if(lua_is_ptr_in_ro_area(str) && l+1 > sizeof(char**) && l == c_strlen(str))
......@@ -121,7 +121,7 @@ TString *ICACHE_FLASH_ATTR luaS_newlstr (lua_State *L, const char *str, size_t l
}
LUAI_FUNC TString *ICACHE_FLASH_ATTR luaS_newrolstr (lua_State *L, const char *str, size_t l) {
LUAI_FUNC TString *luaS_newrolstr (lua_State *L, const char *str, size_t l) {
if(l+1 > sizeof(char**) && l == c_strlen(str))
return luaS_newlstr_helper(L, str, l, LUAS_READONLY_STRING);
else // no point in creating a RO string, as it would actually be larger
......@@ -129,7 +129,7 @@ LUAI_FUNC TString *ICACHE_FLASH_ATTR luaS_newrolstr (lua_State *L, const char *s
}
Udata *ICACHE_FLASH_ATTR luaS_newudata (lua_State *L, size_t s, Table *e) {
Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
Udata *u;
if (s > MAX_SIZET - sizeof(Udata))
luaM_toobig(L);
......
This diff is collapsed.
This diff is collapsed.
......@@ -20,7 +20,7 @@
#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
static int ICACHE_FLASH_ATTR foreachi (lua_State *L) {
static int foreachi (lua_State *L) {
int i;
int n = aux_getn(L, 1);
luaL_checkanyfunction(L, 2);
......@@ -37,7 +37,7 @@ static int ICACHE_FLASH_ATTR foreachi (lua_State *L) {
}
static int ICACHE_FLASH_ATTR foreach (lua_State *L) {
static int foreach (lua_State *L) {
luaL_checktype(L, 1, LUA_TTABLE);
luaL_checkanyfunction(L, 2);
lua_pushnil(L); /* first key */
......@@ -54,7 +54,7 @@ static int ICACHE_FLASH_ATTR foreach (lua_State *L) {
}
static int ICACHE_FLASH_ATTR maxn (lua_State *L) {
static int maxn (lua_State *L) {
lua_Number max = 0;
luaL_checktype(L, 1, LUA_TTABLE);
lua_pushnil(L); /* first key */
......@@ -70,13 +70,13 @@ static int ICACHE_FLASH_ATTR maxn (lua_State *L) {
}
static int ICACHE_FLASH_ATTR getn (lua_State *L) {
static int getn (lua_State *L) {
lua_pushinteger(L, aux_getn(L, 1));
return 1;
}
static int ICACHE_FLASH_ATTR setn (lua_State *L) {
static int setn (lua_State *L) {
luaL_checktype(L, 1, LUA_TTABLE);
#ifndef luaL_setn
luaL_setn(L, 1, luaL_checkint(L, 2));
......@@ -88,7 +88,7 @@ static int ICACHE_FLASH_ATTR setn (lua_State *L) {
}
static int ICACHE_FLASH_ATTR tinsert (lua_State *L) {
static int tinsert (lua_State *L) {
int e = aux_getn(L, 1) + 1; /* first empty element */
int pos; /* where to insert new element */
switch (lua_gettop(L)) {
......@@ -116,7 +116,7 @@ static int ICACHE_FLASH_ATTR tinsert (lua_State *L) {
}
static int ICACHE_FLASH_ATTR tremove (lua_State *L) {
static int tremove (lua_State *L) {
int e = aux_getn(L, 1);
int pos = luaL_optint(L, 2, e);
if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
......@@ -133,7 +133,7 @@ static int ICACHE_FLASH_ATTR tremove (lua_State *L) {
}
static void ICACHE_FLASH_ATTR addfield (lua_State *L, luaL_Buffer *b, int i) {
static void addfield (lua_State *L, luaL_Buffer *b, int i) {
lua_rawgeti(L, 1, i);
if (!lua_isstring(L, -1))
luaL_error(L, "invalid value (%s) at index %d in table for "
......@@ -142,7 +142,7 @@ static void ICACHE_FLASH_ATTR addfield (lua_State *L, luaL_Buffer *b, int i) {
}
static int ICACHE_FLASH_ATTR tconcat (lua_State *L) {
static int tconcat (lua_State *L) {
luaL_Buffer b;
size_t lsep;
int i, last;
......@@ -171,12 +171,12 @@ static int ICACHE_FLASH_ATTR tconcat (lua_State *L) {
*/
static void ICACHE_FLASH_ATTR set2 (lua_State *L, int i, int j) {
static void set2 (lua_State *L, int i, int j) {
lua_rawseti(L, 1, i);
lua_rawseti(L, 1, j);
}
static int ICACHE_FLASH_ATTR sort_comp (lua_State *L, int a, int b) {
static int sort_comp (lua_State *L, int a, int b) {
if (!lua_isnil(L, 2)) { /* function? */
int res;
lua_pushvalue(L, 2);
......@@ -191,7 +191,7 @@ static int ICACHE_FLASH_ATTR sort_comp (lua_State *L, int a, int b) {
return lua_lessthan(L, a, b);
}
static void ICACHE_FLASH_ATTR auxsort (lua_State *L, int l, int u) {
static void auxsort (lua_State *L, int l, int u) {
while (l < u) { /* for tail recursion */
int i, j;
/* sort elements a[l], a[(l+u)/2] and a[u] */
......@@ -254,7 +254,7 @@ static void ICACHE_FLASH_ATTR auxsort (lua_State *L, int l, int u) {
} /* repeat the routine for the larger one */
}
static int ICACHE_FLASH_ATTR sort (lua_State *L) {
static int sort (lua_State *L) {
int n = aux_getn(L, 1);
luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */
if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
......@@ -282,6 +282,6 @@ const LUA_REG_TYPE tab_funcs[] = {
{LNILKEY, LNILVAL}
};
LUALIB_API int ICACHE_FLASH_ATTR luaopen_table (lua_State *L) {
LUALIB_API int luaopen_table (lua_State *L) {
LREGISTER(L, LUA_TABLIBNAME, tab_funcs);
}
......@@ -28,7 +28,7 @@ const char *const luaT_typenames[] = {
};
void ICACHE_FLASH_ATTR luaT_init (lua_State *L) {
void luaT_init (lua_State *L) {
static const char *const luaT_eventname[] = { /* ORDER TM */
"__index", "__newindex",
"__gc", "__mode", "__eq",
......@@ -48,7 +48,7 @@ void ICACHE_FLASH_ATTR luaT_init (lua_State *L) {
** function to be used with macro "fasttm": optimized for absence of
** tag methods
*/
const TValue *ICACHE_FLASH_ATTR luaT_gettm (Table *events, TMS event, TString *ename) {
const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
const TValue *tm = luaR_isrotable(events) ? luaH_getstr_ro(events, ename) : luaH_getstr(events, ename);
lua_assert(event <= TM_EQ);
if (ttisnil(tm)) { /* no tag method? */
......@@ -60,7 +60,7 @@ const TValue *ICACHE_FLASH_ATTR luaT_gettm (Table *events, TMS event, TString *e
}
const TValue *ICACHE_FLASH_ATTR luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
Table *mt;
switch (ttype(o)) {
case LUA_TTABLE:
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -18,7 +18,7 @@
#include "lzio.h"
int ICACHE_FLASH_ATTR luaZ_fill (ZIO *z) {
int luaZ_fill (ZIO *z) {
size_t size;
lua_State *L = z->L;
const char *buff;
......@@ -32,7 +32,7 @@ int ICACHE_FLASH_ATTR luaZ_fill (ZIO *z) {
}
int ICACHE_FLASH_ATTR luaZ_lookahead (ZIO *z) {
int luaZ_lookahead (ZIO *z) {
if (z->n == 0) {
if (luaZ_fill(z) == EOZ)
return EOZ;
......@@ -45,7 +45,7 @@ int ICACHE_FLASH_ATTR luaZ_lookahead (ZIO *z) {
}
void ICACHE_FLASH_ATTR luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
z->L = L;
z->reader = reader;
z->data = data;
......@@ -55,7 +55,7 @@ void ICACHE_FLASH_ATTR luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void
/* --------------------------------------------------------------- read --- */
size_t ICACHE_FLASH_ATTR luaZ_read (ZIO *z, void *b, size_t n) {
size_t luaZ_read (ZIO *z, void *b, size_t n) {
while (n) {
size_t m;
if (luaZ_lookahead(z) == EOZ)
......@@ -74,7 +74,7 @@ size_t ICACHE_FLASH_ATTR luaZ_read (ZIO *z, void *b, size_t n) {
}
/* ------------------------------------------------------------------------ */
char *ICACHE_FLASH_ATTR luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
if (n > buff->buffsize) {
if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
luaZ_resizebuffer(L, buff, n);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment