luaconf.h 19 KB

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