luaconf.h 22 KB

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