mirror of
https://github.com/lua/lua.git
synced 2024-11-23 18:23:43 +08:00
several configuration options that do not change often moved out of
luaconf.h and into more internal files
This commit is contained in:
parent
2af0d3b459
commit
de6fc75d63
34
ldo.c
34
ldo.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ldo.c,v 2.75 2009/12/08 18:59:24 roberto Exp roberto $
|
||||
** $Id: ldo.c,v 2.76 2009/12/10 18:20:07 roberto Exp roberto $
|
||||
** Stack and Call structure of Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -40,6 +40,38 @@
|
||||
** =======================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
** LUAI_THROW/LUAI_TRY define how Lua does exception handling. By
|
||||
** default, Lua handles errors with exceptions when compiling as
|
||||
** C++ code, with _longjmp/_setjmp when asked to use them, and with
|
||||
** longjmp/setjmp otherwise.
|
||||
*/
|
||||
#if !defined(LUAI_THROW)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
/* C++ exceptions */
|
||||
#define LUAI_THROW(L,c) throw(c)
|
||||
#define LUAI_TRY(L,c,a) \
|
||||
try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; }
|
||||
#define luai_jmpbuf int /* dummy variable */
|
||||
|
||||
#elif 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
|
||||
|
||||
#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 luai_jmpbuf jmp_buf
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* chain list of long jump buffers */
|
||||
struct lua_longjmp {
|
||||
|
4
linit.c
4
linit.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: linit.c,v 1.20 2009/09/05 12:39:29 roberto Exp roberto $
|
||||
** $Id: linit.c,v 1.21 2009/12/11 13:40:44 roberto Exp roberto $
|
||||
** Initialization of libraries for lua.c and other clients
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -63,7 +63,7 @@ LUALIB_API void luaL_openlibs (lua_State *L) {
|
||||
lua_setfield(L, -2, lib->name);
|
||||
}
|
||||
lua_pop(L, 1); /* remove package.preload table */
|
||||
#ifdef LUA_COMPAT_DEBUGLIB
|
||||
#if defined(LUA_COMPAT_DEBUGLIB)
|
||||
lua_getfield(L, LUA_GLOBALSINDEX, "require");
|
||||
lua_pushliteral(L, LUA_DBLIBNAME);
|
||||
lua_call(L, 1, 0); /* call 'require"debug"' */
|
||||
|
45
llimits.h
45
llimits.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: llimits.h,v 1.74 2009/08/31 14:26:28 roberto Exp roberto $
|
||||
** $Id: llimits.h,v 1.75 2009/11/17 11:56:03 roberto Exp roberto $
|
||||
** Limits, basic types, and some other `installation-dependent' definitions
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -44,6 +44,10 @@ typedef unsigned char lu_byte;
|
||||
|
||||
|
||||
/* type to ensure maximum alignment */
|
||||
#if !defined(LUAI_USER_ALIGNMENT_T)
|
||||
#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
|
||||
#endif
|
||||
|
||||
typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
|
||||
|
||||
|
||||
@ -52,36 +56,47 @@ typedef LUAI_UACNUMBER l_uacNumber;
|
||||
|
||||
|
||||
/* internal assertions for in-house debugging */
|
||||
#ifdef lua_assert
|
||||
|
||||
#if defined(lua_assert)
|
||||
#define check_exp(c,e) (lua_assert(c), (e))
|
||||
#undef luai_apicheck
|
||||
#define luai_apicheck(L,e) lua_assert(e)
|
||||
|
||||
#else
|
||||
|
||||
#define lua_assert(c) ((void)0)
|
||||
#define check_exp(c,e) (e)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** assertion for checking API calls
|
||||
*/
|
||||
#if defined(LUA_USE_APICHECK)
|
||||
#include <assert.h>
|
||||
#define luai_apicheck(L,e) { (void)L; assert(e); }
|
||||
#elif !defined(luai_apicheck)
|
||||
#define luai_apicheck(L,e) lua_assert(e)
|
||||
#endif
|
||||
|
||||
#define api_check(l,e,msg) luai_apicheck(l,(e) && msg)
|
||||
|
||||
|
||||
#ifndef UNUSED
|
||||
#if !defined(UNUSED)
|
||||
#define UNUSED(x) ((void)(x)) /* to avoid warnings */
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef cast
|
||||
#define cast(t, exp) ((t)(exp))
|
||||
#endif
|
||||
|
||||
#define cast_byte(i) cast(lu_byte, (i))
|
||||
#define cast_num(i) cast(lua_Number, (i))
|
||||
#define cast_int(i) cast(int, (i))
|
||||
|
||||
|
||||
/*
|
||||
** maximum depth for nested C calls and syntactical nested non-terminals
|
||||
** in a program. (Value must fit in an unsigned short int.)
|
||||
*/
|
||||
#if !defined(LUAI_MAXCCALLS)
|
||||
#define LUAI_MAXCCALLS 200
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** type for virtual-machine instructions
|
||||
@ -97,23 +112,23 @@ typedef lu_int32 Instruction;
|
||||
|
||||
|
||||
/* minimum size for the string table (must be power of 2) */
|
||||
#ifndef MINSTRTABSIZE
|
||||
#if !defined(MINSTRTABSIZE)
|
||||
#define MINSTRTABSIZE 32
|
||||
#endif
|
||||
|
||||
|
||||
/* minimum size for string buffer */
|
||||
#ifndef LUA_MINBUFFER
|
||||
#if !defined(LUA_MINBUFFER)
|
||||
#define LUA_MINBUFFER 32
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef lua_lock
|
||||
#if !defined(lua_lock)
|
||||
#define lua_lock(L) ((void) 0)
|
||||
#define lua_unlock(L) ((void) 0)
|
||||
#endif
|
||||
|
||||
#ifndef luai_threadyield
|
||||
#if !defined(luai_threadyield)
|
||||
#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);}
|
||||
#endif
|
||||
|
||||
@ -121,7 +136,7 @@ typedef lu_int32 Instruction;
|
||||
/*
|
||||
** macro to control inclusion of some hard tests on stack reallocation
|
||||
*/
|
||||
#ifndef HARDSTACKTESTS
|
||||
#if !defined(HARDSTACKTESTS)
|
||||
#define condmovestack(L) ((void)0)
|
||||
#else
|
||||
/* realloc stack keeping its size */
|
||||
|
39
loadlib.c
39
loadlib.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: loadlib.c,v 1.67 2009/11/16 15:51:19 roberto Exp roberto $
|
||||
** $Id: loadlib.c,v 1.68 2009/11/24 12:05:44 roberto Exp roberto $
|
||||
** Dynamic library loader for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
**
|
||||
@ -22,6 +22,43 @@
|
||||
#include "lualib.h"
|
||||
|
||||
|
||||
/*
|
||||
** LUA_PATH and LUA_CPATH are the names of the environment variables that
|
||||
** Lua check to set its paths.
|
||||
*/
|
||||
#if !defined(LUA_PATH)
|
||||
#define LUA_PATH "LUA_PATH"
|
||||
#endif
|
||||
|
||||
#if !defined(LUA_CPATH)
|
||||
#define LUA_CPATH "LUA_CPATH"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** LUA_PATHSEP is the character that separates templates in a path.
|
||||
** LUA_PATH_MARK is the string that marks the substitution points in a
|
||||
** template.
|
||||
** LUA_EXECDIR in a Windows path is replaced by the executable's
|
||||
** directory.
|
||||
** LUA_IGMARK is a mark to ignore all before it when building the
|
||||
** luaopen_ function name.
|
||||
*/
|
||||
#if !defined (LUA_PATHSEP)
|
||||
#define LUA_PATHSEP ";"
|
||||
#endif
|
||||
#if !defined (LUA_PATH_MARK)
|
||||
#define LUA_PATH_MARK "?"
|
||||
#endif
|
||||
#if !defined (LUA_EXECDIR)
|
||||
#define LUA_EXECDIR "!"
|
||||
#endif
|
||||
#if !defined (LUA_IGMARK)
|
||||
#define LUA_IGMARK "-"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* prefix for open functions in C libraries */
|
||||
#define LUA_POF "luaopen_"
|
||||
|
||||
|
24
loslib.c
24
loslib.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: loslib.c,v 1.26 2009/11/23 18:20:38 roberto Exp roberto $
|
||||
** $Id: loslib.c,v 1.27 2009/11/24 12:05:44 roberto Exp roberto $
|
||||
** Standard Operating System library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -20,6 +20,28 @@
|
||||
#include "lualib.h"
|
||||
|
||||
|
||||
/*
|
||||
** By default, Lua uses tmpnam except when POSIX is available, where it
|
||||
** uses mkstemp.
|
||||
*/
|
||||
#if defined(LUA_USE_MKSTEMP)
|
||||
#include <unistd.h>
|
||||
#define LUA_TMPNAMBUFSIZE 32
|
||||
#define lua_tmpnam(b,e) { \
|
||||
strcpy(b, "/tmp/lua_XXXXXX"); \
|
||||
e = mkstemp(b); \
|
||||
if (e != -1) close(e); \
|
||||
e = (e == -1); }
|
||||
|
||||
#elif !defined(lua_tmpnam)
|
||||
|
||||
#define LUA_TMPNAMBUFSIZE L_tmpnam
|
||||
#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static int os_pushresult (lua_State *L, int i, const char *filename) {
|
||||
int en = errno; /* calls to Lua API may change this value */
|
||||
if (i) {
|
||||
|
11
lstate.c
11
lstate.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstate.c,v 2.65 2009/12/14 15:27:30 roberto Exp roberto $
|
||||
** $Id: lstate.c,v 2.66 2009/12/16 16:42:58 roberto Exp roberto $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -25,6 +25,15 @@
|
||||
#include "ltm.h"
|
||||
|
||||
|
||||
#if !defined(LUAI_GCPAUSE)
|
||||
#define LUAI_GCPAUSE 162 /* 162% (wait memory to double before next GC) */
|
||||
#endif
|
||||
|
||||
#if !defined(LUAI_GCMUL)
|
||||
#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** thread state + extra space
|
||||
*/
|
||||
|
11
lstrlib.c
11
lstrlib.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstrlib.c,v 1.144 2009/11/24 12:05:44 roberto Exp roberto $
|
||||
** $Id: lstrlib.c,v 1.145 2009/11/26 16:49:28 roberto Exp roberto $
|
||||
** Standard library for string operations and pattern-matching
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -20,6 +20,15 @@
|
||||
#include "lualib.h"
|
||||
|
||||
|
||||
/*
|
||||
** maximum number of captures that a pattern can do during
|
||||
** pattern-matching. This limit is arbitrary.
|
||||
*/
|
||||
#if !defined(LUA_MAXCAPTURES)
|
||||
#define LUA_MAXCAPTURES 32
|
||||
#endif
|
||||
|
||||
|
||||
/* macro to `unsign' a character */
|
||||
#define uchar(c) ((unsigned char)(c))
|
||||
|
||||
|
10
ltests.h
10
ltests.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltests.h,v 2.27 2009/12/14 15:27:30 roberto Exp roberto $
|
||||
** $Id: ltests.h,v 2.28 2009/12/16 16:42:58 roberto Exp roberto $
|
||||
** Internal Header for Debugging of the Lua Implementation
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -44,10 +44,6 @@ void *l_Trick;
|
||||
|
||||
void *debug_realloc (void *ud, void *block, size_t osize, size_t nsize);
|
||||
|
||||
#ifdef lua_c
|
||||
#define luaL_newstate() lua_newstate(debug_realloc, &l_memcontrol)
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct CallInfo *pCallInfo;
|
||||
|
||||
@ -72,7 +68,9 @@ struct L_EXTRA { int lock; int *plock; };
|
||||
|
||||
int luaB_opentests (lua_State *L);
|
||||
|
||||
#ifdef lua_c
|
||||
|
||||
#if defined(lua_c)
|
||||
#define luaL_newstate() lua_newstate(debug_realloc, &l_memcontrol)
|
||||
#define luaL_openlibs(L) { (luaL_openlibs)(L); luaB_opentests(L); }
|
||||
#endif
|
||||
|
||||
|
65
lua.c
65
lua.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lua.c,v 1.176 2009/11/24 18:05:12 roberto Exp roberto $
|
||||
** $Id: lua.c,v 1.177 2009/12/11 13:40:44 roberto Exp roberto $
|
||||
** Lua stand-alone interpreter
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -18,6 +18,69 @@
|
||||
#include "lualib.h"
|
||||
|
||||
|
||||
#if !defined(LUA_PROMPT)
|
||||
#define LUA_PROMPT "> "
|
||||
#define LUA_PROMPT2 ">> "
|
||||
#endif
|
||||
|
||||
#if !defined(LUA_PROGNAME)
|
||||
#define LUA_PROGNAME "lua"
|
||||
#endif
|
||||
|
||||
#if !defined(LUA_MAXINPUT)
|
||||
#define LUA_MAXINPUT 512
|
||||
#endif
|
||||
|
||||
#if !defined(LUA_INIT)
|
||||
#define LUA_INIT "LUA_INIT"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** lua_stdin_is_tty detects whether the standard input is a 'tty' (that
|
||||
** is, whether we're running lua interactively).
|
||||
*/
|
||||
#if defined(LUA_USE_ISATTY)
|
||||
#include <unistd.h>
|
||||
#define lua_stdin_is_tty() isatty(0)
|
||||
#elif defined(LUA_WIN)
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#define lua_stdin_is_tty() _isatty(_fileno(stdin))
|
||||
#else
|
||||
#define lua_stdin_is_tty() 1 /* assume stdin is a tty */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** lua_readline defines how to show a prompt and then read a line from
|
||||
** the standard input.
|
||||
** lua_saveline defines how to "save" a read line in a "history".
|
||||
** lua_freeline defines how to free a line read by lua_readline.
|
||||
*/
|
||||
#if defined(LUA_USE_READLINE)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
|
||||
#define lua_saveline(L,idx) \
|
||||
if (lua_objlen(L,idx) > 0) /* non-empty line? */ \
|
||||
add_history(lua_tostring(L, idx)); /* add it to history */
|
||||
#define lua_freeline(L,b) ((void)L, free(b))
|
||||
|
||||
#elif !defined(lua_readline)
|
||||
|
||||
#define lua_readline(L,b,p) \
|
||||
((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
|
||||
fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
|
||||
#define lua_saveline(L,idx) { (void)L; (void)idx; }
|
||||
#define lua_freeline(L,b) { (void)L; (void)b; }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
static lua_State *globalL = NULL;
|
||||
|
||||
|
239
luaconf.h
239
luaconf.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: luaconf.h,v 1.120 2009/12/10 19:00:33 roberto Exp roberto $
|
||||
** $Id: luaconf.h,v 1.121 2009/12/14 15:27:30 roberto Exp roberto $
|
||||
** Configuration file for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -65,17 +65,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
|
||||
@* Lua check to set its paths.
|
||||
@@ LUA_INIT is the name of the environment variable that Lua
|
||||
@* checks for initialization code.
|
||||
** CHANGE them if you want different names.
|
||||
*/
|
||||
#define LUA_PATH "LUA_PATH"
|
||||
#define LUA_CPATH "LUA_CPATH"
|
||||
#define LUA_INIT "LUA_INIT"
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
|
||||
@ -123,24 +112,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_PATHSEP is the character that separates templates in a path.
|
||||
@@ LUA_PATH_MARK is the string that marks the substitution points in a
|
||||
@* template.
|
||||
@@ LUA_EXECDIR in a Windows path is replaced by the executable's
|
||||
@* directory.
|
||||
@@ LUA_IGMARK is a mark to ignore all before it when building the
|
||||
@* luaopen_ function name.
|
||||
** CHANGE them if for some reason your system cannot use those
|
||||
** characters. (E.g., if one of those characters is a common character
|
||||
** in file/directory names.) Probably you do not need to change them.
|
||||
*/
|
||||
#define LUA_PATHSEP ";"
|
||||
#define LUA_PATH_MARK "?"
|
||||
#define LUA_EXECDIR "!"
|
||||
#define LUA_IGMARK "-"
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_API is a mark for all core API functions.
|
||||
@@ LUALIB_API is a mark for all auxiliary library functions.
|
||||
@ -225,106 +196,6 @@
|
||||
#define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
|
||||
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
** Stand-alone configuration
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#if defined(lua_c) || defined(luaall_c)
|
||||
|
||||
/*
|
||||
@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
|
||||
@* is, whether we're running lua interactively).
|
||||
** CHANGE it if you have a better definition for non-POSIX/non-Windows
|
||||
** systems.
|
||||
*/
|
||||
#if defined(LUA_USE_ISATTY)
|
||||
#include <unistd.h>
|
||||
#define lua_stdin_is_tty() isatty(0)
|
||||
#elif defined(LUA_WIN)
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#define lua_stdin_is_tty() _isatty(_fileno(stdin))
|
||||
#else
|
||||
#define lua_stdin_is_tty() 1 /* assume stdin is a tty */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_PROMPT is the default prompt used by stand-alone Lua.
|
||||
@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
|
||||
** CHANGE them if you want different prompts. (You can also change the
|
||||
** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
|
||||
*/
|
||||
#define LUA_PROMPT "> "
|
||||
#define LUA_PROMPT2 ">> "
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_PROGNAME is the default name for the stand-alone Lua program.
|
||||
** CHANGE it if your stand-alone interpreter has a different name and
|
||||
** your system is not able to detect that name automatically.
|
||||
*/
|
||||
#define LUA_PROGNAME "lua"
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_MAXINPUT is the maximum length for an input line in the
|
||||
@* stand-alone interpreter.
|
||||
** CHANGE it if you need longer lines.
|
||||
*/
|
||||
#define LUA_MAXINPUT 512
|
||||
|
||||
|
||||
/*
|
||||
@@ lua_readline defines how to show a prompt and then read a line from
|
||||
@* the standard input.
|
||||
@@ lua_saveline defines how to "save" a read line in a "history".
|
||||
@@ lua_freeline defines how to free a line read by lua_readline.
|
||||
** CHANGE them if you want to improve/adapt this functionality.
|
||||
*/
|
||||
#if defined(LUA_USE_READLINE)
|
||||
#include <stdio.h>
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
|
||||
#define lua_saveline(L,idx) \
|
||||
if (lua_objlen(L,idx) > 0) /* non-empty line? */ \
|
||||
add_history(lua_tostring(L, idx)); /* add it to history */
|
||||
#define lua_freeline(L,b) ((void)L, free(b))
|
||||
#else
|
||||
#define lua_readline(L,b,p) \
|
||||
((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
|
||||
fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
|
||||
#define lua_saveline(L,idx) { (void)L; (void)idx; }
|
||||
#define lua_freeline(L,b) { (void)L; (void)b; }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles
|
||||
@* as a percentage.
|
||||
** CHANGE it if you want the GC to run faster or slower (higher values
|
||||
** mean larger pauses which mean slower collection.) You can also change
|
||||
** this value dynamically.
|
||||
*/
|
||||
#define LUAI_GCPAUSE 162 /* 162% (wait memory to double before next GC) */
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAI_GCMUL defines the default speed of garbage collection relative to
|
||||
@* memory allocation as a percentage.
|
||||
** CHANGE it if you want to change the granularity of the garbage
|
||||
** collection. (Higher values mean coarser collections. 0 represents
|
||||
** infinity, where each step performs a full collection.) You can also
|
||||
** change this value dynamically.
|
||||
*/
|
||||
#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */
|
||||
|
||||
|
||||
|
||||
@ -373,22 +244,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ luai_apicheck is the assert macro used by the Lua-C API.
|
||||
** CHANGE luai_apicheck if you want Lua to perform some checks in the
|
||||
** parameters it gets from API calls. This may slow down the interpreter
|
||||
** a bit, but may be quite useful when debugging C code that interfaces
|
||||
** with Lua. A useful redefinition is to use assert.h.
|
||||
*/
|
||||
#if defined(LUA_USE_APICHECK)
|
||||
#include <assert.h>
|
||||
#define luai_apicheck(L,o) { (void)L; assert(o); }
|
||||
#else
|
||||
#define luai_apicheck(L,o) { (void)L; }
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAI_BITSINT defines the number of bits in an int.
|
||||
** CHANGE here if Lua cannot automatically detect the number of bits of
|
||||
@ -458,14 +313,6 @@
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAI_MAXCCALLS is the maximum depth for nested C calls and
|
||||
@* syntactical nested non-terminals in a program. (Value must
|
||||
@* fit in an unsigned short int.)
|
||||
*/
|
||||
#define LUAI_MAXCCALLS 200
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
|
||||
*/
|
||||
@ -615,81 +462,6 @@ union luai_Cast { double l_d; long l_l; };
|
||||
/* }================================================================== */
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
|
||||
** CHANGE it if your system requires alignments larger than double. (For
|
||||
** instance, if your system supports long doubles and they must be
|
||||
** 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 { double u; void *s; long l; }
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
|
||||
** CHANGE them if you prefer to use longjmp/setjmp even with C++
|
||||
** or if want/don't to use _longjmp/_setjmp instead of regular
|
||||
** longjmp/setjmp. By default, Lua handles errors with exceptions when
|
||||
** compiling as C++ code, with _longjmp/_setjmp when asked to use them,
|
||||
** and with longjmp/setjmp otherwise.
|
||||
*/
|
||||
#if defined(__cplusplus)
|
||||
/* C++ exceptions */
|
||||
#define LUAI_THROW(L,c) throw(c)
|
||||
#define LUAI_TRY(L,c,a) try { a } catch(...) \
|
||||
{ if ((c)->status == 0) (c)->status = -1; }
|
||||
#define luai_jmpbuf int /* dummy variable */
|
||||
|
||||
#elif 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
|
||||
|
||||
#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 luai_jmpbuf jmp_buf
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern
|
||||
@* can do during pattern-matching.
|
||||
** CHANGE it if you need more captures. This limit is arbitrary.
|
||||
*/
|
||||
#define LUA_MAXCAPTURES 32
|
||||
|
||||
|
||||
/*
|
||||
@@ lua_tmpnam is the function that the OS library uses to create a
|
||||
@* temporary name.
|
||||
@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam.
|
||||
** CHANGE them if you have an alternative to tmpnam (which is considered
|
||||
** insecure) or if you want the original tmpnam anyway. By default, Lua
|
||||
** uses tmpnam except when POSIX is available, where it uses mkstemp.
|
||||
*/
|
||||
#if defined(loslib_c) || defined(luaall_c)
|
||||
|
||||
#if defined(LUA_USE_MKSTEMP)
|
||||
#include <unistd.h>
|
||||
#define LUA_TMPNAMBUFSIZE 32
|
||||
#define lua_tmpnam(b,e) { \
|
||||
strcpy(b, "/tmp/lua_XXXXXX"); \
|
||||
e = mkstemp(b); \
|
||||
if (e != -1) close(e); \
|
||||
e = (e == -1); }
|
||||
|
||||
#else
|
||||
#define LUA_TMPNAMBUFSIZE L_tmpnam
|
||||
#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ LUA_STRFTIMEOPTIONS is the list of valid conversion specifiers
|
||||
@* for the 'strftime' function;
|
||||
@ -752,15 +524,6 @@ union luai_Cast { double l_d; long l_l; };
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State.
|
||||
@* (This data goes just *before* the lua_State pointer.)
|
||||
** CHANGE (define) this if you really need that. If defined, this value
|
||||
** cannot be zero.
|
||||
*/
|
||||
/* #define LUAI_EXTRASPACE ?? */
|
||||
|
||||
|
||||
/*
|
||||
@@ luai_userstate* allow user-specific actions on threads.
|
||||
** CHANGE them if you defined LUAI_EXTRASPACE and need to do something
|
||||
|
Loading…
Reference in New Issue
Block a user