2
0

luaconf.h 23 KB

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