luaconf.h 20 KB

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