2 ** $Id: luaconf.h,v 1.176.1.1 2013/04/12 18:48:47 roberto Exp $
3 ** Configuration file for Lua
4 ** See Copyright Notice in lua.h
16 ** ==================================================================
17 ** Search for "@@" to find all configurable definitions.
18 ** ===================================================================
23 @@ LUA_ANSI controls the use of non-ansi features.
24 ** CHANGE it (define it) if you want Lua to avoid the use of any
25 ** non-ansi feature or library.
27 #if !defined(LUA_ANSI) && defined(__STRICT_ANSI__)
32 #if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE)
33 #define LUA_WIN /* enable goodies for regular Windows platforms */
38 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
43 #if defined(LUA_USE_LINUX)
45 #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
46 #define LUA_USE_READLINE /* needs some extra libraries */
47 #define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
48 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
49 #define LUA_USE_LONGLONG /* assume support for long long */
52 #if defined(LUA_USE_MACOSX)
54 #define LUA_USE_DLOPEN /* does not need -ldl */
55 #define LUA_USE_READLINE /* needs an extra library: -lreadline */
56 #define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
57 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
58 #define LUA_USE_LONGLONG /* assume support for long long */
64 @@ LUA_USE_POSIX includes all functionality listed as X/Open System
65 @* Interfaces Extension (XSI).
66 ** CHANGE it (define it) if your system is XSI compatible.
68 #if defined(LUA_USE_POSIX)
69 #define LUA_USE_MKSTEMP
70 #define LUA_USE_ISATTY
72 #define LUA_USE_ULONGJMP
73 #define LUA_USE_GMTIME_R
79 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
81 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
83 ** CHANGE them if your machine has a non-conventional directory
84 ** hierarchy or if you want to install your libraries in
85 ** non-conventional directories.
87 #if defined(_WIN32) /* { */
89 ** In Windows, any exclamation mark ('!') in the path is replaced by the
90 ** path of the directory of the executable file of the current process.
92 #define LUA_LDIR "!\\lua\\"
93 #define LUA_CDIR "!\\"
94 #define LUA_PATH_DEFAULT \
95 LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
96 LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua"
97 #define LUA_CPATH_DEFAULT \
98 LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll"
100 #elif defined(SYSLINUX)
101 /* Extensions for converting the Syslinux path into package load paths */
102 #define LUA_PATH_DEFAULT ".lua"
103 #define LUA_CPATH_DEFAULT ".c32"
106 #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
107 #define LUA_ROOT "/usr/local/"
108 #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR
109 #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR
110 #define LUA_PATH_DEFAULT \
111 LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
112 LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua"
113 #define LUA_CPATH_DEFAULT \
114 LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
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 "\".)
124 #define LUA_DIRSEP "\\"
126 #define LUA_DIRSEP "/"
131 @@ LUA_ENV is the name of the variable that holds the current
132 @@ environment, used to access global names.
133 ** CHANGE it if you do not like this name.
135 #define LUA_ENV "_ENV"
139 @@ LUA_API is a mark for all core API functions.
140 @@ LUALIB_API is a mark for all auxiliary library functions.
141 @@ LUAMOD_API is a mark for all standard library opening functions.
142 ** CHANGE them if you need to define those functions in some special way.
143 ** For instance, if you want to create one Windows DLL with the core and
144 ** the libraries, you may want to use the following definition (define
145 ** LUA_BUILD_AS_DLL to get it).
147 #if defined(LUA_BUILD_AS_DLL) /* { */
149 #if defined(LUA_CORE) || defined(LUA_LIB) /* { */
150 #define LUA_API __declspec(dllexport)
152 #define LUA_API __declspec(dllimport)
157 #define LUA_API extern
162 /* more often than not the libs go together with the core */
163 #define LUALIB_API LUA_API
164 #define LUAMOD_API LUALIB_API
168 @@ LUAI_FUNC is a mark for all extern functions that are not to be
169 @* exported to outside modules.
170 @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
171 @* that are not to be exported to outside modules (LUAI_DDEF for
172 @* definitions and LUAI_DDEC for declarations).
173 ** CHANGE them if you need to mark them in some special way. Elf/gcc
174 ** (versions 3.2 and later) mark them as "hidden" to optimize access
175 ** when Lua is compiled as a shared library. Not all elf targets support
176 ** this attribute. Unfortunately, gcc does not offer a way to check
177 ** whether the target offers that support, and those without support
178 ** give a warning about it. To avoid these warnings, change to the
179 ** default definition.
181 #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
182 defined(__ELF__) /* { */
183 #define LUAI_FUNC __attribute__((visibility("hidden"))) extern
184 #define LUAI_DDEC LUAI_FUNC
185 #define LUAI_DDEF /* empty */
188 #define LUAI_FUNC extern
189 #define LUAI_DDEC extern
190 #define LUAI_DDEF /* empty */
196 @@ LUA_QL describes how error messages quote program elements.
197 ** CHANGE it if you want a different appearance.
199 #define LUA_QL(x) "'" x "'"
200 #define LUA_QS LUA_QL("%s")
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.
208 #define LUA_IDSIZE 60
212 @@ luai_writestring/luai_writeline define how 'print' prints its results.
213 ** They are only used in libraries and the stand-alone program. (The #if
214 ** avoids including 'stdio.h' everywhere.)
216 #if defined(LUA_LIB) || defined(lua_c)
218 #define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
219 #define luai_writeline() (luai_writestring("\n", 1), fflush(stdout))
223 @@ luai_writestringerror defines how to print error messages.
224 ** (A format string with one argument is enough for Lua...)
226 #define luai_writestringerror(s,p) \
227 (fprintf(stderr, (s), (p)), fflush(stderr))
231 @@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is,
232 ** strings that are internalized. (Cannot be smaller than reserved words
233 ** or tags for metamethods, as these strings must be internalized;
234 ** #("function") = 8, #("__newindex") = 10.)
236 #define LUAI_MAXSHORTLEN 40
241 ** {==================================================================
242 ** Compatibility with previous versions
243 ** ===================================================================
247 @@ LUA_COMPAT_ALL controls all compatibility options.
248 ** You can define it to get all options, or change specific options
249 ** to fit your specific needs.
251 #if defined(LUA_COMPAT_ALL) /* { */
254 @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
255 ** You can replace it with 'table.unpack'.
257 #define LUA_COMPAT_UNPACK
260 @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
261 ** You can replace it with 'package.searchers'.
263 #define LUA_COMPAT_LOADERS
266 @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
267 ** You can call your C function directly (with light C functions).
269 #define lua_cpcall(L,f,u) \
270 (lua_pushcfunction(L, (f)), \
271 lua_pushlightuserdata(L,(u)), \
276 @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
277 ** You can rewrite 'log10(x)' as 'log(x, 10)'.
279 #define LUA_COMPAT_LOG10
282 @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
283 ** library. You can rewrite 'loadstring(s)' as 'load(s)'.
285 #define LUA_COMPAT_LOADSTRING
288 @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
290 #define LUA_COMPAT_MAXN
293 @@ The following macros supply trivial compatibility for some
294 ** changes in the API. The macros themselves document how to
295 ** change your code to avoid using them.
297 #define lua_strlen(L,i) lua_rawlen(L, (i))
299 #define lua_objlen(L,i) lua_rawlen(L, (i))
301 #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
302 #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
305 @@ LUA_COMPAT_MODULE controls compatibility with previous
306 ** module functions 'module' (Lua) and 'luaL_register' (C).
308 #define LUA_COMPAT_MODULE
312 /* }================================================================== */
317 @@ LUAI_BITSINT defines the number of bits in an int.
318 ** CHANGE here if Lua cannot automatically detect the number of bits of
319 ** your machine. Probably you do not need to change this.
321 /* avoid overflows in comparison */
322 #if INT_MAX-20 < 32760 /* { */
323 #define LUAI_BITSINT 16
324 #elif INT_MAX > 2147483640L /* }{ */
325 /* int has at least 32 bits */
326 #define LUAI_BITSINT 32
328 #error "you must define LUA_BITSINT with number of bits in an integer"
333 @@ LUA_INT32 is an signed integer with exactly 32 bits.
334 @@ LUAI_UMEM is an unsigned integer big enough to count the total
335 @* memory used by Lua.
336 @@ LUAI_MEM is a signed integer big enough to count the total memory
338 ** CHANGE here if for some weird reason the default definitions are not
339 ** good enough for your machine. Probably you do not need to change
342 #if LUAI_BITSINT >= 32 /* { */
343 #define LUA_INT32 int
344 #define LUAI_UMEM size_t
345 #define LUAI_MEM ptrdiff_t
348 #define LUA_INT32 long
349 #define LUAI_UMEM unsigned long
350 #define LUAI_MEM long
355 @@ LUAI_MAXSTACK limits the size of the Lua stack.
356 ** CHANGE it if you need a different limit. This limit is arbitrary;
357 ** its only purpose is to stop Lua to consume unlimited stack
358 ** space (and to reserve some numbers for pseudo-indices).
360 #if LUAI_BITSINT >= 32
361 #define LUAI_MAXSTACK 1000000
363 #define LUAI_MAXSTACK 15000
366 /* reserve some space for error handling */
367 #define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000)
373 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
374 ** CHANGE it if it uses too much C-stack space.
376 #define LUAL_BUFFERSIZE BUFSIZ
382 ** {==================================================================
383 @@ LUA_NUMBER is the type of numbers in Lua.
384 ** CHANGE the following definitions only if you want to build Lua
385 ** with a number type different from double. You may also need to
386 ** change lua_number2int & lua_number2integer.
387 ** ===================================================================
390 /* Define LUA_NUMBER_INTEGRAL to produce a system that uses no
391 floating point operations by changing the type of Lua numbers from
392 double to long. It implements division and modulus so that
394 x == (x / y) * y + x % y.
396 The exponentiation function returns zero for negative exponents.
397 Defining LUA_NUMBER_INTEGRAL also removes the difftime function,
398 and the math module should not be used. The string.format function
399 no longer handles the floating point directives %e, %E, %f, %g, and
402 #define LUA_NUMBER_INTEGRAL
403 #ifdef LUA_NUMBER_INTEGRAL
404 #define LUA_NUMBER long
406 #define LUA_NUMBER_DOUBLE
407 #define LUA_NUMBER double
411 @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
414 #define LUAI_UACNUMBER LUA_NUMBER
418 @@ LUA_NUMBER_SCAN is the format for reading numbers.
419 @@ LUA_NUMBER_FMT is the format for writing numbers.
420 @@ lua_number2str converts a number to a string.
421 @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
423 #ifdef LUA_NUMBER_INTEGRAL
424 #define LUA_NUMBER_SCAN "%ld"
425 #define LUA_NUMBER_FMT "%ld"
427 #define LUA_NUMBER_SCAN "%lf"
428 #define LUA_NUMBER_FMT "%.14g"
430 #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
431 #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
435 @@ l_mathop allows the addition of an 'l' or 'f' to all math operations
437 #define l_mathop(x) (x)
441 @@ lua_str2number converts a decimal numeric string to a number.
442 @@ lua_strx2number converts an hexadecimal numeric string to a number.
443 ** In C99, 'strtod' does both conversions. C89, however, has no function
444 ** to convert floating hexadecimal strings to numbers. For these
445 ** systems, you can leave 'lua_strx2number' undefined and Lua will
446 ** provide its own implementation.
448 #ifdef LUA_NUMBER_INTEGRAL
449 #define lua_str2number(s,p) strtol((s), (p), 10)
451 #define lua_str2number(s,p) strtod((s), (p))
455 #define lua_strx2number(s,p) strtol((s), (p), 16)
460 @@ The luai_num* macros define the primitive operations over numbers.
463 #ifndef LUA_NUMBER_INTEGRAL
464 /* the following operations need the math library */
465 #if defined(lobject_c) || defined(lvm_c)
467 #define luai_nummod(L,a,b) ((a) - l_mathop(floor)((a)/(b))*(b))
468 #define luai_numpow(L,a,b) (l_mathop(pow)(a,b))
472 /* these are quite standard operations */
473 #if defined(LUA_CORE)
474 #define luai_numadd(L,a,b) ((a)+(b))
475 #define luai_numsub(L,a,b) ((a)-(b))
476 #define luai_nummul(L,a,b) ((a)*(b))
477 #ifdef LUA_NUMBER_INTEGRAL
478 #define luai_numdiv(L,a,b) \
481 (((a)<0)==((b)<0)||(a)%(b)==0? \
484 #define luai_nummod(L,a,b) \
487 (((a)<0)==((b)<0)||(a)%(b)==0? \
490 #define luai_lnumdiv(L,a,b) \
492 (luaG_runerror(L,"divide by zero"),0): \
494 #define luai_lnummod(L,a,b) \
496 (luaG_runerror(L,"modulo by zero"),0): \
498 LUA_NUMBER
luai_ipow(void *L
, LUA_NUMBER
, LUA_NUMBER
);
499 #define luai_numpow(L,a,b) (luai_ipow(L,a,b))
501 #define luai_numdiv(L,a,b) ((a)/(b))
503 #define luai_numunm(L,a) (-(a))
504 #define luai_numeq(a,b) ((a)==(b))
505 #define luai_numlt(L,a,b) ((a)<(b))
506 #define luai_numle(L,a,b) ((a)<=(b))
507 #define luai_numisnan(L,a) (!luai_numeq((a), (a)))
513 @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
514 ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
515 ** machines, ptrdiff_t gives a good choice between int or long.)
517 #define LUA_INTEGER long
518 /* Changed to long for use with integral Lua numbers. */
521 @@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
522 ** It must have at least 32 bits.
524 #define LUA_UNSIGNED unsigned LUA_INT32
529 ** Some tricks with doubles
532 #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */
534 ** The next definitions activate some tricks to speed up the
535 ** conversion from doubles to integer types, mainly to LUA_UNSIGNED.
537 @@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a
538 ** DirectX idiosyncrasy.
540 @@ LUA_IEEE754TRICK uses a trick that should work on any machine
541 ** using IEEE754 with a 32-bit integer type.
543 @@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be
544 ** defined when LUA_INTEGER is a 32-bit integer.
546 @@ LUA_IEEEENDIAN is the endianness of doubles in your machine
547 ** (0 for little endian, 1 for big endian); if not defined, Lua will
548 ** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK).
550 @@ LUA_NANTRICK controls the use of a trick to pack all types into
551 ** a single double value, using NaN values to represent non-number
552 ** values. The trick only works on 32-bit machines (ints and pointers
553 ** are 32-bit values) with numbers represented as IEEE 754-2008 doubles
554 ** with conventional endianess (12345678 or 87654321), in CPUs that do
555 ** not produce signaling NaN values (all NaNs are quiet).
558 /* Microsoft compiler on a Pentium (32 bit) ? */
559 #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */
561 #define LUA_MSASMTRICK
562 #define LUA_IEEEENDIAN 0
566 /* pentium 32 bits? */
567 #elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */
569 #define LUA_IEEE754TRICK
571 #define LUA_IEEEENDIAN 0
574 /* pentium 64 bits? */
575 #elif defined(__x86_64) /* }{ */
577 #define LUA_IEEE754TRICK
578 #define LUA_IEEEENDIAN 0
580 #elif defined(__POWERPC__) || defined(__ppc__) /* }{ */
582 #define LUA_IEEE754TRICK
583 #define LUA_IEEEENDIAN 1
587 /* assume IEEE754 and a 32-bit integer type */
588 #define LUA_IEEE754TRICK
594 /* }================================================================== */
599 /* =================================================================== */
602 ** Local configuration. You can use this space to add your redefinitions
603 ** without modifying the main part of the file.