00001 /* 00002 ** $Id: luaconf.h 2831 2009-12-08 14:19:44Z haraldkipp $ 00003 ** Configuration file for Lua 00004 ** See Copyright Notice in lua.h 00005 */ 00006 00007 00008 #ifndef lconfig_h 00009 #define lconfig_h 00010 00011 #include <limits.h> 00012 #include <stddef.h> 00013 #include <lua/luanut.h> 00014 00015 00016 /* 00017 ** ================================================================== 00018 ** Search for "@@" to find all configurable definitions. 00019 ** =================================================================== 00020 */ 00021 00022 00023 /* 00024 @@ LUA_ANSI controls the use of non-ansi features. 00025 ** CHANGE it (define it) if you want Lua to avoid the use of any 00026 ** non-ansi feature or library. 00027 */ 00028 #if defined(__STRICT_ANSI__) 00029 #define LUA_ANSI 00030 #endif 00031 00032 00033 #if !defined(LUA_ANSI) && defined(_WIN32) 00034 #define LUA_WIN 00035 #endif 00036 00037 #if defined(LUA_USE_LINUX) 00038 #define LUA_USE_POSIX 00039 #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ 00040 #define LUA_USE_READLINE /* needs some extra libraries */ 00041 #endif 00042 00043 #if defined(LUA_USE_MACOSX) 00044 #define LUA_USE_POSIX 00045 #define LUA_DL_DYLD /* does not need extra library */ 00046 #endif 00047 00048 00049 00050 /* 00051 @@ LUA_USE_POSIX includes all functionallity listed as X/Open System 00052 @* Interfaces Extension (XSI). 00053 ** CHANGE it (define it) if your system is XSI compatible. 00054 */ 00055 #if defined(LUA_USE_POSIX) 00056 #define LUA_USE_MKSTEMP 00057 #define LUA_USE_ISATTY 00058 #define LUA_USE_POPEN 00059 #define LUA_USE_ULONGJMP 00060 #endif 00061 00062 00063 /* 00064 @@ LUA_PATH and LUA_CPATH are the names of the environment variables that 00065 @* Lua check to set its paths. 00066 @@ LUA_INIT is the name of the environment variable that Lua 00067 @* checks for initialization code. 00068 ** CHANGE them if you want different names. 00069 */ 00070 #define LUA_PATH "LUA_PATH" 00071 #define LUA_CPATH "LUA_CPATH" 00072 #define LUA_INIT "LUA_INIT" 00073 00074 00075 /* 00076 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for 00077 @* Lua libraries. 00078 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for 00079 @* C libraries. 00080 ** CHANGE them if your machine has a non-conventional directory 00081 ** hierarchy or if you want to install your libraries in 00082 ** non-conventional directories. 00083 */ 00084 #if defined(_WIN32) 00085 /* 00086 ** In Windows, any exclamation mark ('!') in the path is replaced by the 00087 ** path of the directory of the executable file of the current process. 00088 */ 00089 #define LUA_LDIR "!\\lua\\" 00090 #define LUA_CDIR "!\\" 00091 #define LUA_PATH_DEFAULT \ 00092 ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ 00093 LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" 00094 #define LUA_CPATH_DEFAULT \ 00095 ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" 00096 00097 #else 00098 #define LUA_ROOT "/usr/local/" 00099 #define LUA_LDIR LUA_ROOT "share/lua/5.1/" 00100 #define LUA_CDIR LUA_ROOT "lib/lua/5.1/" 00101 #define LUA_PATH_DEFAULT \ 00102 "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ 00103 LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" 00104 #define LUA_CPATH_DEFAULT \ 00105 "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so" 00106 #endif 00107 00108 00109 /* 00110 @@ LUA_DIRSEP is the directory separator (for submodules). 00111 ** CHANGE it if your machine does not use "/" as the directory separator 00112 ** and is not Windows. (On Windows Lua automatically uses "\".) 00113 */ 00114 #if defined(_WIN32) 00115 #define LUA_DIRSEP "\\" 00116 #else 00117 #define LUA_DIRSEP "/" 00118 #endif 00119 00120 00121 /* 00122 @@ LUA_PATHSEP is the character that separates templates in a path. 00123 @@ LUA_PATH_MARK is the string that marks the substitution points in a 00124 @* template. 00125 @@ LUA_EXECDIR in a Windows path is replaced by the executable's 00126 @* directory. 00127 @@ LUA_IGMARK is a mark to ignore all before it when bulding the 00128 @* luaopen_ function name. 00129 ** CHANGE them if for some reason your system cannot use those 00130 ** characters. (E.g., if one of those characters is a common character 00131 ** in file/directory names.) Probably you do not need to change them. 00132 */ 00133 #define LUA_PATHSEP ";" 00134 #define LUA_PATH_MARK "?" 00135 #define LUA_EXECDIR "!" 00136 #define LUA_IGMARK "-" 00137 00138 00139 /* 00140 @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. 00141 ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most 00142 ** machines, ptrdiff_t gives a good choice between int or long.) 00143 */ 00144 #define LUA_INTEGER ptrdiff_t 00145 00146 00147 /* 00148 @@ LUA_API is a mark for all core API functions. 00149 @@ LUALIB_API is a mark for all standard library functions. 00150 ** CHANGE them if you need to define those functions in some special way. 00151 ** For instance, if you want to create one Windows DLL with the core and 00152 ** the libraries, you may want to use the following definition (define 00153 ** LUA_BUILD_AS_DLL to get it). 00154 */ 00155 #if defined(LUA_BUILD_AS_DLL) 00156 00157 #if defined(LUA_CORE) || defined(LUA_LIB) 00158 #define LUA_API __declspec(dllexport) 00159 #else 00160 #define LUA_API __declspec(dllimport) 00161 #endif 00162 00163 #else 00164 00165 #define LUA_API extern 00166 00167 #endif 00168 00169 /* more often than not the libs go together with the core */ 00170 #define LUALIB_API LUA_API 00171 00172 00173 /* 00174 @@ LUAI_FUNC is a mark for all extern functions that are not to be 00175 @* exported to outside modules. 00176 @@ LUAI_DATA is a mark for all extern (const) variables that are not to 00177 @* be exported to outside modules. 00178 ** CHANGE them if you need to mark them in some special way. Elf/gcc 00179 ** (versions 3.2 and later) mark them as "hidden" to optimize access 00180 ** when Lua is compiled as a shared library. 00181 */ 00182 #if defined(luaall_c) 00183 #define LUAI_FUNC static 00184 #define LUAI_DATA /* empty */ 00185 00186 #elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ 00187 defined(__ELF__) 00188 #define LUAI_FUNC __attribute__((visibility("hidden"))) extern 00189 #define LUAI_DATA LUAI_FUNC 00190 00191 #else 00192 #define LUAI_FUNC extern 00193 #define LUAI_DATA extern 00194 #endif 00195 00196 00197 00198 /* 00199 @@ LUA_QL describes how error messages quote program elements. 00200 ** CHANGE it if you want a different appearance. 00201 */ 00202 #define LUA_QL(x) "'" x "'" 00203 #define LUA_QS LUA_QL("%s") 00204 00205 00206 /* 00207 @@ LUA_IDSIZE gives the maximum size for the description of the source 00208 @* of a function in debug information. 00209 ** CHANGE it if you want a different size. 00210 */ 00211 #define LUA_IDSIZE 60 00212 00213 00214 /* 00215 ** {================================================================== 00216 ** Stand-alone configuration 00217 ** =================================================================== 00218 */ 00219 00220 #if defined(lua_c) || defined(luaall_c) 00221 00222 /* 00223 @@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that 00224 @* is, whether we're running lua interactively). 00225 ** CHANGE it if you have a better definition for non-POSIX/non-Windows 00226 ** systems. 00227 */ 00228 #if defined(LUA_USE_ISATTY) 00229 #include <unistd.h> 00230 #define lua_stdin_is_tty() isatty(0) 00231 #elif defined(LUA_WIN) 00232 #include <io.h> 00233 #include <stdio.h> 00234 #define lua_stdin_is_tty() _isatty(_fileno(stdin)) 00235 #else 00236 #define lua_stdin_is_tty() 1 /* assume stdin is a tty */ 00237 #endif 00238 00239 00240 /* 00241 @@ LUA_PROMPT is the default prompt used by stand-alone Lua. 00242 @@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. 00243 ** CHANGE them if you want different prompts. (You can also change the 00244 ** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) 00245 */ 00246 #define LUA_PROMPT "> " 00247 #define LUA_PROMPT2 ">> " 00248 00249 00250 /* 00251 @@ LUA_PROGNAME is the default name for the stand-alone Lua program. 00252 ** CHANGE it if your stand-alone interpreter has a different name and 00253 ** your system is not able to detect that name automatically. 00254 */ 00255 #define LUA_PROGNAME "lua" 00256 00257 00258 /* 00259 @@ LUA_MAXINPUT is the maximum length for an input line in the 00260 @* stand-alone interpreter. 00261 ** CHANGE it if you need longer lines. 00262 */ 00263 #define LUA_MAXINPUT 512 00264 00265 00266 /* 00267 @@ lua_readline defines how to show a prompt and then read a line from 00268 @* the standard input. 00269 @@ lua_saveline defines how to "save" a read line in a "history". 00270 @@ lua_freeline defines how to free a line read by lua_readline. 00271 ** CHANGE them if you want to improve this functionality (e.g., by using 00272 ** GNU readline and history facilities). 00273 */ 00274 #if defined(LUA_USE_READLINE) 00275 #include <stdio.h> 00276 #include <readline/readline.h> 00277 #include <readline/history.h> 00278 #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) 00279 #define lua_saveline(L,idx) \ 00280 if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ 00281 add_history(lua_tostring(L, idx)); /* add it to history */ 00282 #define lua_freeline(L,b) ((void)L, free(b)) 00283 #else 00284 #define lua_readline(L,b,p) \ 00285 ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ 00286 fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ 00287 #define lua_saveline(L,idx) { (void)L; (void)idx; } 00288 #define lua_freeline(L,b) { (void)L; (void)b; } 00289 #endif 00290 00291 #endif 00292 00293 /* }================================================================== */ 00294 00295 00296 /* 00297 @@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles 00298 @* as a percentage. 00299 ** CHANGE it if you want the GC to run faster or slower (higher values 00300 ** mean larger pauses which mean slower collection.) You can also change 00301 ** this value dynamically. 00302 */ 00303 #define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ 00304 00305 00306 /* 00307 @@ LUAI_GCMUL defines the default speed of garbage collection relative to 00308 @* memory allocation as a percentage. 00309 ** CHANGE it if you want to change the granularity of the garbage 00310 ** collection. (Higher values mean coarser collections. 0 represents 00311 ** infinity, where each step performs a full collection.) You can also 00312 ** change this value dynamically. 00313 */ 00314 #define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ 00315 00316 00317 00318 /* 00319 @@ LUA_COMPAT_GETN controls compatibility with old getn behavior. 00320 ** CHANGE it (define it) if you want exact compatibility with the 00321 ** behavior of setn/getn in Lua 5.0. 00322 */ 00323 #undef LUA_COMPAT_GETN 00324 00325 /* 00326 @@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. 00327 ** CHANGE it to undefined as soon as you do not need a global 'loadlib' 00328 ** function (the function is still available as 'package.loadlib'). 00329 */ 00330 #undef LUA_COMPAT_LOADLIB 00331 00332 /* 00333 @@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. 00334 ** CHANGE it to undefined as soon as your programs use only '...' to 00335 ** access vararg parameters (instead of the old 'arg' table). 00336 */ 00337 #define LUA_COMPAT_VARARG 00338 00339 /* 00340 @@ LUA_COMPAT_MOD controls compatibility with old math.mod function. 00341 ** CHANGE it to undefined as soon as your programs use 'math.fmod' or 00342 ** the new '%' operator instead of 'math.mod'. 00343 */ 00344 #define LUA_COMPAT_MOD 00345 00346 /* 00347 @@ LUA_COMPAT_LSTR controls compatibility with old long string nesting 00348 @* facility. 00349 ** CHANGE it to 2 if you want the old behaviour, or undefine it to turn 00350 ** off the advisory error when nesting [[...]]. 00351 */ 00352 #define LUA_COMPAT_LSTR 1 00353 00354 /* 00355 @@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. 00356 ** CHANGE it to undefined as soon as you rename 'string.gfind' to 00357 ** 'string.gmatch'. 00358 */ 00359 #define LUA_COMPAT_GFIND 00360 00361 /* 00362 @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' 00363 @* behavior. 00364 ** CHANGE it to undefined as soon as you replace to 'luaL_register' 00365 ** your uses of 'luaL_openlib' 00366 */ 00367 #define LUA_COMPAT_OPENLIB 00368 00369 00370 00371 /* 00372 @@ luai_apicheck is the assert macro used by the Lua-C API. 00373 ** CHANGE luai_apicheck if you want Lua to perform some checks in the 00374 ** parameters it gets from API calls. This may slow down the interpreter 00375 ** a bit, but may be quite useful when debugging C code that interfaces 00376 ** with Lua. A useful redefinition is to use assert.h. 00377 */ 00378 #if defined(LUA_USE_APICHECK) 00379 #include <assert.h> 00380 #define luai_apicheck(L,o) { (void)L; assert(o); } 00381 #else 00382 #define luai_apicheck(L,o) { (void)L; } 00383 #endif 00384 00385 00386 /* 00387 @@ LUAI_BITSINT defines the number of bits in an int. 00388 ** CHANGE here if Lua cannot automatically detect the number of bits of 00389 ** your machine. Probably you do not need to change this. 00390 */ 00391 /* avoid overflows in comparison */ 00392 #if INT_MAX-20 < 32760 00393 #define LUAI_BITSINT 16 00394 #elif INT_MAX > 2147483640L 00395 /* int has at least 32 bits */ 00396 #define LUAI_BITSINT 32 00397 #else 00398 #error "you must define LUA_BITSINT with number of bits in an integer" 00399 #endif 00400 00401 00402 /* 00403 @@ LUAI_UINT32 is an unsigned integer with at least 32 bits. 00404 @@ LUAI_INT32 is an signed integer with at least 32 bits. 00405 @@ LUAI_UMEM is an unsigned integer big enough to count the total 00406 @* memory used by Lua. 00407 @@ LUAI_MEM is a signed integer big enough to count the total memory 00408 @* used by Lua. 00409 ** CHANGE here if for some weird reason the default definitions are not 00410 ** good enough for your machine. (The definitions in the 'else' 00411 ** part always works, but may waste space on machines with 64-bit 00412 ** longs.) Probably you do not need to change this. 00413 */ 00414 #if LUAI_BITSINT >= 32 00415 #define LUAI_UINT32 unsigned int 00416 #define LUAI_INT32 int 00417 #define LUAI_MAXINT32 INT_MAX 00418 #define LUAI_UMEM size_t 00419 #define LUAI_MEM ptrdiff_t 00420 #else 00421 /* 16-bit ints */ 00422 #define LUAI_UINT32 unsigned long 00423 #define LUAI_INT32 long 00424 #define LUAI_MAXINT32 LONG_MAX 00425 #define LUAI_UMEM unsigned long 00426 #define LUAI_MEM long 00427 #endif 00428 00429 00430 /* 00431 @@ LUAI_MAXCALLS limits the number of nested calls. 00432 ** CHANGE it if you need really deep recursive calls. This limit is 00433 ** arbitrary; its only purpose is to stop infinite recursion before 00434 ** exhausting memory. 00435 */ 00436 #define LUAI_MAXCALLS 20000 00437 00438 00439 /* 00440 @@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function 00441 @* can use. 00442 ** CHANGE it if you need lots of (Lua) stack space for your C 00443 ** functions. This limit is arbitrary; its only purpose is to stop C 00444 ** functions to consume unlimited stack space. (must be smaller than 00445 ** -LUA_REGISTRYINDEX) 00446 */ 00447 #define LUAI_MAXCSTACK 8000 00448 00449 00450 00451 /* 00452 ** {================================================================== 00453 ** CHANGE (to smaller values) the following definitions if your system 00454 ** has a small C stack. (Or you may want to change them to larger 00455 ** values if your system has a large C stack and these limits are 00456 ** too rigid for you.) Some of these constants control the size of 00457 ** stack-allocated arrays used by the compiler or the interpreter, while 00458 ** others limit the maximum number of recursive calls that the compiler 00459 ** or the interpreter can perform. Values too large may cause a C stack 00460 ** overflow for some forms of deep constructs. 00461 ** =================================================================== 00462 */ 00463 00464 00465 /* 00466 @@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and 00467 @* syntactical nested non-terminals in a program. 00468 */ 00469 #define LUAI_MAXCCALLS 200 00470 00471 00472 /* 00473 @@ LUAI_MAXVARS is the maximum number of local variables per function 00474 @* (must be smaller than 250). 00475 */ 00476 #define LUAI_MAXVARS 200 00477 00478 00479 /* 00480 @@ LUAI_MAXUPVALUES is the maximum number of upvalues per function 00481 @* (must be smaller than 250). 00482 */ 00483 #define LUAI_MAXUPVALUES 60 00484 00485 00486 /* 00487 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. 00488 */ 00489 #define LUAL_BUFFERSIZE 1024 00490 00491 /* }================================================================== */ 00492 00493 00494 00495 00496 /* 00497 ** {================================================================== 00498 @@ LUA_NUMBER is the type of numbers in Lua. 00499 ** CHANGE the following definitions only if you want to build Lua 00500 ** with a number type different from double. You may also need to 00501 ** change lua_number2int & lua_number2integer. 00502 ** =================================================================== 00503 */ 00504 00505 #define LUA_NUMBER_DOUBLE 00506 #define LUA_NUMBER double 00507 00508 /* 00509 @@ LUAI_UACNUMBER is the result of an 'usual argument conversion' 00510 @* over a number. 00511 */ 00512 #define LUAI_UACNUMBER double 00513 00514 00515 /* 00516 @@ LUA_NUMBER_SCAN is the format for reading numbers. 00517 @@ LUA_NUMBER_FMT is the format for writing numbers. 00518 @@ lua_number2str converts a number to a string. 00519 @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. 00520 @@ lua_str2number converts a string to a number. 00521 */ 00522 #define LUA_NUMBER_SCAN "%lf" 00523 #define LUA_NUMBER_FMT "%.14g" 00524 #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) 00525 #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ 00526 #define lua_str2number(s,p) strtod((s), (p)) 00527 00528 00529 /* 00530 @@ The luai_num* macros define the primitive operations over numbers. 00531 */ 00532 #if defined(LUA_CORE) 00533 #include <math.h> 00534 #define luai_numadd(a,b) ((a)+(b)) 00535 #define luai_numsub(a,b) ((a)-(b)) 00536 #define luai_nummul(a,b) ((a)*(b)) 00537 #define luai_numdiv(a,b) ((a)/(b)) 00538 #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) 00539 #define luai_numpow(a,b) (pow(a,b)) 00540 #define luai_numunm(a) (-(a)) 00541 #define luai_numeq(a,b) ((a)==(b)) 00542 #define luai_numlt(a,b) ((a)<(b)) 00543 #define luai_numle(a,b) ((a)<=(b)) 00544 #define luai_numisnan(a) (!luai_numeq((a), (a))) 00545 #endif 00546 00547 00548 /* 00549 @@ lua_number2int is a macro to convert lua_Number to int. 00550 @@ lua_number2integer is a macro to convert lua_Number to lua_Integer. 00551 ** CHANGE them if you know a faster way to convert a lua_Number to 00552 ** int (with any rounding method and without throwing errors) in your 00553 ** system. In Pentium machines, a naive typecast from double to int 00554 ** in C is extremely slow, so any alternative is worth trying. 00555 */ 00556 00557 /* On a Pentium, resort to a trick */ 00558 #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ 00559 (defined(__i386) || defined (_M_IX86) || defined(__i386__)) 00560 00561 /* On a Microsoft compiler, use assembler */ 00562 #if defined(_MSC_VER) 00563 00564 #define lua_number2int(i,d) __asm fld d __asm fistp i 00565 #define lua_number2integer(i,n) lua_number2int(i, n) 00566 00567 /* the next trick should work on any Pentium, but sometimes clashes 00568 with a DirectX idiosyncrasy */ 00569 #else 00570 00571 union luai_Cast { double l_d; long l_l; }; 00572 #define lua_number2int(i,d) \ 00573 { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } 00574 #define lua_number2integer(i,n) lua_number2int(i, n) 00575 00576 #endif 00577 00578 00579 /* this option always works, but may be slow */ 00580 #else 00581 #define lua_number2int(i,d) ((i)=(int)(d)) 00582 #define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) 00583 00584 #endif 00585 00586 /* }================================================================== */ 00587 00588 00589 /* 00590 @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. 00591 ** CHANGE it if your system requires alignments larger than double. (For 00592 ** instance, if your system supports long doubles and they must be 00593 ** aligned in 16-byte boundaries, then you should add long double in the 00594 ** union.) Probably you do not need to change this. 00595 */ 00596 #define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } 00597 00598 00599 /* 00600 @@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. 00601 ** CHANGE them if you prefer to use longjmp/setjmp even with C++ 00602 ** or if want/don't to use _longjmp/_setjmp instead of regular 00603 ** longjmp/setjmp. By default, Lua handles errors with exceptions when 00604 ** compiling as C++ code, with _longjmp/_setjmp when asked to use them, 00605 ** and with longjmp/setjmp otherwise. 00606 */ 00607 #if defined(__cplusplus) 00608 /* C++ exceptions */ 00609 #define LUAI_THROW(L,c) throw(c) 00610 #define LUAI_TRY(L,c,a) try { a } catch(...) \ 00611 { if ((c)->status == 0) (c)->status = -1; } 00612 #define luai_jmpbuf int /* dummy variable */ 00613 00614 #elif defined(LUA_USE_ULONGJMP) 00615 /* in Unix, try _longjmp/_setjmp (more efficient) */ 00616 #define LUAI_THROW(L,c) _longjmp((c)->b, 1) 00617 #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } 00618 #define luai_jmpbuf jmp_buf 00619 00620 #else 00621 /* default handling with long jumps */ 00622 #define LUAI_THROW(L,c) longjmp((c)->b, 1) 00623 #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } 00624 #define luai_jmpbuf jmp_buf 00625 00626 #endif 00627 00628 00629 /* 00630 @@ LUA_MAXCAPTURES is the maximum number of captures that a pattern 00631 @* can do during pattern-matching. 00632 ** CHANGE it if you need more captures. This limit is arbitrary. 00633 */ 00634 #define LUA_MAXCAPTURES 32 00635 00636 00637 /* 00638 @@ lua_tmpnam is the function that the OS library uses to create a 00639 @* temporary name. 00640 @@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. 00641 ** CHANGE them if you have an alternative to tmpnam (which is considered 00642 ** insecure) or if you want the original tmpnam anyway. By default, Lua 00643 ** uses tmpnam except when POSIX is available, where it uses mkstemp. 00644 */ 00645 #if defined(loslib_c) || defined(luaall_c) 00646 00647 #if defined(LUA_USE_MKSTEMP) 00648 #include <unistd.h> 00649 #define LUA_TMPNAMBUFSIZE 32 00650 #define lua_tmpnam(b,e) { \ 00651 strcpy(b, "/tmp/lua_XXXXXX"); \ 00652 e = mkstemp(b); \ 00653 if (e != -1) close(e); \ 00654 e = (e == -1); } 00655 00656 #else 00657 #define LUA_TMPNAMBUFSIZE L_tmpnam 00658 #define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } 00659 #endif 00660 00661 #endif 00662 00663 00664 /* 00665 @@ lua_popen spawns a new process connected to the current one through 00666 @* the file streams. 00667 ** CHANGE it if you have a way to implement it in your system. 00668 */ 00669 #if defined(LUA_USE_POPEN) 00670 00671 #define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) 00672 #define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) 00673 00674 #elif defined(LUA_WIN) 00675 00676 #define lua_popen(L,c,m) ((void)L, _popen(c,m)) 00677 #define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) 00678 00679 #else 00680 00681 #define lua_popen(L,c,m) ((void)((void)c, m), \ 00682 luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) 00683 #define lua_pclose(L,file) ((void)((void)L, file), 0) 00684 00685 #endif 00686 00687 /* 00688 @@ LUA_DL_* define which dynamic-library system Lua should use. 00689 ** CHANGE here if Lua has problems choosing the appropriate 00690 ** dynamic-library system for your platform (either Windows' DLL, Mac's 00691 ** dyld, or Unix's dlopen). If your system is some kind of Unix, there 00692 ** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for 00693 ** it. To use dlopen you also need to adapt the src/Makefile (probably 00694 ** adding -ldl to the linker options), so Lua does not select it 00695 ** automatically. (When you change the makefile to add -ldl, you must 00696 ** also add -DLUA_USE_DLOPEN.) 00697 ** If you do not want any kind of dynamic library, undefine all these 00698 ** options. 00699 ** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. 00700 */ 00701 #if defined(LUA_USE_DLOPEN) 00702 #define LUA_DL_DLOPEN 00703 #endif 00704 00705 #if defined(LUA_WIN) 00706 #define LUA_DL_DLL 00707 #endif 00708 00709 00710 /* 00711 @@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State 00712 @* (the data goes just *before* the lua_State pointer). 00713 ** CHANGE (define) this if you really need that. This value must be 00714 ** a multiple of the maximum alignment required for your machine. 00715 */ 00716 #define LUAI_EXTRASPACE 0 00717 00718 00719 /* 00720 @@ luai_userstate* allow user-specific actions on threads. 00721 ** CHANGE them if you defined LUAI_EXTRASPACE and need to do something 00722 ** extra when a thread is created/deleted/resumed/yielded. 00723 */ 00724 #define luai_userstateopen(L) ((void)L) 00725 #define luai_userstateclose(L) ((void)L) 00726 #define luai_userstatethread(L,L1) ((void)L) 00727 #define luai_userstatefree(L) ((void)L) 00728 #define luai_userstateresume(L,n) ((void)L) 00729 #define luai_userstateyield(L,n) ((void)L) 00730 00731 00732 /* 00733 @@ LUA_INTFRMLEN is the length modifier for integer conversions 00734 @* in 'string.format'. 00735 @@ LUA_INTFRM_T is the integer type correspoding to the previous length 00736 @* modifier. 00737 ** CHANGE them if your system supports long long or does not support long. 00738 */ 00739 00740 #if defined(LUA_USELONGLONG) 00741 00742 #define LUA_INTFRMLEN "ll" 00743 #define LUA_INTFRM_T long long 00744 00745 #else 00746 00747 #define LUA_INTFRMLEN "l" 00748 #define LUA_INTFRM_T long 00749 00750 #endif 00751 00752 00753 00754 /* =================================================================== */ 00755 00756 /* 00757 ** Local configuration. You can use this space to add your redefinitions 00758 ** without modifying the main part of the file. 00759 */ 00760 00761 /* patch starts here */ 00762 #ifdef LUA_NUMBER_INT 00763 00764 #undef LUA_NUMBER_DOUBLE 00765 00766 #undef LUA_NUMBER 00767 #define LUA_NUMBER int 00768 00769 #undef LUAI_UACNUMBER 00770 #define LUAI_UACNUMBER int 00771 00772 #undef LUA_NUMBER_SCAN 00773 #undef LUA_NUMBER_FMT 00774 #undef LUAI_MAXNUMBER2STR 00775 #undef lua_str2number 00776 #define LUA_NUMBER_SCAN "%d" 00777 #define LUA_NUMBER_FMT "%d" 00778 #define LUAI_MAXNUMBER2STR 12 /* 10 digits, sign, point, and \0 */ 00779 #define lua_str2number(s,p) strtol((s), (p), 10) 00780 00781 #undef luai_nummod 00782 #undef luai_numpow 00783 #define luai_nummod(a,b) ((a) % (b)) 00784 #define luai_numpow(a,b) (int)(pow((double)a,(double)b) + 0.5) 00785 00786 #undef lua_number2int 00787 #undef lua_number2integer 00788 #define lua_number2int(i,d) ((i)=(int)(d)) 00789 #define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) 00790 00791 #endif /*LUA_NUMBER_INT*/ 00792 /* patch ends here */ 00793 00794 00795 #define LUA_MAX_ROTABLE_NAME 16 00796 00797 /* NUTLUA_OPTIMIZE_MEMORY: 00798 0 - no optimizations 00799 1 - optimize while maitaining full compatibility with the test suite 00800 2 - aggresive optimizations (breaks compatibility with some tests) 00801 */ 00802 #ifndef NUTLUA_OPTIMIZE_MEMORY 00803 #define NUTLUA_OPTIMIZE_MEMORY 0 00804 #endif 00805 00806 #if NUTLUA_OPTIMIZE_MEMORY == 2 && LUA_USE_POPEN 00807 #error "Pipes not supported in aggresive optimization mode (NUTLUA_OPTIMIZE_MEMORY=2)" 00808 #endif 00809 00810 #endif 00811