Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / luaconf.h @ 14

History | View | Annotate | Download (21.6 KB)

1
/*        $NetBSD: luaconf.h,v 1.14 2015/10/08 13:21:00 mbalmer Exp $        */
2

    
3
/*
4
** Id: luaconf.h,v 1.251 2015/05/20 17:39:23 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
17
#include <machine/limits.h>
18
#include <sys/systm.h>
19
#endif
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_DEFAULT is the default path that Lua uses to look for
170
** Lua libraries.
171
@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
172
** C libraries.
173
** CHANGE them if your machine has a non-conventional directory
174
** hierarchy or if you want to install your libraries in
175
** non-conventional directories.
176
*/
177
#define LUA_VDIR        LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
178
#if defined(_WIN32)        /* { */
179
/*
180
** In Windows, any exclamation mark ('!') in the path is replaced by the
181
** path of the directory of the executable file of the current process.
182
*/
183
#define LUA_LDIR        "!\\lua\\"
184
#define LUA_CDIR        "!\\"
185
#define LUA_SHRDIR        "!\\..\\share\\lua\\" LUA_VDIR "\\"
186
#define LUA_PATH_DEFAULT  \
187
                LUA_LDIR"?.lua;"  LUA_LDIR"?\\init.lua;" \
188
                LUA_CDIR"?.lua;"  LUA_CDIR"?\\init.lua;" \
189
                LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \
190
                ".\\?.lua;" ".\\?\\init.lua"
191
#define LUA_CPATH_DEFAULT \
192
                LUA_CDIR"?.dll;" \
193
                LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
194
                LUA_CDIR"loadall.dll;" ".\\?.dll"
195

    
196
#else                        /* }{ */
197

    
198
#define LUA_ROOT        "/usr/local/"
199
#define LUA_LDIR        LUA_ROOT "share/lua/" LUA_VDIR "/"
200
#define LUA_CDIR        LUA_ROOT "lib/lua/" LUA_VDIR "/"
201
#define LUA_PATH_DEFAULT  \
202
                LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
203
                LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua;" \
204
                "./?.lua;" "./?/init.lua"
205
#define LUA_CPATH_DEFAULT \
206
                LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
207
#endif                        /* } */
208

    
209

    
210
/*
211
@@ LUA_DIRSEP is the directory separator (for submodules).
212
** CHANGE it if your machine does not use "/" as the directory separator
213
** and is not Windows. (On Windows Lua automatically uses "\".)
214
*/
215
#if defined(_WIN32)
216
#define LUA_DIRSEP        "\\"
217
#else
218
#define LUA_DIRSEP        "/"
219
#endif
220

    
221
/* }================================================================== */
222

    
223

    
224
/*
225
** {==================================================================
226
** Marks for exported symbols in the C code
227
** ===================================================================
228
*/
229

    
230
/*
231
@@ LUA_API is a mark for all core API functions.
232
@@ LUALIB_API is a mark for all auxiliary library functions.
233
@@ LUAMOD_API is a mark for all standard library opening functions.
234
** CHANGE them if you need to define those functions in some special way.
235
** For instance, if you want to create one Windows DLL with the core and
236
** the libraries, you may want to use the following definition (define
237
** LUA_BUILD_AS_DLL to get it).
238
*/
239
#if defined(LUA_BUILD_AS_DLL)        /* { */
240

    
241
#if defined(LUA_CORE) || defined(LUA_LIB)        /* { */
242
#define LUA_API __declspec(dllexport)
243
#else                                                /* }{ */
244
#define LUA_API __declspec(dllimport)
245
#endif                                                /* } */
246

    
247
#else                                /* }{ */
248

    
249
#define LUA_API                extern
250

    
251
#endif                                /* } */
252

    
253

    
254
/* more often than not the libs go together with the core */
255
#define LUALIB_API        LUA_API
256
#define LUAMOD_API        LUALIB_API
257

    
258

    
259
/*
260
@@ LUAI_FUNC is a mark for all extern functions that are not to be
261
** exported to outside modules.
262
@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
263
** that are not to be exported to outside modules (LUAI_DDEF for
264
** definitions and LUAI_DDEC for declarations).
265
** CHANGE them if you need to mark them in some special way. Elf/gcc
266
** (versions 3.2 and later) mark them as "hidden" to optimize access
267
** when Lua is compiled as a shared library. Not all elf targets support
268
** this attribute. Unfortunately, gcc does not offer a way to check
269
** whether the target offers that support, and those without support
270
** give a warning about it. To avoid these warnings, change to the
271
** default definition.
272
*/
273
#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
274
    defined(__ELF__)                /* { */
