luaconf.h 20 KB

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