Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
d77666c0
Commit
d77666c0
authored
Feb 17, 2019
by
sergio
Committed by
Terry Ellison
Feb 17, 2019
Browse files
trailing spaces cleanup (#2659)
parent
d7583040
Changes
380
Hide whitespace changes
Inline
Side-by-side
app/lua/lmathlib.c
View file @
d77666c0
...
...
@@ -341,7 +341,7 @@ const LUA_REG_TYPE math_map[] = {
{
LSTRKEY
(
"floor"
),
LFUNCVAL
(
math_floor
)},
// {LSTRKEY("fmod"), LFUNCVAL(math_fmod)},
#if LUA_OPTIMIZE_MEMORY > 0 && defined(LUA_COMPAT_MOD)
// {LSTRKEY("mod"), LFUNCVAL(math_fmod)},
// {LSTRKEY("mod"), LFUNCVAL(math_fmod)},
#endif
// {LSTRKEY("frexp"), LFUNCVAL(math_frexp)},
// {LSTRKEY("ldexp"), LFUNCVAL(math_ldexp)},
...
...
app/lua/loadlib.c
View file @
d77666c0
...
...
@@ -522,7 +522,7 @@ static int ll_require (lua_State *L) {
** 'module' function
** =======================================================
*/
static
void
setfenv
(
lua_State
*
L
)
{
lua_Debug
ar
;
...
...
@@ -672,7 +672,7 @@ LUALIB_API int luaopen_package (lua_State *L) {
#endif
/* create `package' table */
luaL_register_light
(
L
,
LUA_LOADLIBNAME
,
pk_funcs
);
#if defined(LUA_COMPAT_LOADLIB)
#if defined(LUA_COMPAT_LOADLIB)
lua_getfield
(
L
,
-
1
,
"loadlib"
);
lua_setfield
(
L
,
LUA_GLOBALSINDEX
,
"loadlib"
);
#endif
...
...
app/lua/lobject.c
View file @
d77666c0
...
...
@@ -70,7 +70,7 @@ int luaO_log2 (unsigned int x) {
#else
/* Use Normalization Shift Amount Unsigned: 0x1=>31 up to 0xffffffff =>0
* See Xtensa Instruction Set Architecture (ISA) Refman P 462 */
asm
volatile
(
"nsau %0, %1;"
:
"=r"
(
x
)
:
"r"
(
x
));
asm
volatile
(
"nsau %0, %1;"
:
"=r"
(
x
)
:
"r"
(
x
));
return
31
-
x
;
#endif
}
...
...
@@ -103,11 +103,11 @@ int luaO_str2d (const char *s, lua_Number *result) {
*
result
=
lua_str2number
(
s
,
&
endptr
);
if
(
endptr
==
s
)
return
0
;
/* conversion failed */
if
(
*
endptr
==
'x'
||
*
endptr
==
'X'
)
/* maybe an hexadecimal constant? */
#if defined(LUA_CROSS_COMPILER)
#if defined(LUA_CROSS_COMPILER)
{
long
lres
=
strtoul
(
s
,
&
endptr
,
16
);
#if INT_MAX != 2147483647L
if
(
lres
&
~
0xffffffffL
)
if
(
lres
&
~
0xffffffffL
)
*
result
=
cast_num
(
-
1
);
else
if
(
lres
&
0x80000000L
)
*
result
=
cast_num
(
lres
|
~
0x7fffffffL
);
...
...
app/lua/lobject.h
View file @
d77666c0
...
...
@@ -23,7 +23,7 @@
#define NUM_TAGS (LAST_TAG+1)
#define READONLYMASK (1<<7)
/* denormalised bitmask for READONLYBIT and */
#define READONLYMASK (1<<7)
/* denormalised bitmask for READONLYBIT and */
#ifdef LUA_FLASH_STORE
#define LFSMASK (1<<6)
/* LFSBIT to avoid include proliferation */
#endif
...
...
@@ -38,13 +38,13 @@
/*
** force aligned access to critical fields in Flash-based structures
** wo is the offset of aligned word in bytes 0,4,8,..
** bo is the field within the word in bits 0..31
** bo is the field within the word in bits 0..31
*/
#define GET_BYTE_FN(name,t,wo,bo) \
static inline lu_byte get ## name(void *o) { \
lu_byte res;
/* extract named field */
\
asm ("l32i %0, %1, " #wo "; extui %0, %0, " #bo ", 8;" : "=r"(res) : "r"(o) : );\
return res; }
return res; }
#else
#define GET_BYTE_FN(name,t,wo,bo) \
static inline lu_byte get ## name(void *o) { return ((t *)o)->name; }
...
...
@@ -70,7 +70,7 @@ typedef struct GCheader {
/*
** Word aligned inline access functions for the CommonHeader tt and marked fields.
** Note that these MUST be consistent with the CommonHeader definition above. Arg
** Note that these MUST be consistent with the CommonHeader definition above. Arg
** 3 is a word offset (4 bytes in this case) and arg 4 the bit offset in the word.
*/
GET_BYTE_FN
(
tt
,
GCheader
,
4
,
0
)
...
...
@@ -249,7 +249,7 @@ typedef union TString {
}
tsv
;
}
TString
;
#ifdef LUA_CROSS_COMPILER
#ifdef LUA_CROSS_COMPILER
#define isreadonly(o) (0)
#else
#define isreadonly(o) ((o).marked & READONLYMASK)
...
...
app/lua/lopcodes.h
View file @
d77666c0
...
...
@@ -186,8 +186,8 @@ OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
OP_LT
,
/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
OP_LE
,
/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
OP_TEST
,
/* A C if not (R(A) <=> C) then pc++ */
OP_TESTSET
,
/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
OP_TEST
,
/* A C if not (R(A) <=> C) then pc++ */
OP_TESTSET
,
/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
OP_CALL
,
/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
OP_TAILCALL
,
/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
...
...
@@ -197,8 +197,8 @@ OP_FORLOOP,/* A sBx R(A)+=R(A+2);
if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
OP_FORPREP
,
/* A sBx R(A)-=R(A+2); pc+=sBx */
OP_TFORLOOP
,
/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
OP_TFORLOOP
,
/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
OP_SETLIST
,
/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
OP_CLOSE
,
/* A close all variables in the stack up to (>=) R(A)*/
...
...
@@ -240,7 +240,7 @@ OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */
** bits 4-5: B arg mode
** bit 6: instruction set register A
** bit 7: operator is a test
*/
*/
enum
OpArgMask
{
OpArgN
,
/* argument is not used */
...
...
app/lua/lrodefs.h
View file @
d77666c0
...
...
@@ -15,7 +15,7 @@
#undef LNILVAL
#undef LREGISTER
#if LUA_OPTIMIZE_MEMORY >=1
#if LUA_OPTIMIZE_MEMORY >=1
#define LUA_REG_TYPE luaR_entry
#define LSTRKEY LRO_STRKEY
#define LNUMKEY LRO_NUMKEY
...
...
app/lua/lrotable.h
View file @
d77666c0
...
...
@@ -45,7 +45,7 @@ typedef struct luaR_entry {
/*
* The current ROTable implmentation is a vector of luaR_entry terminated by a
* nil record. The convention is to use ROtable * to refer to the entire vector
* nil record. The convention is to use ROtable * to refer to the entire vector
* as a logical ROTable.
*/
typedef
const
struct
luaR_entry
ROTable
;
...
...
@@ -57,9 +57,9 @@ void* luaR_getmeta(ROTable *tab);
int
luaR_isrotable
(
void
*
p
);
/*
* Set inRO check depending on platform. Note that this implementation needs
* to work on both the host (luac.cross) and ESP targets. The luac.cross
* VM is used for the -e option, and is primarily used to be able to debug
* Set inRO check depending on platform. Note that this implementation needs
* to work on both the host (luac.cross) and ESP targets. The luac.cross
* VM is used for the -e option, and is primarily used to be able to debug
* VM changes on the more developer-friendly hot gdb environment.
*/
#if defined(LUA_CROSS_COMPILER)
...
...
@@ -68,7 +68,7 @@ int luaR_isrotable(void *p);
#define _RODATA_END __end__
#else
#define _RODATA_END _edata
#endif
#endif
extern
const
char
_RODATA_END
[];
#define IN_RODATA_AREA(p) (((const char *)(p)) < _RODATA_END)
...
...
app/lua/lstate.c
View file @
d77666c0
...
...
@@ -35,7 +35,7 @@ typedef struct LG {
lua_State
l
;
global_State
g
;
}
LG
;
static
void
stack_init
(
lua_State
*
L1
,
lua_State
*
L
)
{
...
...
@@ -224,7 +224,7 @@ extern lua_State *luaL_newstate (void);
static
lua_State
*
lua_crtstate
;
lua_State
*
lua_open
(
void
)
{
lua_crtstate
=
luaL_newstate
();
lua_crtstate
=
luaL_newstate
();
return
lua_crtstate
;
}
...
...
@@ -232,12 +232,12 @@ lua_State *lua_getstate(void) {
return
lua_crtstate
;
}
LUA_API
void
lua_close
(
lua_State
*
L
)
{
#ifndef LUA_CROSS_COMPILER
#ifndef LUA_CROSS_COMPILER
lua_sethook
(
L
,
NULL
,
0
,
0
);
lua_crtstate
=
NULL
;
lua_pushnil
(
L
);
// lua_rawseti( L, LUA_REGISTRYINDEX, LUA_INT_HANDLER_KEY );
#endif
#endif
L
=
G
(
L
)
->
mainthread
;
/* only the main thread can be closed */
lua_lock
(
L
);
luaF_close
(
L
,
L
->
stack
);
/* close all upvalues for this thread */
...
...
app/lua/lstring.c
View file @
d77666c0
...
...
@@ -81,7 +81,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l,
}
static
int
lua_is_ptr_in_ro_area
(
const
char
*
p
)
{
#ifdef LUA_CROSS_COMPILER
#ifdef LUA_CROSS_COMPILER
return
0
;
// TStrings are never in RO in luac.cross
#else
return
IN_RODATA_AREA
(
p
);
...
...
@@ -90,7 +90,7 @@ static int lua_is_ptr_in_ro_area(const char *p) {
/*
* The string algorithm has been modified to be LFS-friendly. The previous eLua
* algo used the address of the string was in flash and the string was >4 bytes
* algo used the address of the string was in flash and the string was >4 bytes
* This creates miminal savings and prevents the use of LFS based strings
*/
...
...
@@ -119,7 +119,7 @@ LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
*/
if
(
G
(
L
)
->
ROstrt
.
hash
)
{
for
(
o
=
G
(
L
)
->
ROstrt
.
hash
[
lmod
(
h
,
G
(
L
)
->
ROstrt
.
size
)];
o
!=
NULL
;
o
!=
NULL
;
o
=
o
->
gch
.
next
)
{
TString
*
ts
=
rawgco2ts
(
o
);
if
(
ts
->
tsv
.
len
==
l
&&
(
memcmp
(
str
,
getstr
(
ts
),
l
)
==
0
))
{
...
...
app/lua/lstrlib.c
View file @
d77666c0
...
...
@@ -633,7 +633,7 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
lua_pushlstring
(
L
,
s
,
e
-
s
);
/* keep original text */
}
else
if
(
!
lua_isstring
(
L
,
-
1
))
luaL_error
(
L
,
"invalid replacement value (a %s)"
,
luaL_typename
(
L
,
-
1
));
luaL_error
(
L
,
"invalid replacement value (a %s)"
,
luaL_typename
(
L
,
-
1
));
luaL_addvalue
(
b
);
/* add result to accumulator */
}
...
...
@@ -786,7 +786,7 @@ static int str_format (lua_State *L) {
c_sprintf
(
buff
,
form
,
(
unsigned
LUA_INTFRM_T
)
luaL_checknumber
(
L
,
arg
));
break
;
}
#if !defined LUA_NUMBER_INTEGRAL
#if !defined LUA_NUMBER_INTEGRAL
case
'e'
:
case
'E'
:
case
'f'
:
case
'g'
:
case
'G'
:
{
c_sprintf
(
buff
,
form
,
(
double
)
luaL_checknumber
(
L
,
arg
));
...
...
@@ -884,7 +884,7 @@ LUALIB_API int luaopen_string (lua_State *L) {
lua_pushrotable
(
L
,
(
void
*
)
strlib
);
lua_setmetatable
(
L
,
-
2
);
lua_pop
(
L
,
1
);
return
0
;
return
0
;
#endif
}
app/lua/ltable.c
View file @
d77666c0
...
...
@@ -48,7 +48,7 @@
#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t))))
#define hashstr(t,str) hashpow2(t, (str)->tsv.hash)
#define hashboolean(t,p) hashpow2(t, p)
...
...
@@ -330,7 +330,7 @@ static Node *find_prev_node(Node *mp, Node *next) {
** first, check whether the moving node's main position is free. If not, check whether
** colliding node is in its main position or not: if it is not, move colliding
** node to an empty place and put moving node in its main position; otherwise
** (colliding node is in its main position), moving node goes to an empty position.
** (colliding node is in its main position), moving node goes to an empty position.
*/
static
int
move_node
(
lua_State
*
L
,
Table
*
t
,
Node
*
node
)
{
Node
*
mp
=
mainposition
(
t
,
key2tval
(
node
));
...
...
@@ -520,11 +520,11 @@ void luaH_free (lua_State *L, Table *t) {
/*
** inserts a new key into a hash table; first, check whether key's main
** position is free. If not, check whether colliding node is in its main
** position or not: if it is not, move colliding node to an empty place and
** put new key in its main position; otherwise (colliding node is in its main
** position), new key goes to an empty position.
** inserts a new key into a hash table; first, check whether key's main
** position is free. If not, check whether colliding node is in its main
** position or not: if it is not, move colliding node to an empty place and
** put new key in its main position; otherwise (colliding node is in its main
** position), new key goes to an empty position.
*/
static
TValue
*
newkey
(
lua_State
*
L
,
Table
*
t
,
const
TValue
*
key
)
{
Node
*
mp
=
mainposition
(
t
,
key
);
...
...
@@ -599,7 +599,7 @@ const TValue *luaH_getstr (Table *t, TString *key) {
}
/* same thing for rotables */
const
TValue
*
luaH_getstr_ro
(
void
*
t
,
TString
*
key
)
{
const
TValue
*
luaH_getstr_ro
(
void
*
t
,
TString
*
key
)
{
if
(
!
t
||
key
->
tsv
.
len
>
LUA_MAX_ROTABLE_NAME
)
return
luaO_nilobject
;
return
luaR_findentry
(
t
,
key
,
NULL
);
...
...
@@ -740,7 +740,7 @@ int luaH_getn (Table *t) {
/* same thing for rotables */
int
luaH_getn_ro
(
void
*
t
)
{
int
i
=
1
,
len
=
0
;
while
(
luaR_findentryN
(
t
,
i
++
,
NULL
))
len
++
;
return
len
;
...
...
app/lua/ltm.c
View file @
d77666c0
...
...
@@ -54,17 +54,17 @@ const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
lua_assert
(
event
<=
TM_EQ
);
if
(
luaR_isrotable
(
events
))
{
tm
=
luaH_getstr_ro
(
events
,
ename
);
tm
=
luaH_getstr_ro
(
events
,
ename
);
if
(
ttisnil
(
tm
))
{
/* no tag method? */
return
NULL
;
}
}
else
{
tm
=
luaH_getstr
(
events
,
ename
);
tm
=
luaH_getstr
(
events
,
ename
);
if
(
ttisnil
(
tm
))
{
/* no tag method? */
events
->
flags
|=
cast_byte
(
1u
<<
event
);
/* cache this fact */
return
NULL
;
}
}
}
return
tm
;
}
...
...
app/lua/lua.c
View file @
d77666c0
...
...
@@ -336,7 +336,7 @@ int lua_put_line(const char *s, size_t l) {
void
lua_handle_input
(
bool
force
)
{
while
(
gLoad
.
L
&&
(
force
||
readline
(
&
gLoad
)))
{
while
(
gLoad
.
L
&&
(
force
||
readline
(
&
gLoad
)))
{
NODE_DBG
(
"Handle Input: first=%u, pos=%u, len=%u, actual=%u, line=%s
\n
"
,
gLoad
.
firstline
,
gLoad
.
line_position
,
gLoad
.
len
,
c_strlen
(
gLoad
.
line
),
gLoad
.
line
);
dojob
(
&
gLoad
);
...
...
@@ -356,7 +356,7 @@ static void dojob(lua_Load *load){
const
char
*
oldprogname
=
progname
;
progname
=
NULL
;
do
{
if
(
load
->
done
==
1
){
l
=
c_strlen
(
b
);
...
...
@@ -453,7 +453,7 @@ static bool readline(lua_Load *load){
// else if (ch == 0x04)
// {
// if (load->line_position == 0)
// // No input which makes lua interpreter close
// // No input which makes lua interpreter close
// donejob(load);
// else
// continue;
...
...
@@ -484,7 +484,7 @@ static bool readline(lua_Load *load){
// {
// continue;
// }
/* echo */
if
(
uart0_echo
)
uart_putc
(
ch
);
...
...
@@ -510,7 +510,7 @@ static bool readline(lua_Load *load){
ch
=
0
;
}
if
(
(
load
->
line_position
>
0
)
&&
(
!
run_input
)
&&
(
need_len
==
0
)
&&
(
end_char
<
0
)
)
{
uart_on_data_cb
(
load
->
line
,
load
->
line_position
);
...
...
app/lua/luac_cross/Makefile
View file @
d77666c0
#
#
# This Make file is called from the core Makefile hierarchy with is a hierarchical
# make wwhich uses parent callbacks to implement inheritance. However is luac_cross
# build stands outside this and uses the host toolchain to implement a separate
# host build of the luac.cross image.
# host build of the luac.cross image.
#
.NOTPARALLEL
:
...
...
app/lua/luac_cross/lflashimg.c
View file @
d77666c0
...
...
@@ -43,21 +43,21 @@ typedef unsigned int uint;
*
* The start address of the Lua Flash Store (LFS) is build-dependent, and the cross
* compiler '-a' option allows the developer to fix the LFS at a defined flash memory
* address. Alternatively and by default the cross compilation adopts a position
* address. Alternatively and by default the cross compilation adopts a position
* independent image format, which permits the on-device image loader to load the LFS
* image at an appropriate base within the flash address space. As all objects in the
* LFS can be treated as multiples of 4-byte words, also all address fields are both
* LFS can be treated as multiples of 4-byte words, also all address fields are both
* word aligned, and any address references within the LFS are also word-aligned.
*
* This version adds gzip compression of the generated LFS image for more efficient
* over-the-air (OTA) transfer, so the method of tagging address words has been
* over-the-air (OTA) transfer, so the method of tagging address words has been
* replaced by a scheme which achieves better compression: an additional bitmap
* has been added to the image, with each bit corresponding to a word in the image
* has been added to the image, with each bit corresponding to a word in the image
* and set if the corresponding work is an address. The addresses are stored as
* signed relative word offsets.
*
* The unloader is documented in lflash.c Note that his relocation process is
* skipped for absolute addressed images (which are identified by the
* The unloader is documented in lflash.c Note that his relocation process is
* skipped for absolute addressed images (which are identified by the
* FLASH_SIG_ABSOLUTE bit setting in the flash signature).
*
* The flash image has a standard header detailed in lflash.h
...
...
@@ -102,14 +102,14 @@ static uint curOffset = 0;
* The flashAddrTag is a bit array, one bit per flashImage word denoting
* whether the corresponding word is a relative address. The defines
* are access methods for this bit array.
*/
*/
static
uint
flashImage
[
LUA_MAX_FLASH_SIZE
+
LUA_MAX_FLASH_SIZE
/
32
];
static
uint
*
flashAddrTag
=
flashImage
+
LUA_MAX_FLASH_SIZE
;
#define _TW(v) (v)>>5
#define _TB(v) (1<<((v)&0x1F))
#define setFlashAddrTag(v) flashAddrTag[_TW(v)] |= _TB(v)
#define getFlashAddrTag(v) ((flashAddrTag[_TW(v)]&_TB(v)) != 0)
#define getFlashAddrTag(v) ((flashAddrTag[_TW(v)]&_TB(v)) != 0)
#define fatal luac_fatal
extern
void
__attribute__
((
noreturn
))
luac_fatal
(
const
char
*
message
);
...
...
@@ -395,8 +395,8 @@ static void *functionToFlash(lua_State* L, const Proto* orig) {
return
cast
(
void
*
,
flashCopy
(
L
,
1
,
PROTO_COPY_MASK
,
&
f
));
}
uint
dumpToFlashImage
(
lua_State
*
L
,
const
Proto
*
main
,
lua_Writer
w
,
void
*
data
,
int
strip
,
uint
dumpToFlashImage
(
lua_State
*
L
,
const
Proto
*
main
,
lua_Writer
w
,
void
*
data
,
int
strip
,
lu_int32
address
,
lu_int32
maxSize
)
{
// parameter strip is ignored for now
FlashHeader
*
fh
=
cast
(
FlashHeader
*
,
flashAlloc
(
L
,
sizeof
(
FlashHeader
)));
...
...
@@ -405,7 +405,7 @@ uint dumpToFlashImage (lua_State* L, const Proto *main, lua_Writer w,
scanProtoStrings
(
L
,
main
);
createROstrt
(
L
,
fh
);
toFlashAddr
(
L
,
fh
->
mainProto
,
functionToFlash
(
L
,
main
));
fh
->
flash_sig
=
FLASH_SIG
+
(
address
?
FLASH_SIG_ABSOLUTE
:
0
);
fh
->
flash_size
=
curOffset
*
WORDSIZE
;
if
(
fh
->
flash_size
>
maxSize
)
{
...
...
@@ -413,7 +413,7 @@ uint dumpToFlashImage (lua_State* L, const Proto *main, lua_Writer w,
}
if
(
address
)
{
/* in absolute mode convert addresses to mapped address */
for
(
i
=
0
;
i
<
curOffset
;
i
++
)
if
(
getFlashAddrTag
(
i
))
if
(
getFlashAddrTag
(
i
))
flashImage
[
i
]
=
4
*
flashImage
[
i
]
+
address
;
lua_unlock
(
L
);
status
=
w
(
L
,
flashImage
,
fh
->
flash_size
,
data
);
...
...
@@ -424,22 +424,22 @@ uint dumpToFlashImage (lua_State* L, const Proto *main, lua_Writer w,
*/
uint
oLen
;
uint8_t
*
oBuf
;
int
bmLen
=
sizeof
(
uint
)
*
((
curOffset
+
31
)
/
32
);
/* 32 flags to a word */
memmove
(
flashImage
+
curOffset
,
flashAddrTag
,
bmLen
);
status
=
uzlib_compress
(
&
oBuf
,
&
oLen
,
status
=
uzlib_compress
(
&
oBuf
,
&
oLen
,
(
const
uint8_t
*
)
flashImage
,
bmLen
+
fh
->
flash_size
);
if
(
status
!=
UZLIB_OK
)
{
luac_fatal
(
"Out of memory during image compression"
);
}
lua_unlock
(
L
);
#if 0
status = w(L, flashImage, bmLen+fh->flash_size, data);
status = w(L, flashImage, bmLen+fh->flash_size, data);
#else
status
=
w
(
L
,
oBuf
,
oLen
,
data
);
free
(
oBuf
);
status
=
w
(
L
,
oBuf
,
oLen
,
data
);
free
(
oBuf
);
#endif
}
lua_lock
(
L
);
return
status
;
...
...
app/lua/luac_cross/liolib.c
View file @
d77666c0
...
...
@@ -28,8 +28,8 @@
/* "Pseudo-random" keys for the registry */
static
const
size_t
liolib_keys
[]
=
{
(
size_t
)
&
luaL_callmeta
,
(
size_t
)
&
luaL_typerror
,
(
size_t
)
&
luaL_callmeta
,
(
size_t
)
&
luaL_typerror
,
(
size_t
)
&
luaL_argerror
};
...
...
@@ -485,7 +485,7 @@ LUALIB_API int luaopen_io(lua_State *L) {
luaL_register_light
(
L
,
LUA_IOLIBNAME
,
io_base
);
lua_pushvalue
(
L
,
-
1
);
lua_setmetatable
(
L
,
-
2
);
lua_pushliteral
(
L
,
"__index"
);
lua_pushliteral
(
L
,
"__index"
);
lua_pushrotable
(
L
,
(
void
*
)
iolib_funcs
);
lua_rawset
(
L
,
-
3
);
...
...
app/lua/luac_cross/luac.c
View file @
d77666c0
...
...
@@ -72,7 +72,7 @@ static void usage(const char* message)
" -e name execute a lua source file
\n
"
" -f output a flash image file
\n
"
" -a addr generate an absolute, rather than position independent flash image file
\n
"
" -i generate lookup combination master (default with option -f)
\n
"
" -i generate lookup combination master (default with option -f)
\n
"
" -m size maximum LFS image in bytes
\n
"
" -p parse only
\n
"
" -s strip debug information
\n
"
...
...
@@ -106,7 +106,7 @@ static int doargs(int argc, char* argv[])
else
if
(
IS
(
"-e"
))
/* execute a lua source file file */
{
execute
=
argv
[
++
i
];
if
(
execute
==
NULL
||
*
execute
==
0
||
*
execute
==
'-'
)
if
(
execute
==
NULL
||
*
execute
==
0
||
*
execute
==
'-'
)
usage
(
LUA_QL
(
"-e"
)
" needs argument"
);
}
else
if
(
IS
(
"-f"
))
/* Flash image file */
...
...
@@ -140,7 +140,7 @@ static int doargs(int argc, char* argv[])
}
else
if
(
IS
(
"-p"
))
/* parse only */
dumping
=
0
;
dumping
=
0
;
else
if
(
IS
(
"-s"
))
/* strip debug information */
stripping
=
1
;
else
if
(
IS
(
"-v"
))
/* show version */
...
...
@@ -164,7 +164,7 @@ static int doargs(int argc, char* argv[])
#define toproto(L,i) (clvalue(L->top+(i))->l.p)
static
TString
*
corename
(
lua_State
*
L
,
const
TString
*
filename
)
static
TString
*
corename
(
lua_State
*
L
,
const
TString
*
filename
)
{
const
char
*
fn
=
getstr
(
filename
)
+
1
;
const
char
*
s
=
strrchr
(
fn
,
'/'
);
...
...
@@ -173,13 +173,13 @@ static TString *corename(lua_State *L, const TString *filename)
const
char
*
e
=
strchr
(
s
,
'.'
);
int
l
=
e
?
e
-
s
:
strlen
(
s
);
return
l
?
luaS_newlstr
(
L
,
s
,
l
)
:
luaS_new
(
L
,
fn
);
}
}
/*
* If the luac command line includes multiple files or has the -f option
* If the luac command line includes multiple files or has the -f option
* then luac generates a main function to reference all sub-main prototypes.
* This is one of two types:
* Type 0 The standard luac combination main
* Type 1 A lookup wrapper that facilitates indexing into the generated protos
* Type 1 A lookup wrapper that facilitates indexing into the generated protos
*/
static
const
Proto
*
combine
(
lua_State
*
L
,
int
n
,
int
type
)
{
...
...
@@ -194,14 +194,14 @@ static const Proto* combine(lua_State* L, int n, int type)
f
->
source
=
luaS_newliteral
(
L
,
"=("
PROGNAME
")"
);
f
->
p
=
luaM_newvector
(
L
,
n
,
Proto
*
);
f
->
sizep
=
n
;
for
(
i
=
0
;
i
<
n
;
i
++
)
for
(
i
=
0
;
i
<
n
;
i
++
)
f
->
p
[
i
]
=
toproto
(
L
,
i
-
n
-
1
);
pc
=
0
;
if
(
type
==
0
)
{
/*
* Type 0 is as per the standard luac, which is just a main routine which
* invokes all of the compiled functions sequentially. This is fine if
* Type 0 is as per the standard luac, which is just a main routine which
* invokes all of the compiled functions sequentially. This is fine if
* they are self registering modules, but useless otherwise.
*/
f
->
numparams
=
0
;
...
...
@@ -218,7 +218,7 @@ static const Proto* combine(lua_State* L, int n, int type)
*
pc
++
=
CREATE_ABC
(
OP_RETURN
,
0
,
1
,
0
);
}
else
{
/*
* The Type 1 main() is a lookup which takes a single argument, the name to
* The Type 1 main() is a lookup which takes a single argument, the name to
* be resolved. If this matches root name of one of the compiled files then
* a closure to this file main is returned. Otherwise the Unixtime of the
* compile and the list of root names is returned.
...
...
@@ -235,11 +235,11 @@ static const Proto* combine(lua_State* L, int n, int type)
f
->
sizelocvars
=
0
;
f
->
code
=
luaM_newvector
(
L
,
f
->
sizecode
,
Instruction
);
f
->
k
=
luaM_newvector
(
L
,
f
->
sizek
,
TValue
);
for
(
i
=
0
,
pc
=
f
->
code
;
i
<
n
;
i
++
)
for
(
i
=
0
,
pc
=
f
->
code
;
i
<
n
;
i
++
)
{
/* if arg1 == FnameA then return function (...) -- funcA -- end end */
setsvalue2n
(
L
,
f
->
k
+
i
,
corename
(
L
,
f
->
p
[
i
]
->
source
));
*
pc
++
=
CREATE_ABC
(
OP_EQ
,
0
,
0
,
RKASK
(
i
));
*
pc
++
=
CREATE_ABC
(
OP_EQ
,
0
,
0
,
RKASK
(
i
));
*
pc
++
=
CREATE_ABx
(
OP_JMP
,
0
,
MAXARG_sBx
+
2
);
*
pc
++
=
CREATE_ABx
(
OP_CLOSURE
,
1
,
i
);
*
pc
++
=
CREATE_ABC
(
OP_RETURN
,
1
,
2
,
0
);
...
...
@@ -248,10 +248,10 @@ static const Proto* combine(lua_State* L, int n, int type)
setnvalue
(
f
->
k
+
n
,
(
lua_Number
)
time
(
NULL
));
*
pc
++
=
CREATE_ABx
(
OP_LOADK
,
1
,
n
);
*
pc
++
=
CREATE_ABC
(
OP_NEWTABLE
,
2
,
luaO_int2fb
(
i
),
0
);
for
(
i
=
0
;
i
<
n
;
i
++
)
*
pc
++
=
CREATE_ABC
(
OP_NEWTABLE
,
2
,
luaO_int2fb
(
i
),
0
);
for
(
i
=
0
;
i
<
n
;
i
++
)
*
pc
++
=
CREATE_ABx
(
OP_LOADK
,
i
+
3
,
i
);
*
pc
++
=
CREATE_ABC
(
OP_SETLIST
,
2
,
i
,
1
);
*
pc
++
=
CREATE_ABC
(
OP_SETLIST
,
2
,
i
,
1
);
*
pc
++
=
CREATE_ABC
(
OP_RETURN
,
1
,
3
,
0
);
*
pc
++
=
CREATE_ABC
(
OP_RETURN
,
0
,
1
,
0
);
}
...
...
@@ -272,8 +272,8 @@ struct Smain {
char
**
argv
;
};
extern
uint
dumpToFlashImage
(
lua_State
*
L
,
const
Proto
*
main
,
lua_Writer
w
,
void
*
data
,
int
strip
,
extern
uint
dumpToFlashImage
(
lua_State
*
L
,
const
Proto
*
main
,
lua_Writer
w
,
void
*
data
,
int
strip
,
lu_int32
address
,
lu_int32
maxSize
);
static
int
pmain
(
lua_State
*
L
)
...
...
@@ -290,7 +290,7 @@ static int pmain(lua_State* L)
luaL_openlibs
(
L
);
lua_pushstring
(
L
,
execute
);
if
(
lua_pcall
(
L
,
1
,
1
,
0
))
fatal
(
lua_tostring
(
L
,
-
1
));
if
(
!
lua_isfunction
(
L
,
-
1
))
if
(
!
lua_isfunction
(
L
,
-
1
))
{
lua_pop
(
L
,
1
);
if
(
argc
==
0
)
return
0
;
...
...
@@ -310,13 +310,13 @@ static int pmain(lua_State* L)
FILE
*
D
=
(
output
==
NULL
)
?
stdout
:
fopen
(
output
,
"wb"
);
if
(
D
==
NULL
)
cannot
(
"open"
);
lua_lock
(
L
);
if
(
flash
)
if
(
flash
)
{
result
=
dumpToFlashImage
(
L
,
f
,
writer
,
D
,
stripping
,
address
,
maxSize
);
}
else
{
result
=
luaU_dump_crosscompile
(
L
,
f
,
writer
,
D
,
stripping
,
target
);
}
}
lua_unlock
(
L
);
if
(
result
==
LUA_ERR_CC_INTOVERFLOW
)
fatal
(
"value too big or small for target integer type"
);
if
(
result
==
LUA_ERR_CC_NOTINTEGER
)
fatal
(
"target lua_Number is integral but fractional value found"
);
...
...
@@ -330,7 +330,7 @@ int main(int argc, char* argv[])
{
lua_State
*
L
;
struct
Smain
s
;
int
test
=
1
;
target
.
little_endian
=*
(
char
*
)
&
test
;
target
.
sizeof_int
=
sizeof
(
int
);
...
...
app/lua/luaconf.h
View file @
d77666c0
...
...
@@ -298,7 +298,7 @@ else
** CHANGE it if you need longer lines.
*/
#define LUA_MAXINPUT 256
/*
@@ lua_readline defines how to show a prompt and then read a line from
...
...
@@ -558,7 +558,7 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
** Attention: This value should probably not be set higher than 1K.
** The size has direct impact on the C stack size needed be auxlib functions.
** For example: If set to 4K a call to string.gsub will need more than
** For example: If set to 4K a call to string.gsub will need more than
** 5k C stack space.
*/
#define LUAL_BUFFERSIZE 256
...
...
@@ -579,10 +579,10 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
/* Define LUA_NUMBER_INTEGRAL to produce a system that uses no
floating point operations by changing the type of Lua numbers from
double to long. It implements division and modulus so that
double to long. It implements division and modulus so that
x == (x / y) * y + x % y.
x == (x / y) * y + x % y.
The exponentiation function returns zero for negative exponents.
Defining LUA_NUMBER_INTEGRAL also removes the difftime function,
and the math module should not be used. The string.format function
...
...
app/lua/lualib.h
View file @
d77666c0
...
...
@@ -41,7 +41,7 @@ LUALIB_API int (luaopen_package) (lua_State *L);
/* open all previous libraries */
LUALIB_API
void
(
luaL_openlibs
)
(
lua_State
*
L
);
LUALIB_API
void
(
luaL_openlibs
)
(
lua_State
*
L
);
...
...
app/lwip/Makefile
View file @
d77666c0
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
ifndef
PDIR
UP_EXTRACT_DIR
=
..
GEN_LIBS
=
liblwip.a
COMPONENTS_liblwip
=
api/liblwipapi.a
\
app/liblwipapp.a
\
core/liblwipcore.a
\
core/ipv4/liblwipipv4.a
\
netif/liblwipnetif.a
endif
#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#
INCLUDES
:=
$(INCLUDES)
-I
$(PDIR)
include
INCLUDES
+=
-I
./
PDIR
:=
../
$(PDIR)
sinclude
$(PDIR)Makefile
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
ifndef
PDIR
UP_EXTRACT_DIR
=
..
GEN_LIBS
=
liblwip.a
COMPONENTS_liblwip
=
api/liblwipapi.a
\
app/liblwipapp.a
\
core/liblwipcore.a
\
core/ipv4/liblwipipv4.a
\
netif/liblwipnetif.a
endif
#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#
INCLUDES
:=
$(INCLUDES)
-I
$(PDIR)
include
INCLUDES
+=
-I
./
PDIR
:=
../
$(PDIR)
sinclude
$(PDIR)Makefile
Prev
1
…
3
4
5
6
7
8
9
10
11
…
19
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment