Counter Strike : Global Offensive Source Code
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.

762 lines
22 KiB

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