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