luaconf.h 20 KB

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