3 ** $Id: luaconf.h,v 1.176.1.2 2013/11/21 17:26:16 roberto Exp $
4 ** Configuration file for Lua
5 ** See Copyright Notice in lua.h
12 #include <sys/zfs_context.h>
15 extern ssize_t lcompat_sprintf(char *, size_t size, const char *, ...);
16 extern int64_t lcompat_strtoll(const char *, char **);
17 extern int64_t lcompat_pow(int64_t, int64_t);
18 extern int lcompat_hashnum(int64_t);
21 ** ==================================================================
22 ** Search for "@@" to find all configurable definitions.
23 ** ===================================================================
28 @@ LUA_ANSI controls the use of non-ansi features.
29 ** CHANGE it (define it) if you want Lua to avoid the use of any
30 ** non-ansi feature or library.
32 #if !defined(LUA_ANSI) && defined(__STRICT_ANSI__)
37 #if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE)
38 #define LUA_WIN /* enable goodies for regular Windows platforms */
43 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
48 #if defined(LUA_USE_LINUX)
50 #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
51 #define LUA_USE_READLINE /* needs some extra libraries */
52 #define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
53 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
54 #define LUA_USE_LONGLONG /* assume support for long long */
57 #if defined(LUA_USE_MACOSX)
59 #define LUA_USE_DLOPEN /* does not need -ldl */
60 #define LUA_USE_READLINE /* needs an extra library: -lreadline */
61 #define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
62 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
63 #define LUA_USE_LONGLONG /* assume support for long long */
69 @@ LUA_USE_POSIX includes all functionality listed as X/Open System
70 @* Interfaces Extension (XSI).
71 ** CHANGE it (define it) if your system is XSI compatible.
73 #if defined(LUA_USE_POSIX)
74 #define LUA_USE_MKSTEMP
75 #define LUA_USE_ISATTY
77 #define LUA_USE_ULONGJMP
78 #define LUA_USE_GMTIME_R
84 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
86 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
88 ** CHANGE them if your machine has a non-conventional directory
89 ** hierarchy or if you want to install your libraries in
90 ** non-conventional directories.
92 #if defined(_WIN32) /* { */
94 ** In Windows, any exclamation mark ('!') in the path is replaced by the
95 ** path of the directory of the executable file of the current process.
97 #define LUA_LDIR "!\\lua\\"
98 #define LUA_CDIR "!\\"
99 #define LUA_PATH_DEFAULT \
100 LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
101 LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua"
102 #define LUA_CPATH_DEFAULT \
103 LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll"
107 #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
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;" "./?.lua"
114 #define LUA_CPATH_DEFAULT \
115 LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
120 @@ LUA_DIRSEP is the directory separator (for submodules).
121 ** CHANGE it if your machine does not use "/" as the directory separator
122 ** and is not Windows. (On Windows Lua automatically uses "\".)
125 #define LUA_DIRSEP "\\"
127 #define LUA_DIRSEP "/"
132 @@ LUA_ENV is the name of the variable that holds the current
133 @@ environment, used to access global names.
134 ** CHANGE it if you do not like this name.
136 #define LUA_ENV "_ENV"
140 @@ LUA_API is a mark for all core API functions.
141 @@ LUALIB_API is a mark for all auxiliary library functions.
142 @@ LUAMOD_API is a mark for all standard library opening functions.
143 ** CHANGE them if you need to define those functions in some special way.
144 ** For instance, if you want to create one Windows DLL with the core and
145 ** the libraries, you may want to use the following definition (define
146 ** LUA_BUILD_AS_DLL to get it).
148 #if defined(LUA_BUILD_AS_DLL) /* { */
150 #if defined(LUA_CORE) || defined(LUA_LIB) /* { */
151 #define LUA_API __declspec(dllexport)
153 #define LUA_API __declspec(dllimport)
158 #define LUA_API extern
163 /* more often than not the libs go together with the core */
164 #define LUALIB_API LUA_API
165 #define LUAMOD_API LUALIB_API
169 @@ LUAI_FUNC is a mark for all extern functions that are not to be
170 @* exported to outside modules.
171 @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
172 @* that are not to be exported to outside modules (LUAI_DDEF for
173 @* definitions and LUAI_DDEC for declarations).
174 ** CHANGE them if you need to mark them in some special way. Elf/gcc
175 ** (versions 3.2 and later) mark them as "hidden" to optimize access
176 ** when Lua is compiled as a shared library. Not all elf targets support
177 ** this attribute. Unfortunately, gcc does not offer a way to check
178 ** whether the target offers that support, and those without support
179 ** give a warning about it. To avoid these warnings, change to the
180 ** default definition.
182 #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
183 defined(__ELF__) /* { */
184 #define LUAI_FUNC __attribute__((visibility("hidden"))) extern
185 #define LUAI_DDEC LUAI_FUNC
186 #define LUAI_DDEF /* empty */
189 #define LUAI_FUNC extern
190 #define LUAI_DDEC extern
191 #define LUAI_DDEF /* empty */
197 @@ LUA_QL describes how error messages quote program elements.
198 ** CHANGE it if you want a different appearance.
200 #define LUA_QL(x) "'" x "'"
201 #define LUA_QS LUA_QL("%s")
205 @@ LUA_IDSIZE gives the maximum size for the description of the source
206 @* of a function in debug information.
207 ** CHANGE it if you want a different size.
209 #define LUA_IDSIZE 60
213 @@ luai_writestringerror defines how to print error messages.
214 ** (A format string with one argument is enough for Lua...)
217 #define luai_writestringerror(s,p) \
218 (zfs_dbgmsg((s), (p)))
220 #define luai_writestringerror(s,p) \
221 (fprintf(stderr, (s), (p)), fflush(stderr))
226 @@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is,
227 ** strings that are internalized. (Cannot be smaller than reserved words
228 ** or tags for metamethods, as these strings must be internalized;
229 ** #("function") = 8, #("__newindex") = 10.)
231 #define LUAI_MAXSHORTLEN 40
236 ** {==================================================================
237 ** Compatibility with previous versions
238 ** ===================================================================
242 @@ LUA_COMPAT_ALL controls all compatibility options.
243 ** You can define it to get all options, or change specific options
244 ** to fit your specific needs.
246 #if defined(LUA_COMPAT_ALL) /* { */
249 @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
250 ** You can replace it with 'table.unpack'.
252 #define LUA_COMPAT_UNPACK
255 @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
256 ** You can replace it with 'package.searchers'.
258 #define LUA_COMPAT_LOADERS
261 @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
262 ** You can call your C function directly (with light C functions).
264 #define lua_cpcall(L,f,u) \
265 (lua_pushcfunction(L, (f)), \
266 lua_pushlightuserdata(L,(u)), \
271 @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
272 ** You can rewrite 'log10(x)' as 'log(x, 10)'.
274 #define LUA_COMPAT_LOG10
277 @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
278 ** library. You can rewrite 'loadstring(s)' as 'load(s)'.
280 #define LUA_COMPAT_LOADSTRING
283 @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
285 #define LUA_COMPAT_MAXN
288 @@ The following macros supply trivial compatibility for some
289 ** changes in the API. The macros themselves document how to
290 ** change your code to avoid using them.
292 #define lua_strlen(L,i) lua_rawlen(L, (i))
294 #define lua_objlen(L,i) lua_rawlen(L, (i))
296 #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
297 #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
300 @@ LUA_COMPAT_MODULE controls compatibility with previous
301 ** module functions 'module' (Lua) and 'luaL_register' (C).
303 #define LUA_COMPAT_MODULE
307 /* }================================================================== */
311 #define INT_MAX 2147483647L
314 @@ LUAI_BITSINT defines the number of bits in an int.
315 ** CHANGE here if Lua cannot automatically detect the number of bits of
316 ** your machine. Probably you do not need to change this.
318 /* avoid overflows in comparison */
319 #if INT_MAX-20 < 32760 /* { */
320 #define LUAI_BITSINT 16
321 #elif INT_MAX > 2147483640L /* }{ */
322 /* int has at least 32 bits */
323 #define LUAI_BITSINT 32
325 #error "you must define LUA_BITSINT with number of bits in an integer"
330 @@ LUA_INT32 is a signed integer with exactly 32 bits.
331 @@ LUAI_UMEM is an unsigned integer big enough to count the total
332 @* memory used by Lua.
333 @@ LUAI_MEM is a signed integer big enough to count the total memory
335 ** CHANGE here if for some weird reason the default definitions are not
336 ** good enough for your machine. Probably you do not need to change
339 #if LUAI_BITSINT >= 32 /* { */
340 #define LUA_INT32 int
341 #define LUAI_UMEM size_t
342 #define LUAI_MEM ptrdiff_t
345 #define LUA_INT32 long
346 #define LUAI_UMEM unsigned long
347 #define LUAI_MEM long
352 @@ LUAI_MAXSTACK limits the size of the Lua stack.
353 ** CHANGE it if you need a different limit. This limit is arbitrary;
354 ** its only purpose is to stop Lua from consuming unlimited stack
355 ** space (and to reserve some numbers for pseudo-indices).
357 #if LUAI_BITSINT >= 32
358 #define LUAI_MAXSTACK 1000000
360 #define LUAI_MAXSTACK 15000
363 /* reserve some space for error handling */
364 #define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000)
368 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
369 ** CHANGE it if it uses too much C-stack space.
371 #define LUAL_BUFFERSIZE 512
375 ** {==================================================================
376 @@ LUA_NUMBER is the type of numbers in Lua.
377 ** CHANGE the following definitions only if you want to build Lua
378 ** with a number type different from double. You may also need to
379 ** change lua_number2int & lua_number2integer.
380 ** ===================================================================
383 #define LUA_NUMBER int64_t
386 @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
389 #define LUAI_UACNUMBER int64_t
393 @@ LUA_NUMBER_SCAN is the format for reading numbers.
394 @@ LUA_NUMBER_FMT is the format for writing numbers.
395 @@ lua_number2str converts a number to a string.
396 @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
402 #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
403 #define LUA_NUMBER_FMT "%" PRId64
404 #define lua_number2str(s,n) \
405 lcompat_sprintf((s), LUAI_MAXNUMBER2STR, LUA_NUMBER_FMT, (n))
409 @@ l_mathop allows the addition of an 'l' or 'f' to all math operations
411 #define l_mathop(x) (x ## l)
415 @@ lua_str2number converts a decimal numeric string to a number.
416 @@ lua_strx2number converts an hexadecimal numeric string to a number.
417 ** In C99, 'strtod' does both conversions. C89, however, has no function
418 ** to convert floating hexadecimal strings to numbers. For these
419 ** systems, you can leave 'lua_strx2number' undefined and Lua will
420 ** provide its own implementation.
422 #define lua_str2number(s,p) lcompat_strtoll((s), (p))
424 #if defined(LUA_USE_STRTODHEX)
425 #define lua_strx2number(s,p) lcompat_strtoll((s), (p))
430 @@ The luai_num* macros define the primitive operations over numbers.
433 /* the following operations need the math library */
434 #if defined(lobject_c) || defined(lvm_c)
435 #define luai_nummod(L,a,b) ((a) % (b))
436 #define luai_numpow(L,a,b) (lcompat_pow((a),(b)))
439 /* these are quite standard operations */
440 #if defined(LUA_CORE)
441 #define luai_numadd(L,a,b) ((a)+(b))
442 #define luai_numsub(L,a,b) ((a)-(b))
443 #define luai_nummul(L,a,b) ((a)*(b))
444 #define luai_numdiv(L,a,b) ((a)/(b))
445 #define luai_numunm(L,a) (-(a))
446 #define luai_numeq(a,b) ((a)==(b))
447 #define luai_numlt(L,a,b) ((a)<(b))
448 #define luai_numle(L,a,b) ((a)<=(b))
449 #define luai_numisnan(L,a) (!luai_numeq((a), (a)))
455 @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
456 ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
457 ** machines, ptrdiff_t gives a good choice between int or long.)
459 #define LUA_INTEGER ptrdiff_t
462 @@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
463 ** It must have at least 32 bits.
465 #define LUA_UNSIGNED uint64_t
470 ** Some tricks with doubles
473 #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */
475 ** The next definitions activate some tricks to speed up the
476 ** conversion from doubles to integer types, mainly to LUA_UNSIGNED.
478 @@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a
479 ** DirectX idiosyncrasy.
481 @@ LUA_IEEE754TRICK uses a trick that should work on any machine
482 ** using IEEE754 with a 32-bit integer type.
484 @@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be
485 ** defined when LUA_INTEGER is a 32-bit integer.
487 @@ LUA_IEEEENDIAN is the endianness of doubles in your machine
488 ** (0 for little endian, 1 for big endian); if not defined, Lua will
489 ** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK).
491 @@ LUA_NANTRICK controls the use of a trick to pack all types into
492 ** a single double value, using NaN values to represent non-number
493 ** values. The trick only works on 32-bit machines (ints and pointers
494 ** are 32-bit values) with numbers represented as IEEE 754-2008 doubles
495 ** with conventional endianness (12345678 or 87654321), in CPUs that do
496 ** not produce signaling NaN values (all NaNs are quiet).
499 /* Microsoft compiler on a Pentium (32 bit) ? */
500 #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */
502 #define LUA_MSASMTRICK
503 #define LUA_IEEEENDIAN 0
507 /* pentium 32 bits? */
508 #elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */
510 #define LUA_IEEE754TRICK
512 #define LUA_IEEEENDIAN 0
515 /* pentium 64 bits? */
516 #elif defined(__x86_64) /* }{ */
518 #define LUA_IEEE754TRICK
519 #define LUA_IEEEENDIAN 0
521 #elif defined(__POWERPC__) || defined(__ppc__) /* }{ */
523 #define LUA_IEEE754TRICK
524 #define LUA_IEEEENDIAN 1
528 /* assume IEEE754 and a 32-bit integer type */
529 #define LUA_IEEE754TRICK
535 /* }================================================================== */
540 /* =================================================================== */
543 ** Local configuration. You can use this space to add your redefinitions
544 ** without modifying the main part of the file.
547 #define getlocaledecpoint() ('.')
550 #define abs(x) (((x) < 0) ? -(x) : (x))
553 #if !defined(UCHAR_MAX)
554 #define UCHAR_MAX (0xff)