luaconf.h 21 KB

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