luaconf.h 13 KB

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