275
#define LUAI_FUNC        __attribute__((visibility("hidden"))) extern
276
#else                                /* }{ */
277
#define LUAI_FUNC        extern
278
#endif                                /* } */
279

    
280
#define LUAI_DDEC        LUAI_FUNC
281
#define LUAI_DDEF        /* empty */
282

    
283
/* }================================================================== */
284

    
285

    
286
/*
287
** {==================================================================
288
** Compatibility with previous versions
289
** ===================================================================
290
*/
291

    
292
/*
293
@@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2.
294
@@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1.
295
** You can define it to get all options, or change specific options
296
** to fit your specific needs.
297
*/
298
#if defined(LUA_COMPAT_5_2)        /* { */
299

    
300
/*
301
@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated
302
** functions in the mathematical library.
303
*/
304
#define LUA_COMPAT_MATHLIB
305

    
306
/*
307
@@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'.
308
*/
309
#define LUA_COMPAT_BITLIB
310

    
311
/*
312
@@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod.
313
*/
314
#define LUA_COMPAT_IPAIRS
315

    
316
/*
317
@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for
318
** manipulating other integer types (lua_pushunsigned, lua_tounsigned,
319
** luaL_checkint, luaL_checklong, etc.)
320
*/
321
#define LUA_COMPAT_APIINTCASTS
322

    
323
#endif                                /* } */
324

    
325

    
326
#if defined(LUA_COMPAT_5_1)        /* { */
327

    
328
/* Incompatibilities from 5.2 -> 5.3 */
329
#define LUA_COMPAT_MATHLIB
330
#define LUA_COMPAT_APIINTCASTS
331

    
332
/*
333
@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
334
** You can replace it with 'table.unpack'.
335
*/
336
#define LUA_COMPAT_UNPACK
337

    
338
/*
339
@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
340
** You can replace it with 'package.searchers'.
341
*/
342
#define LUA_COMPAT_LOADERS
343

    
344
/*
345
@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
346
** You can call your C function directly (with light C functions).
347
*/
348
#define lua_cpcall(L,f,u)  \
349
        (lua_pushcfunction(L, (f)), \
350
         lua_pushlightuserdata(L,(u)), \
351
         lua_pcall(L,1,0,0))
