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