xref: /freebsd/stand/liblua/luaconf.h (revision 74ca7bf1d4c7173d5575ba168bc4b5f6d181ff5a)
1 /* $FreeBSD$ */
2 /*
3 ** $Id: luaconf.h,v 1.259 2016/12/22 13:08:50 roberto Exp $
4 ** Configuration file for Lua
5 ** See Copyright Notice in lua.h
6 */
7 
8 
9 #ifndef luaconf_h
10 #define luaconf_h
11 
12 #include <limits.h>
13 #include <stddef.h>
14 
15 
16 /*
17 ** ===================================================================
18 ** Search for "@@" to find all configurable definitions.
19 ** ===================================================================
20 */
21 
22 
23 /*
24 ** {====================================================================
25 ** System Configuration: macros to adapt (if needed) Lua to some
26 ** particular platform, for instance compiling it with 32-bit numbers or
27 ** restricting it to C89.
28 ** =====================================================================
29 */
30 
31 /*
32 @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You
33 ** can also define LUA_32BITS in the make file, but changing here you
34 ** ensure that all software connected to Lua will be compiled with the
35 ** same configuration.
36 */
37 /* #define LUA_32BITS */
38 
39 
40 /*
41 @@ LUA_USE_C89 controls the use of non-ISO-C89 features.
42 ** Define it if you want Lua to avoid the use of a few C99 features
43 ** or Windows-specific features on Windows.
44 */
45 /* #define LUA_USE_C89 */
46 
47 
48 /*
49 ** By default, Lua on Windows use (some) specific Windows features
50 */
51 #if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE)
52 #define LUA_USE_WINDOWS  /* enable goodies for regular Windows */
53 #endif
54 
55 
56 #if defined(LUA_USE_WINDOWS)
57 #define LUA_DL_DLL	/* enable support for DLL */
58 #define LUA_USE_C89	/* broadly, Windows is C89 */
59 #endif
60 
61 
62 #if defined(LUA_USE_LINUX)
63 #define LUA_USE_POSIX
64 #define LUA_USE_DLOPEN		/* needs an extra library: -ldl */
65 #define LUA_USE_READLINE	/* needs some extra libraries */
66 #endif
67 
68 
69 #if defined(LUA_USE_MACOSX)
70 #define LUA_USE_POSIX
71 #define LUA_USE_DLOPEN		/* MacOS does not need -ldl */
72 #define LUA_USE_READLINE	/* needs an extra library: -lreadline */
73 #endif
74 
75 
76 /*
77 @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for
78 ** C89 ('long' and 'double'); Windows always has '__int64', so it does
79 ** not need to use this case.
80 */
81 #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS)
82 #define LUA_C89_NUMBERS
83 #endif
84 
85 
86 
87 /*
88 @@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'.
89 */
90 /* avoid undefined shifts */
91 #if ((INT_MAX >> 15) >> 15) >= 1
92 #define LUAI_BITSINT	32
93 #else
94 /* 'int' always must have at least 16 bits */
95 #define LUAI_BITSINT	16
96 #endif
97 
98 
99 /*
100 @@ LUA_INT_TYPE defines the type for Lua integers.
101 @@ LUA_FLOAT_TYPE defines the type for Lua floats.
102 ** Lua should work fine with any mix of these options (if supported
103 ** by your C compiler). The usual configurations are 64-bit integers
104 ** and 'double' (the default), 32-bit integers and 'float' (for
105 ** restricted platforms), and 'long'/'double' (for C compilers not
106 ** compliant with C99, which may not have support for 'long long').
107 */
108 
109 /* predefined options for LUA_INT_TYPE */
110 #define LUA_INT_INT		1
111 #define LUA_INT_LONG		2
112 #define LUA_INT_LONGLONG	3
113 
114 /* predefined options for LUA_FLOAT_TYPE */
115 #define LUA_FLOAT_FLOAT		1
116 #define LUA_FLOAT_DOUBLE	2
117 #define LUA_FLOAT_LONGDOUBLE	3
118 #define LUA_FLOAT_INT64		4
119 
120 #if defined(LUA_32BITS)		/* { */
121 /*
122 ** 32-bit integers and 'float'
123 */
124 #if LUAI_BITSINT >= 32  /* use 'int' if big enough */
125 #define LUA_INT_TYPE	LUA_INT_INT
126 #else  /* otherwise use 'long' */
127 #define LUA_INT_TYPE	LUA_INT_LONG
128 #endif
129 #define LUA_FLOAT_TYPE	LUA_FLOAT_FLOAT
130 
131 #elif defined(LUA_C89_NUMBERS)	/* }{ */
132 /*
133 ** largest types available for C89 ('long' and 'double')
134 */
135 #define LUA_INT_TYPE	LUA_INT_LONG
136 #define LUA_FLOAT_TYPE	LUA_FLOAT_DOUBLE
137 
138 #endif				/* } */
139 
140 
141 /*
142 ** default configuration for 64-bit Lua ('long long' and 'double')
143 */
144 #if !defined(LUA_INT_TYPE)
145 #define LUA_INT_TYPE	LUA_INT_LONGLONG
146 #endif
147 
148 #if !defined(LUA_FLOAT_TYPE)
149 #define LUA_FLOAT_TYPE	LUA_FLOAT_DOUBLE
150 #endif
151 
152 /* }================================================================== */
153 
154 
155 
156 
157 /*
158 ** {==================================================================
159 ** Configuration for Paths.
160 ** ===================================================================
161 */
162 
163 /*
164 ** LUA_PATH_SEP is the character that separates templates in a path.
165 ** LUA_PATH_MARK is the string that marks the substitution points in a
166 ** template.
167 ** LUA_EXEC_DIR in a Windows path is replaced by the executable's
168 ** directory.
169 */
170 #define LUA_PATH_SEP            ";"
171 #define LUA_PATH_MARK           "?"
172 #define LUA_EXEC_DIR            "!"
173 
174 
175 /*
176 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
177 ** Lua libraries.
178 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
179 ** C libraries.
180 ** CHANGE them if your machine has a non-conventional directory
181 ** hierarchy or if you want to install your libraries in
182 ** non-conventional directories.
183 */
184 #define LUA_VDIR	LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
185 #if defined(_WIN32)	/* { */
186 /*
187 ** In Windows, any exclamation mark ('!') in the path is replaced by the
188 ** path of the directory of the executable file of the current process.
189 */
190 #define LUA_LDIR	"!\\lua\\"
191 #define LUA_CDIR	"!\\"
192 #define LUA_SHRDIR	"!\\..\\share\\lua\\" LUA_VDIR "\\"
193 #define LUA_PATH_DEFAULT  \
194 		LUA_LDIR"?.lua;"  LUA_LDIR"?\\init.lua;" \
195 		LUA_CDIR"?.lua;"  LUA_CDIR"?\\init.lua;" \
196 		LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \
197 		".\\?.lua;" ".\\?\\init.lua"
198 #define LUA_CPATH_DEFAULT \
199 		LUA_CDIR"?.dll;" \
200 		LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
201 		LUA_CDIR"loadall.dll;" ".\\?.dll"
202 
203 #else			/* }{ */
204 
205 #define LUA_ROOT	"/usr/local/"
206 #define LUA_LDIR	LUA_ROOT "share/lua/" LUA_VDIR "/"
207 #define LUA_CDIR	LUA_ROOT "lib/lua/" LUA_VDIR "/"
208 #ifndef LUA_PATH_DEFAULT
209 #define LUA_PATH_DEFAULT  \
210 		LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
211 		LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua;" \
212 		"./?.lua;" "./?/init.lua"
213 #endif
214 #define LUA_CPATH_DEFAULT \
215 		LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
216 #endif			/* } */
217 
218 
219 /*
220 @@ LUA_DIRSEP is the directory separator (for submodules).
221 ** CHANGE it if your machine does not use "/" as the directory separator
222 ** and is not Windows. (On Windows Lua automatically uses "\".)
223 */
224 #if defined(_WIN32)
225 #define LUA_DIRSEP	"\\"
226 #else
227 #define LUA_DIRSEP	"/"
228 #endif
229 
230 /* }================================================================== */
231 
232 
233 /*
234 ** {==================================================================
235 ** Marks for exported symbols in the C code
236 ** ===================================================================
237 */
238 
239 /*
240 @@ LUA_API is a mark for all core API functions.
241 @@ LUALIB_API is a mark for all auxiliary library functions.
242 @@ LUAMOD_API is a mark for all standard library opening functions.
243 ** CHANGE them if you need to define those functions in some special way.
244 ** For instance, if you want to create one Windows DLL with the core and
245 ** the libraries, you may want to use the following definition (define
246 ** LUA_BUILD_AS_DLL to get it).
247 */
248 #if defined(LUA_BUILD_AS_DLL)	/* { */
249 
250 #if defined(LUA_CORE) || defined(LUA_LIB)	/* { */
251 #define LUA_API __declspec(dllexport)
252 #else						/* }{ */
253 #define LUA_API __declspec(dllimport)
254 #endif						/* } */
255 
256 #else				/* }{ */
257 
258 #define LUA_API		extern
259 
260 #endif				/* } */
261 
262 
263 /* more often than not the libs go together with the core */
264 #define LUALIB_API	LUA_API
265 #define LUAMOD_API	LUALIB_API
266 
267 
268 /*
269 @@ LUAI_FUNC is a mark for all extern functions that are not to be
270 ** exported to outside modules.
271 @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
272 ** that are not to be exported to outside modules (LUAI_DDEF for
273 ** definitions and LUAI_DDEC for declarations).
274 ** CHANGE them if you need to mark them in some special way. Elf/gcc
275 ** (versions 3.2 and later) mark them as "hidden" to optimize access
276 ** when Lua is compiled as a shared library. Not all elf targets support
277 ** this attribute. Unfortunately, gcc does not offer a way to check
278 ** whether the target offers that support, and those without support
279 ** give a warning about it. To avoid these warnings, change to the
280 ** default definition.
281 */
282 #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
283     defined(__ELF__)		/* { */
284 #define LUAI_FUNC	__attribute__((visibility("hidden"))) extern
285 #else				/* }{ */
286 #define LUAI_FUNC	extern
287 #endif				/* } */
288 
289 #define LUAI_DDEC	LUAI_FUNC
290 #define LUAI_DDEF	/* empty */
291 
292 /* }================================================================== */
293 
294 
295 /*
296 ** {==================================================================
297 ** Compatibility with previous versions
298 ** ===================================================================
299 */
300 
301 /*
302 @@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2.
303 @@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1.
304 ** You can define it to get all options, or change specific options
305 ** to fit your specific needs.
306 */
307 #if defined(LUA_COMPAT_5_2)	/* { */
308 
309 /*
310 @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated
311 ** functions in the mathematical library.
312 */
313 #define LUA_COMPAT_MATHLIB
314 
315 /*
316 @@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'.
317 */
318 #define LUA_COMPAT_BITLIB
319 
320 /*
321 @@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod.
322 */
323 #define LUA_COMPAT_IPAIRS
324 
325 /*
326 @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for
327 ** manipulating other integer types (lua_pushunsigned, lua_tounsigned,
328 ** luaL_checkint, luaL_checklong, etc.)
329 */
330 #define LUA_COMPAT_APIINTCASTS
331 
332 #endif				/* } */
333 
334 
335 #if defined(LUA_COMPAT_5_1)	/* { */
336 
337 /* Incompatibilities from 5.2 -> 5.3 */
338 #define LUA_COMPAT_MATHLIB
339 #define LUA_COMPAT_APIINTCASTS
340 
341 /*
342 @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
343 ** You can replace it with 'table.unpack'.
344 */
345 #define LUA_COMPAT_UNPACK
346 
347 /*
348 @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
349 ** You can replace it with 'package.searchers'.
350 */
351 #define LUA_COMPAT_LOADERS
352 
353 /*
354 @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
355 ** You can call your C function directly (with light C functions).
356 */
357 #define lua_cpcall(L,f,u)  \
358 	(lua_pushcfunction(L, (f)), \
359 	 lua_pushlightuserdata(L,(u)), \
360 	 lua_pcall(L,1,0,0))
361 
362 
363 /*
364 @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
365 ** You can rewrite 'log10(x)' as 'log(x, 10)'.
366 */
367 #define LUA_COMPAT_LOG10
368 
369 /*
370 @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
371 ** library. You can rewrite 'loadstring(s)' as 'load(s)'.
372 */
373 #define LUA_COMPAT_LOADSTRING
374 
375 /*
376 @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
377 */
378 #define LUA_COMPAT_MAXN
379 
380 /*
381 @@ The following macros supply trivial compatibility for some
382 ** changes in the API. The macros themselves document how to
383 ** change your code to avoid using them.
384 */
385 #define lua_strlen(L,i)		lua_rawlen(L, (i))
386 
387 #define lua_objlen(L,i)		lua_rawlen(L, (i))
388 
389 #define lua_equal(L,idx1,idx2)		lua_compare(L,(idx1),(idx2),LUA_OPEQ)
390 #define lua_lessthan(L,idx1,idx2)	lua_compare(L,(idx1),(idx2),LUA_OPLT)
391 
392 /*
393 @@ LUA_COMPAT_MODULE controls compatibility with previous
394 ** module functions 'module' (Lua) and 'luaL_register' (C).
395 */
396 #define LUA_COMPAT_MODULE
397 
398 #endif				/* } */
399 
400 
401 /*
402 @@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a
403 @@ a float mark ('.0').
404 ** This macro is not on by default even in compatibility mode,
405 ** because this is not really an incompatibility.
406 */
407 /* #define LUA_COMPAT_FLOATSTRING */
408 #define	LUA_COMPAT_FLOATSTRING
409 
410 /* }================================================================== */
411 
412 
413 
414 /*
415 ** {==================================================================
416 ** Configuration for Numbers.
417 ** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_*
418 ** satisfy your needs.
419 ** ===================================================================
420 */
421 
422 /*
423 @@ LUA_NUMBER is the floating-point type used by Lua.
424 @@ LUAI_UACNUMBER is the result of a 'default argument promotion'
425 @@ over a floating number.
426 @@ l_mathlim(x) corrects limit name 'x' to the proper float type
427 ** by prefixing it with one of FLT/DBL/LDBL.
428 @@ LUA_NUMBER_FRMLEN is the length modifier for writing floats.
429 @@ LUA_NUMBER_FMT is the format for writing floats.
430 @@ lua_number2str converts a float to a string.
431 @@ l_mathop allows the addition of an 'l' or 'f' to all math operations.
432 @@ l_floor takes the floor of a float.
433 @@ lua_str2number converts a decimal numeric string to a number.
434 */
435 
436 
437 /* The following definitions are good for most cases here */
438 
439 #define l_floor(x)		(l_mathop(floor)(x))
440 
441 #define lua_number2str(s,sz,n)  \
442 	l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n))
443 
444 /*
445 @@ lua_numbertointeger converts a float number to an integer, or
446 ** returns 0 if float is not within the range of a lua_Integer.
447 ** (The range comparisons are tricky because of rounding. The tests
448 ** here assume a two-complement representation, where MININTEGER always
449 ** has an exact representation as a float; MAXINTEGER may not have one,
450 ** and therefore its conversion to float may have an ill-defined value.)
451 */
452 #define lua_numbertointeger(n,p) \
453   ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
454    (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
455       (*(p) = (LUA_INTEGER)(n), 1))
456 
457 
458 /* now the variable definitions */
459 
460 #if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT		/* { single float */
461 
462 #define LUA_NUMBER	float
463 
464 #define l_mathlim(n)		(FLT_##n)
465 
466 #define LUAI_UACNUMBER	double
467 
468 #define LUA_NUMBER_FRMLEN	""
469 #define LUA_NUMBER_FMT		"%.7g"
470 
471 #define l_mathop(op)		op##f
472 
473 #define lua_str2number(s,p)	strtof((s), (p))
474 
475 #elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE	/* }{ long double */
476 
477 #define LUA_NUMBER	long double
478 
479 #define l_mathlim(n)		(LDBL_##n)
480 
481 #define LUAI_UACNUMBER	long double
482 
483 #define LUA_NUMBER_FRMLEN	"L"
484 #define LUA_NUMBER_FMT		"%.19Lg"
485 
486 #define l_mathop(op)		op##l
487 
488 #define lua_str2number(s,p)	strtold((s), (p))
489 
490 #elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE	/* }{ double */
491 
492 #define LUA_NUMBER	double
493 
494 #define l_mathlim(n)		(DBL_##n)
495 
496 #define LUAI_UACNUMBER	double
497 
498 #define LUA_NUMBER_FRMLEN	""
499 #define LUA_NUMBER_FMT		"%.14g"
500 
501 #define l_mathop(op)		op
502 
503 #define lua_str2number(s,p)	strtod((s), (p))
504 
505 #elif LUA_FLOAT_TYPE == LUA_FLOAT_INT64	/* }{ int64 */
506 
507 #include "lstd.h"
508 
509 #include <machine/_inttypes.h>
510 
511 #define panic lua_panic
512 /* Hack to use int64 as the LUA_NUMBER from ZFS code, kinda */
513 
514 #define LUA_NUMBER	int64_t
515 
516 #define l_mathlim(n)		(LUA_FLOAT_INT_HACK_##n)
517 #define LUA_FLOAT_INT_HACK_MANT_DIG	32
518 #define LUA_FLOAT_INT_HACK_MAX_10_EXP	32
519 
520 #define LUAI_UACNUMBER	int64_t
521 
522 #define LUA_NUMBER_FRMLEN	""
523 #define LUA_NUMBER_FMT		"%" PRId64
524 
525 #define l_mathop(x)		(lstd_ ## x)
526 
527 #define lua_str2number(s,p)	strtoll((s), (p), 0)
528 
529 #define lua_getlocaledecpoint()		'.'
530 
531 #else						/* }{ */
532 
533 #error "numeric float type not defined"
534 
535 #endif					/* } */
536 
537 
538 
539 /*
540 @@ LUA_INTEGER is the integer type used by Lua.
541 **
542 @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
543 **
544 @@ LUAI_UACINT is the result of a 'default argument promotion'
545 @@ over a lUA_INTEGER.
546 @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
547 @@ LUA_INTEGER_FMT is the format for writing integers.
548 @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
549 @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
550 @@ lua_integer2str converts an integer to a string.
551 */
552 
553 
554 /* The following definitions are good for most cases here */
555 
556 #define LUA_INTEGER_FMT		"%" LUA_INTEGER_FRMLEN "d"
557 
558 #define LUAI_UACINT		LUA_INTEGER
559 
560 #define lua_integer2str(s,sz,n)  \
561 	l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n))
562 
563 /*
564 ** use LUAI_UACINT here to avoid problems with promotions (which
565 ** can turn a comparison between unsigneds into a signed comparison)
566 */
567 #define LUA_UNSIGNED		unsigned LUAI_UACINT
568 
569 
570 /* now the variable definitions */
571 
572 #if LUA_INT_TYPE == LUA_INT_INT		/* { int */
573 
574 #define LUA_INTEGER		int
575 #define LUA_INTEGER_FRMLEN	""
576 
577 #define LUA_MAXINTEGER		INT_MAX
578 #define LUA_MININTEGER		INT_MIN
579 
580 #elif LUA_INT_TYPE == LUA_INT_LONG	/* }{ long */
581 
582 #define LUA_INTEGER		long
583 #define LUA_INTEGER_FRMLEN	"l"
584 
585 #define LUA_MAXINTEGER		LONG_MAX
586 #define LUA_MININTEGER		LONG_MIN
587 
588 #elif LUA_INT_TYPE == LUA_INT_LONGLONG	/* }{ long long */
589 
590 /* use presence of macro LLONG_MAX as proxy for C99 compliance */
591 #if defined(LLONG_MAX)		/* { */
592 /* use ISO C99 stuff */
593 
594 #define LUA_INTEGER		long long
595 #define LUA_INTEGER_FRMLEN	"ll"
596 
597 #define LUA_MAXINTEGER		LLONG_MAX
598 #define LUA_MININTEGER		LLONG_MIN
599 
600 #elif defined(LUA_USE_WINDOWS) /* }{ */
601 /* in Windows, can use specific Windows types */
602 
603 #define LUA_INTEGER		__int64
604 #define LUA_INTEGER_FRMLEN	"I64"
605 
606 #define LUA_MAXINTEGER		_I64_MAX
607 #define LUA_MININTEGER		_I64_MIN
608 
609 #else				/* }{ */
610 
611 #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \
612   or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)"
613 
614 #endif				/* } */
615 
616 #else				/* }{ */
617 
618 #error "numeric integer type not defined"
619 
620 #endif				/* } */
621 
622 /* }================================================================== */
623 
624 
625 /*
626 ** {==================================================================
627 ** Dependencies with C99 and other C details
628 ** ===================================================================
629 */
630 
631 /*
632 @@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89.
633 ** (All uses in Lua have only one format item.)
634 */
635 #if !defined(LUA_USE_C89)
636 #define l_sprintf(s,sz,f,i)	snprintf(s,sz,f,i)
637 #else
638 #define l_sprintf(s,sz,f,i)	((void)(sz), sprintf(s,f,i))
639 #endif
640 
641 
642 /*
643 @@ lua_strx2number converts an hexadecimal numeric string to a number.
644 ** In C99, 'strtod' does that conversion. Otherwise, you can
645 ** leave 'lua_strx2number' undefined and Lua will provide its own
646 ** implementation.
647 */
648 #if !defined(LUA_USE_C89)
649 #define lua_strx2number(s,p)		lua_str2number(s,p)
650 #endif
651 
652 
653 /*
654 @@ lua_number2strx converts a float to an hexadecimal numeric string.
655 ** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that.
656 ** Otherwise, you can leave 'lua_number2strx' undefined and Lua will
657 ** provide its own implementation.
658 */
659 #if !defined(LUA_USE_C89)
660 #define lua_number2strx(L,b,sz,f,n)  \
661 	((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n)))
662 #endif
663 
664 
665 /*
666 ** 'strtof' and 'opf' variants for math functions are not valid in
667 ** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the
668 ** availability of these variants. ('math.h' is already included in
669 ** all files that use these macros.)
670 */
671 #if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF))
672 #undef l_mathop  /* variants not available */
673 #undef lua_str2number
674 #define l_mathop(op)		(lua_Number)op  /* no variant */
675 #define lua_str2number(s,p)	((lua_Number)strtod((s), (p)))
676 #endif
677 
678 
679 /*
680 @@ LUA_KCONTEXT is the type of the context ('ctx') for continuation
681 ** functions.  It must be a numerical type; Lua will use 'intptr_t' if
682 ** available, otherwise it will use 'ptrdiff_t' (the nearest thing to
683 ** 'intptr_t' in C89)
684 */
685 #define LUA_KCONTEXT	ptrdiff_t
686 
687 #if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
688     __STDC_VERSION__ >= 199901L
689 #include <stdint.h>
690 #if defined(INTPTR_MAX)  /* even in C99 this type is optional */
691 #undef LUA_KCONTEXT
692 #define LUA_KCONTEXT	intptr_t
693 #endif
694 #endif
695 
696 
697 /*
698 @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point).
699 ** Change that if you do not want to use C locales. (Code using this
700 ** macro must include header 'locale.h'.)
701 */
702 #if !defined(lua_getlocaledecpoint)
703 #define lua_getlocaledecpoint()		(localeconv()->decimal_point[0])
704 #endif
705 
706 /* }================================================================== */
707 
708 
709 /*
710 ** {==================================================================
711 ** Language Variations
712 ** =====================================================================
713 */
714 
715 /*
716 @@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some
717 ** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from
718 ** numbers to strings. Define LUA_NOCVTS2N to turn off automatic
719 ** coercion from strings to numbers.
720 */
721 /* #define LUA_NOCVTN2S */
722 /* #define LUA_NOCVTS2N */
723 
724 
725 /*
726 @@ LUA_USE_APICHECK turns on several consistency checks on the C API.
727 ** Define it as a help when debugging C code.
728 */
729 #if defined(LUA_USE_APICHECK)
730 #include <assert.h>
731 #define luai_apicheck(l,e)	assert(e)
732 #endif
733 
734 /* }================================================================== */
735 
736 
737 /*
738 ** {==================================================================
739 ** Macros that affect the API and must be stable (that is, must be the
740 ** same when you compile Lua and when you compile code that links to
741 ** Lua). You probably do not want/need to change them.
742 ** =====================================================================
743 */
744 
745 /*
746 @@ LUAI_MAXSTACK limits the size of the Lua stack.
747 ** CHANGE it if you need a different limit. This limit is arbitrary;
748 ** its only purpose is to stop Lua from consuming unlimited stack
749 ** space (and to reserve some numbers for pseudo-indices).
750 */
751 #if LUAI_BITSINT >= 32
752 #define LUAI_MAXSTACK		1000000
753 #else
754 #define LUAI_MAXSTACK		15000
755 #endif
756 
757 
758 /*
759 @@ LUA_EXTRASPACE defines the size of a raw memory area associated with
760 ** a Lua state with very fast access.
761 ** CHANGE it if you need a different size.
762 */
763 #define LUA_EXTRASPACE		(sizeof(void *))
764 
765 
766 /*
767 @@ LUA_IDSIZE gives the maximum size for the description of the source
768 @@ of a function in debug information.
769 ** CHANGE it if you want a different size.
770 */
771 #define LUA_IDSIZE	60
772 
773 
774 /*
775 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
776 ** CHANGE it if it uses too much C-stack space. (For long double,
777 ** 'string.format("%.99f", -1e4932)' needs 5034 bytes, so a
778 ** smaller buffer would force a memory allocation for each call to
779 ** 'string.format'.)
780 */
781 #if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE
782 #define LUAL_BUFFERSIZE		8192
783 #else
784 #define LUAL_BUFFERSIZE   ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer)))
785 #endif
786 
787 /* }================================================================== */
788 
789 
790 /*
791 @@ LUA_QL describes how error messages quote program elements.
792 ** Lua does not use these macros anymore; they are here for
793 ** compatibility only.
794 */
795 #define LUA_QL(x)	"'" x "'"
796 #define LUA_QS		LUA_QL("%s")
797 
798 
799 
800 
801 /* =================================================================== */
802 
803 /*
804 ** Local configuration. You can use this space to add your redefinitions
805 ** without modifying the main part of the file.
806 */
807 
808 
809 
810 
811 
812 #endif
813