352

    
353

    
354
/*
355
@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
356
** You can rewrite 'log10(x)' as 'log(x, 10)'.
357
*/
358
#define LUA_COMPAT_LOG10
359

    
360
/*
361
@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
362
** library. You can rewrite 'loadstring(s)' as 'load(s)'.
363
*/
364
#define LUA_COMPAT_LOADSTRING
365

    
366
/*
367
@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
368
*/
369
#define LUA_COMPAT_MAXN
370

    
371
/*
372
@@ The following macros supply trivial compatibility for some
373
** changes in the API. The macros themselves document how to
374
** change your code to avoid using them.
375
*/
376
#define lua_strlen(L,i)                lua_rawlen(L, (i))
377

    
378
#define lua_objlen(L,i)                lua_rawlen(L, (i))
379

    
380
#define lua_equal(L,idx1,idx2)                lua_compare(L,(idx1),(idx2),LUA_OPEQ)
381
#define lua_lessthan(L,idx1,idx2)        lua_compare(L,(idx1),(idx2),LUA_OPLT)
382

    
383
/*
384
@@ LUA_COMPAT_MODULE controls compatibility with previous
385
** module functions 'module' (Lua) and 'luaL_register' (C).
386
*/
387
#define LUA_COMPAT_MODULE
388

    
389
#endif                                /* } */
390

    
391

    
392
/*
393
@@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a
394
@@ a float mark ('.0').
395
** This macro is not on by default even in compatibility mode,
396
** because this is not really an incompatibility.
397
*/
398
/* #define LUA_COMPAT_FLOATSTRING */
399

    
400
/* }================================================================== */
401

    
402

    
403

    
404
/*
405
** {==================================================================
406
** Configuration for Numbers.
407
** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_*
408
** satisfy your needs.
409
** ===================================================================
410
*/
411

    
412
#ifndef _KERNEL
413
/*
414
@@ LUA_NUMBER is the floating-point type used by Lua.
415
@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
416
@@ over a floating number.
417
@@ l_mathlim(x) corrects limit name 'x' to the proper float type
418
** by prefixing it with one of FLT/DBL/LDBL.
419
@@ LUA_NUMBER_FRMLEN is the length modifier for writing floats.
420
@@ LUA_NUMBER_FMT is the format for writing floats.
421
@@ lua_number2str converts a float to a string.
422
@@ l_mathop allows the addition of an 'l' or 'f' to all math operations.
423
@@ lua_str2number converts a decimal numeric string to a number.
424
*/
425

    
426
#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT                /* { single float */
427

    
428
#define LUA_NUMBER        float
429

    
430
#define l_mathlim(n)                (FLT_##n)
431

    
432
#define LUAI_UACNUMBER        double
433

    
434
#define LUA_NUMBER_FRMLEN        ""
435
#define LUA_NUMBER_FMT                "%.7g"
436

    
437
#define l_mathop(op)                op##f
438

    
439
#define lua_str2number(s,p)        strtof((s), (p))
440

    
441

    
442
#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE        /* }{ long double */
443

    
444
#define LUA_NUMBER        long double
445

    
446
#define l_mathlim(n)                (LDBL_##n)
447

    
448
#define LUAI_UACNUMBER        long double
449

    
450
#define LUA_NUMBER_FRMLEN        "L"
451
#define LUA_NUMBER_FMT                "%.19Lg"
452

    
453
#define l_mathop(op)                op##l
454

    
455
#define lua_str2number(s,p)        strtold((s), (p))
456

    
457
#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE        /* }{ double */
458

    
459
#define LUA_NUMBER        double
460

    
461
#define l_mathlim(n)                (DBL_##n)
462

    
463
#define LUAI_UACNUMBER        double
464

    
465
#define LUA_NUMBER_FRMLEN        ""
466
#define LUA_NUMBER_FMT                "%.14g"
467

    
468
#define l_mathop(op)                op
469

    
470
#define lua_str2number(s,p)        strtod((s), (p))
471

    
472
#else                                                /* }{ */
473

    
474
#error "numeric float type not defined"
475

    
476
#endif                                        /* } */
477

    
478

    
479
#define l_floor(x)                (l_mathop(floor)(x))
480

    
481
#define lua_number2str(s,n)        sprintf((s), LUA_NUMBER_FMT, (n))
482

    
483

    
484
/*
485
@@ lua_numbertointeger converts a float number to an integer, or
486
** returns 0 if float is not within the range of a lua_Integer.
487
** (The range comparisons are tricky because of rounding. The tests
488
** here assume a two-complement representation, where MININTEGER always
489
** has an exact representation as a float; MAXINTEGER may not have one,
490
** and therefore its conversion to float may have an ill-defined value.)
491
*/
492
#define lua_numbertointeger(n,p) \
493
  ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
494
   (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
495
      (*(p) = (LUA_INTEGER)(n), 1))
496

    
497
#endif /*_KERNEL */
498

    
499

    
500
/*
501
@@ LUA_INTEGER is the integer type used by Lua.
502
**
503
@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
504
**
505
@@ LUAI_UACINT is the result of an 'usual argument conversion'
506
@@ over a lUA_INTEGER.
507
@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
508
@@ LUA_INTEGER_FMT is the format for writing integers.
509
@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
510
@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
511
@@ lua_integer2str converts an integer to a string.
512
*/
513

    
514

    
515
/* The following definitions are good for most cases here */
516

    
517
#define LUA_INTEGER_FMT                "%" LUA_INTEGER_FRMLEN "d"
518
#define lua_integer2str(s,n)        sprintf((s), LUA_INTEGER_FMT, (n))
519

    
520
#define LUAI_UACINT                LUA_INTEGER
521

    
522
/*
523
** use LUAI_UACINT here to avoid problems with promotions (which
524
** can turn a comparison between unsigneds into a signed comparison)
525
*/
526
#define LUA_UNSIGNED                unsigned LUAI_UACINT
527

    
528

    
529
/* now the variable definitions */
530

    
531
#if LUA_INT_TYPE == LUA_INT_INT                /* { int */
532

    
533
#define LUA_INTEGER                int
534
#define LUA_INTEGER_FRMLEN        ""
535

    
536
#define LUA_MAXINTEGER                INT_MAX
537
#define LUA_MININTEGER                INT_MIN
538

    
539
#elif LUA_INT_TYPE == LUA_INT_LONG        /* }{ long */
540

    
541
#define LUA_INTEGER                long
542
#define LUA_INTEGER_FRMLEN        "l"
543

    
544
#define LUA_MAXINTEGER                LONG_MAX
545
#define LUA_MININTEGER                LONG_MIN
546

    
547
#elif LUA_INT_TYPE == LUA_INT_LONGLONG        /* }{ long long */
548

    
549
#if defined(LLONG_MAX)                /* { */
550
/* use ISO C99 stuff */
551

    
552
#define LUA_INTEGER                long long
553
#define LUA_INTEGER_FRMLEN        "ll"
554

    
555
#define LUA_MAXINTEGER                LLONG_MAX
556
#define LUA_MININTEGER                LLONG_MIN
557

    
558
#elif defined(LUA_USE_WINDOWS) /* }{ */
559
/* in Windows, can use specific Windows types */
560

    
561
#define LUA_INTEGER                __int64
562
#define LUA_INTEGER_FRMLEN        "I64"
563

    
564
#define LUA_MAXINTEGER                _I64_MAX
565
#define LUA_MININTEGER                _I64_MIN
566

    
567
#else                                /* }{ */
568

    
569
#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \
570
  or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)"
