mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
Lua long long preliminary support
This commit is contained in:
parent
c9127c8893
commit
f17b2a3bb2
11
SConstruct
11
SConstruct
@ -162,9 +162,9 @@ vars.AddVariables(
|
||||
'none',
|
||||
allowed_values = [ 'none', 'emblod' ] ),
|
||||
MatchEnumVariable('target',
|
||||
'build "regular" float lua or integer-only "lualong"',
|
||||
'build "regular" float lua, 32 bit integer-only "lualong" or 64-bit integer-only "lualonglong"',
|
||||
'lua',
|
||||
allowed_values = [ 'lua', 'lualong' ] ),
|
||||
allowed_values = [ 'lua', 'lualong', 'lualonglong' ] ),
|
||||
MatchEnumVariable('cpu',
|
||||
'build for the specified CPU (board will be inferred, if possible)',
|
||||
'auto',
|
||||
@ -277,6 +277,9 @@ if not GetOption( 'help' ):
|
||||
# Build the compilation command now
|
||||
compcmd = ''
|
||||
if comp['romfs'] == 'compile':
|
||||
if comp['target'] == 'lualonglong':
|
||||
print "Cross-compilation is not yet supported in 64-bit mode"
|
||||
Exit( -1 )
|
||||
if syspl.system() == 'Windows':
|
||||
suffix = '.exe'
|
||||
else:
|
||||
@ -336,8 +339,10 @@ if not GetOption( 'help' ):
|
||||
lua_full_files = " " + " ".join( [ "src/lua/%s" % name for name in lua_files.split() ] )
|
||||
|
||||
comp.Append(CPPPATH = ['inc', 'inc/newlib', 'inc/remotefs', 'src/platform', 'src/lua'])
|
||||
if comp['target'] == 'lualong':
|
||||
if comp['target'] == 'lualong' or comp['target'] == 'lualonglong':
|
||||
conf.env.Append(CPPDEFINES = ['LUA_NUMBER_INTEGRAL'])
|
||||
if comp['target'] == 'lualonglong':
|
||||
conf.env.Append(CPPDEFINES = ['LUA_INTEGRAL_LONGLONG'])
|
||||
|
||||
conf.env.Append(CPPPATH = ['src/modules', 'src/platform/%s' % platform])
|
||||
conf.env.Append(CPPDEFINES = {"LUA_OPTIMIZE_MEMORY" : ( comp['optram'] != 0 and 2 or 0 ) } )
|
||||
|
@ -206,7 +206,7 @@ for k, v in pairs( board_list ) do
|
||||
end
|
||||
end
|
||||
|
||||
builder:add_option( 'target', 'build "regular" float lua or integer-only "lualong"', 'lua', { 'lua', 'lualong' } )
|
||||
builder:add_option( 'target', 'build "regular" float lua, 32 bit integer-only "lualong" or 64-bit integer only lua "lualonglong"', 'lua', { 'lua', 'lualong', 'lualonglong' } )
|
||||
builder:add_option( 'cpu', 'build for the specified CPU (board will be inferred, if possible)', 'auto', { cpu_list, 'auto' } )
|
||||
builder:add_option( 'allocator', 'select memory allocator', 'auto', { 'newlib', 'multiple', 'simple', 'auto' } )
|
||||
builder:add_option( 'board', 'selects board for target (cpu will be inferred)', 'auto', { utils.table_keys( board_list ), 'auto' } )
|
||||
@ -310,6 +310,10 @@ end
|
||||
-- Build the compilation command now
|
||||
local fscompcmd = ''
|
||||
if comp.romfs == 'compile' then
|
||||
if comp.target == 'lualonglong' then
|
||||
print "Cross-compilation is not yet supported for 64-bit integer only Lua (lualonglong)."
|
||||
os.exit( -1 )
|
||||
end
|
||||
local suffix = ''
|
||||
if utils.is_windows() then
|
||||
suffix = '.exe'
|
||||
@ -362,7 +366,8 @@ elseif comp.allocator == 'simple' then
|
||||
addm( "USE_SIMPLE_ALLOCATOR" )
|
||||
end
|
||||
if comp.boot == 'luarpc' then addm( "ELUA_BOOT_RPC" ) end
|
||||
if comp.target == 'lualong' then addm( "LUA_NUMBER_INTEGRAL" ) end
|
||||
if comp.target == 'lualong' or comp.target == 'lualonglong' then addm( "LUA_NUMBER_INTEGRAL" ) end
|
||||
if comp.target == 'lualonglong' then addm( "LUA_INTEGRAL_LONGLONG" ) end
|
||||
|
||||
-- Special macro definitions for the SYM target
|
||||
if platform == 'sim' then addm( { "ELUA_SIMULATOR", "ELUA_SIM_" .. cnorm( comp.cpu ) } ) end
|
||||
|
@ -4,7 +4,7 @@
|
||||
stty -echo raw -igncr
|
||||
|
||||
# Run simulator
|
||||
./elua_lua_linux.elf
|
||||
./elua_lua$1_linux.elf
|
||||
|
||||
# Restore terminal to default settings
|
||||
stty echo cooked
|
||||
|
@ -160,8 +160,12 @@
|
||||
#if !defined LUA_NUMBER_INTEGRAL
|
||||
#define LUA_INTEGER ptrdiff_t
|
||||
#else
|
||||
#define LUA_INTEGER long
|
||||
#endif
|
||||
#if !defined LUA_INTEGRAL_LONGLONG
|
||||
#define LUA_INTEGER long
|
||||
#else
|
||||
#define LUA_INTEGER long long
|
||||
#endif // #if !defined LUA_INTEGRAL_LONGLONG
|
||||
#endif // #if !defined LUA_NUMBER_INTEGRAL
|
||||
|
||||
/*
|
||||
@@ LUA_API is a mark for all core API functions.
|
||||
@ -553,7 +557,7 @@
|
||||
%G. */
|
||||
|
||||
#if defined LUA_NUMBER_INTEGRAL
|
||||
#define LUA_NUMBER long
|
||||
#define LUA_NUMBER LUA_INTEGER
|
||||
#else
|
||||
#define LUA_NUMBER_DOUBLE
|
||||
#define LUA_NUMBER double
|
||||
@ -574,20 +578,28 @@
|
||||
@@ lua_str2number converts a string to a number.
|
||||
*/
|
||||
#if defined LUA_NUMBER_INTEGRAL
|
||||
#define LUA_NUMBER_SCAN "%ld"
|
||||
#define LUA_NUMBER_FMT "%ld"
|
||||
#if !defined LUA_INTEGRAL_LONGLONG
|
||||
#define LUA_NUMBER_SCAN "%ld"
|
||||
#define LUA_NUMBER_FMT "%ld"
|
||||
#else
|
||||
#define LUA_NUMBER_SCAN "%lld"
|
||||
#define LUA_NUMBER_FMT "%lld"
|
||||
#endif // #if !defined LUA_INTEGRAL_LONGLONG
|
||||
#else
|
||||
#define LUA_NUMBER_SCAN "%lf"
|
||||
#define LUA_NUMBER_FMT "%.14g"
|
||||
#endif
|
||||
#endif // #if defined LUA_NUMBER_INTEGRAL
|
||||
#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
|
||||
#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
|
||||
#if defined LUA_NUMBER_INTEGRAL
|
||||
#define lua_str2number(s,p) strtol((s), (p), 10)
|
||||
#if !defined LUA_INTEGRAL_LONGLONG
|
||||
#define lua_str2number(s,p) strtol((s), (p), 10)
|
||||
#else
|
||||
#define lua_str2number(s,p) strtoll((s), (p), 10)
|
||||
#endif // #if !defined LUA_INTEGRAL_LONGLONG
|
||||
#else
|
||||
#define lua_str2number(s,p) strtod((s), (p))
|
||||
#endif
|
||||
|
||||
#endif // #if defined LUA_NUMBER_INTEGRAL
|
||||
|
||||
/*
|
||||
@@ The luai_num* macros define the primitive operations over numbers.
|
||||
@ -827,7 +839,7 @@ union luai_Cast { double l_d; long l_l; };
|
||||
** CHANGE them if your system supports long long or does not support long.
|
||||
*/
|
||||
|
||||
#if defined(LUA_USELONGLONG)
|
||||
#if defined(LUA_USELONGLONG) || defined(LUA_INTEGRAL_LONGLONG)
|
||||
|
||||
#define LUA_INTFRMLEN "ll"
|
||||
#define LUA_INTFRM_T long long
|
||||
|
Loading…
x
Reference in New Issue
Block a user