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
13b08cda
Commit
13b08cda
authored
Mar 06, 2015
by
funshine
Browse files
add macro to control built-in lib for lua, add libm.a
parent
1d1f0857
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/Makefile
View file @
13b08cda
...
...
@@ -106,7 +106,8 @@ LINKFLAGS_eagle.app.v6 = \
-lsmartconfig
\
-lssl
\
$(DEP_LIBS_eagle.app.v6)
\
-Wl
,--end-group
-Wl
,--end-group
\
-lm
DEPENDS_eagle.app.v6
=
\
$(LD_FILE)
\
...
...
app/include/user_modules.h
View file @
13b08cda
#ifndef __USER_MODULES_H__
#define __USER_MODULES_H__
#define LUA_USE_BUILTIN_STRING // for string.xxx()
#define LUA_USE_BUILTIN_TABLE // for table.xxx()
#define LUA_USE_BUILTIN_COROUTINE // for coroutine.xxx()
// #define LUA_USE_BUILTIN_MATH // for math.xxx(), partially work
// #define LUA_USE_BUILTIN_IO // for io.xxx(), partially work
// #define LUA_USE_BUILTIN_OS // for os.xxx(), not work
// #define LUA_USE_BUILTIN_DEBUG // for debug.xxx(), not work
#define LUA_USE_MODULES
#ifdef LUA_USE_MODULES
...
...
app/lua/lmathlib.c
View file @
13b08cda
...
...
@@ -324,36 +324,36 @@ const LUA_REG_TYPE math_map[] = {
#endif
#else
{
LSTRKEY
(
"abs"
),
LFUNCVAL
(
math_abs
)},
{
LSTRKEY
(
"acos"
),
LFUNCVAL
(
math_acos
)},
{
LSTRKEY
(
"asin"
),
LFUNCVAL
(
math_asin
)},
{
LSTRKEY
(
"atan2"
),
LFUNCVAL
(
math_atan2
)},
{
LSTRKEY
(
"atan"
),
LFUNCVAL
(
math_atan
)},
//
{LSTRKEY("acos"), LFUNCVAL(math_acos)},
//
{LSTRKEY("asin"), LFUNCVAL(math_asin)},
//
{LSTRKEY("atan2"), LFUNCVAL(math_atan2)},
//
{LSTRKEY("atan"), LFUNCVAL(math_atan)},
{
LSTRKEY
(
"ceil"
),
LFUNCVAL
(
math_ceil
)},
{
LSTRKEY
(
"cosh"
),
LFUNCVAL
(
math_cosh
)},
{
LSTRKEY
(
"cos"
),
LFUNCVAL
(
math_cos
)},
{
LSTRKEY
(
"deg"
),
LFUNCVAL
(
math_deg
)},
{
LSTRKEY
(
"exp"
),
LFUNCVAL
(
math_exp
)},
//
{LSTRKEY("cosh"), LFUNCVAL(math_cosh)},
//
{LSTRKEY("cos"), LFUNCVAL(math_cos)},
//
{LSTRKEY("deg"), LFUNCVAL(math_deg)},
//
{LSTRKEY("exp"), LFUNCVAL(math_exp)},
{
LSTRKEY
(
"floor"
),
LFUNCVAL
(
math_floor
)},
{
LSTRKEY
(
"fmod"
),
LFUNCVAL
(
math_fmod
)},
//
{LSTRKEY("fmod"), LFUNCVAL(math_fmod)},
#if LUA_OPTIMIZE_MEMORY > 0 && defined(LUA_COMPAT_MOD)
{
LSTRKEY
(
"mod"
),
LFUNCVAL
(
math_fmod
)},
#endif
{
LSTRKEY
(
"frexp"
),
LFUNCVAL
(
math_frexp
)},
{
LSTRKEY
(
"ldexp"
),
LFUNCVAL
(
math_ldexp
)},
{
LSTRKEY
(
"log10"
),
LFUNCVAL
(
math_log10
)},
{
LSTRKEY
(
"log"
),
LFUNCVAL
(
math_log
)},
//
{LSTRKEY("frexp"), LFUNCVAL(math_frexp)},
//
{LSTRKEY("ldexp"), LFUNCVAL(math_ldexp)},
//
{LSTRKEY("log10"), LFUNCVAL(math_log10)},
//
{LSTRKEY("log"), LFUNCVAL(math_log)},
{
LSTRKEY
(
"max"
),
LFUNCVAL
(
math_max
)},
{
LSTRKEY
(
"min"
),
LFUNCVAL
(
math_min
)},
{
LSTRKEY
(
"modf"
),
LFUNCVAL
(
math_modf
)},
//
{LSTRKEY("modf"), LFUNCVAL(math_modf)},
{
LSTRKEY
(
"pow"
),
LFUNCVAL
(
math_pow
)},
{
LSTRKEY
(
"rad"
),
LFUNCVAL
(
math_rad
)},
//
{LSTRKEY("rad"), LFUNCVAL(math_rad)},
{
LSTRKEY
(
"random"
),
LFUNCVAL
(
math_random
)},
{
LSTRKEY
(
"randomseed"
),
LFUNCVAL
(
math_randomseed
)},
{
LSTRKEY
(
"sinh"
),
LFUNCVAL
(
math_sinh
)},
{
LSTRKEY
(
"sin"
),
LFUNCVAL
(
math_sin
)},
//
{LSTRKEY("sinh"), LFUNCVAL(math_sinh)},
//
{LSTRKEY("sin"), LFUNCVAL(math_sin)},
{
LSTRKEY
(
"sqrt"
),
LFUNCVAL
(
math_sqrt
)},
{
LSTRKEY
(
"tanh"
),
LFUNCVAL
(
math_tanh
)},
{
LSTRKEY
(
"tan"
),
LFUNCVAL
(
math_tan
)},
//
{LSTRKEY("tanh"), LFUNCVAL(math_tanh)},
//
{LSTRKEY("tan"), LFUNCVAL(math_tan)},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"pi"
),
LNUMVAL
(
PI
)},
{
LSTRKEY
(
"huge"
),
LNUMVAL
(
HUGE_VAL
)},
...
...
app/lua/lualib.h
View file @
13b08cda
...
...
@@ -24,17 +24,17 @@ LUALIB_API int (luaopen_table) (lua_State *L);
#define LUA_IOLIBNAME "io"
LUALIB_API
int
(
luaopen_io
)
(
lua_State
*
L
);
//
#define LUA_OSLIBNAME "os"
//
LUALIB_API int (luaopen_os) (lua_State *L);
#define LUA_OSLIBNAME "os"
LUALIB_API
int
(
luaopen_os
)
(
lua_State
*
L
);
#define LUA_STRLIBNAME "string"
LUALIB_API
int
(
luaopen_string
)
(
lua_State
*
L
);
//
#define LUA_MATHLIBNAME "math"
//
LUALIB_API int (luaopen_math) (lua_State *L);
#define LUA_MATHLIBNAME "math"
LUALIB_API
int
(
luaopen_math
)
(
lua_State
*
L
);
//
#define LUA_DBLIBNAME "debug"
//
LUALIB_API int (luaopen_debug) (lua_State *L);
#define LUA_DBLIBNAME "debug"
LUALIB_API
int
(
luaopen_debug
)
(
lua_State
*
L
);
#define LUA_LOADLIBNAME "package"
LUALIB_API
int
(
luaopen_package
)
(
lua_State
*
L
);
...
...
app/modules/linit.c
View file @
13b08cda
...
...
@@ -30,12 +30,26 @@ LUA_MODULES_ROM
static
const
luaL_Reg
lualibs
[]
=
{
{
""
,
luaopen_base
},
{
LUA_LOADLIBNAME
,
luaopen_package
},
// {LUA_IOLIBNAME, luaopen_io},
{
LUA_STRLIBNAME
,
luaopen_string
},
#if defined(LUA_USE_BUILTIN_IO)
{
LUA_IOLIBNAME
,
luaopen_io
},
#endif
#if defined(LUA_USE_BUILTIN_STRING)
{
LUA_STRLIBNAME
,
luaopen_string
},
#endif
#if LUA_OPTIMIZE_MEMORY == 0
// {LUA_MATHLIBNAME, luaopen_math},
#if defined(LUA_USE_BUILTIN_MATH)
{
LUA_MATHLIBNAME
,
luaopen_math
},
#endif
#if defined(LUA_USE_BUILTIN_TABLE)
{
LUA_TABLIBNAME
,
luaopen_table
},
// {LUA_DBLIBNAME, luaopen_debug},
#endif
#if defined(LUA_USE_BUILTIN_DEBUG)
{
LUA_DBLIBNAME
,
luaopen_debug
},
#endif
#endif
#if defined(LUA_MODULES_ROM)
#undef _ROM
...
...
@@ -45,12 +59,30 @@ static const luaL_Reg lualibs[] = {
{
NULL
,
NULL
}
};
#if defined(LUA_USE_BUILTIN_STRING)
extern
const
luaR_entry
strlib
[];
#endif
#if defined(LUA_USE_BUILTIN_OS)
extern
const
luaR_entry
syslib
[];
#endif
#if defined(LUA_USE_BUILTIN_TABLE)
extern
const
luaR_entry
tab_funcs
[];
// extern const luaR_entry dblib[];
#endif
#if defined(LUA_USE_BUILTIN_DEBUG)
extern
const
luaR_entry
dblib
[];
#endif
#if defined(LUA_USE_BUILTIN_COROUTINE)
extern
const
luaR_entry
co_funcs
[];
// extern const luaR_entry math_map[];
#endif
#if defined(LUA_USE_BUILTIN_MATH)
extern
const
luaR_entry
math_map
[];
#endif
#if defined(LUA_MODULES_ROM) && LUA_OPTIMIZE_MEMORY == 2
#undef _ROM
#define _ROM( name, openf, table ) extern const luaR_entry table[];
...
...
@@ -59,11 +91,30 @@ LUA_MODULES_ROM
const
luaR_table
lua_rotable
[]
=
{
#if LUA_OPTIMIZE_MEMORY > 0
#if defined(LUA_USE_BUILTIN_STRING)
{
LUA_STRLIBNAME
,
strlib
},
#endif
#if defined(LUA_USE_BUILTIN_TABLE)
{
LUA_TABLIBNAME
,
tab_funcs
},
// {LUA_DBLIBNAME, dblib},
#endif
#if defined(LUA_USE_BUILTIN_DEBUG)
{
LUA_DBLIBNAME
,
dblib
},
#endif
#if defined(LUA_USE_BUILTIN_COROUTINE)
{
LUA_COLIBNAME
,
co_funcs
},
// {LUA_MATHLIBNAME, math_map},
#endif
#if defined(LUA_USE_BUILTIN_MATH)
{
LUA_MATHLIBNAME
,
math_map
},
#endif
#if defined(LUA_USE_BUILTIN_OS)
{
LUA_OSLIBNAME
,
syslib
},
#endif
#if defined(LUA_MODULES_ROM) && LUA_OPTIMIZE_MEMORY == 2
#undef _ROM
#define _ROM( name, openf, table ) { name, table },
...
...
ld/eagle.app.v6.ld
View file @
13b08cda
...
...
@@ -5,7 +5,7 @@ MEMORY
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40210000, len = 0x5
5
000
irom0_0_seg : org = 0x40210000, len = 0x5
6
000
}
PHDRS
...
...
lib/libm.a
0 → 100644
View file @
13b08cda
File added
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