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
4905381c
Commit
4905381c
authored
Apr 04, 2019
by
Terry Ellison
Browse files
Resolve merge conflict on docs/index.md
parents
11592951
3f5ae99e
Changes
544
Hide whitespace changes
Inline
Side-by-side
app/lua/lstrlib.c
View file @
4905381c
...
...
@@ -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 @
4905381c
...
...
@@ -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 @
4905381c
...
...
@@ -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 @
4905381c
...
...
@@ -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 @
4905381c
#
# This Make
file is called from the core Makefile hierarchy w
it
h is a hierarchical
# make
w
which uses parent callbacks to implement inheritance. However i
s
luac_cross
# build stands outside this
and
uses the host toolchain to implement a separate
# host build of the luac.cross image.
#
# This Makefile is called from the core Makefile hierarchy w
hic
h is a hierarchical
# make which uses parent callbacks to implement inheritance. However i
f
luac_cross
# build stands outside this
, it
uses the host toolchain to implement a separate
# host build of the luac.cross image.
#
.NOTPARALLEL
:
summary
?=
@true
CCFLAGS
:=
-I
..
-I
../../include
-I
../../libc
-I
../../uzlib
LDFLAGS
:=
-L
$(SDK_DIR)
/lib
-L
$(SDK_DIR)
/ld
-lm
-ldl
-Wl
,-Map
=
mapfile
...
...
@@ -52,13 +54,19 @@ CC := $(WRAPCC) gcc
ECHO
:=
echo
IMAGE
:=
../../../luac.cross
BUILD_TYPE
:=
$(
shell
$(CC)
$(EXTRA_CCFLAGS)
-E
-dM
- <../../../app/include/user_config.h |
grep
LUA_NUMBER_INTEGRAL |
wc
-l
)
ifeq
($(BUILD_TYPE),0)
IMAGE
:=
../../../luac.cross
else
IMAGE
:=
../../../luac.cross.int
endif
.PHONY
:
test clean all
all
:
$(DEPS) $(IMAGE)
$(IMAGE)
:
$(OBJS)
$(summary)
HOSTLD
$@
$(CC)
$(OBJS)
-o
$@
$(LDFLAGS)
test
:
...
...
@@ -66,6 +74,7 @@ test :
@
echo
SRC:
$(SRC)
@
echo
OBJS:
$(OBJS)
@
echo
DEPS:
$(DEPS)
@
echo
IMAGE:
$(IMAGE)
clean
:
$(RM)
-r
$(ODIR)
...
...
@@ -76,11 +85,12 @@ endif
$(ODIR)/%.o
:
%.c
@
mkdir
-p
$(ODIR)
;
$(summary)
HOSTCC
$(CURDIR)
/
$<
$(CC)
$(
if
$(
findstring
$<
,
$(DSRCS)
)
,
$(DFLAGS)
,
$(CFLAGS)
)
$
(
COPTS_
$
(
*
F
))
-o
$@
-c
$<
$(ODIR)/%.d
:
%.c
@
mkdir
-p
$(ODIR)
;
@
echo
DEPEND:
$(CC)
-M
$(CFLAGS)
$<
$(summary)
DEPEND: HOSTCC
$(CURDIR)
/
$<
@
set
-e
;
rm
-f
$@
;
\
$(CC)
-M
$(CFLAGS)
$<
>
$@
.
$$$$
;
\
sed
's,\($*\.o\)[ :]*,
$(ODIR)
/\1 $@ : ,g'
<
$@
.
$$$$
>
$@
;
\
...
...
app/lua/luac_cross/lflashimg.c
View file @
4905381c
...
...
@@ -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,17 +102,21 @@ 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
#ifdef _MSC_VER
extern
void
__declspec
(
noreturn
)
luac_fatal
(
const
char
*
message
);
#else
extern
void
__attribute__
((
noreturn
))
luac_fatal
(
const
char
*
message
);
#endif
#ifdef LOCAL_DEBUG
#define DBG_PRINT(...) printf(__VA_ARGS__)
...
...
@@ -395,8 +399,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 +409,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 +417,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 +428,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 @
4905381c
...
...
@@ -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 @
4905381c
...
...
@@ -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,22 +164,23 @@ 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
,
'/'
);
if
(
!
s
)
s
=
strrchr
(
fn
,
'\\'
);
s
=
s
?
s
+
1
:
fn
;
while
(
*
s
==
'.'
)
s
++
;
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 +195,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 +219,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 +236,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 +249,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 +273,11 @@ struct Smain {
char
**
argv
;
};
extern
uint
dumpToFlashImage
(
lua_State
*
L
,
const
Proto
*
main
,
lua_Writer
w
,
void
*
data
,
int
strip
,
#if defined(_MSC_VER) || defined(__MINGW32__)
typedef
unsigned
int
uint
;
#endif
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 +294,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 +314,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 +334,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/luac_cross/mingw32-Makefile.mak
0 → 100644
View file @
4905381c
#
# This is a minimal Make file designed to be called from within a MinGW Cmd prompt.
# So if the distro ZIP file has been unpacked into C:\nodemcu-firmware then
#
# C:\nodemcu-firmware\app\lua\luac_cross> mingw32-make -f mingw32-makefile.mak
#
# will create the WinX EXE luac.cross.exe within the root C:\nodemcu-firmware folder.
# This make has been stripped down to use the basic non-graphics MinGW32 install and
# standard Windows commands available at the Cmd> prompt. This make is quite separate
# from the normal toolchain build.
.NOTPARALLEL
:
CCFLAGS
:=
-I
..
-I
../../include
-I
../../libc
-I
../../uzlib
-Wall
LDFLAGS
:=
-lm
-Wl
,-Map
=
mapfile
DEFINES
+=
-DLUA_CROSS_COMPILER
-DLUA_OPTIMIZE_MEMORY
=
2
CFLAGS
=
$(CCFLAGS)
$(DEFINES)
$(EXTRA_CCFLAGS)
$(STD_CFLAGS)
$(INCLUDES)
TARGET
=
host
CC
:=
gcc
ifeq
($(FLAVOR),debug)
CCFLAGS
+=
-O0
-g
TARGET_LDFLAGS
+=
-O0
-g
DEFINES
+=
-DLUA_DEBUG_BUILD
else
FLAVOR
=
release
CCFLAGS
+=
-O2
TARGET_LDFLAGS
+=
-O2
endif
#
# C files needed to compile luac.cross
#
LUACSRC
:=
luac.c lflashimg.c liolib.c loslib.c print.c
LUASRC
:=
lapi.c lauxlib.c lbaselib.c lcode.c ldblib.c ldebug.c
\
ldo.c
ldump.c
lfunc.c
lgc.c
linit.c
llex.c
\
lmathlib.c
lmem.c
loadlib.c
lobject.c
lopcodes.c
lparser.c
\
lrotable.c
lstate.c
lstring.c
lstrlib.c
ltable.c
ltablib.c
\
ltm.c
lundump.c
lvm.c
lzio.c
LIBCSRC
:=
c_stdlib.c
UZSRC
:=
uzlib_deflate.c crc32.c
#
# This relies on the files being unique on the vpath
#
SRC
:=
$(LUACSRC)
$(LUASRC)
$(LIBCSRC)
$(UZSRC)
vpath %.c .
:
..:../../libc:../../uzlib
INCS
:=
-I
..
-I
../..
-I
../../libc
-I
../../uzlib
ODIR
:=
.output
\o
bj
OBJS
:=
$
(
SRC:%.c
=
$(ODIR)
/%.o
)
IMAGE
:=
../../../luac.cross.exe
.PHONY
:
test clean all
all
:
$(DEPS) $(IMAGE)
$(IMAGE)
:
$(OBJS)
$(CC)
$(OBJS)
-o
$@
$(LDFLAGS)
test
:
@
echo
CC:
$(CC)
@
echo
SRC:
$(SRC)
@
echo
OBJS:
$(OBJS)
clean
:
del /s /q
$(ODIR)
$(ODIR)/%.o
:
%.c
@
mkdir
$(ODIR)
||
echo
.
$(CC)
$(INCS)
$(CFLAGS)
-o
$@
-c
$<
app/lua/luaconf.h
View file @
4905381c
...
...
@@ -39,7 +39,7 @@
#endif
#if defined(LUA_CROSS_COMPILER)
#if defined(LUA_CROSS_COMPILER)
&& !defined(_MSC_VER) && !defined(__MINGW32__)
#define LUA_USE_LINUX
#endif
...
...
@@ -264,7 +264,7 @@
#include <io.h>
#ifdef LUA_CROSS_COMPILER
#include <stdio.h>
else
#
else
#include "c_stdio.h"
#endif
...
...
@@ -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
...
...
@@ -631,7 +631,11 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
#define lua_str2number(s,p) c_strtoll((s), (p), 10)
#endif // #if !defined LUA_INTEGRAL_LONGLONG
#else
#ifdef _MSC_VER //what's wrong with stdlib strtod?
#define lua_str2number(s,p) strtod((s), (p))
#else
#define lua_str2number(s,p) c_strtod((s), (p))
#endif
#endif // #if defined LUA_NUMBER_INTEGRAL
/*
...
...
@@ -717,8 +721,18 @@ union luai_Cast { double l_d; long l_l; };
/* this option always works, but may be slow */
#else
#define lua_number2int(i,d) ((i)=(int)(d))
#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
#ifdef LUA_NUMBER_INTEGRAL
#define lua_number2int(i, d) ((i) = (int)(d))
#define lua_number2integer(i, d) ((i) = (lua_Integer)(d))
#else // for floating-point builds, cast to a larger integer first to avoid undefined behavior on overflows.
#define lua_number2int(i, d) ((i) = (int)(long long)(d))
#define lua_number2integer(i, d) ((i) = (lua_Integer)(long long)(d))
#endif // LUA_NUMBER_INTEGRAL
#endif
...
...
@@ -750,18 +764,18 @@ union luai_Cast { double l_d; long l_l; };
{ if ((c)->status == 0) (c)->status = -1; }
#define luai_jmpbuf int
/* dummy variable */
#elif defined(LUA_USE_ULONGJMP)
#else
#if defined(LUA_USE_ULONGJMP)
/* in Unix, try _longjmp/_setjmp (more efficient) */
#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
#define luai_jmpbuf jmp_buf
#define LONGJMP(a,b) _longjmp(a,b)
#define SETJMP(a) _setjmp(a)
#else
/* default handling with long jumps */
#define LUAI_THROW(L,c) longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
#define LONGJMP(a,b) longjmp(a,b)
#define SETJMP(a) setjmp(a)
#endif
#define LUAI_THROW(L,c) LONGJMP((c)->b, 1)
#define LUAI_TRY(L,c,a) if (SETJMP((c)->b) == 0) { a }
#define luai_jmpbuf jmp_buf
#endif
...
...
app/lua/lualib.h
View file @
4905381c
...
...
@@ -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 @
4905381c
#############################################################
# 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
app/lwip/api/Makefile
View file @
4905381c
#############################################################
# 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
GEN_LIBS
=
liblwipapi.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
GEN_LIBS
=
liblwipapi.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
app/lwip/api/api_lib.c
View file @
4905381c
...
...
@@ -3,12 +3,12 @@
* Sequential API External module
*
*/
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
...
...
@@ -17,21 +17,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
...
...
app/lwip/api/api_msg.c
View file @
4905381c
...
...
@@ -6,9 +6,9 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
...
...
@@ -17,21 +17,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
...
...
@@ -332,7 +332,7 @@ sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len)
API_EVENT
(
conn
,
NETCONN_EVT_SENDPLUS
,
len
);
}
}
return
ERR_OK
;
}
...
...
@@ -1465,7 +1465,7 @@ do_close(struct api_msg_msg *msg)
*/
void
do_join_leave_group
(
struct
api_msg_msg
*
msg
)
{
{
if
(
ERR_IS_FATAL
(
msg
->
conn
->
last_err
))
{
msg
->
err
=
msg
->
conn
->
last_err
;
}
else
{
...
...
app/lwip/api/err.c
View file @
4905381c
...
...
@@ -6,9 +6,9 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
...
...
@@ -17,21 +17,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
...
...
app/lwip/api/netbuf.c
View file @
4905381c
...
...
@@ -3,12 +3,12 @@
* Network buffer management
*
*/
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
...
...
@@ -17,21 +17,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
...
...
app/lwip/api/netdb.c
View file @
4905381c
...
...
@@ -5,7 +5,7 @@
*/
/*
* Redistribution and use in source and binary forms, with or without modification,
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
...
...
@@ -14,21 +14,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Simon Goldschmidt
*
*/
...
...
@@ -257,7 +257,7 @@ lwip_freeaddrinfo(struct addrinfo *ai)
*
* @param nodename descriptive name or address string of the host
* (may be NULL -> local address)
* @param servname port number as string of NULL
* @param servname port number as string of NULL
* @param hints structure containing input values that set socktype and protocol
* @param res pointer to a pointer where to store the result (set to NULL on failure)
* @return 0 on success, non-zero on failure
...
...
app/lwip/api/netifapi.c
View file @
4905381c
...
...
@@ -5,7 +5,7 @@
*/
/*
* Redistribution and use in source and binary forms, with or without modification,
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
...
...
@@ -14,21 +14,21 @@
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
*/
#include "lwip/opt.h"
...
...
app/lwip/api/sockets.c
View file @
4905381c
...
...
@@ -75,7 +75,7 @@ struct lwip_sock {
tested by select */
u16_t
sendevent
;
/** error happened for this socket, set by event_callback(), tested by select */
u16_t
errevent
;
u16_t
errevent
;
/** last error that occurred on this socket */
int
err
;
/** counter of how many threads are waiting for this socket using select */
...
...
@@ -572,7 +572,7 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
buf
=
sock
->
lastdata
;
}
else
{
/* If this is non-blocking call, then check first */
if
(((
flags
&
MSG_DONTWAIT
)
||
netconn_is_nonblocking
(
sock
->
conn
))
&&
if
(((
flags
&
MSG_DONTWAIT
)
||
netconn_is_nonblocking
(
sock
->
conn
))
&&
(
sock
->
rcvevent
<=
0
))
{
if
(
off
>
0
)
{
/* update receive window */
...
...
@@ -644,9 +644,9 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags,
if
(
netconn_type
(
sock
->
conn
)
==
NETCONN_TCP
)
{
LWIP_ASSERT
(
"invalid copylen, len would underflow"
,
len
>=
copylen
);
len
-=
copylen
;
if
(
(
len
<=
0
)
||
(
p
->
flags
&
PBUF_FLAG_PUSH
)
||
(
sock
->
rcvevent
<=
0
)
||
if
(
(
len
<=
0
)
||
(
p
->
flags
&
PBUF_FLAG_PUSH
)
||
(
sock
->
rcvevent
<=
0
)
||
((
flags
&
MSG_PEEK
)
!=
0
))
{
done
=
1
;
}
...
...
@@ -868,7 +868,7 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
#endif
/* LWIP_UDP */
}
UNLOCK_TCPIP_CORE
();
pbuf_free
(
p
);
}
else
{
err
=
ERR_MEM
;
...
...
@@ -1452,11 +1452,11 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
/* Do length and type checks for the various options first, to keep it readable. */
switch
(
level
)
{
/* Level: SOL_SOCKET */
case
SOL_SOCKET
:
switch
(
optname
)
{
case
SO_ACCEPTCONN
:
case
SO_BROADCAST
:
/* UNIMPL case SO_DEBUG: */
...
...
@@ -1505,7 +1505,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
err
=
ENOPROTOOPT
;
}
/* switch (optname) */
break
;
/* Level: IPPROTO_IP */
case
IPPROTO_IP
:
switch
(
optname
)
{
...
...
@@ -1545,7 +1545,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
err
=
ENOPROTOOPT
;
}
/* switch (optname) */
break
;
#if LWIP_TCP
/* Level: IPPROTO_TCP */
case
IPPROTO_TCP
:
...
...
@@ -1553,7 +1553,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
err
=
EINVAL
;
break
;
}
/* If this is no TCP socket, ignore any options. */
if
(
sock
->
conn
->
type
!=
NETCONN_TCP
)
return
0
;
...
...
@@ -1567,7 +1567,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
case
TCP_KEEPCNT
:
#endif
/* LWIP_TCP_KEEPALIVE */
break
;
default:
LWIP_DEBUGF
(
SOCKETS_DEBUG
,
(
"lwip_getsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)
\n
"
,
s
,
optname
));
...
...
@@ -1582,7 +1582,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
err
=
EINVAL
;
break
;
}
/* If this is no UDP lite socket, ignore any options. */
if
(
sock
->
conn
->
type
!=
NETCONN_UDPLITE
)
{
return
0
;
...
...
@@ -1592,7 +1592,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
case
UDPLITE_SEND_CSCOV
:
case
UDPLITE_RECV_CSCOV
:
break
;
default:
LWIP_DEBUGF
(
SOCKETS_DEBUG
,
(
"lwip_getsockopt(%d, IPPROTO_UDPLITE, UNIMPL: optname=0x%x, ..)
\n
"
,
s
,
optname
));
...
...
@@ -1607,7 +1607,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
err
=
ENOPROTOOPT
;
}
/* switch */
if
(
err
!=
ERR_OK
)
{
sock_set_errno
(
sock
,
err
);
return
-
1
;
...
...
@@ -1702,7 +1702,7 @@ lwip_getsockopt_internal(void *arg)
/* only overwrite ERR_OK or tempoary errors */
if
((
sock
->
err
==
0
)
||
(
sock
->
err
==
EINPROGRESS
))
{
sock_set_errno
(
sock
,
err_to_errno
(
sock
->
conn
->
last_err
));
}
}
*
(
int
*
)
optval
=
sock
->
err
;
sock
->
err
=
0
;
LWIP_DEBUGF
(
SOCKETS_DEBUG
,
(
"lwip_getsockopt(%d, SOL_SOCKET, SO_ERROR) = %d
\n
"
,
...
...
Prev
1
…
6
7
8
9
10
11
12
13
14
…
28
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