luaconf.h 20 KB

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