luaconf.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /*
  2. ** $Id: luaconf.h,v 1.176.1.2 2013/11/21 17:26:16 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 hex 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 hex 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. #define LUA_API extern
  123. #endif /* } */
  124. /* more often than not the libs go together with the core */
  125. #define LUALIB_API LUA_API
  126. #define LUAMOD_API LUALIB_API
  127. /*
  128. @@ LUAI_FUNC is a mark for all extern functions that are not to be
  129. @* exported to outside modules.
  130. @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
  131. @* that are not to be exported to outside modules (LUAI_DDEF for
  132. @* definitions and LUAI_DDEC for declarations).
  133. ** CHANGE them if you need to mark them in some special way. Elf/gcc
  134. ** (versions 3.2 and later) mark them as "hidden" to optimize access
  135. ** when Lua is compiled as a shared library. Not all elf targets support
  136. ** this attribute. Unfortunately, gcc does not offer a way to check
  137. ** whether the target offers that support, and those without support
  138. ** give a warning about it. To avoid these warnings, change to the
  139. ** default definition.
  140. */
  141. #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
  142. defined(__ELF__) /* { */
  143. #define LUAI_FUNC __attribute__((visibility("hidden"))) extern
  144. #define LUAI_DDEC LUAI_FUNC
  145. #define LUAI_DDEF /* empty */
  146. #else /* }{ */
  147. #define LUAI_FUNC extern
  148. #define LUAI_DDEC extern
  149. #define LUAI_DDEF /* empty */
  150. #endif /* } */
  151. /*
  152. @@ LUA_QL describes how error messages quote program elements.
  153. ** CHANGE it if you want a different appearance.
  154. */
  155. #define LUA_QL(x) "'" x "'"
  156. #define LUA_QS LUA_QL("%s")
  157. /*
  158. @@ LUA_IDSIZE gives the maximum size for the description of the source
  159. @* of a function in debug information.
  160. ** CHANGE it if you want a different size.
  161. */
  162. #define LUA_IDSIZE 60
  163. /*
  164. @@ luai_writestring/luai_writeline define how 'print' prints its results.
  165. ** They are only used in libraries and the stand-alone program. (The #if
  166. ** avoids including 'stdio.h' everywhere.)
  167. */
  168. #if defined(LUA_LIB) || defined(lua_c)
  169. #include <stdio.h>
  170. #define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
  171. #define luai_writeline() (luai_writestring("\n", 1), fflush(stdout))
  172. #endif
  173. /*
  174. @@ luai_writestringerror defines how to print error messages.
  175. ** (A format string with one argument is enough for Lua...)
  176. */
  177. #define luai_writestringerror(s,p) \
  178. (fprintf(stderr, (s), (p)), fflush(stderr))
  179. /*
  180. @@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is,
  181. ** strings that are internalized. (Cannot be smaller than reserved words
  182. ** or tags for metamethods, as these strings must be internalized;
  183. ** #("function") = 8, #("__newindex") = 10.)
  184. */
  185. #define LUAI_MAXSHORTLEN 40
  186. /*
  187. ** {==================================================================
  188. ** Compatibility with previous versions
  189. ** ===================================================================
  190. */
  191. /*
  192. @@ LUA_COMPAT_ALL controls all compatibility options.
  193. ** You can define it to get all options, or change specific options
  194. ** to fit your specific needs.
  195. */
  196. #if defined(LUA_COMPAT_ALL) /* { */
  197. /*
  198. @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
  199. ** You can replace it with 'table.unpack'.
  200. */
  201. #define LUA_COMPAT_UNPACK
  202. /*
  203. @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
  204. ** You can replace it with 'package.searchers'.
  205. */
  206. #define LUA_COMPAT_LOADERS
  207. /*
  208. @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
  209. ** You can call your C function directly (with light C functions).
  210. */
  211. #define lua_cpcall(L,f,u) \
  212. (lua_pushcfunction(L, (f)), \
  213. lua_pushlightuserdata(L,(u)), \
  214. lua_pcall(L,1,0,0))
  215. /*
  216. @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
  217. ** You can rewrite 'log10(x)' as 'log(x, 10)'.
  218. */
  219. #define LUA_COMPAT_LOG10
  220. /*
  221. @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
  222. ** library. You can rewrite 'loadstring(s)' as 'load(s)'.
  223. */
  224. #define LUA_COMPAT_LOADSTRING
  225. /*
  226. @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
  227. */
  228. #define LUA_COMPAT_MAXN
  229. /*
  230. @@ The following macros supply trivial compatibility for some
  231. ** changes in the API. The macros themselves document how to
  232. ** change your code to avoid using them.
  233. */
  234. #define lua_strlen(L,i) lua_rawlen(L, (i))
  235. #define lua_objlen(L,i) lua_rawlen(L, (i))
  236. #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
  237. #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
  238. /*
  239. @@ LUA_COMPAT_MODULE controls compatibility with previous
  240. ** module functions 'module' (Lua) and 'luaL_register' (C).
  241. */
  242. #define LUA_COMPAT_MODULE
  243. #endif /* } */
  244. /* }================================================================== */
  245. /*
  246. @@ LUAI_BITSINT defines the number of bits in an int.
  247. ** CHANGE here if Lua cannot automatically detect the number of bits of
  248. ** your machine. Probably you do not need to change this.
  249. */
  250. /* avoid overflows in comparison */
  251. #if INT_MAX-20 < 32760 /* { */
  252. #define LUAI_BITSINT 16
  253. #elif INT_MAX > 2147483640L /* }{ */
  254. /* int has at least 32 bits */
  255. #define LUAI_BITSINT 32
  256. #else /* }{ */
  257. #error "you must define LUA_BITSINT with number of bits in an integer"
  258. #endif /* } */
  259. /*
  260. @@ LUA_INT32 is a signed integer with exactly 32 bits.
  261. @@ LUAI_UMEM is an unsigned integer big enough to count the total
  262. @* memory used by Lua.
  263. @@ LUAI_MEM is a signed integer big enough to count the total memory
  264. @* used by Lua.
  265. ** CHANGE here if for some weird reason the default definitions are not
  266. ** good enough for your machine. Probably you do not need to change
  267. ** this.
  268. */
  269. #if LUAI_BITSINT >= 32 /* { */
  270. #define LUA_INT32 int
  271. #define LUAI_UMEM size_t
  272. #define LUAI_MEM ptrdiff_t
  273. #else /* }{ */
  274. /* 16-bit ints */
  275. #define LUA_INT32 long
  276. #define LUAI_UMEM unsigned long
  277. #define LUAI_MEM long
  278. #endif /* } */
  279. /*
  280. @@ LUAI_MAXSTACK limits the size of the Lua stack.
  281. ** CHANGE it if you need a different limit. This limit is arbitrary;
  282. ** its only purpose is to stop Lua from consuming unlimited stack
  283. ** space (and to reserve some numbers for pseudo-indices).
  284. */
  285. #if LUAI_BITSINT >= 32
  286. #define LUAI_MAXSTACK 1000000
  287. #else
  288. #define LUAI_MAXSTACK 15000
  289. #endif
  290. /* reserve some space for error handling */
  291. #define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000)
  292. /*
  293. @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
  294. ** CHANGE it if it uses too much C-stack space.
  295. */
  296. #define LUAL_BUFFERSIZE BUFSIZ
  297. /*
  298. ** {==================================================================
  299. @@ LUA_NUMBER is the type of numbers in Lua.
  300. ** CHANGE the following definitions only if you want to build Lua
  301. ** with a number type different from double. You may also need to
  302. ** change lua_number2int & lua_number2integer.
  303. ** ===================================================================
  304. */
  305. #define LUA_NUMBER_DOUBLE
  306. #define LUA_NUMBER double
  307. /*
  308. @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
  309. @* over a number.
  310. */
  311. #define LUAI_UACNUMBER double
  312. /*
  313. @@ LUA_NUMBER_SCAN is the format for reading numbers.
  314. @@ LUA_NUMBER_FMT is the format for writing numbers.
  315. @@ lua_number2str converts a number to a string.
  316. @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
  317. */
  318. #define LUA_NUMBER_SCAN "%lf"
  319. #define LUA_NUMBER_FMT "%.14g"
  320. #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
  321. #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
  322. /*
  323. @@ l_mathop allows the addition of an 'l' or 'f' to all math operations
  324. */
  325. #define l_mathop(x) (x)
  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' does 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) - l_mathop(floor)((a)/(b))*(b))
  345. #define luai_numpow(L,a,b) (l_mathop(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_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */
  374. /*
  375. ** The next definitions activate some tricks to speed up the
  376. ** conversion from doubles to integer types, mainly to LUA_UNSIGNED.
  377. **
  378. @@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a
  379. ** DirectX idiosyncrasy.
  380. **
  381. @@ LUA_IEEE754TRICK uses a trick that should work on any machine
  382. ** using IEEE754 with a 32-bit integer type.
  383. **
  384. @@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be
  385. ** defined when LUA_INTEGER is a 32-bit integer.
  386. **
  387. @@ LUA_IEEEENDIAN is the endianness of doubles in your machine
  388. ** (0 for little endian, 1 for big endian); if not defined, Lua will
  389. ** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK).
  390. **
  391. @@ LUA_NANTRICK controls the use of a trick to pack all types into
  392. ** a single double value, using NaN values to represent non-number
  393. ** values. The trick only works on 32-bit machines (ints and pointers
  394. ** are 32-bit values) with numbers represented as IEEE 754-2008 doubles
  395. ** with conventional endianess (12345678 or 87654321), in CPUs that do
  396. ** not produce signaling NaN values (all NaNs are quiet).
  397. */
  398. /* Microsoft compiler on a Pentium (32 bit) ? */
  399. #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */
  400. #define LUA_MSASMTRICK
  401. #define LUA_IEEEENDIAN 0
  402. #define LUA_NANTRICK
  403. /* pentium 32 bits? */
  404. #elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */
  405. #define LUA_IEEE754TRICK
  406. #define LUA_IEEELL
  407. #define LUA_IEEEENDIAN 0
  408. #define LUA_NANTRICK
  409. /* pentium 64 bits? */
  410. #elif defined(__x86_64) /* }{ */
  411. #define LUA_IEEE754TRICK
  412. #define LUA_IEEEENDIAN 0
  413. #elif defined(__POWERPC__) || defined(__ppc__) /* }{ */
  414. #define LUA_IEEE754TRICK
  415. #define LUA_IEEEENDIAN 1
  416. #else /* }{ */
  417. /* assume IEEE754 and a 32-bit integer type */
  418. #define LUA_IEEE754TRICK
  419. #endif /* } */
  420. #endif /* } */
  421. /* }================================================================== */
  422. /* =================================================================== */
  423. /*
  424. ** Local configuration. You can use this space to add your redefinitions
  425. ** without modifying the main part of the file.
  426. */
  427. #endif