571

    
572
#endif                                /* } */
573

    
574
#else                                /* }{ */
575

    
576
#error "numeric integer type not defined"
577

    
578
#endif                                /* } */
579

    
580
/* }================================================================== */
581

    
582

    
583
/*
584
** {==================================================================
585
** Dependencies with C99 and other C details
586
** ===================================================================
587
*/
588

    
589
/*
590
@@ lua_strx2number converts an hexadecimal numeric string to a number.
591
** In C99, 'strtod' does that conversion. Otherwise, you can
592
** leave 'lua_strx2number' undefined and Lua will provide its own
593
** implementation.
594
*/
595
#if !defined(LUA_USE_C89)
596
#define lua_strx2number(s,p)        lua_str2number(s,p)
597
#endif
598

    
599

    
600
/*
601
@@ lua_number2strx converts a float to an hexadecimal numeric string. 
602
** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that.
603
** Otherwise, you can leave 'lua_number2strx' undefined and Lua will
604
** provide its own implementation.
605
*/
606
#if !defined(LUA_USE_C89)
607
#define lua_number2strx(L,b,f,n)        sprintf(b,f,n)
608
#endif
609

    
610

    
611
/*
612
** 'strtof' and 'opf' variants for math functions are not valid in
613
** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the
614
** availability of these variants. ('math.h' is already included in
615
** all files that use these macros.)
616
*/
617
#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF))
618
#undef l_mathop  /* variants not available */
619
#undef lua_str2number
620
#define l_mathop(op)                (lua_Number)op  /* no variant */
621
#define lua_str2number(s,p)        ((lua_Number)strtod((s), (p)))
622
#endif
623

    
624

    
625
/*
626
@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation
627
** functions.  It must be a numerical type; Lua will use 'intptr_t' if
628
** available, otherwise it will use 'ptrdiff_t' (the nearest thing to
629
** 'intptr_t' in C89)
630
*/
631
#define LUA_KCONTEXT        ptrdiff_t
632

    
633
#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
634
    __STDC_VERSION__ >= 199901L
