luaconf.h 20 KB

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