Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

551 строка
15 KiB

  1. /*
  2. ** $Id: luaconf.h,v 1.172 2012/05/11 14:14:42 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(LUA_ANSI) && defined(__STRICT_ANSI__)
  21. #define LUA_ANSI
  22. #endif
  23. #if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE)
  24. #define LUA_WIN /* enable goodies for regular Windows platforms */
  25. #endif
  26. #if defined(LUA_WIN)
  27. #define LUA_DL_DLL
  28. #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
  29. #endif
  30. #if defined(LUA_USE_LINUX)
  31. #define LUA_USE_POSIX
  32. #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
  33. #define LUA_USE_READLINE /* needs some extra libraries */
  34. #define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */
  35. #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
  36. #define LUA_USE_LONGLONG /* assume support for long long */
  37. #endif
  38. #if defined(LUA_USE_MACOSX)
  39. #define LUA_USE_POSIX
  40. #define LUA_USE_DLOPEN /* does not need -ldl */
  41. #define LUA_USE_READLINE /* needs an extra library: -lreadline */
  42. #define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */
  43. #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
  44. #define LUA_USE_LONGLONG /* assume support for long long */
  45. #endif
  46. /*
  47. @@ LUA_USE_POSIX includes all functionality listed as X/Open System
  48. @* Interfaces Extension (XSI).
  49. ** CHANGE it (define it) if your system is XSI compatible.
  50. */
  51. #if defined(LUA_USE_POSIX)
  52. #define LUA_USE_MKSTEMP
  53. #define LUA_USE_ISATTY
  54. #define LUA_USE_POPEN
  55. #define LUA_USE_ULONGJMP
  56. #define LUA_USE_GMTIME_R
  57. #endif
  58. /*
  59. @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
  60. @* Lua libraries.
  61. @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
  62. @* C libraries.
  63. ** CHANGE them if your machine has a non-conventional directory
  64. ** hierarchy or if you want to install your libraries in
  65. ** non-conventional directories.
  66. */
  67. #if defined(_WIN32) /* { */
  68. /*
  69. ** In Windows, any exclamation mark ('!') in the path is replaced by the
  70. ** path of the directory of the executable file of the current process.
  71. */
  72. #define LUA_LDIR "!\\lua\\"
  73. #define LUA_CDIR "!\\"
  74. #define LUA_PATH_DEFAULT \
  75. LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
  76. LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua"
  77. #define LUA_CPATH_DEFAULT \
  78. LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll"
  79. #else /* }{ */
  80. #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
  81. #define LUA_ROOT "/usr/local/"
  82. #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR
  83. #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR
  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_ENV is the name of the variable that holds the current
  102. @@ environment, used to access global names.
  103. ** CHANGE it if you do not like this name.
  104. */
  105. #define LUA_ENV "_ENV"
  106. /*
  107. @@ LUA_API is a mark for all core API functions.
  108. @@ LUALIB_API is a mark for all auxiliary library functions.
  109. @@ LUAMOD_API is a mark for all standard library opening functions.
  110. ** CHANGE them if you need to define those functions in some special way.
  111. ** For instance, if you want to create one Windows DLL with the core and
  112. ** the libraries, you may want to use the following definition (define
  113. ** LUA_BUILD_AS_DLL to get it).
  114. */
  115. #if defined(LUA_BUILD_AS_DLL) /* { */
  116. #if defined(LUA_CORE) || defined(LUA_LIB) /* { */
  117. #define LUA_API __declspec(dllexport)
  118. #else /* }{ */
  119. #define LUA_API __declspec(dllimport)
  120. #endif /* } */
  121. #else /* }{ */
  122. #if __cplusplus // LOL BEGIN
  123. #define LUA_API extern "C"
  124. #else
  125. #define LUA_API extern
  126. #endif // LOL END
  127. #endif /* } */
  128. /* more often than not the libs go together with the core */
  129. #define LUALIB_API LUA_API
  130. #define LUAMOD_API LUALIB_API
  131. /*
  132. @@ LUAI_FUNC is a mark for all extern functions that are not to be
  133. @* exported to outside modules.
  134. @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
  135. @* that are not to be exported to outside modules (LUAI_DDEF for
  136. @* definitions and LUAI_DDEC for declarations).
  137. ** CHANGE them if you need to mark them in some special way. Elf/gcc
  138. ** (versions 3.2 and later) mark them as "hidden" to optimize access
  139. ** when Lua is compiled as a shared library. Not all elf targets support
  140. ** this attribute. Unfortunately, gcc does not offer a way to check
  141. ** whether the target offers that support, and those without support
  142. ** give a warning about it. To avoid these warnings, change to the
  143. ** default definition.
  144. */
  145. #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
  146. defined(__ELF__) /* { */
  147. #define LUAI_FUNC __attribute__((visibility("hidden"))) extern
  148. #define LUAI_DDEC LUAI_FUNC
  149. #define LUAI_DDEF /* empty */
  150. #else /* }{ */
  151. #define LUAI_FUNC extern
  152. #define LUAI_DDEC extern
  153. #define LUAI_DDEF /* empty */
  154. #endif /* } */
  155. /*
  156. @@ LUA_QL describes how error messages quote program elements.
  157. ** CHANGE it if you want a different appearance.
  158. */
  159. #define LUA_QL(x) "'" x "'"
  160. #define LUA_QS LUA_QL("%s")
  161. /*
  162. @@ LUA_IDSIZE gives the maximum size for the description of the source
  163. @* of a function in debug information.
  164. ** CHANGE it if you want a different size.
  165. */
  166. #define LUA_IDSIZE 60
  167. /*
  168. @@ luai_writestring/luai_writeline define how 'print' prints its results.
  169. ** They are only used in libraries and the stand-alone program. (The #if
  170. ** avoids including 'stdio.h' everywhere.)
  171. */
  172. #if defined(LUA_LIB) || defined(lua_c)
  173. #include <stdio.h>
  174. #define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
  175. #define luai_writeline() (luai_writestring("\n", 1), fflush(stdout))
  176. #endif
  177. /*
  178. @@ luai_writestringerror defines how to print error messages.
  179. ** (A format string with one argument is enough for Lua...)
  180. */
  181. #define luai_writestringerror(s,p) \
  182. (fprintf(stderr, (s), (p)), fflush(stderr))
  183. /*
  184. @@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is,
  185. ** strings that are internalized. (Cannot be smaller than reserved words
  186. ** or tags for metamethods, as these strings must be internalized;
  187. ** #("function") = 8, #("__newindex") = 10.)
  188. */
  189. #define LUAI_MAXSHORTLEN 40
  190. /*
  191. ** {==================================================================
  192. ** Compatibility with previous versions
  193. ** ===================================================================
  194. */
  195. /*
  196. @@ LUA_COMPAT_ALL controls all compatibility options.
  197. ** You can define it to get all options, or change specific options
  198. ** to fit your specific needs.
  199. */
  200. #if defined(LUA_COMPAT_ALL) /* { */
  201. /*
  202. @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
  203. ** You can replace it with 'table.unpack'.
  204. */
  205. #define LUA_COMPAT_UNPACK
  206. /*
  207. @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
  208. ** You can replace it with 'package.searchers'.
  209. */
  210. #define LUA_COMPAT_LOADERS
  211. /*
  212. @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
  213. ** You can call your C function directly (with light C functions).
  214. */
  215. #define lua_cpcall(L,f,u) \
  216. (lua_pushcfunction(L, (f)), \
  217. lua_pushlightuserdata(L,(u)), \
  218. lua_pcall(L,1,0,0))
  219. /*
  220. @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
  221. ** You can rewrite 'log10(x)' as 'log(x, 10)'.
  222. */
  223. #define LUA_COMPAT_LOG10
  224. /*
  225. @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
  226. ** library. You can rewrite 'loadstring(s)' as 'load(s)'.
  227. */
  228. #define LUA_COMPAT_LOADSTRING
  229. /*
  230. @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
  231. */
  232. #define LUA_COMPAT_MAXN
  233. /*
  234. @@ The following macros supply trivial compatibility for some
  235. ** changes in the API. The macros themselves document how to
  236. ** change your code to avoid using them.
  237. */
  238. #define lua_strlen(L,i) lua_rawlen(L, (i))
  239. #define lua_objlen(L,i) lua_rawlen(L, (i))
  240. #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
  241. #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
  242. /*
  243. @@ LUA_COMPAT_MODULE controls compatibility with previous
  244. ** module functions 'module' (Lua) and 'luaL_register' (C).
  245. */
  246. #define LUA_COMPAT_MODULE
  247. #endif /* } */
  248. /* }================================================================== */
  249. /*
  250. @@ LUAI_BITSINT defines the number of bits in an int.
  251. ** CHANGE here if Lua cannot automatically detect the number of bits of
  252. ** your machine. Probably you do not need to change this.
  253. */
  254. /* avoid overflows in comparison */
  255. #if INT_MAX-20 < 32760 /* { */
  256. #define LUAI_BITSINT 16
  257. #elif INT_MAX > 2147483640L /* }{ */
  258. /* int has at least 32 bits */
  259. #define LUAI_BITSINT 32
  260. #else /* }{ */
  261. #error "you must define LUA_BITSINT with number of bits in an integer"
  262. #endif /* } */
  263. /*
  264. @@ LUA_INT32 is an signed integer with exactly 32 bits.
  265. @@ LUAI_UMEM is an unsigned integer big enough to count the total
  266. @* memory used by Lua.
  267. @@ LUAI_MEM is a signed integer big enough to count the total memory
  268. @* used by Lua.
  269. ** CHANGE here if for some weird reason the default definitions are not
  270. ** good enough for your machine. Probably you do not need to change
  271. ** this.
  272. */
  273. #if LUAI_BITSINT >= 32 /* { */
  274. #define LUA_INT32 int
  275. #define LUAI_UMEM size_t
  276. #define LUAI_MEM ptrdiff_t
  277. #else /* }{ */
  278. /* 16-bit ints */
  279. #define LUA_INT32 long
  280. #define LUAI_UMEM unsigned long
  281. #define LUAI_MEM long
  282. #endif /* } */
  283. /*
  284. @@ LUAI_MAXSTACK limits the size of the Lua stack.
  285. ** CHANGE it if you need a different limit. This limit is arbitrary;
  286. ** its only purpose is to stop Lua to consume unlimited stack
  287. ** space (and to reserve some numbers for pseudo-indices).
  288. */
  289. #if LUAI_BITSINT >= 32
  290. #define LUAI_MAXSTACK 1000000
  291. #else
  292. #define LUAI_MAXSTACK 15000
  293. #endif
  294. /* reserve some space for error handling */
  295. #define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000)
  296. /*
  297. @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
  298. ** CHANGE it if it uses too much C-stack space.
  299. */
  300. #define LUAL_BUFFERSIZE BUFSIZ
  301. /*
  302. ** {==================================================================
  303. @@ LUA_NUMBER is the type of numbers in Lua.
  304. ** CHANGE the following definitions only if you want to build Lua
  305. ** with a number type different from double. You may also need to
  306. ** change lua_number2int & lua_number2integer.
  307. ** ===================================================================
  308. */
  309. #define LUA_NUMBER_DOUBLE
  310. #define LUA_NUMBER double
  311. /*
  312. @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
  313. @* over a number.
  314. */
  315. #define LUAI_UACNUMBER double
  316. /*
  317. @@ LUA_NUMBER_SCAN is the format for reading numbers.
  318. @@ LUA_NUMBER_FMT is the format for writing numbers.
  319. @@ lua_number2str converts a number to a string.
  320. @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
  321. */
  322. #define LUA_NUMBER_SCAN "%lf"
  323. #define LUA_NUMBER_FMT "%.14g"
  324. #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
  325. #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
  326. /*
  327. @@ lua_str2number converts a decimal numeric string to a number.
  328. @@ lua_strx2number converts an hexadecimal numeric string to a number.
  329. ** In C99, 'strtod' do both conversions. C89, however, has no function
  330. ** to convert floating hexadecimal strings to numbers. For these
  331. ** systems, you can leave 'lua_strx2number' undefined and Lua will
  332. ** provide its own implementation.
  333. */
  334. #define lua_str2number(s,p) strtod((s), (p))
  335. #if defined(LUA_USE_STRTODHEX)
  336. #define lua_strx2number(s,p) strtod((s), (p))
  337. #endif
  338. /*
  339. @@ The luai_num* macros define the primitive operations over numbers.
  340. */
  341. /* the following operations need the math library */
  342. #if defined(lobject_c) || defined(lvm_c)
  343. #include <math.h>
  344. #define luai_nummod(L,a,b) ((a) - floor((a)/(b))*(b))
  345. #define luai_numpow(L,a,b) (pow(a,b))
  346. #endif
  347. /* these are quite standard operations */
  348. #if defined(LUA_CORE)
  349. #define luai_numadd(L,a,b) ((a)+(b))
  350. #define luai_numsub(L,a,b) ((a)-(b))
  351. #define luai_nummul(L,a,b) ((a)*(b))
  352. #define luai_numdiv(L,a,b) ((a)/(b))
  353. #define luai_numunm(L,a) (-(a))
  354. #define luai_numeq(a,b) ((a)==(b))
  355. #define luai_numlt(L,a,b) ((a)<(b))
  356. #define luai_numle(L,a,b) ((a)<=(b))
  357. #define luai_numisnan(L,a) (!luai_numeq((a), (a)))
  358. #endif
  359. /*
  360. @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
  361. ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
  362. ** machines, ptrdiff_t gives a good choice between int or long.)
  363. */
  364. #define LUA_INTEGER ptrdiff_t
  365. /*
  366. @@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
  367. ** It must have at least 32 bits.
  368. */
  369. #define LUA_UNSIGNED unsigned LUA_INT32
  370. /*
  371. ** Some tricks with doubles
  372. */
  373. #if defined(LUA_CORE) && \
  374. defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */
  375. /*
  376. ** The next definitions activate some tricks to speed up the
  377. ** conversion from doubles to integer types, mainly to LUA_UNSIGNED.
  378. **
  379. @@ MS_ASMTRICK uses Microsoft assembler to avoid clashes with a
  380. ** DirectX idiosyncrasy.
  381. **
  382. @@ LUA_IEEE754TRICK uses a trick that should work on any machine
  383. ** using IEEE754 with a 32-bit integer type.
  384. **
  385. @@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be
  386. ** defined when LUA_INTEGER is a 32-bit integer.
  387. **
  388. @@ LUA_IEEEENDIAN is the endianness of doubles in your machine
  389. ** (0 for little endian, 1 for big endian); if not defined, Lua will
  390. ** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK).
  391. **
  392. @@ LUA_NANTRICK controls the use of a trick to pack all types into
  393. ** a single double value, using NaN values to represent non-number
  394. ** values. The trick only works on 32-bit machines (ints and pointers
  395. ** are 32-bit values) with numbers represented as IEEE 754-2008 doubles
  396. ** with conventional endianess (12345678 or 87654321), in CPUs that do
  397. ** not produce signaling NaN values (all NaNs are quiet).
  398. */
  399. /* Microsoft compiler on a Pentium (32 bit) ? */
  400. #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */
  401. #define MS_ASMTRICK
  402. #define LUA_IEEEENDIAN 0
  403. #define LUA_NANTRICK
  404. /* pentium 32 bits? */
  405. #elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */
  406. #define LUA_IEEE754TRICK
  407. #define LUA_IEEELL
  408. #define LUA_IEEEENDIAN 0
  409. #define LUA_NANTRICK
  410. /* pentium 64 bits? */
  411. #elif defined(__x86_64) /* }{ */
  412. #define LUA_IEEE754TRICK
  413. #define LUA_IEEEENDIAN 0
  414. #elif defined(__POWERPC__) || defined(__ppc__) /* }{ */
  415. #define LUA_IEEE754TRICK
  416. #define LUA_IEEEENDIAN 1
  417. #else /* }{ */
  418. /* assume IEEE754 and a 32-bit integer type */
  419. #define LUA_IEEE754TRICK
  420. #endif /* } */
  421. #endif /* } */
  422. /* }================================================================== */
  423. /* =================================================================== */
  424. /*
  425. ** Local configuration. You can use this space to add your redefinitions
  426. ** without modifying the main part of the file.
  427. */
  428. #endif