1 /* $NetBSD: luaconf.h,v 1.13 2015/02/19 04:46:22 lneto Exp $ */ 2 3 /* 4 ** Id: luaconf.h,v 1.238 2014/12/29 13:27:55 roberto Exp 5 ** Configuration file for Lua 6 ** See Copyright Notice in lua.h 7 */ 8 9 10 #ifndef luaconf_h 11 #define luaconf_h 12 13 #ifndef _KERNEL 14 #include <limits.h> 15 #include <stddef.h> 16 #else 17 #include <machine/limits.h> 18 #include <sys/systm.h> 19 #endif 20 21 22 /* 23 ** =================================================================== 24 ** Search for "@@" to find all configurable definitions. 25 ** =================================================================== 26 */ 27 28 29 /* 30 ** {==================================================================== 31 ** System Configuration: macros to adapt (if needed) Lua to some 32 ** particular platform, for instance compiling it with 32-bit numbers or 33 ** restricting it to C89. 34 ** ===================================================================== 35 */ 36 37 /* 38 @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You 39 ** can also define LUA_32BITS in the make file, but changing here you 40 ** ensure that all software connected to Lua will be compiled with the 41 ** same configuration. 42 */ 43 /* #define LUA_32BITS */ 44 45 46 /* 47 @@ LUA_USE_C89 controls the use of non-ISO-C89 features. 48 ** Define it if you want Lua to avoid the use of a few C99 features 49 ** or Windows-specific features on Windows. 50 */ 51 /* #define LUA_USE_C89 */ 52 53 54 /* 55 ** By default, Lua on Windows use (some) specific Windows features 56 */ 57 #if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE) 58 #define LUA_USE_WINDOWS /* enable goodies for regular Windows */ 59 #endif 60 61 62 #if defined(LUA_USE_WINDOWS) 63 #define LUA_DL_DLL /* enable support for DLL */ 64 #define LUA_USE_C89 /* broadly, Windows is C89 */ 65 #endif 66 67 68 #if defined(LUA_USE_LINUX) 69 #define LUA_USE_POSIX 70 #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ 71 #define LUA_USE_READLINE /* needs some extra libraries */ 72 #endif 73 74 75 #if defined(LUA_USE_MACOSX) 76 #define LUA_USE_POSIX 77 #define LUA_USE_DLOPEN /* MacOS does not need -ldl */ 78 #define LUA_USE_READLINE /* needs an extra library: -lreadline */ 79 #endif 80 81 82 /* 83 @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for 84 ** C89 ('long' and 'double'); Windows always has '__int64', so it does 85 ** not need to use this case. 86 */ 87 #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) 88 #define LUA_C89_NUMBERS 89 #endif 90 91 92 93 /* 94 @@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. 95 */ 96 /* avoid undefined shifts */ 97 #if ((INT_MAX >> 15) >> 15) >= 1 98 #define LUAI_BITSINT 32 99 #else 100 /* 'int' always must have at least 16 bits */ 101 #define LUAI_BITSINT 16 102 #endif 103 104 105 /* 106 @@ LUA_INT_INT / LUA_INT_LONG / LUA_INT_LONGLONG defines the type for 107 ** Lua integers. 108 @@ LUA_REAL_FLOAT / LUA_REAL_DOUBLE / LUA_REAL_LONGDOUBLE defines 109 ** the type for Lua floats. 110 ** Lua should work fine with any mix of these options (if supported 111 ** by your C compiler). The usual configurations are 64-bit integers 112 ** and 'double' (the default), 32-bit integers and 'float' (for 113 ** restricted platforms), and 'long'/'double' (for C compilers not 114 ** compliant with C99, which may not have support for 'long long'). 115 */ 116 117 #if defined(LUA_32BITS) /* { */ 118 /* 119 ** 32-bit integers and 'float' 120 */ 121 #if LUAI_BITSINT >= 32 /* use 'int' if big enough */ 122 #define LUA_INT_INT 123 #else /* otherwise use 'long' */ 124 #define LUA_INT_LONG 125 #endif 126 #define LUA_REAL_FLOAT 127 128 #elif defined(LUA_C89_NUMBERS) /* }{ */ 129 /* 130 ** largest types available for C89 ('long' and 'double') 131 */ 132 #define LUA_INT_LONG 133 #define LUA_REAL_DOUBLE 134 135 #else /* }{ */ 136 /* 137 ** default configuration for 64-bit Lua ('long long' and 'double') 138 */ 139 #define LUA_INT_LONGLONG 140 #define LUA_REAL_DOUBLE 141 142 #endif /* } */ 143 144 /* }================================================================== */ 145 146 147 148 149 /* 150 ** {================================================================== 151 ** Configuration for Paths. 152 ** =================================================================== 153 */ 154 155 /* 156 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for 157 ** Lua libraries. 158 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for 159 ** C libraries. 160 ** CHANGE them if your machine has a non-conventional directory 161 ** hierarchy or if you want to install your libraries in 162 ** non-conventional directories. 163 */ 164 #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR 165 #if defined(_WIN32) /* { */ 166 /* 167 ** In Windows, any exclamation mark ('!') in the path is replaced by the 168 ** path of the directory of the executable file of the current process. 169 */ 170 #define LUA_LDIR "!\\lua\\" 171 #define LUA_CDIR "!\\" 172 #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" 173 #define LUA_PATH_DEFAULT \ 174 LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ 175 LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ 176 LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ 177 ".\\?.lua;" ".\\?\\init.lua" 178 #define LUA_CPATH_DEFAULT \ 179 LUA_CDIR"?.dll;" \ 180 LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ 181 LUA_CDIR"loadall.dll;" ".\\?.dll" 182 183 #else /* }{ */ 184 185 #define LUA_ROOT "/usr/local/" 186 #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" 187 #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" 188 #define LUA_PATH_DEFAULT \ 189 LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ 190 LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ 191 "./?.lua;" "./?/init.lua" 192 #define LUA_CPATH_DEFAULT \ 193 LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" 194 #endif /* } */ 195 196 197 /* 198 @@ LUA_DIRSEP is the directory separator (for submodules). 199 ** CHANGE it if your machine does not use "/" as the directory separator 200 ** and is not Windows. (On Windows Lua automatically uses "\".) 201 */ 202 #if defined(_WIN32) 203 #define LUA_DIRSEP "\\" 204 #else 205 #define LUA_DIRSEP "/" 206 #endif 207 208 /* }================================================================== */ 209 210 211 /* 212 ** {================================================================== 213 ** Marks for exported symbols in the C code 214 ** =================================================================== 215 */ 216 217 /* 218 @@ LUA_API is a mark for all core API functions. 219 @@ LUALIB_API is a mark for all auxiliary library functions. 220 @@ LUAMOD_API is a mark for all standard library opening functions. 221 ** CHANGE them if you need to define those functions in some special way. 222 ** For instance, if you want to create one Windows DLL with the core and 223 ** the libraries, you may want to use the following definition (define 224 ** LUA_BUILD_AS_DLL to get it). 225 */ 226 #if defined(LUA_BUILD_AS_DLL) /* { */ 227 228 #if defined(LUA_CORE) || defined(LUA_LIB) /* { */ 229 #define LUA_API __declspec(dllexport) 230 #else /* }{ */ 231 #define LUA_API __declspec(dllimport) 232 #endif /* } */ 233 234 #else /* }{ */ 235 236 #define LUA_API extern 237 238 #endif /* } */ 239 240 241 /* more often than not the libs go together with the core */ 242 #define LUALIB_API LUA_API 243 #define LUAMOD_API LUALIB_API 244 245 246 /* 247 @@ LUAI_FUNC is a mark for all extern functions that are not to be 248 ** exported to outside modules. 249 @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables 250 ** that are not to be exported to outside modules (LUAI_DDEF for 251 ** definitions and LUAI_DDEC for declarations). 252 ** CHANGE them if you need to mark them in some special way. Elf/gcc 253 ** (versions 3.2 and later) mark them as "hidden" to optimize access 254 ** when Lua is compiled as a shared library. Not all elf targets support 255 ** this attribute. Unfortunately, gcc does not offer a way to check 256 ** whether the target offers that support, and those without support 257 ** give a warning about it. To avoid these warnings, change to the 258 ** default definition. 259 */ 260 #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ 261 defined(__ELF__) /* { */ 262 #define LUAI_FUNC __attribute__((visibility("hidden"))) extern 263 #else /* }{ */ 264 #define LUAI_FUNC extern 265 #endif /* } */ 266 267 #define LUAI_DDEC LUAI_FUNC 268 #define LUAI_DDEF /* empty */ 269 270 /* }================================================================== */ 271 272 273 /* 274 ** {================================================================== 275 ** Compatibility with previous versions 276 ** =================================================================== 277 */ 278 279 /* 280 @@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2. 281 @@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1. 282 ** You can define it to get all options, or change specific options 283 ** to fit your specific needs. 284 */ 285 #if defined(LUA_COMPAT_5_2) /* { */ 286 287 /* 288 @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated 289 ** functions in the mathematical library. 290 */ 291 #define LUA_COMPAT_MATHLIB 292 293 /* 294 @@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'. 295 */ 296 #define LUA_COMPAT_BITLIB 297 298 /* 299 @@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod. 300 */ 301 #define LUA_COMPAT_IPAIRS 302 303 /* 304 @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for 305 ** manipulating other integer types (lua_pushunsigned, lua_tounsigned, 306 ** luaL_checkint, luaL_checklong, etc.) 307 */ 308 #define LUA_COMPAT_APIINTCASTS 309 310 311 /* 312 @@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a 313 @@ a float mark ('.0'). 314 ** This macro is not on by default even in compatibility mode, 315 ** because this is not really an incompatibility. 316 */ 317 /* #define LUA_COMPAT_FLOATSTRING */ 318 319 #endif /* } */ 320 321 322 #if defined(LUA_COMPAT_5_1) /* { */ 323 324 /* 325 @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. 326 ** You can replace it with 'table.unpack'. 327 */ 328 #define LUA_COMPAT_UNPACK 329 330 /* 331 @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. 332 ** You can replace it with 'package.searchers'. 333 */ 334 #define LUA_COMPAT_LOADERS 335 336 /* 337 @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. 338 ** You can call your C function directly (with light C functions). 339 */ 340 #define lua_cpcall(L,f,u) \ 341 (lua_pushcfunction(L, (f)), \ 342 lua_pushlightuserdata(L,(u)), \ 343 lua_pcall(L,1,0,0)) 344 345 346 /* 347 @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. 348 ** You can rewrite 'log10(x)' as 'log(x, 10)'. 349 */ 350 #define LUA_COMPAT_LOG10 351 352 /* 353 @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base 354 ** library. You can rewrite 'loadstring(s)' as 'load(s)'. 355 */ 356 #define LUA_COMPAT_LOADSTRING 357 358 /* 359 @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. 360 */ 361 #define LUA_COMPAT_MAXN 362 363 /* 364 @@ The following macros supply trivial compatibility for some 365 ** changes in the API. The macros themselves document how to 366 ** change your code to avoid using them. 367 */ 368 #define lua_strlen(L,i) lua_rawlen(L, (i)) 369 370 #define lua_objlen(L,i) lua_rawlen(L, (i)) 371 372 #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) 373 #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) 374 375 /* 376 @@ LUA_COMPAT_MODULE controls compatibility with previous 377 ** module functions 'module' (Lua) and 'luaL_register' (C). 378 */ 379 #define LUA_COMPAT_MODULE 380 381 #endif /* } */ 382 383 /* }================================================================== */ 384 385 386 387 /* 388 ** {================================================================== 389 ** Configuration for Numbers. 390 ** Change these definitions if no predefined LUA_REAL_* / LUA_INT_* 391 ** satisfy your needs. 392 ** =================================================================== 393 */ 394 395 #ifndef _KERNEL 396 /* 397 @@ LUA_NUMBER is the floating-point type used by Lua. 398 ** 399 @@ LUAI_UACNUMBER is the result of an 'usual argument conversion' 400 @@ over a floating number. 401 ** 402 @@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. 403 @@ LUA_NUMBER_FMT is the format for writing floats. 404 @@ lua_number2str converts a float to a string. 405 ** 406 @@ l_mathop allows the addition of an 'l' or 'f' to all math operations. 407 ** 408 @@ lua_str2number converts a decimal numeric string to a number. 409 */ 410 411 #if defined(LUA_REAL_FLOAT) /* { single float */ 412 413 #define LUA_NUMBER float 414 415 #define LUAI_UACNUMBER double 416 417 #define LUA_NUMBER_FRMLEN "" 418 #define LUA_NUMBER_FMT "%.7g" 419 420 #define l_mathop(op) op##f 421 422 #define lua_str2number(s,p) strtof((s), (p)) 423 424 425 #elif defined(LUA_REAL_LONGDOUBLE) /* }{ long double */ 426 427 #define LUA_NUMBER long double 428 429 #define LUAI_UACNUMBER long double 430 431 #define LUA_NUMBER_FRMLEN "L" 432 #define LUA_NUMBER_FMT "%.19Lg" 433 434 #define l_mathop(op) op##l 435 436 #define lua_str2number(s,p) strtold((s), (p)) 437 438 #elif defined(LUA_REAL_DOUBLE) /* }{ double */ 439 440 #define LUA_NUMBER double 441 442 #define LUAI_UACNUMBER double 443 444 #define LUA_NUMBER_FRMLEN "" 445 #define LUA_NUMBER_FMT "%.14g" 446 447 #define l_mathop(op) op 448 449 #define lua_str2number(s,p) strtod((s), (p)) 450 451 #else /* }{ */ 452 453 #error "numeric real type not defined" 454 455 #endif /* } */ 456 457 458 #define l_floor(x) (l_mathop(floor)(x)) 459 460 #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) 461 462 463 /* 464 @@ lua_numbertointeger converts a float number to an integer, or 465 ** returns 0 if float is not within the range of a lua_Integer. 466 ** (The range comparisons are tricky because of rounding. The tests 467 ** here assume a two-complement representation, where MININTEGER always 468 ** has an exact representation as a float; MAXINTEGER may not have one, 469 ** and therefore its conversion to float may have an ill-defined value.) 470 */ 471 #define lua_numbertointeger(n,p) \ 472 ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ 473 (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ 474 (*(p) = (LUA_INTEGER)(n), 1)) 475 476 477 /* 478 @@ The luai_num* macros define the primitive operations over numbers. 479 ** They should work for any size of floating numbers. 480 */ 481 482 /* the following operations need the math library */ 483 #if defined(lobject_c) || defined(lvm_c) 484 #include <math.h> 485 486 /* floor division (defined as 'floor(a/b)') */ 487 #define luai_numidiv(L,a,b) ((void)L, l_mathop(floor)(luai_numdiv(L,a,b))) 488 489 /* 490 ** module: defined as 'a - floor(a/b)*b'; the previous definition gives 491 ** NaN when 'b' is huge, but the result should be 'a'. 'fmod' gives the 492 ** result of 'a - trunc(a/b)*b', and therefore must be corrected when 493 ** 'trunc(a/b) ~= floor(a/b)'. That happens when the division has a 494 ** non-integer negative result, which is equivalent to the test below 495 */ 496 #define luai_nummod(L,a,b,m) \ 497 { (m) = l_mathop(fmod)(a,b); if ((m)*(b) < 0) (m) += (b); } 498 499 /* exponentiation */ 500 #define luai_numpow(L,a,b) ((void)L, l_mathop(pow)(a,b)) 501 502 #endif 503 #endif /*_KERNEL */ 504 505 /* these are quite standard operations */ 506 #if defined(LUA_CORE) 507 #define luai_numadd(L,a,b) ((a)+(b)) 508 #define luai_numsub(L,a,b) ((a)-(b)) 509 #define luai_nummul(L,a,b) ((a)*(b)) 510 #define luai_numdiv(L,a,b) ((a)/(b)) 511 #define luai_numunm(L,a) (-(a)) 512 #define luai_numeq(a,b) ((a)==(b)) 513 #define luai_numlt(a,b) ((a)<(b)) 514 #define luai_numle(a,b) ((a)<=(b)) 515 #define luai_numisnan(a) (!luai_numeq((a), (a))) 516 #endif 517 518 519 /* 520 @@ LUA_INTEGER is the integer type used by Lua. 521 ** 522 @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. 523 ** 524 @@ LUAI_UACINT is the result of an 'usual argument conversion' 525 @@ over a lUA_INTEGER. 526 @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. 527 @@ LUA_INTEGER_FMT is the format for writing integers. 528 @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. 529 @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. 530 @@ lua_integer2str converts an integer to a string. 531 */ 532 533 534 /* The following definitions are good for most cases here */ 535 536 #define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" 537 #define lua_integer2str(s,n) sprintf((s), LUA_INTEGER_FMT, (n)) 538 539 #define LUAI_UACINT LUA_INTEGER 540 541 /* 542 ** use LUAI_UACINT here to avoid problems with promotions (which 543 ** can turn a comparison between unsigneds into a signed comparison) 544 */ 545 #define LUA_UNSIGNED unsigned LUAI_UACINT 546 547 548 /* now the variable definitions */ 549 550 #if defined(LUA_INT_INT) /* { int */ 551 552 #define LUA_INTEGER int 553 #define LUA_INTEGER_FRMLEN "" 554 555 #define LUA_MAXINTEGER INT_MAX 556 #define LUA_MININTEGER INT_MIN 557 558 #elif defined(LUA_INT_LONG) /* }{ long */ 559 560 #define LUA_INTEGER long 561 #define LUA_INTEGER_FRMLEN "l" 562 563 #define LUA_MAXINTEGER LONG_MAX 564 #define LUA_MININTEGER LONG_MIN 565 566 #elif defined(LUA_INT_LONGLONG) /* }{ long long */ 567 568 #if defined(LLONG_MAX) /* { */ 569 /* use ISO C99 stuff */ 570 571 #define LUA_INTEGER long long 572 #define LUA_INTEGER_FRMLEN "ll" 573 574 #define LUA_MAXINTEGER LLONG_MAX 575 #define LUA_MININTEGER LLONG_MIN 576 577 #elif defined(LUA_USE_WINDOWS) /* }{ */ 578 /* in Windows, can use specific Windows types */ 579 580 #define LUA_INTEGER __int64 581 #define LUA_INTEGER_FRMLEN "I64" 582 583 #define LUA_MAXINTEGER _I64_MAX 584 #define LUA_MININTEGER _I64_MIN 585 586 #else /* }{ */ 587 588 #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ 589 or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" 590 591 #endif /* } */ 592 593 #else /* }{ */ 594 595 #error "numeric integer type not defined" 596 597 #endif /* } */ 598 599 /* }================================================================== */ 600 601 602 /* 603 ** {================================================================== 604 ** Dependencies with C99 605 ** =================================================================== 606 */ 607 608 /* 609 @@ lua_strx2number converts an hexadecimal numeric string to a number. 610 ** In C99, 'strtod' does both conversions. Otherwise, you can 611 ** leave 'lua_strx2number' undefined and Lua will provide its own 612 ** implementation. 613 */ 614 #if !defined(LUA_USE_C89) 615 #define lua_strx2number(s,p) lua_str2number(s,p) 616 #endif 617 618 619 /* 620 @@ LUA_USE_AFORMAT allows '%a'/'%A' specifiers in 'string.format' 621 ** Enable it if the C function 'printf' supports these specifiers. 622 ** (C99 demands it and Windows also supports it.) 623 */ 624 #if !defined(LUA_USE_C89) || defined(LUA_USE_WINDOWS) 625 #define LUA_USE_AFORMAT 626 #endif 627 628 629 /* 630 ** 'strtof' and 'opf' variants for math functions are not valid in 631 ** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the 632 ** availability of these variants. ('math.h' is already included in 633 ** all files that use these macros.) 634 */ 635 #if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF)) 636 #undef l_mathop /* variants not available */ 637 #undef lua_str2number 638 #define l_mathop(op) (lua_Number)op /* no variant */ 639 #define lua_str2number(s,p) ((lua_Number)strtod((s), (p))) 640 #endif 641 642 643 /* 644 @@ LUA_KCONTEXT is the type of the context ('ctx') for continuation 645 ** functions. It must be a numerical type; Lua will use 'intptr_t' if 646 ** available, otherwise it will use 'ptrdiff_t' (the nearest thing to 647 ** 'intptr_t' in C89) 648 */ 649 #define LUA_KCONTEXT ptrdiff_t 650 651 #if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ 652 __STDC_VERSION__ >= 199901L 653 #include <stdint.h> 654 #if defined (INTPTR_MAX) /* even in C99 this type is optional */ 655 #undef LUA_KCONTEXT 656 #define LUA_KCONTEXT intptr_t 657 #endif 658 #endif 659 660 /* }================================================================== */ 661 662 663 /* 664 ** {================================================================== 665 ** Macros that affect the API and must be stable (that is, must be the 666 ** same when you compile Lua and when you compile code that links to 667 ** Lua). You probably do not want/need to change them. 668 ** ===================================================================== 669 */ 670 671 /* 672 @@ LUAI_MAXSTACK limits the size of the Lua stack. 673 ** CHANGE it if you need a different limit. This limit is arbitrary; 674 ** its only purpose is to stop Lua from consuming unlimited stack 675 ** space (and to reserve some numbers for pseudo-indices). 676 */ 677 #if LUAI_BITSINT >= 32 678 #define LUAI_MAXSTACK 1000000 679 #else 680 #define LUAI_MAXSTACK 15000 681 #endif 682 683 /* reserve some space for error handling */ 684 #define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000) 685 686 687 /* 688 @@ LUA_EXTRASPACE defines the size of a raw memory area associated with 689 ** a Lua state with very fast access. 690 ** CHANGE it if you need a different size. 691 */ 692 #define LUA_EXTRASPACE (sizeof(void *)) 693 694 695 /* 696 @@ LUA_IDSIZE gives the maximum size for the description of the source 697 @@ of a function in debug information. 698 ** CHANGE it if you want a different size. 699 */ 700 #define LUA_IDSIZE 60 701 702 703 /* 704 @@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is, 705 ** strings that are internalized. (Cannot be smaller than reserved words 706 ** or tags for metamethods, as these strings must be internalized; 707 ** #("function") = 8, #("__newindex") = 10.) 708 */ 709 #define LUAI_MAXSHORTLEN 40 710 711 712 /* 713 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. 714 ** CHANGE it if it uses too much C-stack space. 715 */ 716 #define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer))) 717 718 /* }================================================================== */ 719 720 721 /* 722 @@ LUA_QL describes how error messages quote program elements. 723 ** Lua does not use these macros anymore; they are here for 724 ** compatibility only. 725 */ 726 #define LUA_QL(x) "'" x "'" 727 #define LUA_QS LUA_QL("%s") 728 729 730 731 732 /* =================================================================== */ 733 734 /* 735 ** Local configuration. You can use this space to add your redefinitions 736 ** without modifying the main part of the file. 737 */ 738 739 #ifdef __NetBSD__ 740 741 /* Integer types */ 742 #undef LUA_INTEGER 743 #undef LUA_INTEGER_FRMLEN 744 #undef LUA_UNSIGNED 745 #undef LUA_MAXUNSIGNED 746 #undef LUA_MAXINTEGER 747 #undef LUA_MININTEGER 748 749 #define LUA_INTEGER intmax_t 750 #define LUA_INTEGER_FRMLEN "j" 751 #define LUA_UNSIGNED uintmax_t 752 #define LUA_MAXUNSIGNED UINTMAX_MAX 753 #define LUA_MAXINTEGER INTMAX_MAX 754 #define LUA_MININTEGER INTMAX_MIN 755 756 /* Path */ 757 #undef LUA_ROOT 758 #undef LUA_PATH_DEFAULT 759 #undef LUA_CPATH_DEFAULT 760 761 #define LUA_ROOT "/usr/" 762 #define LUA_PATH_DEFAULT \ 763 LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ 764 LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" 765 #define LUA_CPATH_DEFAULT \ 766 LUA_CDIR"?.so;" LUA_CDIR"loadall.so" 767 768 #ifndef _KERNEL 769 770 #include <stdint.h> 771 772 #else /* _KERNEL */ 773 774 #define LUA_NUMBER LUA_INTEGER 775 #define LUA_NUMBER_FMT LUA_INTEGER_FMT 776 777 /* setjmp.h */ 778 #define LUAI_THROW(L,c) longjmp(&((c)->b)) 779 #define LUAI_TRY(L,c,a) if (setjmp(&((c)->b)) == 0) { a } 780 #define luai_jmpbuf label_t 781 782 /* time.h */ 783 #include <sys/time.h> 784 #define time(p) (time_uptime) 785 786 /* stdio.h */ 787 #define lua_writestring(s,l) printf("%s", (s)) 788 #define lua_writeline() printf("\n") 789 790 #define sprintf(s,fmt,...) snprintf(s, sizeof(s), fmt, __VA_ARGS__) 791 792 /* string.h */ 793 #define strcoll strcmp 794 795 /* stdlib.h */ 796 #define abort() panic("Lua has aborted!") 797 798 #endif /* _KERNEL */ 799 800 #endif /* __NetBSD__ */ 801 802 #endif 803 804