luaconf.h 21 KB

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