635
#include <stdint.h>
636
#if defined(INTPTR_MAX)  /* even in C99 this type is optional */
637
#undef LUA_KCONTEXT
638
#define LUA_KCONTEXT        intptr_t
639
#endif
640
#endif
641

    
642

    
643
/*
644
@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point).
645
** Change that if you do not want to use C locales. (Code using this
646
** macro must include header 'locale.h'.)
647
*/
648
#if !defined(lua_getlocaledecpoint)
649
#define lua_getlocaledecpoint()                (localeconv()->decimal_point[0])
650
#endif
651

    
652
/* }================================================================== */
653

    
654

    
655
/*
656
** {==================================================================
657
** Language Variations
658
** =====================================================================
659
*/
660

    
661
/*
662
@@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some
663
** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from
664
** numbers to strings. Define LUA_NOCVTS2N to turn off automatic
665
** coercion from strings to numbers.
666
*/
667
/* #define LUA_NOCVTN2S */
668
/* #define LUA_NOCVTS2N */
669

    
670

    
671
/*
672
@@ LUA_USE_APICHECK turns on several consistency checks on the C API.
673
** Define it as a help when debugging C code.
674
*/
675
#if defined(LUA_USE_APICHECK)
676
#include <assert.h>
677
#define luai_apicheck(l,e)        assert(e)
678
#endif
679

    
680
/* }================================================================== */
681

    
682

    
683
/*
684
** {==================================================================
685
** Macros that affect the API and must be stable (that is, must be the
686
** same when you compile Lua and when you compile code that links to
687
** Lua). You probably do not want/need to change them.
688
** =====================================================================
689
*/
690

    
691
/*
692
@@ LUAI_MAXSTACK limits the size of the Lua stack.
693
** CHANGE it if you need a different limit. This limit is arbitrary;
694
** its only purpose is to stop Lua from consuming unlimited stack
695
** space (and to reserve some numbers for pseudo-indices).
696
*/
697
#if LUAI_BITSINT >= 32
698
#define LUAI_MAXSTACK                1000000
699
#else
700
#define LUAI_MAXSTACK                15000
701
#endif
702

    
703

    
704
/*
705
@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
706
** a Lua state with very fast access.
707
** CHANGE it if you need a different size.
708
*/
709
#define LUA_EXTRASPACE                (sizeof(void *))
710

    
711

    
712
/*
713
@@ LUA_IDSIZE gives the maximum size for the description of the source
714
@@ of a function in debug information.
715
** CHANGE it if you want a different size.
716
*/
717
#define LUA_IDSIZE        60
718

    
719

    
720
/*
721
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
722
** CHANGE it if it uses too much C-stack space. (For long double,
723
** 'string.format("%.99f", 1e4932)' needs ~5030 bytes, so a
724
** smaller buffer would force a memory allocation for each call to
725
** 'string.format'.)
726
*/
727
#if defined(LUA_FLOAT_LONGDOUBLE)
728
#define LUAL_BUFFERSIZE                8192
729
#else
730
#define LUAL_BUFFERSIZE   ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer)))
731
#endif
732

    
733
/* }================================================================== */
734

    
735

    
736
/*
737
@@ LUA_QL describes how error messages quote program elements.
738
** Lua does not use these macros anymore; they are here for
739
** compatibility only.
740
*/
741
#define LUA_QL(x)        "'" x "'"
742
#define LUA_QS                LUA_QL("%s")
743

    
744

    
745

    
746

    
747
/* =================================================================== */
748

    
749
/*
750
** Local configuration. You can use this space to add your redefinitions
751
** without modifying the main part of the file.
752
*/
753

    
754
#if defined(__NetBSD__) || defined(__minix)
755

    
756
/* Integer types */
757
#undef LUA_INTEGER
758
#undef LUA_INTEGER_FRMLEN
759
#undef LUA_UNSIGNED
760
#undef LUA_MAXUNSIGNED
761
#undef LUA_MAXINTEGER
762
#undef LUA_MININTEGER
763

    
764
#define LUA_INTEGER                intmax_t
765
#define LUA_INTEGER_FRMLEN        "j"
766
#define LUA_UNSIGNED                uintmax_t
767
#define LUA_MAXUNSIGNED                UINTMAX_MAX
768
#define LUA_MAXINTEGER                INTMAX_MAX
769
#define LUA_MININTEGER                INTMAX_MIN
770

    
771
/* Path */
772
#undef LUA_ROOT
773
#undef LUA_PATH_DEFAULT
774
#undef LUA_CPATH_DEFAULT
775

    
776
#define LUA_ROOT        "/usr/"
777
#define LUA_PATH_DEFAULT  \
778
                LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
779
                LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua"
780
#define LUA_CPATH_DEFAULT \
781
                LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
782

    
783
#ifndef _KERNEL
784

    
785
#include <stdint.h>
786

    
787
#else /* _KERNEL */
788

    
789
#define LUA_NUMBER                LUA_INTEGER
790
#define LUA_NUMBER_FMT                LUA_INTEGER_FMT
791

    
792
/* setjmp.h */
793
#define LUAI_THROW(L,c)                longjmp(&((c)->b))
794
#define LUAI_TRY(L,c,a)                if (setjmp(&((c)->b)) == 0) { a }
795
#define luai_jmpbuf                label_t
796

    
797
/* time.h */
798
#include <sys/time.h>
799
#define time(p)                        (time_uptime)
800

    
801
/* stdio.h */
802
#define lua_writestring(s,l)        printf("%s", (s))
803
#define lua_writeline()                printf("\n")
804

    
805
#define sprintf(s,fmt,...)        snprintf(s, sizeof(s), fmt, __VA_ARGS__)
806

    
807
/* string.h */
808
#define strcoll strcmp
809

    
810
/* stdlib.h */
811
#define abort()                        panic("Lua has aborted!")
812

    
813
#endif /* _KERNEL */
814

    
815
#endif /* __NetBSD__ || __minix */
816

    
817
#endif
818