1 /* $NetBSD: luaconf.h,v 1.7 2014/03/26 22:03:26 christos Exp $ */ 2 3 /* 4 ** Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ 5 ** Configuration file for Lua 6 ** See Copyright Notice in lua.h 7 */ 8 9 10 #ifndef lconfig_h 11 #define lconfig_h 12 13 #include <limits.h> 14 #include <stddef.h> 15 16 17 /* 18 ** ================================================================== 19 ** Search for "@@" to find all configurable definitions. 20 ** =================================================================== 21 */ 22 23 24 /* 25 @@ LUA_ANSI controls the use of non-ansi features. 26 ** CHANGE it (define it) if you want Lua to avoid the use of any 27 ** non-ansi feature or library. 28 */ 29 #if defined(__STRICT_ANSI__) 30 #define LUA_ANSI 31 #endif 32 33 34 #if !defined(LUA_ANSI) && defined(_WIN32) 35 #define LUA_WIN 36 #endif 37 38 #if defined(LUA_USE_LINUX) 39 #define LUA_USE_POSIX 40 #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ 41 #define LUA_USE_READLINE /* needs some extra libraries */ 42 #endif 43 44 #if defined(LUA_USE_MACOSX) 45 #define LUA_USE_POSIX 46 #define LUA_DL_DYLD /* does not need extra library */ 47 #endif 48 49 50 51 /* 52 @@ LUA_USE_POSIX includes all functionallity listed as X/Open System 53 @* Interfaces Extension (XSI). 54 ** CHANGE it (define it) if your system is XSI compatible. 55 */ 56 #if defined(LUA_USE_POSIX) 57 #define LUA_USE_MKSTEMP 58 #define LUA_USE_ISATTY 59 #define LUA_USE_POPEN 60 #define LUA_USE_ULONGJMP 61 #endif 62 63 64 /* 65 @@ LUA_PATH and LUA_CPATH are the names of the environment variables that 66 @* Lua check to set its paths. 67 @@ LUA_INIT is the name of the environment variable that Lua 68 @* checks for initialization code. 69 ** CHANGE them if you want different names. 70 */ 71 #define LUA_PATH "LUA_PATH" 72 #define LUA_CPATH "LUA_CPATH" 73 #define LUA_INIT "LUA_INIT" 74 75 76 /* 77 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for 78 @* Lua libraries. 79 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for 80 @* C libraries. 81 ** CHANGE them if your machine has a non-conventional directory 82 ** hierarchy or if you want to install your libraries in 83 ** non-conventional directories. 84 */ 85 #if defined(_WIN32) 86 /* 87 ** In Windows, any exclamation mark ('!') in the path is replaced by the 88 ** path of the directory of the executable file of the current process. 89 */ 90 #define LUA_LDIR "!\\lua\\" 91 #define LUA_CDIR "!\\" 92 #define LUA_PATH_DEFAULT \ 93 ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ 94 LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" 95 #define LUA_CPATH_DEFAULT \ 96 ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" 97 98 #else 99 #define LUA_ROOT "/usr/" 100 #define LUA_LDIR LUA_ROOT "share/lua/5.1/" 101 #define LUA_CDIR LUA_ROOT "lib/lua/5.1/" 102 103 /* 104 * The original Lua distribution contain "./?.lua" at the beginning 105 * of LUA_PATH_DEFAULT and "./?.so" at the beginning of LUA_CPATH_DEFAULT. 106 * These path elements have been removed for the NetBSD version of Lua 107 * to avoid potential security problems. 108 */ 109 #define LUA_PATH_DEFAULT \ 110 LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ 111 LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" 112 #define LUA_CPATH_DEFAULT \ 113 LUA_CDIR"?.so;" LUA_CDIR"loadall.so" 114 #endif 115 116 117 /* 118 @@ LUA_DIRSEP is the directory separator (for submodules). 119 ** CHANGE it if your machine does not use "/" as the directory separator 120 ** and is not Windows. (On Windows Lua automatically uses "\".) 121 */ 122 #if defined(_WIN32) 123 #define LUA_DIRSEP "\\" 124 #else 125 #define LUA_DIRSEP "/" 126 #endif 127 128 129 /* 130 @@ LUA_PATHSEP is the character that separates templates in a path. 131 @@ LUA_PATH_MARK is the string that marks the substitution points in a 132 @* template. 133 @@ LUA_EXECDIR in a Windows path is replaced by the executable's 134 @* directory. 135 @@ LUA_IGMARK is a mark to ignore all before it when bulding the 136 @* luaopen_ function name. 137 ** CHANGE them if for some reason your system cannot use those 138 ** characters. (E.g., if one of those characters is a common character 139 ** in file/directory names.) Probably you do not need to change them. 140 */ 141 #define LUA_PATHSEP ";" 142 #define LUA_PATH_MARK "?" 143 #define LUA_EXECDIR "!" 144 #define LUA_IGMARK "-" 145 146 147 /* 148 @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. 149 ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most 150 ** machines, ptrdiff_t gives a good choice between int or long.) 151 */ 152 #ifdef _KERNEL 153 #define LUA_INTEGER LUA_NUMBER 154 #else 155 #define LUA_INTEGER ptrdiff_t 156 #endif 157 158 159 /* 160 @@ LUA_API is a mark for all core API functions. 161 @@ LUALIB_API is a mark for all standard library functions. 162 ** CHANGE them if you need to define those functions in some special way. 163 ** For instance, if you want to create one Windows DLL with the core and 164 ** the libraries, you may want to use the following definition (define 165 ** LUA_BUILD_AS_DLL to get it). 166 */ 167 #if defined(LUA_BUILD_AS_DLL) 168 169 #if defined(LUA_CORE) || defined(LUA_LIB) 170 #define LUA_API __declspec(dllexport) 171 #else 172 #define LUA_API __declspec(dllimport) 173 #endif 174 175 #else 176 177 #define LUA_API extern 178 179 #endif 180 181 /* more often than not the libs go together with the core */ 182 #define LUALIB_API LUA_API 183 184 185 /* 186 @@ LUAI_FUNC is a mark for all extern functions that are not to be 187 @* exported to outside modules. 188 @@ LUAI_DATA is a mark for all extern (const) variables that are not to 189 @* be exported to outside modules. 190 ** CHANGE them if you need to mark them in some special way. Elf/gcc 191 ** (versions 3.2 and later) mark them as "hidden" to optimize access 192 ** when Lua is compiled as a shared library. 193 */ 194 #if defined(luaall_c) 195 #define LUAI_FUNC static 196 #define LUAI_DATA /* empty */ 197 198 #elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ 199 defined(__ELF__) 200 #define LUAI_FUNC __attribute__((visibility("hidden"))) extern 201 #define LUAI_DATA LUAI_FUNC 202 203 #else 204 #define LUAI_FUNC extern 205 #define LUAI_DATA extern 206 #endif 207 208 209 210 /* 211 @@ LUA_QL describes how error messages quote program elements. 212 ** CHANGE it if you want a different appearance. 213 */ 214 #define LUA_QL(x) "'" x "'" 215 #define LUA_QS LUA_QL("%s") 216 217 218 /* 219 @@ LUA_IDSIZE gives the maximum size for the description of the source 220 @* of a function in debug information. 221 ** CHANGE it if you want a different size. 222 */ 223 #define LUA_IDSIZE 60 224 225 226 /* 227 ** {================================================================== 228 ** Stand-alone configuration 229 ** =================================================================== 230 */ 231 232 #if defined(lua_c) || defined(luaall_c) 233 234 /* 235 @@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that 236 @* is, whether we're running lua interactively). 237 ** CHANGE it if you have a better definition for non-POSIX/non-Windows 238 ** systems. 239 */ 240 #if defined(LUA_USE_ISATTY) 241 #include <unistd.h> 242 #define lua_stdin_is_tty() isatty(0) 243 #elif defined(LUA_WIN) 244 #include <io.h> 245 #include <stdio.h> 246 #define lua_stdin_is_tty() _isatty(_fileno(stdin)) 247 #else 248 #define lua_stdin_is_tty() 1 /* assume stdin is a tty */ 249 #endif 250 251 252 /* 253 @@ LUA_PROMPT is the default prompt used by stand-alone Lua. 254 @@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. 255 ** CHANGE them if you want different prompts. (You can also change the 256 ** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) 257 */ 258 #define LUA_PROMPT "> " 259 #define LUA_PROMPT2 ">> " 260 261 262 /* 263 @@ LUA_PROGNAME is the default name for the stand-alone Lua program. 264 ** CHANGE it if your stand-alone interpreter has a different name and 265 ** your system is not able to detect that name automatically. 266 */ 267 #define LUA_PROGNAME "lua" 268 269 270 /* 271 @@ LUA_MAXINPUT is the maximum length for an input line in the 272 @* stand-alone interpreter. 273 ** CHANGE it if you need longer lines. 274 */ 275 #define LUA_MAXINPUT 512 276 277 278 /* 279 @@ lua_readline defines how to show a prompt and then read a line from 280 @* the standard input. 281 @@ lua_saveline defines how to "save" a read line in a "history". 282 @@ lua_freeline defines how to free a line read by lua_readline. 283 ** CHANGE them if you want to improve this functionality (e.g., by using 284 ** GNU readline and history facilities). 285 */ 286 #if defined(LUA_USE_READLINE) 287 #include <stdio.h> 288 #include <readline/readline.h> 289 #include <readline/history.h> 290 #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) 291 #define lua_saveline(L,idx) \ 292 if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ 293 add_history(lua_tostring(L, idx)); /* add it to history */ 294 #define lua_freeline(L,b) ((void)L, free(b)) 295 #else 296 #define lua_readline(L,b,p) \ 297 ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ 298 fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ 299 #define lua_saveline(L,idx) { (void)L; (void)idx; } 300 #define lua_freeline(L,b) { (void)L; (void)b; } 301 #endif 302 303 #endif 304 305 /* }================================================================== */ 306 307 308 /* 309 @@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles 310 @* as a percentage. 311 ** CHANGE it if you want the GC to run faster or slower (higher values 312 ** mean larger pauses which mean slower collection.) You can also change 313 ** this value dynamically. 314 */ 315 #define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ 316 317 318 /* 319 @@ LUAI_GCMUL defines the default speed of garbage collection relative to 320 @* memory allocation as a percentage. 321 ** CHANGE it if you want to change the granularity of the garbage 322 ** collection. (Higher values mean coarser collections. 0 represents 323 ** infinity, where each step performs a full collection.) You can also 324 ** change this value dynamically. 325 */ 326 #define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ 327 328 329 330 /* 331 @@ LUA_COMPAT_GETN controls compatibility with old getn behavior. 332 ** CHANGE it (define it) if you want exact compatibility with the 333 ** behavior of setn/getn in Lua 5.0. 334 */ 335 #undef LUA_COMPAT_GETN 336 337 /* 338 @@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. 339 ** CHANGE it to undefined as soon as you do not need a global 'loadlib' 340 ** function (the function is still available as 'package.loadlib'). 341 */ 342 #undef LUA_COMPAT_LOADLIB 343 344 /* 345 @@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. 346 ** CHANGE it to undefined as soon as your programs use only '...' to 347 ** access vararg parameters (instead of the old 'arg' table). 348 */ 349 #define LUA_COMPAT_VARARG 350 351 /* 352 @@ LUA_COMPAT_MOD controls compatibility with old math.mod function. 353 ** CHANGE it to undefined as soon as your programs use 'math.fmod' or 354 ** the new '%' operator instead of 'math.mod'. 355 */ 356 #define LUA_COMPAT_MOD 357 358 /* 359 @@ LUA_COMPAT_LSTR controls compatibility with old long string nesting 360 @* facility. 361 ** CHANGE it to 2 if you want the old behaviour, or undefine it to turn 362 ** off the advisory error when nesting [[...]]. 363 */ 364 #define LUA_COMPAT_LSTR 1 365 366 /* 367 @@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. 368 ** CHANGE it to undefined as soon as you rename 'string.gfind' to 369 ** 'string.gmatch'. 370 */ 371 #define LUA_COMPAT_GFIND 372 373 /* 374 @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' 375 @* behavior. 376 ** CHANGE it to undefined as soon as you replace to 'luaL_register' 377 ** your uses of 'luaL_openlib' 378 */ 379 #define LUA_COMPAT_OPENLIB 380 381 382 383 /* 384 @@ luai_apicheck is the assert macro used by the Lua-C API. 385 ** CHANGE luai_apicheck if you want Lua to perform some checks in the 386 ** parameters it gets from API calls. This may slow down the interpreter 387 ** a bit, but may be quite useful when debugging C code that interfaces 388 ** with Lua. A useful redefinition is to use assert.h. 389 */ 390 #if defined(LUA_USE_APICHECK) 391 #include <assert.h> 392 #define luai_apicheck(L,o) { (void)L; assert(o); } 393 #else 394 #define luai_apicheck(L,o) { (void)L; } 395 #endif 396 397 398 /* 399 @@ LUAI_BITSINT defines the number of bits in an int. 400 ** CHANGE here if Lua cannot automatically detect the number of bits of 401 ** your machine. Probably you do not need to change this. 402 */ 403 /* avoid overflows in comparison */ 404 #if INT_MAX-20 < 32760 405 #define LUAI_BITSINT 16 406 #elif INT_MAX > 2147483640L 407 /* int has at least 32 bits */ 408 #define LUAI_BITSINT 32 409 #else 410 #error "you must define LUA_BITSINT with number of bits in an integer" 411 #endif 412 413 414 /* 415 @@ LUAI_UINT32 is an unsigned integer with at least 32 bits. 416 @@ LUAI_INT32 is an signed integer with at least 32 bits. 417 @@ LUAI_UMEM is an unsigned integer big enough to count the total 418 @* memory used by Lua. 419 @@ LUAI_MEM is a signed integer big enough to count the total memory 420 @* used by Lua. 421 ** CHANGE here if for some weird reason the default definitions are not 422 ** good enough for your machine. (The definitions in the 'else' 423 ** part always works, but may waste space on machines with 64-bit 424 ** longs.) Probably you do not need to change this. 425 */ 426 #if LUAI_BITSINT >= 32 427 #define LUAI_UINT32 unsigned int 428 #define LUAI_INT32 int 429 #define LUAI_MAXINT32 INT_MAX 430 #define LUAI_UMEM size_t 431 #define LUAI_MEM ptrdiff_t 432 #else 433 /* 16-bit ints */ 434 #define LUAI_UINT32 unsigned long 435 #define LUAI_INT32 long 436 #define LUAI_MAXINT32 LONG_MAX 437 #define LUAI_UMEM unsigned long 438 #define LUAI_MEM long 439 #endif 440 441 442 /* 443 @@ LUAI_MAXCALLS limits the number of nested calls. 444 ** CHANGE it if you need really deep recursive calls. This limit is 445 ** arbitrary; its only purpose is to stop infinite recursion before 446 ** exhausting memory. 447 */ 448 #define LUAI_MAXCALLS 20000 449 450 451 /* 452 @@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function 453 @* can use. 454 ** CHANGE it if you need lots of (Lua) stack space for your C 455 ** functions. This limit is arbitrary; its only purpose is to stop C 456 ** functions to consume unlimited stack space. (must be smaller than 457 ** -LUA_REGISTRYINDEX) 458 */ 459 #define LUAI_MAXCSTACK 8000 460 461 462 463 /* 464 ** {================================================================== 465 ** CHANGE (to smaller values) the following definitions if your system 466 ** has a small C stack. (Or you may want to change them to larger 467 ** values if your system has a large C stack and these limits are 468 ** too rigid for you.) Some of these constants control the size of 469 ** stack-allocated arrays used by the compiler or the interpreter, while 470 ** others limit the maximum number of recursive calls that the compiler 471 ** or the interpreter can perform. Values too large may cause a C stack 472 ** overflow for some forms of deep constructs. 473 ** =================================================================== 474 */ 475 476 477 /* 478 @@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and 479 @* syntactical nested non-terminals in a program. 480 */ 481 #define LUAI_MAXCCALLS 200 482 483 484 /* 485 @@ LUAI_MAXVARS is the maximum number of local variables per function 486 @* (must be smaller than 250). 487 */ 488 #define LUAI_MAXVARS 200 489 490 491 /* 492 @@ LUAI_MAXUPVALUES is the maximum number of upvalues per function 493 @* (must be smaller than 250). 494 */ 495 #define LUAI_MAXUPVALUES 60 496 497 498 /* 499 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. 500 */ 501 #define LUAL_BUFFERSIZE BUFSIZ 502 503 /* }================================================================== */ 504 505 506 507 508 /* 509 ** {================================================================== 510 @@ LUA_NUMBER is the type of numbers in Lua. 511 ** CHANGE the following definitions only if you want to build Lua 512 ** with a number type different from double. You may also need to 513 ** change lua_number2int & lua_number2integer. 514 ** =================================================================== 515 */ 516 517 #ifdef _KERNEL 518 #include <sys/stdint.h> 519 #define LUA_NUMBER intmax_t 520 #else 521 #define LUA_NUMBER_DOUBLE 522 #define LUA_NUMBER double 523 #endif 524 525 /* 526 @@ LUAI_UACNUMBER is the result of an 'usual argument conversion' 527 @* over a number. 528 */ 529 #define LUAI_UACNUMBER LUA_NUMBER 530 531 /* 532 @@ LUA_NUMBER_SCAN is the format for reading numbers. 533 @@ LUA_NUMBER_FMT is the format for writing numbers. 534 @@ lua_number2str converts a number to a string. 535 @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. 536 @@ lua_str2number converts a string to a number. 537 */ 538 #ifdef _KERNEL 539 #define LUA_NUMBER_SCAN "%jd" 540 #define LUA_NUMBER_FMT "%jd" 541 #define lua_str2number(s,p) strtoimax((s), (p), 10) 542 #else 543 #define LUA_NUMBER_SCAN "%lf" 544 #define LUA_NUMBER_FMT "%.14g" 545 #define lua_str2number(s,p) strtod((s), (p)) 546 #endif 547 548 #define lua_number2str(s,l,n) snprintf((s), (l), LUA_NUMBER_FMT, (n)) 549 #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ 550 551 /* 552 @@ The luai_num* macros define the primitive operations over numbers. 553 */ 554 #if defined(LUA_CORE) 555 #ifdef _KERNEL 556 #define luai_nummod(a,b) ((a)%(b)) 557 #define luai_numpow(a,b) luai_nummul(a,b) 558 #else 559 #include <math.h> 560 #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) 561 #define luai_numpow(a,b) (pow(a,b)) 562 #endif 563 564 #define luai_numadd(a,b) ((a)+(b)) 565 #define luai_numsub(a,b) ((a)-(b)) 566 #define luai_nummul(a,b) ((a)*(b)) 567 #define luai_numdiv(a,b) ((a)/(b)) 568 #define luai_numunm(a) (-(a)) 569 #define luai_numeq(a,b) ((a)==(b)) 570 #define luai_numlt(a,b) ((a)<(b)) 571 #define luai_numle(a,b) ((a)<=(b)) 572 #define luai_numisnan(a) (!luai_numeq((a), (a))) 573 #endif 574 575 576 /* 577 @@ lua_number2int is a macro to convert lua_Number to int. 578 @@ lua_number2integer is a macro to convert lua_Number to lua_Integer. 579 ** CHANGE them if you know a faster way to convert a lua_Number to 580 ** int (with any rounding method and without throwing errors) in your 581 ** system. In Pentium machines, a naive typecast from double to int 582 ** in C is extremely slow, so any alternative is worth trying. 583 */ 584 585 /* On a Pentium, resort to a trick */ 586 #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ 587 (defined(__i386) || defined (_M_IX86) || defined(__i386__)) 588 589 /* On a Microsoft compiler, use assembler */ 590 #if defined(_MSC_VER) 591 592 #define lua_number2int(i,d) __asm fld d __asm fistp i 593 #define lua_number2integer(i,n) lua_number2int(i, n) 594 595 /* the next trick should work on any Pentium, but sometimes clashes 596 with a DirectX idiosyncrasy */ 597 #else 598 599 union luai_Cast { double l_d; long l_l; }; 600 #define lua_number2int(i,d) \ 601 { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } 602 #define lua_number2integer(i,n) lua_number2int(i, n) 603 604 #endif 605 606 607 /* this option always works, but may be slow */ 608 #else 609 #define lua_number2int(i,d) ((i)=(int)(d)) 610 #define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) 611 612 #endif 613 614 /* }================================================================== */ 615 616 617 /* 618 @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. 619 ** CHANGE it if your system requires alignments larger than double. (For 620 ** instance, if your system supports long doubles and they must be 621 ** aligned in 16-byte boundaries, then you should add long double in the 622 ** union.) Probably you do not need to change this. 623 */ 624 #define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } 625 626 627 /* 628 @@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. 629 ** CHANGE them if you prefer to use longjmp/setjmp even with C++ 630 ** or if want/don't to use _longjmp/_setjmp instead of regular 631 ** longjmp/setjmp. By default, Lua handles errors with exceptions when 632 ** compiling as C++ code, with _longjmp/_setjmp when asked to use them, 633 ** and with longjmp/setjmp otherwise. 634 */ 635 #ifdef _KERNEL 636 /* in NetBSD kernel */ 637 #define LUAI_THROW(L,c) longjmp(& ((c)->b)) 638 #define LUAI_TRY(L,c,a) if (setjmp(& ((c)->b)) == 0) { a } 639 #define luai_jmpbuf label_t 640 641 #elif defined(__cplusplus) 642 /* C++ exceptions */ 643 #define LUAI_THROW(L,c) throw(c) 644 #define LUAI_TRY(L,c,a) try { a } catch(...) \ 645 { if ((c)->status == 0) (c)->status = -1; } 646 #define luai_jmpbuf int /* dummy variable */ 647 648 #elif defined(LUA_USE_ULONGJMP) 649 /* in Unix, try _longjmp/_setjmp (more efficient) */ 650 #define LUAI_THROW(L,c) _longjmp((c)->b, 1) 651 #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } 652 #define luai_jmpbuf jmp_buf 653 654 #else 655 /* default handling with long jumps */ 656 #define LUAI_THROW(L,c) longjmp((c)->b, 1) 657 #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } 658 #define luai_jmpbuf jmp_buf 659 660 #endif 661 662 663 /* 664 @@ LUA_MAXCAPTURES is the maximum number of captures that a pattern 665 @* can do during pattern-matching. 666 ** CHANGE it if you need more captures. This limit is arbitrary. 667 */ 668 #define LUA_MAXCAPTURES 32 669 670 671 /* 672 @@ lua_tmpnam is the function that the OS library uses to create a 673 @* temporary name. 674 @@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. 675 ** CHANGE them if you have an alternative to tmpnam (which is considered 676 ** insecure) or if you want the original tmpnam anyway. By default, Lua 677 ** uses tmpnam except when POSIX is available, where it uses mkstemp. 678 */ 679 #if defined(loslib_c) || defined(luaall_c) 680 681 #if defined(LUA_USE_MKSTEMP) 682 #include <unistd.h> 683 #define LUA_TMPNAMBUFSIZE 32 684 #define lua_tmpnam(b,e) { \ 685 strcpy(b, "/tmp/lua_XXXXXX"); \ 686 e = mkstemp(b); \ 687 if (e != -1) close(e); \ 688 e = (e == -1); } 689 690 #else 691 #define LUA_TMPNAMBUFSIZE L_tmpnam 692 #define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } 693 #endif 694 695 #endif 696 697 698 /* 699 @@ lua_popen spawns a new process connected to the current one through 700 @* the file streams. 701 ** CHANGE it if you have a way to implement it in your system. 702 */ 703 #if defined(LUA_USE_POPEN) 704 705 #define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) 706 #define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) 707 708 #elif defined(LUA_WIN) 709 710 #define lua_popen(L,c,m) ((void)L, _popen(c,m)) 711 #define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) 712 713 #else 714 715 #define lua_popen(L,c,m) ((void)((void)c, m), \ 716 luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) 717 #define lua_pclose(L,file) ((void)((void)L, file), 0) 718 719 #endif 720 721 /* 722 @@ LUA_DL_* define which dynamic-library system Lua should use. 723 ** CHANGE here if Lua has problems choosing the appropriate 724 ** dynamic-library system for your platform (either Windows' DLL, Mac's 725 ** dyld, or Unix's dlopen). If your system is some kind of Unix, there 726 ** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for 727 ** it. To use dlopen you also need to adapt the src/Makefile (probably 728 ** adding -ldl to the linker options), so Lua does not select it 729 ** automatically. (When you change the makefile to add -ldl, you must 730 ** also add -DLUA_USE_DLOPEN.) 731 ** If you do not want any kind of dynamic library, undefine all these 732 ** options. 733 ** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. 734 */ 735 #if defined(LUA_USE_DLOPEN) 736 #define LUA_DL_DLOPEN 737 #endif 738 739 #if defined(LUA_WIN) 740 #define LUA_DL_DLL 741 #endif 742 743 744 /* 745 @@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State 746 @* (the data goes just *before* the lua_State pointer). 747 ** CHANGE (define) this if you really need that. This value must be 748 ** a multiple of the maximum alignment required for your machine. 749 */ 750 #define LUAI_EXTRASPACE 0 751 752 753 /* 754 @@ luai_userstate* allow user-specific actions on threads. 755 ** CHANGE them if you defined LUAI_EXTRASPACE and need to do something 756 ** extra when a thread is created/deleted/resumed/yielded. 757 */ 758 #define luai_userstateopen(L) ((void)L) 759 #define luai_userstateclose(L) ((void)L) 760 #define luai_userstatethread(L,L1) ((void)L) 761 #define luai_userstatefree(L) ((void)L) 762 #define luai_userstateresume(L,n) ((void)L) 763 #define luai_userstateyield(L,n) ((void)L) 764 765 766 /* 767 @@ LUA_INTFRMLEN is the length modifier for integer conversions 768 @* in 'string.format'. 769 @@ LUA_INTFRM_T is the integer type correspoding to the previous length 770 @* modifier. 771 ** CHANGE them if your system supports long long or does not support long. 772 */ 773 774 #ifdef _KERNEL 775 776 #define LUA_INTFRMLEN "j" 777 #define LUA_INTFRM_T intmax_t 778 #define LUA_UINTFRM_T uintmax_t 779 780 #elif defined(LUA_USELONGLONG) 781 782 #define LUA_INTFRMLEN "ll" 783 #define LUA_INTFRM_T long long 784 785 #else 786 787 #define LUA_INTFRMLEN "l" 788 #define LUA_INTFRM_T long 789 790 #endif 791 792 793 794 /* =================================================================== */ 795 796 /* 797 ** Local configuration. You can use this space to add your redefinitions 798 ** without modifying the main part of the file. 799 */ 800 801 802 803 #endif 804 805