rlm@1: /* rlm@1: ** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ rlm@1: ** Configuration file for Lua rlm@1: ** See Copyright Notice in lua.h rlm@1: */ rlm@1: rlm@1: rlm@1: #ifndef lconfig_h rlm@1: #define lconfig_h rlm@1: rlm@1: #include rlm@1: #include rlm@1: rlm@1: rlm@1: /* rlm@1: ** ================================================================== rlm@1: ** Search for "@@" to find all configurable definitions. rlm@1: ** =================================================================== rlm@1: */ rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_ANSI controls the use of non-ansi features. rlm@1: ** CHANGE it (define it) if you want Lua to avoid the use of any rlm@1: ** non-ansi feature or library. rlm@1: */ rlm@1: #if defined(__STRICT_ANSI__) rlm@1: #define LUA_ANSI rlm@1: #endif rlm@1: rlm@1: rlm@1: #if !defined(LUA_ANSI) && defined(_WIN32) rlm@1: #define LUA_WIN rlm@1: #endif rlm@1: rlm@1: #if defined(LUA_USE_LINUX) rlm@1: #define LUA_USE_POSIX rlm@1: #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ rlm@1: #define LUA_USE_READLINE /* needs some extra libraries */ rlm@1: #endif rlm@1: rlm@1: #if defined(LUA_USE_MACOSX) rlm@1: #define LUA_USE_POSIX rlm@1: #define LUA_DL_DYLD /* does not need extra library */ rlm@1: #endif rlm@1: rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_USE_POSIX includes all functionallity listed as X/Open System rlm@1: @* Interfaces Extension (XSI). rlm@1: ** CHANGE it (define it) if your system is XSI compatible. rlm@1: */ rlm@1: #if defined(LUA_USE_POSIX) rlm@1: #define LUA_USE_MKSTEMP rlm@1: #define LUA_USE_ISATTY rlm@1: #define LUA_USE_POPEN rlm@1: #define LUA_USE_ULONGJMP rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_PATH and LUA_CPATH are the names of the environment variables that rlm@1: @* Lua check to set its paths. rlm@1: @@ LUA_INIT is the name of the environment variable that Lua rlm@1: @* checks for initialization code. rlm@1: ** CHANGE them if you want different names. rlm@1: */ rlm@1: #define LUA_PATH "LUA_PATH" rlm@1: #define LUA_CPATH "LUA_CPATH" rlm@1: #define LUA_INIT "LUA_INIT" rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for rlm@1: @* Lua libraries. rlm@1: @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for rlm@1: @* C libraries. rlm@1: ** CHANGE them if your machine has a non-conventional directory rlm@1: ** hierarchy or if you want to install your libraries in rlm@1: ** non-conventional directories. rlm@1: */ rlm@1: #if defined(_WIN32) rlm@1: /* rlm@1: ** In Windows, any exclamation mark ('!') in the path is replaced by the rlm@1: ** path of the directory of the executable file of the current process. rlm@1: */ rlm@1: #define LUA_LDIR "!\\lua\\" rlm@1: #define LUA_CDIR "!\\" rlm@1: #define LUA_PATH_DEFAULT \ rlm@1: ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ rlm@1: LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" rlm@1: #define LUA_CPATH_DEFAULT \ rlm@1: ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" rlm@1: rlm@1: #else rlm@1: #define LUA_ROOT "/usr/local/" rlm@1: #define LUA_LDIR LUA_ROOT "share/lua/5.1/" rlm@1: #define LUA_CDIR LUA_ROOT "lib/lua/5.1/" rlm@1: #define LUA_PATH_DEFAULT \ rlm@1: "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ rlm@1: LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" rlm@1: #define LUA_CPATH_DEFAULT \ rlm@1: "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so" rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_DIRSEP is the directory separator (for submodules). rlm@1: ** CHANGE it if your machine does not use "/" as the directory separator rlm@1: ** and is not Windows. (On Windows Lua automatically uses "\".) rlm@1: */ rlm@1: #if defined(_WIN32) rlm@1: #define LUA_DIRSEP "\\" rlm@1: #else rlm@1: #define LUA_DIRSEP "/" rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_PATHSEP is the character that separates templates in a path. rlm@1: @@ LUA_PATH_MARK is the string that marks the substitution points in a rlm@1: @* template. rlm@1: @@ LUA_EXECDIR in a Windows path is replaced by the executable's rlm@1: @* directory. rlm@1: @@ LUA_IGMARK is a mark to ignore all before it when bulding the rlm@1: @* luaopen_ function name. rlm@1: ** CHANGE them if for some reason your system cannot use those rlm@1: ** characters. (E.g., if one of those characters is a common character rlm@1: ** in file/directory names.) Probably you do not need to change them. rlm@1: */ rlm@1: #define LUA_PATHSEP ";" rlm@1: #define LUA_PATH_MARK "?" rlm@1: #define LUA_EXECDIR "!" rlm@1: #define LUA_IGMARK "-" rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. rlm@1: ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most rlm@1: ** machines, ptrdiff_t gives a good choice between int or long.) rlm@1: */ rlm@1: #define LUA_INTEGER ptrdiff_t rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_API is a mark for all core API functions. rlm@1: @@ LUALIB_API is a mark for all standard library functions. rlm@1: ** CHANGE them if you need to define those functions in some special way. rlm@1: ** For instance, if you want to create one Windows DLL with the core and rlm@1: ** the libraries, you may want to use the following definition (define rlm@1: ** LUA_BUILD_AS_DLL to get it). rlm@1: */ rlm@1: #if defined(LUA_BUILD_AS_DLL) rlm@1: rlm@1: #if defined(LUA_CORE) || defined(LUA_LIB) rlm@1: #define LUA_API __declspec(dllexport) rlm@1: #else rlm@1: #define LUA_API __declspec(dllimport) rlm@1: #endif rlm@1: rlm@1: #else rlm@1: rlm@1: #define LUA_API extern rlm@1: rlm@1: #endif rlm@1: rlm@1: /* more often than not the libs go together with the core */ rlm@1: #define LUALIB_API LUA_API rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_FUNC is a mark for all extern functions that are not to be rlm@1: @* exported to outside modules. rlm@1: @@ LUAI_DATA is a mark for all extern (const) variables that are not to rlm@1: @* be exported to outside modules. rlm@1: ** CHANGE them if you need to mark them in some special way. Elf/gcc rlm@1: ** (versions 3.2 and later) mark them as "hidden" to optimize access rlm@1: ** when Lua is compiled as a shared library. rlm@1: */ rlm@1: #if defined(luaall_c) rlm@1: #define LUAI_FUNC static rlm@1: #define LUAI_DATA /* empty */ rlm@1: rlm@1: #elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ rlm@1: defined(__ELF__) rlm@1: #define LUAI_FUNC __attribute__((visibility("hidden"))) extern rlm@1: #define LUAI_DATA LUAI_FUNC rlm@1: rlm@1: #else rlm@1: #define LUAI_FUNC extern rlm@1: #define LUAI_DATA extern rlm@1: #endif rlm@1: rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_QL describes how error messages quote program elements. rlm@1: ** CHANGE it if you want a different appearance. rlm@1: */ rlm@1: #define LUA_QL(x) "'" x "'" rlm@1: #define LUA_QS LUA_QL("%s") rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_IDSIZE gives the maximum size for the description of the source rlm@1: @* of a function in debug information. rlm@1: ** CHANGE it if you want a different size. rlm@1: */ rlm@1: #define LUA_IDSIZE 60 rlm@1: rlm@1: rlm@1: /* rlm@1: ** {================================================================== rlm@1: ** Stand-alone configuration rlm@1: ** =================================================================== rlm@1: */ rlm@1: rlm@1: #if defined(lua_c) || defined(luaall_c) rlm@1: rlm@1: /* rlm@1: @@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that rlm@1: @* is, whether we're running lua interactively). rlm@1: ** CHANGE it if you have a better definition for non-POSIX/non-Windows rlm@1: ** systems. rlm@1: */ rlm@1: #if defined(LUA_USE_ISATTY) rlm@1: #include rlm@1: #define lua_stdin_is_tty() isatty(0) rlm@1: #elif defined(LUA_WIN) rlm@1: #include rlm@1: #include rlm@1: #define lua_stdin_is_tty() _isatty(_fileno(stdin)) rlm@1: #else rlm@1: #define lua_stdin_is_tty() 1 /* assume stdin is a tty */ rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_PROMPT is the default prompt used by stand-alone Lua. rlm@1: @@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. rlm@1: ** CHANGE them if you want different prompts. (You can also change the rlm@1: ** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) rlm@1: */ rlm@1: #define LUA_PROMPT "> " rlm@1: #define LUA_PROMPT2 ">> " rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_PROGNAME is the default name for the stand-alone Lua program. rlm@1: ** CHANGE it if your stand-alone interpreter has a different name and rlm@1: ** your system is not able to detect that name automatically. rlm@1: */ rlm@1: #define LUA_PROGNAME "lua" rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_MAXINPUT is the maximum length for an input line in the rlm@1: @* stand-alone interpreter. rlm@1: ** CHANGE it if you need longer lines. rlm@1: */ rlm@1: #define LUA_MAXINPUT 512 rlm@1: rlm@1: rlm@1: /* rlm@1: @@ lua_readline defines how to show a prompt and then read a line from rlm@1: @* the standard input. rlm@1: @@ lua_saveline defines how to "save" a read line in a "history". rlm@1: @@ lua_freeline defines how to free a line read by lua_readline. rlm@1: ** CHANGE them if you want to improve this functionality (e.g., by using rlm@1: ** GNU readline and history facilities). rlm@1: */ rlm@1: #if defined(LUA_USE_READLINE) rlm@1: #include rlm@1: #include rlm@1: #include rlm@1: #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) rlm@1: #define lua_saveline(L,idx) \ rlm@1: if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ rlm@1: add_history(lua_tostring(L, idx)); /* add it to history */ rlm@1: #define lua_freeline(L,b) ((void)L, free(b)) rlm@1: #else rlm@1: #define lua_readline(L,b,p) \ rlm@1: ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ rlm@1: fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ rlm@1: #define lua_saveline(L,idx) { (void)L; (void)idx; } rlm@1: #define lua_freeline(L,b) { (void)L; (void)b; } rlm@1: #endif rlm@1: rlm@1: #endif rlm@1: rlm@1: /* }================================================================== */ rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles rlm@1: @* as a percentage. rlm@1: ** CHANGE it if you want the GC to run faster or slower (higher values rlm@1: ** mean larger pauses which mean slower collection.) You can also change rlm@1: ** this value dynamically. rlm@1: */ rlm@1: #define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_GCMUL defines the default speed of garbage collection relative to rlm@1: @* memory allocation as a percentage. rlm@1: ** CHANGE it if you want to change the granularity of the garbage rlm@1: ** collection. (Higher values mean coarser collections. 0 represents rlm@1: ** infinity, where each step performs a full collection.) You can also rlm@1: ** change this value dynamically. rlm@1: */ rlm@1: #define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ rlm@1: rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_COMPAT_GETN controls compatibility with old getn behavior. rlm@1: ** CHANGE it (define it) if you want exact compatibility with the rlm@1: ** behavior of setn/getn in Lua 5.0. rlm@1: */ rlm@1: #undef LUA_COMPAT_GETN rlm@1: rlm@1: /* rlm@1: @@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. rlm@1: ** CHANGE it to undefined as soon as you do not need a global 'loadlib' rlm@1: ** function (the function is still available as 'package.loadlib'). rlm@1: */ rlm@1: #undef LUA_COMPAT_LOADLIB rlm@1: rlm@1: /* rlm@1: @@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. rlm@1: ** CHANGE it to undefined as soon as your programs use only '...' to rlm@1: ** access vararg parameters (instead of the old 'arg' table). rlm@1: */ rlm@1: #define LUA_COMPAT_VARARG rlm@1: rlm@1: /* rlm@1: @@ LUA_COMPAT_MOD controls compatibility with old math.mod function. rlm@1: ** CHANGE it to undefined as soon as your programs use 'math.fmod' or rlm@1: ** the new '%' operator instead of 'math.mod'. rlm@1: */ rlm@1: #define LUA_COMPAT_MOD rlm@1: rlm@1: /* rlm@1: @@ LUA_COMPAT_LSTR controls compatibility with old long string nesting rlm@1: @* facility. rlm@1: ** CHANGE it to 2 if you want the old behaviour, or undefine it to turn rlm@1: ** off the advisory error when nesting [[...]]. rlm@1: */ rlm@1: #define LUA_COMPAT_LSTR 1 rlm@1: rlm@1: /* rlm@1: @@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. rlm@1: ** CHANGE it to undefined as soon as you rename 'string.gfind' to rlm@1: ** 'string.gmatch'. rlm@1: */ rlm@1: #define LUA_COMPAT_GFIND rlm@1: rlm@1: /* rlm@1: @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' rlm@1: @* behavior. rlm@1: ** CHANGE it to undefined as soon as you replace to 'luaL_register' rlm@1: ** your uses of 'luaL_openlib' rlm@1: */ rlm@1: #define LUA_COMPAT_OPENLIB rlm@1: rlm@1: rlm@1: rlm@1: /* rlm@1: @@ luai_apicheck is the assert macro used by the Lua-C API. rlm@1: ** CHANGE luai_apicheck if you want Lua to perform some checks in the rlm@1: ** parameters it gets from API calls. This may slow down the interpreter rlm@1: ** a bit, but may be quite useful when debugging C code that interfaces rlm@1: ** with Lua. A useful redefinition is to use assert.h. rlm@1: */ rlm@1: #if defined(LUA_USE_APICHECK) rlm@1: #include rlm@1: #define luai_apicheck(L,o) { (void)L; assert(o); } rlm@1: #else rlm@1: #define luai_apicheck(L,o) { (void)L; } rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_BITSINT defines the number of bits in an int. rlm@1: ** CHANGE here if Lua cannot automatically detect the number of bits of rlm@1: ** your machine. Probably you do not need to change this. rlm@1: */ rlm@1: /* avoid overflows in comparison */ rlm@1: #if INT_MAX-20 < 32760 rlm@1: #define LUAI_BITSINT 16 rlm@1: #elif INT_MAX > 2147483640L rlm@1: /* int has at least 32 bits */ rlm@1: #define LUAI_BITSINT 32 rlm@1: #else rlm@1: #error "you must define LUA_BITSINT with number of bits in an integer" rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_UINT32 is an unsigned integer with at least 32 bits. rlm@1: @@ LUAI_INT32 is an signed integer with at least 32 bits. rlm@1: @@ LUAI_UMEM is an unsigned integer big enough to count the total rlm@1: @* memory used by Lua. rlm@1: @@ LUAI_MEM is a signed integer big enough to count the total memory rlm@1: @* used by Lua. rlm@1: ** CHANGE here if for some weird reason the default definitions are not rlm@1: ** good enough for your machine. (The definitions in the 'else' rlm@1: ** part always works, but may waste space on machines with 64-bit rlm@1: ** longs.) Probably you do not need to change this. rlm@1: */ rlm@1: #if LUAI_BITSINT >= 32 rlm@1: #define LUAI_UINT32 unsigned int rlm@1: #define LUAI_INT32 int rlm@1: #define LUAI_MAXINT32 INT_MAX rlm@1: #define LUAI_UMEM size_t rlm@1: #define LUAI_MEM ptrdiff_t rlm@1: #else rlm@1: /* 16-bit ints */ rlm@1: #define LUAI_UINT32 unsigned long rlm@1: #define LUAI_INT32 long rlm@1: #define LUAI_MAXINT32 LONG_MAX rlm@1: #define LUAI_UMEM unsigned long rlm@1: #define LUAI_MEM long rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_MAXCALLS limits the number of nested calls. rlm@1: ** CHANGE it if you need really deep recursive calls. This limit is rlm@1: ** arbitrary; its only purpose is to stop infinite recursion before rlm@1: ** exhausting memory. rlm@1: */ rlm@1: #define LUAI_MAXCALLS 20000 rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function rlm@1: @* can use. rlm@1: ** CHANGE it if you need lots of (Lua) stack space for your C rlm@1: ** functions. This limit is arbitrary; its only purpose is to stop C rlm@1: ** functions to consume unlimited stack space. (must be smaller than rlm@1: ** -LUA_REGISTRYINDEX) rlm@1: */ rlm@1: #define LUAI_MAXCSTACK 8000 rlm@1: rlm@1: rlm@1: rlm@1: /* rlm@1: ** {================================================================== rlm@1: ** CHANGE (to smaller values) the following definitions if your system rlm@1: ** has a small C stack. (Or you may want to change them to larger rlm@1: ** values if your system has a large C stack and these limits are rlm@1: ** too rigid for you.) Some of these constants control the size of rlm@1: ** stack-allocated arrays used by the compiler or the interpreter, while rlm@1: ** others limit the maximum number of recursive calls that the compiler rlm@1: ** or the interpreter can perform. Values too large may cause a C stack rlm@1: ** overflow for some forms of deep constructs. rlm@1: ** =================================================================== rlm@1: */ rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and rlm@1: @* syntactical nested non-terminals in a program. rlm@1: */ rlm@1: #define LUAI_MAXCCALLS 200 rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_MAXVARS is the maximum number of local variables per function rlm@1: @* (must be smaller than 250). rlm@1: */ rlm@1: #define LUAI_MAXVARS 200 rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_MAXUPVALUES is the maximum number of upvalues per function rlm@1: @* (must be smaller than 250). rlm@1: */ rlm@1: #define LUAI_MAXUPVALUES 60 rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. rlm@1: */ rlm@1: #define LUAL_BUFFERSIZE BUFSIZ rlm@1: rlm@1: /* }================================================================== */ rlm@1: rlm@1: rlm@1: rlm@1: rlm@1: /* rlm@1: ** {================================================================== rlm@1: @@ LUA_NUMBER is the type of numbers in Lua. rlm@1: ** CHANGE the following definitions only if you want to build Lua rlm@1: ** with a number type different from double. You may also need to rlm@1: ** change lua_number2int & lua_number2integer. rlm@1: ** =================================================================== rlm@1: */ rlm@1: rlm@1: #define LUA_NUMBER_DOUBLE rlm@1: #define LUA_NUMBER double rlm@1: rlm@1: /* rlm@1: @@ LUAI_UACNUMBER is the result of an 'usual argument conversion' rlm@1: @* over a number. rlm@1: */ rlm@1: #define LUAI_UACNUMBER double rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_NUMBER_SCAN is the format for reading numbers. rlm@1: @@ LUA_NUMBER_FMT is the format for writing numbers. rlm@1: @@ lua_number2str converts a number to a string. rlm@1: @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. rlm@1: @@ lua_str2number converts a string to a number. rlm@1: */ rlm@1: #define LUA_NUMBER_SCAN "%lf" rlm@1: #define LUA_NUMBER_FMT "%.14g" rlm@1: #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) rlm@1: #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ rlm@1: #define lua_str2number(s,p) strtod((s), (p)) rlm@1: rlm@1: rlm@1: /* rlm@1: @@ The luai_num* macros define the primitive operations over numbers. rlm@1: */ rlm@1: #if defined(LUA_CORE) rlm@1: #include rlm@1: #define luai_numadd(a,b) ((a)+(b)) rlm@1: #define luai_numsub(a,b) ((a)-(b)) rlm@1: #define luai_nummul(a,b) ((a)*(b)) rlm@1: #define luai_numdiv(a,b) ((a)/(b)) rlm@1: #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) rlm@1: #define luai_numpow(a,b) (pow(a,b)) rlm@1: #define luai_numunm(a) (-(a)) rlm@1: #define luai_numeq(a,b) ((a)==(b)) rlm@1: #define luai_numlt(a,b) ((a)<(b)) rlm@1: #define luai_numle(a,b) ((a)<=(b)) rlm@1: #define luai_numisnan(a) (!luai_numeq((a), (a))) rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: @@ lua_number2int is a macro to convert lua_Number to int. rlm@1: @@ lua_number2integer is a macro to convert lua_Number to lua_Integer. rlm@1: ** CHANGE them if you know a faster way to convert a lua_Number to rlm@1: ** int (with any rounding method and without throwing errors) in your rlm@1: ** system. In Pentium machines, a naive typecast from double to int rlm@1: ** in C is extremely slow, so any alternative is worth trying. rlm@1: */ rlm@1: rlm@1: /* On a Pentium, resort to a trick */ rlm@1: #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ rlm@1: (defined(__i386) || defined (_M_IX86) || defined(__i386__)) rlm@1: rlm@1: /* On a Microsoft compiler, use assembler */ rlm@1: #if 0//defined(_MSC_VER) // nitsuja: the "using assembly" method doesn't correctly handle integers between 0xFF000000 and and 0xFFFFFFFF, while the other branch does handle it correctly and it's not slower. rlm@1: rlm@1: #define lua_number2int(i,d) __asm fld d __asm fistp i rlm@1: #define lua_number2integer(i,n) lua_number2int(i, n) rlm@1: rlm@1: /* the next trick should work on any Pentium, but sometimes clashes rlm@1: with a DirectX idiosyncrasy */ rlm@1: #else rlm@1: rlm@1: union luai_Cast { double l_d; long l_l; }; rlm@1: #define lua_number2int(i,d) \ rlm@1: { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } rlm@1: #define lua_number2integer(i,n) lua_number2int(i, n) rlm@1: rlm@1: #endif rlm@1: rlm@1: rlm@1: /* this option always works, but may be slow */ rlm@1: #else rlm@1: #define lua_number2int(i,d) ((i)=(int)(d)) rlm@1: #define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) rlm@1: rlm@1: #endif rlm@1: rlm@1: /* }================================================================== */ rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. rlm@1: ** CHANGE it if your system requires alignments larger than double. (For rlm@1: ** instance, if your system supports long doubles and they must be rlm@1: ** aligned in 16-byte boundaries, then you should add long double in the rlm@1: ** union.) Probably you do not need to change this. rlm@1: */ rlm@1: #define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. rlm@1: ** CHANGE them if you prefer to use longjmp/setjmp even with C++ rlm@1: ** or if want/don't to use _longjmp/_setjmp instead of regular rlm@1: ** longjmp/setjmp. By default, Lua handles errors with exceptions when rlm@1: ** compiling as C++ code, with _longjmp/_setjmp when asked to use them, rlm@1: ** and with longjmp/setjmp otherwise. rlm@1: */ rlm@1: #if defined(__cplusplus) rlm@1: /* C++ exceptions */ rlm@1: #define LUAI_THROW(L,c) throw(c) rlm@1: #define LUAI_TRY(L,c,a) try { a } catch(...) \ rlm@1: { if ((c)->status == 0) (c)->status = -1; } rlm@1: #define luai_jmpbuf int /* dummy variable */ rlm@1: rlm@1: #elif defined(LUA_USE_ULONGJMP) rlm@1: /* in Unix, try _longjmp/_setjmp (more efficient) */ rlm@1: #define LUAI_THROW(L,c) _longjmp((c)->b, 1) rlm@1: #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } rlm@1: #define luai_jmpbuf jmp_buf rlm@1: rlm@1: #else rlm@1: /* default handling with long jumps */ rlm@1: #define LUAI_THROW(L,c) longjmp((c)->b, 1) rlm@1: #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } rlm@1: #define luai_jmpbuf jmp_buf rlm@1: rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_MAXCAPTURES is the maximum number of captures that a pattern rlm@1: @* can do during pattern-matching. rlm@1: ** CHANGE it if you need more captures. This limit is arbitrary. rlm@1: */ rlm@1: #define LUA_MAXCAPTURES 32 rlm@1: rlm@1: rlm@1: /* rlm@1: @@ lua_tmpnam is the function that the OS library uses to create a rlm@1: @* temporary name. rlm@1: @@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. rlm@1: ** CHANGE them if you have an alternative to tmpnam (which is considered rlm@1: ** insecure) or if you want the original tmpnam anyway. By default, Lua rlm@1: ** uses tmpnam except when POSIX is available, where it uses mkstemp. rlm@1: */ rlm@1: #if defined(loslib_c) || defined(luaall_c) rlm@1: rlm@1: #if defined(LUA_USE_MKSTEMP) rlm@1: #include rlm@1: #define LUA_TMPNAMBUFSIZE 32 rlm@1: #define lua_tmpnam(b,e) { \ rlm@1: strcpy(b, "/tmp/lua_XXXXXX"); \ rlm@1: e = mkstemp(b); \ rlm@1: if (e != -1) close(e); \ rlm@1: e = (e == -1); } rlm@1: rlm@1: #else rlm@1: #define LUA_TMPNAMBUFSIZE L_tmpnam rlm@1: #define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } rlm@1: #endif rlm@1: rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: @@ lua_popen spawns a new process connected to the current one through rlm@1: @* the file streams. rlm@1: ** CHANGE it if you have a way to implement it in your system. rlm@1: */ rlm@1: #if defined(LUA_USE_POPEN) rlm@1: rlm@1: #define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) rlm@1: #define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) rlm@1: rlm@1: #elif defined(LUA_WIN) rlm@1: rlm@1: #define lua_popen(L,c,m) ((void)L, _popen(c,m)) rlm@1: #define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) rlm@1: rlm@1: #else rlm@1: rlm@1: #define lua_popen(L,c,m) ((void)((void)c, m), \ rlm@1: luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) rlm@1: #define lua_pclose(L,file) ((void)((void)L, file), 0) rlm@1: rlm@1: #endif rlm@1: rlm@1: /* rlm@1: @@ LUA_DL_* define which dynamic-library system Lua should use. rlm@1: ** CHANGE here if Lua has problems choosing the appropriate rlm@1: ** dynamic-library system for your platform (either Windows' DLL, Mac's rlm@1: ** dyld, or Unix's dlopen). If your system is some kind of Unix, there rlm@1: ** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for rlm@1: ** it. To use dlopen you also need to adapt the src/Makefile (probably rlm@1: ** adding -ldl to the linker options), so Lua does not select it rlm@1: ** automatically. (When you change the makefile to add -ldl, you must rlm@1: ** also add -DLUA_USE_DLOPEN.) rlm@1: ** If you do not want any kind of dynamic library, undefine all these rlm@1: ** options. rlm@1: ** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. rlm@1: */ rlm@1: #if defined(LUA_USE_DLOPEN) rlm@1: #define LUA_DL_DLOPEN rlm@1: #endif rlm@1: rlm@1: #if defined(LUA_WIN) rlm@1: #define LUA_DL_DLL rlm@1: #endif rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State rlm@1: @* (the data goes just *before* the lua_State pointer). rlm@1: ** CHANGE (define) this if you really need that. This value must be rlm@1: ** a multiple of the maximum alignment required for your machine. rlm@1: */ rlm@1: #define LUAI_EXTRASPACE 0 rlm@1: rlm@1: rlm@1: /* rlm@1: @@ luai_userstate* allow user-specific actions on threads. rlm@1: ** CHANGE them if you defined LUAI_EXTRASPACE and need to do something rlm@1: ** extra when a thread is created/deleted/resumed/yielded. rlm@1: */ rlm@1: #define luai_userstateopen(L) ((void)L) rlm@1: #define luai_userstateclose(L) ((void)L) rlm@1: #define luai_userstatethread(L,L1) ((void)L) rlm@1: #define luai_userstatefree(L) ((void)L) rlm@1: #define luai_userstateresume(L,n) ((void)L) rlm@1: #define luai_userstateyield(L,n) ((void)L) rlm@1: rlm@1: rlm@1: /* rlm@1: @@ LUA_INTFRMLEN is the length modifier for integer conversions rlm@1: @* in 'string.format'. rlm@1: @@ LUA_INTFRM_T is the integer type correspoding to the previous length rlm@1: @* modifier. rlm@1: ** CHANGE them if your system supports long long or does not support long. rlm@1: */ rlm@1: rlm@1: #if defined(LUA_USELONGLONG) rlm@1: rlm@1: #define LUA_INTFRMLEN "ll" rlm@1: #define LUA_INTFRM_T long long rlm@1: rlm@1: #else rlm@1: rlm@1: #define LUA_INTFRMLEN "l" rlm@1: #define LUA_INTFRM_T long rlm@1: rlm@1: #endif rlm@1: rlm@1: rlm@1: rlm@1: /* =================================================================== */ rlm@1: rlm@1: /* rlm@1: ** Local configuration. You can use this space to add your redefinitions rlm@1: ** without modifying the main part of the file. rlm@1: */ rlm@1: rlm@1: rlm@1: rlm@1: #endif rlm@1: