luaconf.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. /*
  2. ** $Id: luaconf.h,v 1.150 2010/11/10 17:38:10 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_MAXN defines the function 'maxn' in the table library.
  201. */
  202. #define LUA_COMPAT_MAXN
  203. /*
  204. @@ The following macros supply trivial compatibility for some
  205. ** changes in the API. The macros themselves document how to
  206. ** change your code to avoid using them.
  207. */
  208. #define lua_strlen(L,i) lua_rawlen(L, (i))
  209. #define lua_objlen(L,i) lua_rawlen(L, (i))
  210. #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
  211. #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
  212. /*
  213. @@ LUA_COMPAT_MODULE controls compatibility with previous
  214. ** module functions 'module' (Lua) and 'luaL_register' (C).
  215. */
  216. #define LUA_COMPAT_MODULE
  217. #endif /* } */
  218. /* }================================================================== */
  219. /*
  220. @@ LUAI_BITSINT defines the number of bits in an int.
  221. ** CHANGE here if Lua cannot automatically detect the number of bits of
  222. ** your machine. Probably you do not need to change this.
  223. */
  224. /* avoid overflows in comparison */
  225. #if INT_MAX-20 < 32760 /* { */
  226. #define LUAI_BITSINT 16
  227. #elif INT_MAX > 2147483640L /* }{ */
  228. /* int has at least 32 bits */
  229. #define LUAI_BITSINT 32
  230. #else /* }{ */
  231. #error "you must define LUA_BITSINT with number of bits in an integer"
  232. #endif /* } */
  233. /*
  234. @@ LUA_INT32 is an signed integer with exactly 32 bits.
  235. @@ LUAI_UMEM is an unsigned integer big enough to count the total
  236. @* memory used by Lua.
  237. @@ LUAI_MEM is a signed integer big enough to count the total memory
  238. @* used by Lua.
  239. ** CHANGE here if for some weird reason the default definitions are not
  240. ** good enough for your machine. Probably you do not need to change
  241. ** this.
  242. */
  243. #if LUAI_BITSINT >= 32 /* { */
  244. #define LUA_INT32 int
  245. #define LUAI_UMEM size_t
  246. #define LUAI_MEM ptrdiff_t
  247. #else /* }{ */
  248. /* 16-bit ints */
  249. #define LUA_INT32 long
  250. #define LUAI_UMEM unsigned long
  251. #define LUAI_MEM long
  252. #endif /* } */
  253. /*
  254. @@ LUAI_MAXSTACK limits the size of the Lua stack.
  255. ** CHANGE it if you need a different limit. This limit is arbitrary;
  256. ** its only purpose is to stop Lua to consume unlimited stack
  257. ** space (and to reserve some numbers for pseudo-indices).
  258. */
  259. #if LUAI_BITSINT >= 32
  260. #define LUAI_MAXSTACK 1000000
  261. #else
  262. #define LUAI_MAXSTACK 15000
  263. #endif
  264. /* reserve some space for error handling */
  265. #define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000)
  266. /*
  267. @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
  268. ** CHANGE it if it uses too much C-stack space.
  269. */
  270. #define LUAL_BUFFERSIZE BUFSIZ
  271. /*
  272. ** {==================================================================
  273. @@ LUA_NUMBER is the type of numbers in Lua.
  274. ** CHANGE the following definitions only if you want to build Lua
  275. ** with a number type different from double. You may also need to
  276. ** change lua_number2int & lua_number2integer.
  277. ** ===================================================================
  278. */
  279. #define LUA_NUMBER_DOUBLE
  280. #define LUA_NUMBER double
  281. /*
  282. @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
  283. @* over a number.
  284. */
  285. #define LUAI_UACNUMBER double
  286. /*
  287. @@ LUA_NUMBER_SCAN is the format for reading numbers.
  288. @@ LUA_NUMBER_FMT is the format for writing numbers.
  289. @@ lua_number2str converts a number to a string.
  290. @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
  291. @@ lua_str2number converts a string to a number.
  292. */
  293. #define LUA_NUMBER_SCAN "%lf"
  294. #define LUA_NUMBER_FMT "%.14g"
  295. #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
  296. #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
  297. #define lua_str2number(s,p) strtod((s), (p))
  298. /*
  299. @@ The luai_num* macros define the primitive operations over numbers.
  300. */
  301. /* the following operations need the math library */
  302. #if defined(lobject_c) || defined(lvm_c) || defined(luaall_c)
  303. #include <math.h>
  304. #define luai_nummod(L,a,b) ((a) - floor((a)/(b))*(b))
  305. #define luai_numpow(L,a,b) (pow(a,b))
  306. #endif
  307. /* these are quite standard operations */
  308. #if defined(LUA_CORE)
  309. #define luai_numadd(L,a,b) ((a)+(b))
  310. #define luai_numsub(L,a,b) ((a)-(b))
  311. #define luai_nummul(L,a,b) ((a)*(b))
  312. #define luai_numdiv(L,a,b) ((a)/(b))
  313. #define luai_numunm(L,a) (-(a))
  314. #define luai_numeq(a,b) ((a)==(b))
  315. #define luai_numlt(L,a,b) ((a)<(b))
  316. #define luai_numle(L,a,b) ((a)<=(b))
  317. #define luai_numisnan(L,a) (!luai_numeq((a), (a)))
  318. #endif
  319. /*
  320. @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
  321. ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
  322. ** machines, ptrdiff_t gives a good choice between int or long.)
  323. */
  324. #define LUA_INTEGER ptrdiff_t
  325. /*
  326. @@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
  327. ** It must have at least 32 bits.
  328. */
  329. #define LUA_UNSIGNED unsigned LUA_INT32
  330. #if defined(LUA_CORE) /* { */
  331. #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */
  332. /* On a Microsoft compiler on a Pentium, use assembler to avoid clashes
  333. with a DirectX idiosyncrasy */
  334. #if defined(_MSC_VER) && defined(M_IX86) /* { */
  335. #define MS_ASMTRICK
  336. #else /* }{ */
  337. /* the next definition uses a trick that should work on any machine
  338. using IEEE754 with a 32-bit integer type */
  339. #define LUA_IEEE754TRICK
  340. /*
  341. @@ LUA_IEEEENDIAN is the endianness of doubles in your machine
  342. @@ (0 for little endian, 1 for big endian); if not defined, Lua will
  343. @@ check it dynamically.
  344. */
  345. /* check for known architectures */
  346. #if defined(__i386__) || defined(__i386) || defined(i386) || \
  347. defined (__x86_64)
  348. #define LUA_IEEEENDIAN 0
  349. #elif defined(__POWERPC__) || defined(__ppc__)
  350. #define LUA_IEEEENDIAN 1
  351. #endif
  352. #endif /* } */
  353. #endif /* } */
  354. #endif /* } */
  355. /* }================================================================== */
  356. /* =================================================================== */
  357. /*
  358. ** Local configuration. You can use this space to add your redefinitions
  359. ** without modifying the main part of the file.
  360. */
  361. #endif