luaconf.h 19 KB

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