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