luaconf.h 20 KB

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