luaconf.h 12 KB

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