Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

763 lines
22 KiB

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