luaconf.h 21 KB

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