luaconf.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. /*
  2. ** $Id: luaconf.h,v 1.250 2015/04/03 18:41:57 roberto Exp roberto $
  3. ** Configuration file for Lua
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef luaconf_h
  7. #define luaconf_h
  8. #include <limits.h>
  9. #include <stddef.h>
  10. /*
  11. ** ===================================================================
  12. ** Search for "@@" to find all configurable definitions.
  13. ** ===================================================================
  14. */
  15. /*
  16. ** {====================================================================
  17. ** System Configuration: macros to adapt (if needed) Lua to some
  18. ** particular platform, for instance compiling it with 32-bit numbers or
  19. ** restricting it to C89.
  20. ** =====================================================================
  21. */
  22. /*
  23. @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You
  24. ** can also define LUA_32BITS in the make file, but changing here you
  25. ** ensure that all software connected to Lua will be compiled with the
  26. ** same configuration.
  27. */
  28. /* #define LUA_32BITS */
  29. /*
  30. @@ LUA_USE_C89 controls the use of non-ISO-C89 features.
  31. ** Define it if you want Lua to avoid the use of a few C99 features
  32. ** or Windows-specific features on Windows.
  33. */
  34. /* #define LUA_USE_C89 */
  35. /*
  36. ** By default, Lua on Windows use (some) specific Windows features
  37. */
  38. #if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE)
  39. #define LUA_USE_WINDOWS /* enable goodies for regular Windows */
  40. #endif
  41. #if defined(LUA_USE_WINDOWS)
  42. #define LUA_DL_DLL /* enable support for DLL */
  43. #define LUA_USE_C89 /* broadly, Windows is C89 */
  44. #endif
  45. #if defined(LUA_USE_LINUX)
  46. #define LUA_USE_POSIX
  47. #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
  48. #define LUA_USE_READLINE /* needs some extra libraries */
  49. #endif
  50. #if defined(LUA_USE_MACOSX)
  51. #define LUA_USE_POSIX
  52. #define LUA_USE_DLOPEN /* MacOS does not need -ldl */
  53. #define LUA_USE_READLINE /* needs an extra library: -lreadline */
  54. #endif
  55. /*
  56. @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for
  57. ** C89 ('long' and 'double'); Windows always has '__int64', so it does
  58. ** not need to use this case.
  59. */
  60. #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS)
  61. #define LUA_C89_NUMBERS
  62. #endif
  63. /*
  64. @@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'.
  65. */
  66. /* avoid undefined shifts */
  67. #if ((INT_MAX >> 15) >> 15) >= 1
  68. #define LUAI_BITSINT 32
  69. #else
  70. /* 'int' always must have at least 16 bits */
  71. #define LUAI_BITSINT 16
  72. #endif
  73. /*
  74. @@ LUA_INT_TYPE defines the type for Lua integers.
  75. @@ LUA_FLOAT_TYPE defines the type for Lua floats.
  76. ** Lua should work fine with any mix of these options (if supported
  77. ** by your C compiler). The usual configurations are 64-bit integers
  78. ** and 'double' (the default), 32-bit integers and 'float' (for
  79. ** restricted platforms), and 'long'/'double' (for C compilers not
  80. ** compliant with C99, which may not have support for 'long long').
  81. */
  82. /* predefined options for LUA_INT_TYPE */
  83. #define LUA_INT_INT 1
  84. #define LUA_INT_LONG 2
  85. #define LUA_INT_LONGLONG 3
  86. /* predefined options for LUA_FLOAT_TYPE */
  87. #define LUA_FLOAT_FLOAT 1
  88. #define LUA_FLOAT_DOUBLE 2
  89. #define LUA_FLOAT_LONGDOUBLE 3
  90. #if defined(LUA_32BITS) /* { */
  91. /*
  92. ** 32-bit integers and 'float'
  93. */
  94. #if LUAI_BITSINT >= 32 /* use 'int' if big enough */
  95. #define LUA_INT_TYPE LUA_INT_INT
  96. #else /* otherwise use 'long' */
  97. #define LUA_INT_TYPE LUA_INT_LONG
  98. #endif
  99. #define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT
  100. #elif defined(LUA_C89_NUMBERS) /* }{ */
  101. /*
  102. ** largest types available for C89 ('long' and 'double')
  103. */
  104. #define LUA_INT_TYPE LUA_INT_LONG
  105. #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE
  106. #endif /* } */
  107. /*
  108. ** default configuration for 64-bit Lua ('long long' and 'double')
  109. */
  110. #if !defined(LUA_INT_TYPE)
  111. #define LUA_INT_TYPE LUA_INT_LONGLONG
  112. #endif
  113. #if !defined(LUA_FLOAT_TYPE)
  114. #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE
  115. #endif /* } */
  116. /* }================================================================== */
  117. /*
  118. ** {==================================================================
  119. ** Configuration for Paths.
  120. ** ===================================================================
  121. */
  122. /*
  123. @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
  124. ** Lua libraries.
  125. @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
  126. ** C libraries.
  127. ** CHANGE them if your machine has a non-conventional directory
  128. ** hierarchy or if you want to install your libraries in
  129. ** non-conventional directories.
  130. */
  131. #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
  132. #if defined(_WIN32) /* { */
  133. /*
  134. ** In Windows, any exclamation mark ('!') in the path is replaced by the
  135. ** path of the directory of the executable file of the current process.
  136. */
  137. #define LUA_LDIR "!\\lua\\"
  138. #define LUA_CDIR "!\\"
  139. #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\"
  140. #define LUA_PATH_DEFAULT \
  141. LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
  142. LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \
  143. LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \
  144. ".\\?.lua;" ".\\?\\init.lua"
  145. #define LUA_CPATH_DEFAULT \
  146. LUA_CDIR"?.dll;" \
  147. LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
  148. LUA_CDIR"loadall.dll;" ".\\?.dll"
  149. #else /* }{ */
  150. #define LUA_ROOT "/usr/local/"
  151. #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/"
  152. #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/"
  153. #define LUA_PATH_DEFAULT \
  154. LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
  155. LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
  156. "./?.lua;" "./?/init.lua"
  157. #define LUA_CPATH_DEFAULT \
  158. LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
  159. #endif /* } */
  160. /*
  161. @@ LUA_DIRSEP is the directory separator (for submodules).
  162. ** CHANGE it if your machine does not use "/" as the directory separator
  163. ** and is not Windows. (On Windows Lua automatically uses "\".)
  164. */
  165. #if defined(_WIN32)
  166. #define LUA_DIRSEP "\\"
  167. #else
  168. #define LUA_DIRSEP "/"
  169. #endif
  170. /* }================================================================== */
  171. /*
  172. ** {==================================================================
  173. ** Marks for exported symbols in the C code
  174. ** ===================================================================
  175. */
  176. /*
  177. @@ LUA_API is a mark for all core API functions.
  178. @@ LUALIB_API is a mark for all auxiliary library functions.
  179. @@ LUAMOD_API is a mark for all standard library opening functions.
  180. ** CHANGE them if you need to define those functions in some special way.
  181. ** For instance, if you want to create one Windows DLL with the core and
  182. ** the libraries, you may want to use the following definition (define
  183. ** LUA_BUILD_AS_DLL to get it).
  184. */
  185. #if defined(LUA_BUILD_AS_DLL) /* { */
  186. #if defined(LUA_CORE) || defined(LUA_LIB) /* { */
  187. #define LUA_API __declspec(dllexport)
  188. #else /* }{ */
  189. #define LUA_API __declspec(dllimport)
  190. #endif /* } */
  191. #else /* }{ */
  192. #define LUA_API extern
  193. #endif /* } */
  194. /* more often than not the libs go together with the core */
  195. #define LUALIB_API LUA_API
  196. #define LUAMOD_API LUALIB_API
  197. /*
  198. @@ LUAI_FUNC is a mark for all extern functions that are not to be
  199. ** exported to outside modules.
  200. @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
  201. ** that are not to be exported to outside modules (LUAI_DDEF for
  202. ** definitions and LUAI_DDEC for declarations).
  203. ** CHANGE them if you need to mark them in some special way. Elf/gcc
  204. ** (versions 3.2 and later) mark them as "hidden" to optimize access
  205. ** when Lua is compiled as a shared library. Not all elf targets support
  206. ** this attribute. Unfortunately, gcc does not offer a way to check
  207. ** whether the target offers that support, and those without support
  208. ** give a warning about it. To avoid these warnings, change to the
  209. ** default definition.
  210. */
  211. #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
  212. defined(__ELF__) /* { */
  213. #define LUAI_FUNC __attribute__((visibility("hidden"))) extern
  214. #else /* }{ */
  215. #define LUAI_FUNC extern
  216. #endif /* } */
  217. #define LUAI_DDEC LUAI_FUNC
  218. #define LUAI_DDEF /* empty */
  219. /* }================================================================== */
  220. /*
  221. ** {==================================================================
  222. ** Compatibility with previous versions
  223. ** ===================================================================
  224. */
  225. /*
  226. @@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2.
  227. @@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1.
  228. ** You can define it to get all options, or change specific options
  229. ** to fit your specific needs.
  230. */
  231. #if defined(LUA_COMPAT_5_2) /* { */
  232. /*
  233. @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated
  234. ** functions in the mathematical library.
  235. */
  236. #define LUA_COMPAT_MATHLIB
  237. /*
  238. @@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'.
  239. */
  240. #define LUA_COMPAT_BITLIB
  241. /*
  242. @@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod.
  243. */
  244. #define LUA_COMPAT_IPAIRS
  245. /*
  246. @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for
  247. ** manipulating other integer types (lua_pushunsigned, lua_tounsigned,
  248. ** luaL_checkint, luaL_checklong, etc.)
  249. */
  250. #define LUA_COMPAT_APIINTCASTS
  251. #endif /* } */
  252. #if defined(LUA_COMPAT_5_1) /* { */
  253. /* Incompatibilities from 5.2 -> 5.3 */
  254. #define LUA_COMPAT_MATHLIB
  255. #define LUA_COMPAT_APIINTCASTS
  256. /*
  257. @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
  258. ** You can replace it with 'table.unpack'.
  259. */
  260. #define LUA_COMPAT_UNPACK
  261. /*
  262. @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
  263. ** You can replace it with 'package.searchers'.
  264. */
  265. #define LUA_COMPAT_LOADERS
  266. /*
  267. @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
  268. ** You can call your C function directly (with light C functions).
  269. */
  270. #define lua_cpcall(L,f,u) \
  271. (lua_pushcfunction(L, (f)), \
  272. lua_pushlightuserdata(L,(u)), \
  273. lua_pcall(L,1,0,0))
  274. /*
  275. @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
  276. ** You can rewrite 'log10(x)' as 'log(x, 10)'.
  277. */
  278. #define LUA_COMPAT_LOG10
  279. /*
  280. @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
  281. ** library. You can rewrite 'loadstring(s)' as 'load(s)'.
  282. */
  283. #define LUA_COMPAT_LOADSTRING
  284. /*
  285. @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
  286. */
  287. #define LUA_COMPAT_MAXN
  288. /*
  289. @@ The following macros supply trivial compatibility for some
  290. ** changes in the API. The macros themselves document how to
  291. ** change your code to avoid using them.
  292. */
  293. #define lua_strlen(L,i) lua_rawlen(L, (i))
  294. #define lua_objlen(L,i) lua_rawlen(L, (i))
  295. #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
  296. #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
  297. /*
  298. @@ LUA_COMPAT_MODULE controls compatibility with previous
  299. ** module functions 'module' (Lua) and 'luaL_register' (C).
  300. */
  301. #define LUA_COMPAT_MODULE
  302. #endif /* } */
  303. /*
  304. @@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a
  305. @@ a float mark ('.0').
  306. ** This macro is not on by default even in compatibility mode,
  307. ** because this is not really an incompatibility.
  308. */
  309. /* #define LUA_COMPAT_FLOATSTRING */
  310. /* }================================================================== */
  311. /*
  312. ** {==================================================================
  313. ** Configuration for Numbers.
  314. ** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_*
  315. ** satisfy your needs.
  316. ** ===================================================================
  317. */
  318. /*
  319. @@ LUA_NUMBER is the floating-point type used by Lua.
  320. @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
  321. @@ over a floating number.
  322. @@ l_mathlim(x) corrects limit name 'x' to the proper float type
  323. ** by prefixing it with one of FLT/DBL/LDBL.
  324. @@ LUA_NUMBER_FRMLEN is the length modifier for writing floats.
  325. @@ LUA_NUMBER_FMT is the format for writing floats.
  326. @@ lua_number2str converts a float to a string.
  327. @@ l_mathop allows the addition of an 'l' or 'f' to all math operations.
  328. @@ lua_str2number converts a decimal numeric string to a number.
  329. */
  330. #if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */
  331. #define LUA_NUMBER float
  332. #define l_mathlim(n) (FLT_##n)
  333. #define LUAI_UACNUMBER double
  334. #define LUA_NUMBER_FRMLEN ""
  335. #define LUA_NUMBER_FMT "%.7g"
  336. #define l_mathop(op) op##f
  337. #define lua_str2number(s,p) strtof((s), (p))
  338. #elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */
  339. #define LUA_NUMBER long double
  340. #define l_mathlim(n) (LDBL_##n)
  341. #define LUAI_UACNUMBER long double
  342. #define LUA_NUMBER_FRMLEN "L"
  343. #define LUA_NUMBER_FMT "%.19Lg"
  344. #define l_mathop(op) op##l
  345. #define lua_str2number(s,p) strtold((s), (p))
  346. #elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */
  347. #define LUA_NUMBER double
  348. #define l_mathlim(n) (DBL_##n)
  349. #define LUAI_UACNUMBER double
  350. #define LUA_NUMBER_FRMLEN ""
  351. #define LUA_NUMBER_FMT "%.14g"
  352. #define l_mathop(op) op
  353. #define lua_str2number(s,p) strtod((s), (p))
  354. #else /* }{ */
  355. #error "numeric float type not defined"
  356. #endif /* } */
  357. #define l_floor(x) (l_mathop(floor)(x))
  358. #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
  359. /*
  360. @@ lua_numbertointeger converts a float number to an integer, or
  361. ** returns 0 if float is not within the range of a lua_Integer.
  362. ** (The range comparisons are tricky because of rounding. The tests
  363. ** here assume a two-complement representation, where MININTEGER always
  364. ** has an exact representation as a float; MAXINTEGER may not have one,
  365. ** and therefore its conversion to float may have an ill-defined value.)
  366. */
  367. #define lua_numbertointeger(n,p) \
  368. ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
  369. (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
  370. (*(p) = (LUA_INTEGER)(n), 1))
  371. /*
  372. @@ LUA_INTEGER is the integer type used by Lua.
  373. **
  374. @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
  375. **
  376. @@ LUAI_UACINT is the result of an 'usual argument conversion'
  377. @@ over a lUA_INTEGER.
  378. @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
  379. @@ LUA_INTEGER_FMT is the format for writing integers.
  380. @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
  381. @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
  382. @@ lua_integer2str converts an integer to a string.
  383. */
  384. /* The following definitions are good for most cases here */
  385. #define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
  386. #define lua_integer2str(s,n) sprintf((s), LUA_INTEGER_FMT, (n))
  387. #define LUAI_UACINT LUA_INTEGER
  388. /*
  389. ** use LUAI_UACINT here to avoid problems with promotions (which
  390. ** can turn a comparison between unsigneds into a signed comparison)
  391. */
  392. #define LUA_UNSIGNED unsigned LUAI_UACINT
  393. /* now the variable definitions */
  394. #if LUA_INT_TYPE == LUA_INT_INT /* { int */
  395. #define LUA_INTEGER int
  396. #define LUA_INTEGER_FRMLEN ""
  397. #define LUA_MAXINTEGER INT_MAX
  398. #define LUA_MININTEGER INT_MIN
  399. #elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */
  400. #define LUA_INTEGER long
  401. #define LUA_INTEGER_FRMLEN "l"
  402. #define LUA_MAXINTEGER LONG_MAX
  403. #define LUA_MININTEGER LONG_MIN
  404. #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */
  405. #if defined(LLONG_MAX) /* { */
  406. /* use ISO C99 stuff */
  407. #define LUA_INTEGER long long
  408. #define LUA_INTEGER_FRMLEN "ll"
  409. #define LUA_MAXINTEGER LLONG_MAX
  410. #define LUA_MININTEGER LLONG_MIN
  411. #elif defined(LUA_USE_WINDOWS) /* }{ */
  412. /* in Windows, can use specific Windows types */
  413. #define LUA_INTEGER __int64
  414. #define LUA_INTEGER_FRMLEN "I64"
  415. #define LUA_MAXINTEGER _I64_MAX
  416. #define LUA_MININTEGER _I64_MIN
  417. #else /* }{ */
  418. #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \
  419. or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)"
  420. #endif /* } */
  421. #else /* }{ */
  422. #error "numeric integer type not defined"
  423. #endif /* } */
  424. /* }================================================================== */
  425. /*
  426. ** {==================================================================
  427. ** Dependencies with C99 and other C details
  428. ** ===================================================================
  429. */
  430. /*
  431. @@ lua_strx2number converts an hexadecimal numeric string to a number.
  432. ** In C99, 'strtod' does that conversion. Otherwise, you can
  433. ** leave 'lua_strx2number' undefined and Lua will provide its own
  434. ** implementation.
  435. */
  436. #if !defined(LUA_USE_C89)
  437. #define lua_strx2number(s,p) lua_str2number(s,p)
  438. #endif
  439. /*
  440. @@ lua_number2strx converts a float to an hexadecimal numeric string.
  441. ** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that.
  442. ** Otherwise, you can leave 'lua_number2strx' undefined and Lua will
  443. ** provide its own implementation.
  444. */
  445. #if !defined(LUA_USE_C89)
  446. #define lua_number2strx(L,b,f,n) sprintf(b,f,n)
  447. #endif
  448. /*
  449. ** 'strtof' and 'opf' variants for math functions are not valid in
  450. ** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the
  451. ** availability of these variants. ('math.h' is already included in
  452. ** all files that use these macros.)
  453. */
  454. #if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF))
  455. #undef l_mathop /* variants not available */
  456. #undef lua_str2number
  457. #define l_mathop(op) (lua_Number)op /* no variant */
  458. #define lua_str2number(s,p) ((lua_Number)strtod((s), (p)))
  459. #endif
  460. /*
  461. @@ LUA_KCONTEXT is the type of the context ('ctx') for continuation
  462. ** functions. It must be a numerical type; Lua will use 'intptr_t' if
  463. ** available, otherwise it will use 'ptrdiff_t' (the nearest thing to
  464. ** 'intptr_t' in C89)
  465. */
  466. #define LUA_KCONTEXT ptrdiff_t
  467. #if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
  468. __STDC_VERSION__ >= 199901L
  469. #include <stdint.h>
  470. #if defined(INTPTR_MAX) /* even in C99 this type is optional */
  471. #undef LUA_KCONTEXT
  472. #define LUA_KCONTEXT intptr_t
  473. #endif
  474. #endif
  475. /*
  476. @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point).
  477. ** Change that if you do not want to use C locales. (Code using this
  478. ** macro must include header 'locale.h'.)
  479. */
  480. #if !defined(lua_getlocaledecpoint)
  481. #define lua_getlocaledecpoint() (localeconv()->decimal_point[0])
  482. #endif
  483. /* }================================================================== */
  484. /*
  485. ** {==================================================================
  486. ** Language Variations
  487. ** =====================================================================
  488. */
  489. /*
  490. @@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some
  491. ** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from
  492. ** numbers to strings. Define LUA_NOCVTS2N to turn off automatic
  493. ** coercion from strings to numbers.
  494. */
  495. /* #define LUA_NOCVTN2S */
  496. /* #define LUA_NOCVTS2N */
  497. /*
  498. @@ LUA_USE_APICHECK turns on several consistency checks on the C API.
  499. ** Define it as a help when debugging C code.
  500. */
  501. #if defined(LUA_USE_APICHECK)
  502. #include <assert.h>
  503. #define luai_apicheck(l,e) assert(e)
  504. #endif
  505. /* }================================================================== */
  506. /*
  507. ** {==================================================================
  508. ** Macros that affect the API and must be stable (that is, must be the
  509. ** same when you compile Lua and when you compile code that links to
  510. ** Lua). You probably do not want/need to change them.
  511. ** =====================================================================
  512. */
  513. /*
  514. @@ LUAI_MAXSTACK limits the size of the Lua stack.
  515. ** CHANGE it if you need a different limit. This limit is arbitrary;
  516. ** its only purpose is to stop Lua from consuming unlimited stack
  517. ** space (and to reserve some numbers for pseudo-indices).
  518. */
  519. #if LUAI_BITSINT >= 32
  520. #define LUAI_MAXSTACK 1000000
  521. #else
  522. #define LUAI_MAXSTACK 15000
  523. #endif
  524. /*
  525. @@ LUA_EXTRASPACE defines the size of a raw memory area associated with
  526. ** a Lua state with very fast access.
  527. ** CHANGE it if you need a different size.
  528. */
  529. #define LUA_EXTRASPACE (sizeof(void *))
  530. /*
  531. @@ LUA_IDSIZE gives the maximum size for the description of the source
  532. @@ of a function in debug information.
  533. ** CHANGE it if you want a different size.
  534. */
  535. #define LUA_IDSIZE 60
  536. /*
  537. @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
  538. ** CHANGE it if it uses too much C-stack space. (For long double,
  539. ** 'string.format("%.99f", 1e4932)' needs ~5030 bytes, so a
  540. ** smaller buffer would force a memory allocation for each call to
  541. ** 'string.format'.)
  542. */
  543. #if defined(LUA_FLOAT_LONGDOUBLE)
  544. #define LUAL_BUFFERSIZE 8192
  545. #else
  546. #define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer)))
  547. #endif
  548. /* }================================================================== */
  549. /*
  550. @@ LUA_QL describes how error messages quote program elements.
  551. ** Lua does not use these macros anymore; they are here for
  552. ** compatibility only.
  553. */
  554. #define LUA_QL(x) "'" x "'"
  555. #define LUA_QS LUA_QL("%s")
  556. /* =================================================================== */
  557. /*
  558. ** Local configuration. You can use this space to add your redefinitions
  559. ** without modifying the main part of the file.
  560. */
  561. #endif