1
0
Fork 0
forked from len0rd/rockbox

lua reduce heap allocated buffer sizes, organize luaconf.h

Change-Id: Ib9e568ea73a01474facd57cc155e62fa3dc093f7
This commit is contained in:
William Wilgus 2019-07-11 11:57:50 -05:00
parent a332924f68
commit ee58f2601c

View file

@ -1,5 +1,5 @@
/*
** $Id$
** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@ -333,14 +333,14 @@
** CHANGE it to undefined as soon as your programs use only '...' to
** access vararg parameters (instead of the old 'arg' table).
*/
#undef LUA_COMPAT_VARARG
#define LUA_COMPAT_VARARG
/*
@@ LUA_COMPAT_MOD controls compatibility with old math.mod function.
** CHANGE it to undefined as soon as your programs use 'math.fmod' or
** the new '%' operator instead of 'math.mod'.
*/
#undef LUA_COMPAT_MOD
#define LUA_COMPAT_MOD
/*
@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting
@ -348,22 +348,22 @@
** CHANGE it to 2 if you want the old behaviour, or undefine it to turn
** off the advisory error when nesting [[...]].
*/
#undef LUA_COMPAT_LSTR
#define LUA_COMPAT_LSTR 1
/*
@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name.
** CHANGE it to undefined as soon as you rename 'string.gfind' to
** 'string.gmatch'.
*/
#undef LUA_COMPAT_GFIND
#define LUA_COMPAT_GFIND
/*
@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
@* behavior.
** CHANGE it to undefined as soon as you replace to 'luaL_registry'
** CHANGE it to undefined as soon as you replace to 'luaL_register'
** your uses of 'luaL_openlib'
*/
#undef LUA_COMPAT_OPENLIB
#define LUA_COMPAT_OPENLIB
@ -485,7 +485,7 @@
/*
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
*/
#define LUAL_BUFFERSIZE 1024
#define LUAL_BUFFERSIZE BUFSIZ
/* }================================================================== */
@ -501,14 +501,14 @@
** ===================================================================
*/
#undef LUA_NUMBER_DOUBLE
#define LUA_NUMBER long
#define LUA_NUMBER_DOUBLE
#define LUA_NUMBER double
/*
@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
@* over a number.
*/
#define LUAI_UACNUMBER long
#define LUAI_UACNUMBER double
/*
@ -518,24 +518,24 @@
@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
@@ lua_str2number converts a string to a number.
*/
#define LUA_NUMBER_SCAN "%ld"
#define LUA_NUMBER_FMT "%ld"
#define LUA_NUMBER_SCAN "%lf"
#define LUA_NUMBER_FMT "%.14g"
#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
#define lua_number2str(s,n) snprintf((s), 32, LUA_NUMBER_FMT, (n))
#define lua_str2number(s,p) strtol((s), (p), 10)
#define lua_str2number(s,p) strtod((s), (p))
/*
@@ The luai_num* macros define the primitive operations over numbers.
*/
#if defined(LUA_CORE)
extern long rb_pow(long, long);
/*#include <math.h> //ROCKLUA_REMOVED */
#define luai_numadd(a,b) ((a)+(b))
#define luai_numsub(a,b) ((a)-(b))
#define luai_nummul(a,b) ((a)*(b))
#define luai_numdiv(a,b) ((a)/(b))
#define luai_nummod(a,b) ((a)%(b))
#define luai_numpow(a,b) (rb_pow(a,b))
#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
#define luai_numpow(a,b) (pow(a,b))
#define luai_numunm(a) (-(a))
#define luai_numeq(a,b) ((a)==(b))
#define luai_numlt(a,b) ((a)<(b))
@ -592,7 +592,7 @@ union luai_Cast { double l_d; long l_l; };
** aligned in 16-byte boundaries, then you should add long double in the
** union.) Probably you do not need to change this.
*/
#define LUAI_USER_ALIGNMENT_T union { void *s; long l; }
#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
/*
@ -757,7 +757,60 @@ union luai_Cast { double l_d; long l_l; };
** without modifying the main part of the file.
*/
#include "rockconf.h"
#define LUAC_TRUST_BINARIES
#endif
/*Rocklua integer patch */
#undef LUA_NUMBER_DOUBLE
#undef LUA_NUMBER
#define LUA_NUMBER long
#undef LUAI_UACNUMBER
#define LUAI_UACNUMBER long
#undef LUA_NUMBER_SCAN
#define LUA_NUMBER_SCAN "%ld"
#undef LUA_NUMBER_FMT
#define LUA_NUMBER_FMT "%ld"
#undef lua_number2str
#define lua_number2str(s,n) snprintf((s), 32, LUA_NUMBER_FMT, (n))
#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
#undef lua_str2number
#define lua_str2number(s,p) strtol((s), (p), 10)
#undef luai_nummod
#define luai_nummod(a,b) ((a)%(b))
extern long rb_pow(long, long);
#undef luai_numpow
#define luai_numpow(a,b) (rb_pow(a,b))
#undef LUAI_USER_ALIGNMENT_T
#define LUAI_USER_ALIGNMENT_T union { void *s; long l; }
/* Compatibility */
#undef LUA_COMPAT_VARARG
#undef LUA_COMPAT_MOD
#undef LUA_COMPAT_LSTR
#undef LUA_COMPAT_GFIND
#undef LUA_COMPAT_OPENLIB
/* Resize heap allocated buffers */
#undef LUAI_MAXVARS /*200*/
#define LUAI_MAXVARS 100
#undef LUAI_MAXUPVALUES /*60*/
#define LUAI_MAXUPVALUES 30
#undef LUAL_BUFFERSIZE /*1024*/
#define LUAL_BUFFERSIZE 512
/*Rocklua functions*/
#include "rockconf.h"
/*else*/
#define LUAC_TRUST_BINARIES
#endif