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