2 ** $Id: luaconf.h,v 1.176.1.2 2013/11/21 17:26:16 roberto Exp $
3 ** Configuration file for Lua
4 ** See Copyright Notice in lua.h
11 #include <sys/zfs_context.h>
14 extern ssize_t
lcompat_sprintf(char *, size_t size
, const char *, ...);
15 extern int64_t lcompat_strtoll(const char *, char **);
16 extern int64_t lcompat_pow(int64_t, int64_t);
17 extern int lcompat_hashnum(int64_t);
20 ** ==================================================================
21 ** Search for "@@" to find all configurable definitions.
22 ** ===================================================================
27 @@ LUA_ANSI controls the use of non-ansi features.
28 ** CHANGE it (define it) if you want Lua to avoid the use of any
29 ** non-ansi feature or library.
31 #if !defined(LUA_ANSI) && defined(__STRICT_ANSI__)
36 #if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE)
37 #define LUA_WIN /* enable goodies for regular Windows platforms */
42 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
47 #if defined(LUA_USE_LINUX)
49 #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
50 #define LUA_USE_READLINE /* needs some extra libraries */
51 #define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
52 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
53 #define LUA_USE_LONGLONG /* assume support for long long */
56 #if defined(LUA_USE_MACOSX)
58 #define LUA_USE_DLOPEN /* does not need -ldl */
59 #define LUA_USE_READLINE /* needs an extra library: -lreadline */
60 #define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
61 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
62 #define LUA_USE_LONGLONG /* assume support for long long */
68 @@ LUA_USE_POSIX includes all functionality listed as X/Open System
69 @* Interfaces Extension (XSI).
70 ** CHANGE it (define it) if your system is XSI compatible.
72 #if defined(LUA_USE_POSIX)
73 #define LUA_USE_MKSTEMP
74 #define LUA_USE_ISATTY
76 #define LUA_USE_ULONGJMP
77 #define LUA_USE_GMTIME_R
83 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
85 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
87 ** CHANGE them if your machine has a non-conventional directory
88 ** hierarchy or if you want to install your libraries in
89 ** non-conventional directories.
91 #if defined(_WIN32) /* { */
93 ** In Windows, any exclamation mark ('!') in the path is replaced by the
94 ** path of the directory of the executable file of the current process.
96 #define LUA_LDIR "!\\lua\\"
97 #define LUA_CDIR "!\\"
98 #define LUA_PATH_DEFAULT \
99 LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
100 LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua"
101 #define LUA_CPATH_DEFAULT \
102 LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll"
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_writestringerror defines how to print error messages.
213 ** (A format string with one argument is enough for Lua...)
216 #define luai_writestringerror(s,p) \
217 (zfs_dbgmsg((s), (p)))
219 #define luai_writestringerror(s,p) \
220 (fprintf(stderr, (s), (p)), fflush(stderr))
225 @@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is,
226 ** strings that are internalized. (Cannot be smaller than reserved words
227 ** or tags for metamethods, as these strings must be internalized;
228 ** #("function") = 8, #("__newindex") = 10.)
230 #define LUAI_MAXSHORTLEN 40
235 ** {==================================================================
236 ** Compatibility with previous versions
237 ** ===================================================================
241 @@ LUA_COMPAT_ALL controls all compatibility options.
242 ** You can define it to get all options, or change specific options
243 ** to fit your specific needs.
245 #if defined(LUA_COMPAT_ALL) /* { */
248 @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
249 ** You can replace it with 'table.unpack'.
251 #define LUA_COMPAT_UNPACK
254 @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
255 ** You can replace it with 'package.searchers'.
257 #define LUA_COMPAT_LOADERS
260 @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
261 ** You can call your C function directly (with light C functions).
263 #define lua_cpcall(L,f,u) \
264 (lua_pushcfunction(L, (f)), \
265 lua_pushlightuserdata(L,(u)), \
270 @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
271 ** You can rewrite 'log10(x)' as 'log(x, 10)'.
273 #define LUA_COMPAT_LOG10
276 @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
277 ** library. You can rewrite 'loadstring(s)' as 'load(s)'.
279 #define LUA_COMPAT_LOADSTRING
282 @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
284 #define LUA_COMPAT_MAXN
287 @@ The following macros supply trivial compatibility for some
288 ** changes in the API. The macros themselves document how to
289 ** change your code to avoid using them.
291 #define lua_strlen(L,i) lua_rawlen(L, (i))
293 #define lua_objlen(L,i) lua_rawlen(L, (i))
295 #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
296 #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
299 @@ LUA_COMPAT_MODULE controls compatibility with previous
300 ** module functions 'module' (Lua) and 'luaL_register' (C).
302 #define LUA_COMPAT_MODULE
306 /* }================================================================== */
310 #define INT_MAX 2147483647L
313 @@ LUAI_BITSINT defines the number of bits in an int.
314 ** CHANGE here if Lua cannot automatically detect the number of bits of
315 ** your machine. Probably you do not need to change this.
317 /* avoid overflows in comparison */
318 #if INT_MAX-20 < 32760 /* { */
319 #define LUAI_BITSINT 16
320 #elif INT_MAX > 2147483640L /* }{ */
321 /* int has at least 32 bits */
322 #define LUAI_BITSINT 32
324 #error "you must define LUA_BITSINT with number of bits in an integer"
329 @@ LUA_INT32 is a signed integer with exactly 32 bits.
330 @@ LUAI_UMEM is an unsigned integer big enough to count the total
331 @* memory used by Lua.
332 @@ LUAI_MEM is a signed integer big enough to count the total memory
334 ** CHANGE here if for some weird reason the default definitions are not
335 ** good enough for your machine. Probably you do not need to change
338 #if LUAI_BITSINT >= 32 /* { */
339 #define LUA_INT32 int
340 #define LUAI_UMEM size_t
341 #define LUAI_MEM ptrdiff_t
344 #define LUA_INT32 long
345 #define LUAI_UMEM unsigned long
346 #define LUAI_MEM long
351 @@ LUAI_MAXSTACK limits the size of the Lua stack.
352 ** CHANGE it if you need a different limit. This limit is arbitrary;
353 ** its only purpose is to stop Lua from consuming unlimited stack
354 ** space (and to reserve some numbers for pseudo-indices).
356 #if LUAI_BITSINT >= 32
357 #define LUAI_MAXSTACK 1000000
359 #define LUAI_MAXSTACK 15000
362 /* reserve some space for error handling */
363 #define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000)
367 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
368 ** CHANGE it if it uses too much C-stack space.
370 #define LUAL_BUFFERSIZE 512
374 ** {==================================================================
375 @@ LUA_NUMBER is the type of numbers in Lua.
376 ** CHANGE the following definitions only if you want to build Lua
377 ** with a number type different from double. You may also need to
378 ** change lua_number2int & lua_number2integer.
379 ** ===================================================================
382 #define LUA_NUMBER int64_t
385 @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
388 #define LUAI_UACNUMBER int64_t
392 @@ LUA_NUMBER_SCAN is the format for reading numbers.
393 @@ LUA_NUMBER_FMT is the format for writing numbers.
394 @@ lua_number2str converts a number to a string.
395 @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
401 #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
402 #define LUA_NUMBER_FMT "%" PRId64
403 #define lua_number2str(s,n) \
404 lcompat_sprintf((s), LUAI_MAXNUMBER2STR, LUA_NUMBER_FMT, (n))
408 @@ l_mathop allows the addition of an 'l' or 'f' to all math operations
410 #define l_mathop(x) (x ## l)
414 @@ lua_str2number converts a decimal numeric string to a number.
415 @@ lua_strx2number converts an hexadecimal numeric string to a number.
416 ** In C99, 'strtod' does both conversions. C89, however, has no function
417 ** to convert floating hexadecimal strings to numbers. For these
418 ** systems, you can leave 'lua_strx2number' undefined and Lua will
419 ** provide its own implementation.
421 #define lua_str2number(s,p) lcompat_strtoll((s), (p))
423 #if defined(LUA_USE_STRTODHEX)
424 #define lua_strx2number(s,p) lcompat_strtoll((s), (p))
429 @@ The luai_num* macros define the primitive operations over numbers.
432 /* the following operations need the math library */
433 #if defined(lobject_c) || defined(lvm_c)
434 #define luai_nummod(L,a,b) ((a) % (b))
435 #define luai_numpow(L,a,b) (lcompat_pow((a),(b)))
438 /* these are quite standard operations */
439 #if defined(LUA_CORE)
440 #define luai_numadd(L,a,b) ((a)+(b))
441 #define luai_numsub(L,a,b) ((a)-(b))
442 #define luai_nummul(L,a,b) ((a)*(b))
443 #define luai_numdiv(L,a,b) ((a)/(b))
444 #define luai_numunm(L,a) (-(a))
445 #define luai_numeq(a,b) ((a)==(b))
446 #define luai_numlt(L,a,b) ((a)<(b))
447 #define luai_numle(L,a,b) ((a)<=(b))
448 #define luai_numisnan(L,a) (!luai_numeq((a), (a)))
454 @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
455 ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
456 ** machines, ptrdiff_t gives a good choice between int or long.)
458 #define LUA_INTEGER ptrdiff_t
461 @@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
462 ** It must have at least 32 bits.
464 #define LUA_UNSIGNED uint64_t
469 ** Some tricks with doubles
472 #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */
474 ** The next definitions activate some tricks to speed up the
475 ** conversion from doubles to integer types, mainly to LUA_UNSIGNED.
477 @@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a
478 ** DirectX idiosyncrasy.
480 @@ LUA_IEEE754TRICK uses a trick that should work on any machine
481 ** using IEEE754 with a 32-bit integer type.
483 @@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be
484 ** defined when LUA_INTEGER is a 32-bit integer.
486 @@ LUA_IEEEENDIAN is the endianness of doubles in your machine
487 ** (0 for little endian, 1 for big endian); if not defined, Lua will
488 ** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK).
490 @@ LUA_NANTRICK controls the use of a trick to pack all types into
491 ** a single double value, using NaN values to represent non-number
492 ** values. The trick only works on 32-bit machines (ints and pointers
493 ** are 32-bit values) with numbers represented as IEEE 754-2008 doubles
494 ** with conventional endianness (12345678 or 87654321), in CPUs that do
495 ** not produce signaling NaN values (all NaNs are quiet).
498 /* Microsoft compiler on a Pentium (32 bit) ? */
499 #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */
501 #define LUA_MSASMTRICK
502 #define LUA_IEEEENDIAN 0
506 /* pentium 32 bits? */
507 #elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */
509 #define LUA_IEEE754TRICK
511 #define LUA_IEEEENDIAN 0
514 /* pentium 64 bits? */
515 #elif defined(__x86_64) /* }{ */
517 #define LUA_IEEE754TRICK
518 #define LUA_IEEEENDIAN 0
520 #elif defined(__POWERPC__) || defined(__ppc__) /* }{ */
522 #define LUA_IEEE754TRICK
523 #define LUA_IEEEENDIAN 1
527 /* assume IEEE754 and a 32-bit integer type */
528 #define LUA_IEEE754TRICK
534 /* }================================================================== */
539 /* =================================================================== */
542 ** Local configuration. You can use this space to add your redefinitions
543 ** without modifying the main part of the file.
546 #define getlocaledecpoint() ('.')
549 #define abs(x) (((x) < 0) ? -(x) : (x))
552 #if !defined(UCHAR_MAX)
553 #define UCHAR_MAX (0xff)