1/*
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
5*/
6
7
8#ifndef lconfig_h
9#define lconfig_h
10
11#include <sys/zfs_context.h>
12#ifdef illumos
13#include <sys/int_fmtio.h>
14#else
15#include <machine/_inttypes.h>
16#endif
17
18extern ssize_t lcompat_sprintf(char *, const char *, ...);
19extern int64_t lcompat_strtoll(const char *, char **);
20extern int64_t lcompat_pow(int64_t, int64_t);
21
22/*
23** ==================================================================
24** Search for "@@" to find all configurable definitions.
25** ===================================================================
26*/
27
28
29/*
30@@ LUA_ANSI controls the use of non-ansi features.
31** CHANGE it (define it) if you want Lua to avoid the use of any
32** non-ansi feature or library.
33*/
34#if !defined(LUA_ANSI) && defined(__STRICT_ANSI__)
35#define LUA_ANSI
36#endif
37
38
39#if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE)
40#define LUA_WIN		/* enable goodies for regular Windows platforms */
41#endif
42
43#if defined(LUA_WIN)
44#define LUA_DL_DLL
45#define LUA_USE_AFORMAT		/* assume 'printf' handles 'aA' specifiers */
46#endif
47
48
49
50#if defined(LUA_USE_LINUX)
51#define LUA_USE_POSIX
52#define LUA_USE_DLOPEN		/* needs an extra library: -ldl */
53#define LUA_USE_READLINE	/* needs some extra libraries */
54#define LUA_USE_STRTODHEX	/* assume 'strtod' handles hex formats */
55#define LUA_USE_AFORMAT		/* assume 'printf' handles 'aA' specifiers */
56#define LUA_USE_LONGLONG	/* assume support for long long */
57#endif
58
59#if defined(LUA_USE_MACOSX)
60#define LUA_USE_POSIX
61#define LUA_USE_DLOPEN		/* does not need -ldl */
62#define LUA_USE_READLINE	/* needs an extra library: -lreadline */
63#define LUA_USE_STRTODHEX	/* assume 'strtod' handles hex formats */
64#define LUA_USE_AFORMAT		/* assume 'printf' handles 'aA' specifiers */
65#define LUA_USE_LONGLONG	/* assume support for long long */
66#endif
67
68
69
70/*
71@@ LUA_USE_POSIX includes all functionality listed as X/Open System
72@* Interfaces Extension (XSI).
73** CHANGE it (define it) if your system is XSI compatible.
74*/
75#if defined(LUA_USE_POSIX)
76#define LUA_USE_MKSTEMP
77#define LUA_USE_ISATTY
78#define LUA_USE_POPEN
79#define LUA_USE_ULONGJMP
80#define LUA_USE_GMTIME_R
81#endif
82
83
84
85/*
86@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
87@* Lua libraries.
88@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
89@* C libraries.
90** CHANGE them if your machine has a non-conventional directory
91** hierarchy or if you want to install your libraries in
92** non-conventional directories.
93*/
94#if defined(_WIN32)	/* { */
95/*
96** In Windows, any exclamation mark ('!') in the path is replaced by the
97** path of the directory of the executable file of the current process.
98*/
99#define LUA_LDIR	"!\\lua\\"
100#define LUA_CDIR	"!\\"
101#define LUA_PATH_DEFAULT  \
102		LUA_LDIR"?.lua;"  LUA_LDIR"?\\init.lua;" \
103		LUA_CDIR"?.lua;"  LUA_CDIR"?\\init.lua;" ".\\?.lua"
104#define LUA_CPATH_DEFAULT \
105		LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll"
106
107#else			/* }{ */
108
109#define LUA_VDIR	LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
110#define LUA_ROOT	"/usr/local/"
111#define LUA_LDIR	LUA_ROOT "share/lua/" LUA_VDIR
112#define LUA_CDIR	LUA_ROOT "lib/lua/" LUA_VDIR
113#define LUA_PATH_DEFAULT  \
114		LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
115		LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua;" "./?.lua"
116#define LUA_CPATH_DEFAULT \
117		LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
118#endif			/* } */
119
120
121/*
122@@ LUA_DIRSEP is the directory separator (for submodules).
123** CHANGE it if your machine does not use "/" as the directory separator
124** and is not Windows. (On Windows Lua automatically uses "\".)
125*/
126#if defined(_WIN32)
127#define LUA_DIRSEP	"\\"
128#else
129#define LUA_DIRSEP	"/"
130#endif
131
132
133/*
134@@ LUA_ENV is the name of the variable that holds the current
135@@ environment, used to access global names.
136** CHANGE it if you do not like this name.
137*/
138#define LUA_ENV		"_ENV"
139
140
141/*
142@@ LUA_API is a mark for all core API functions.
143@@ LUALIB_API is a mark for all auxiliary library functions.
144@@ LUAMOD_API is a mark for all standard library opening functions.
145** CHANGE them if you need to define those functions in some special way.
146** For instance, if you want to create one Windows DLL with the core and
147** the libraries, you may want to use the following definition (define
148** LUA_BUILD_AS_DLL to get it).
149*/
150#if defined(LUA_BUILD_AS_DLL)	/* { */
151
152#if defined(LUA_CORE) || defined(LUA_LIB)	/* { */
153#define LUA_API __declspec(dllexport)
154#else						/* }{ */
155#define LUA_API __declspec(dllimport)
156#endif						/* } */
157
158#else				/* }{ */
159
160#define LUA_API		extern
161
162#endif				/* } */
163
164
165/* more often than not the libs go together with the core */
166#define LUALIB_API	LUA_API
167#define LUAMOD_API	LUALIB_API
168
169
170/*
171@@ LUAI_FUNC is a mark for all extern functions that are not to be
172@* exported to outside modules.
173@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
174@* that are not to be exported to outside modules (LUAI_DDEF for
175@* definitions and LUAI_DDEC for declarations).
176** CHANGE them if you need to mark them in some special way. Elf/gcc
177** (versions 3.2 and later) mark them as "hidden" to optimize access
178** when Lua is compiled as a shared library. Not all elf targets support
179** this attribute. Unfortunately, gcc does not offer a way to check
180** whether the target offers that support, and those without support
181** give a warning about it. To avoid these warnings, change to the
182** default definition.
183*/
184#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
185    defined(__ELF__)		/* { */
186#define LUAI_FUNC	__attribute__((visibility("hidden"))) extern
187#define LUAI_DDEC	LUAI_FUNC
188#define LUAI_DDEF	/* empty */
189
190#else				/* }{ */
191#define LUAI_FUNC	extern
192#define LUAI_DDEC	extern
193#define LUAI_DDEF	/* empty */
194#endif				/* } */
195
196
197
198/*
199@@ LUA_QL describes how error messages quote program elements.
200** CHANGE it if you want a different appearance.
201*/
202#define LUA_QL(x)	"'" x "'"
203#define LUA_QS		LUA_QL("%s")
204
205
206/*
207@@ LUA_IDSIZE gives the maximum size for the description of the source
208@* of a function in debug information.
209** CHANGE it if you want a different size.
210*/
211#define LUA_IDSIZE	60
212
213
214/*
215@@ luai_writestringerror defines how to print error messages.
216** (A format string with one argument is enough for Lua...)
217*/
218#ifdef _KERNEL
219#define luai_writestringerror(s,p) \
220	(zfs_dbgmsg((s), (p)))
221#else
222#define luai_writestringerror(s,p) \
223	(fprintf(stderr, (s), (p)), fflush(stderr))
224#endif
225
226
227/*
228@@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is,
229** strings that are internalized. (Cannot be smaller than reserved words
230** or tags for metamethods, as these strings must be internalized;
231** #("function") = 8, #("__newindex") = 10.)
232*/
233#define LUAI_MAXSHORTLEN        40
234
235
236
237/*
238** {==================================================================
239** Compatibility with previous versions
240** ===================================================================
241*/
242
243/*
244@@ LUA_COMPAT_ALL controls all compatibility options.
245** You can define it to get all options, or change specific options
246** to fit your specific needs.
247*/
248#if defined(LUA_COMPAT_ALL)	/* { */
249
250/*
251@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
252** You can replace it with 'table.unpack'.
253*/
254#define LUA_COMPAT_UNPACK
255
256/*
257@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
258** You can replace it with 'package.searchers'.
259*/
260#define LUA_COMPAT_LOADERS
261
262/*
263@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
264** You can call your C function directly (with light C functions).
265*/
266#define lua_cpcall(L,f,u)  \
267	(lua_pushcfunction(L, (f)), \
268	 lua_pushlightuserdata(L,(u)), \
269	 lua_pcall(L,1,0,0))
270
271
272/*
273@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
274** You can rewrite 'log10(x)' as 'log(x, 10)'.
275*/
276#define LUA_COMPAT_LOG10
277
278/*
279@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
280** library. You can rewrite 'loadstring(s)' as 'load(s)'.
281*/
282#define LUA_COMPAT_LOADSTRING
283
284/*
285@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
286*/
287#define LUA_COMPAT_MAXN
288
289/*
290@@ The following macros supply trivial compatibility for some
291** changes in the API. The macros themselves document how to
292** change your code to avoid using them.
293*/
294#define lua_strlen(L,i)		lua_rawlen(L, (i))
295
296#define lua_objlen(L,i)		lua_rawlen(L, (i))
297
298#define lua_equal(L,idx1,idx2)		lua_compare(L,(idx1),(idx2),LUA_OPEQ)
299#define lua_lessthan(L,idx1,idx2)	lua_compare(L,(idx1),(idx2),LUA_OPLT)
300
301/*
302@@ LUA_COMPAT_MODULE controls compatibility with previous
303** module functions 'module' (Lua) and 'luaL_register' (C).
304*/
305#define LUA_COMPAT_MODULE
306
307#endif				/* } */
308
309/* }================================================================== */
310
311
312
313/*
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.
317*/
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
324#else				/* }{ */
325#error "you must define LUA_BITSINT with number of bits in an integer"
326#endif				/* } */
327
328
329/*
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
334@* used by Lua.
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
337** this.
338*/
339#if LUAI_BITSINT >= 32		/* { */
340#define LUA_INT32	int
341#define LUAI_UMEM	size_t
342#define LUAI_MEM	ptrdiff_t
343#else				/* }{ */
344/* 16-bit ints */
345#define LUA_INT32	long
346#define LUAI_UMEM	unsigned long
347#define LUAI_MEM	long
348#endif				/* } */
349
350
351/*
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).
356*/
357#if LUAI_BITSINT >= 32
358#define LUAI_MAXSTACK		1000000
359#else
360#define LUAI_MAXSTACK		15000
361#endif
362
363/* reserve some space for error handling */
364#define LUAI_FIRSTPSEUDOIDX	(-LUAI_MAXSTACK - 1000)
365
366
367
368
369/*
370@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
371** CHANGE it if it uses too much C-stack space.
372*/
373#define LUAL_BUFFERSIZE		1024
374
375
376
377
378/*
379** {==================================================================
380@@ LUA_NUMBER is the type of numbers in Lua.
381** CHANGE the following definitions only if you want to build Lua
382** with a number type different from double. You may also need to
383** change lua_number2int & lua_number2integer.
384** ===================================================================
385*/
386
387#define LUA_NUMBER	int64_t
388
389/*
390@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
391@* over a number.
392*/
393#define LUAI_UACNUMBER	int64_t
394
395
396/*
397@@ LUA_NUMBER_SCAN is the format for reading numbers.
398@@ LUA_NUMBER_FMT is the format for writing numbers.
399@@ lua_number2str converts a number to a string.
400@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
401*/
402#define LUA_NUMBER_FMT		"%" PRId64
403#define lua_number2str(s,n)	lcompat_sprintf((s), LUA_NUMBER_FMT, (n))
404#define LUAI_MAXNUMBER2STR	32 /* 16 digits, sign, point, and \0 */
405
406
407/*
408@@ l_mathop allows the addition of an 'l' or 'f' to all math operations
409*/
410#define l_mathop(x)		(x ## l)
411
412
413/*
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.
420*/
421#define lua_str2number(s,p)	lcompat_strtoll((s), (p))
422
423#if defined(LUA_USE_STRTODHEX)
424#define lua_strx2number(s,p)	lcompat_strtoll((s), (p))
425#endif
426
427
428/*
429@@ The luai_num* macros define the primitive operations over numbers.
430*/
431
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)))
436#endif
437
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)))
449#endif
450
451
452
453/*
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.)
457*/
458#define LUA_INTEGER	ptrdiff_t
459
460/*
461@@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
462** It must have at least 32 bits.
463*/
464#define LUA_UNSIGNED	uint64_t
465
466
467
468/*
469** Some tricks with doubles
470*/
471
472#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI)	/* { */
473/*
474** The next definitions activate some tricks to speed up the
475** conversion from doubles to integer types, mainly to LUA_UNSIGNED.
476**
477@@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a
478** DirectX idiosyncrasy.
479**
480@@ LUA_IEEE754TRICK uses a trick that should work on any machine
481** using IEEE754 with a 32-bit integer type.
482**
483@@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be
484** defined when LUA_INTEGER is a 32-bit integer.
485**
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).
489**
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 endianess (12345678 or 87654321), in CPUs that do
495** not produce signaling NaN values (all NaNs are quiet).
496*/
497
498/* Microsoft compiler on a Pentium (32 bit) ? */
499#if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86)	/* { */
500
501#define LUA_MSASMTRICK
502#define LUA_IEEEENDIAN		0
503#define LUA_NANTRICK
504
505
506/* pentium 32 bits? */
507#elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */
508
509#define LUA_IEEE754TRICK
510#define LUA_IEEELL
511#define LUA_IEEEENDIAN		0
512#define LUA_NANTRICK
513
514/* pentium 64 bits? */
515#elif defined(__x86_64)						/* }{ */
516
517#define LUA_IEEE754TRICK
518#define LUA_IEEEENDIAN		0
519
520#elif defined(__POWERPC__) || defined(__ppc__)			/* }{ */
521
522#define LUA_IEEE754TRICK
523#define LUA_IEEEENDIAN		1
524
525#else								/* }{ */
526
527/* assume IEEE754 and a 32-bit integer type */
528#define LUA_IEEE754TRICK
529
530#endif								/* } */
531
532#endif							/* } */
533
534/* }================================================================== */
535
536
537
538
539/* =================================================================== */
540
541/*
542** Local configuration. You can use this space to add your redefinitions
543** without modifying the main part of the file.
544*/
545
546#define	getlocaledecpoint() ('.')
547
548#define abs(x) (((x) < 0) ? -(x) : (x))
549
550#if !defined(UCHAR_MAX)
551#define	UCHAR_MAX (0xff)
552#endif
553
554#endif
555
556