rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
luaconf.h
Go to the documentation of this file.
1/*
2** $Id: luaconf.h $
3** Configuration file for Lua
4** See Copyright Notice in lua.h
5*/
6
7
8#ifndef luaconf_h
9#define luaconf_h
10
11#include <limits.h>
12#include <stddef.h>
13
14
15/*
16** ===================================================================
17** General Configuration File for Lua
18**
19** Some definitions here can be changed externally, through the compiler
20** (e.g., with '-D' options): They are commented out or protected
21** by '#if !defined' guards. However, several other definitions
22** should be changed directly here, either because they affect the
23** Lua ABI (by making the changes here, you ensure that all software
24** connected to Lua, such as C libraries, will be compiled with the same
25** configuration); or because they are seldom changed.
26**
27** Search for "@@" to find all configurable definitions.
28** ===================================================================
29*/
30
31/*
32@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits.
33*/
34#define LUAI_IS32INT ((UINT_MAX >> 30) >= 3)
35
36/*
37@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats.
38*/
39#define LUA_32BITS 1
40
41/*
42** {==================================================================
43** Configuration for Paths.
44** ===================================================================
45*/
46
47/*
48** LUA_PATH_SEP is the character that separates templates in a path.
49** LUA_PATH_MARK is the string that marks the substitution points in a
50** template.
51** LUA_EXEC_DIR in a Windows path is replaced by the executable's
52** directory.
53*/
54#define LUA_PATH_SEP ";"
55#define LUA_PATH_MARK "?"
56#define LUA_EXEC_DIR "!"
57
58/*
59** LUA_IGMARK is a mark to ignore all after it when building the
60** module name (e.g., used to build the luaopen_ function name).
61** Typically, the suffix after the mark is the module version,
62** as in "mod-v1.2.so".
63*/
64#ifndef LUA_IGMARK
65#define LUA_IGMARK "-"
66#endif
67
68
69/*
70@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
71** Lua libraries.
72@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
73** C libraries.
74** CHANGE them if your machine has a non-conventional directory
75** hierarchy or if you want to install your libraries in
76** non-conventional directories.
77*/
78
79#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
80#if defined(_WIN32) /* { */
81/*
82** In Windows, any exclamation mark ('!') in the path is replaced by the
83** path of the directory of the executable file of the current process.
84*/
85#define LUA_LDIR "!\\lua\\"
86#define LUA_CDIR "!\\"
87#define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\"
88
89#if !defined(LUA_PATH_DEFAULT)
90#define LUA_PATH_DEFAULT \
91 LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
92 LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \
93 LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \
94 ".\\?.lua;" ".\\?\\init.lua"
95#endif
96
97#if !defined(LUA_CPATH_DEFAULT)
98#define LUA_CPATH_DEFAULT \
99 LUA_CDIR"?.dll;" \
100 LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
101 LUA_CDIR"loadall.dll;" ".\\?.dll"
102#endif
103
104#else /* }{ */
105
106#define LUA_ROOT "/usr/local/"
107#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/"
108#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/"
109
110#if !defined(LUA_PATH_DEFAULT)
111#define LUA_PATH_DEFAULT \
112 LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
113 LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
114 "./?.lua;" "./?/init.lua"
115#endif
116
117#if !defined(LUA_CPATH_DEFAULT)
118#define LUA_CPATH_DEFAULT \
119 LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
120#endif
121
122#endif /* } */
123
124
125/*
126@@ LUA_DIRSEP is the directory separator (for submodules).
127** CHANGE it if your machine does not use "/" as the directory separator
128** and is not Windows. (On Windows Lua automatically uses "\".)
129*/
130#if !defined(LUA_DIRSEP)
131
132#if defined(_WIN32)
133#define LUA_DIRSEP "\\"
134#else
135#define LUA_DIRSEP "/"
136#endif
137
138#endif
139
140/* }================================================================== */
141
142
143/*
144** {==================================================================
145** Marks for exported symbols in the C code
146** ===================================================================
147*/
148
149/*
150@@ LUA_API is a mark for all core API functions.
151@@ LUALIB_API is a mark for all auxiliary library functions.
152@@ LUAMOD_API is a mark for all standard library opening functions.
153** CHANGE them if you need to define those functions in some special way.
154** For instance, if you want to create one Windows DLL with the core and
155** the libraries, you may want to use the following definition (define
156** LUA_BUILD_AS_DLL to get it).
157*/
158#if defined(LUA_BUILD_AS_DLL) /* { */
159
160#if defined(LUA_CORE) || defined(LUA_LIB) /* { */
161#define LUA_API __declspec(dllexport)
162#else /* }{ */
163#define LUA_API __declspec(dllimport)
164#endif /* } */
165
166#else /* }{ */
167
168#define LUA_API extern
169
170#endif /* } */
171
172
173/*
174** More often than not the libs go together with the core.
175*/
176#define LUALIB_API LUA_API
177#define LUAMOD_API LUA_API
178
179
180/*
181@@ LUAI_FUNC is a mark for all extern functions that are not to be
182** exported to outside modules.
183@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables,
184** none of which to be exported to outside modules (LUAI_DDEF for
185** definitions and LUAI_DDEC for declarations).
186** CHANGE them if you need to mark them in some special way. Elf/gcc
187** (versions 3.2 and later) mark them as "hidden" to optimize access
188** when Lua is compiled as a shared library. Not all elf targets support
189** this attribute. Unfortunately, gcc does not offer a way to check
190** whether the target offers that support, and those without support
191** give a warning about it. To avoid these warnings, change to the
192** default definition.
193*/
194#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
195 defined(__ELF__) /* { */
196#define LUAI_FUNC __attribute__((visibility("internal"))) extern
197#else /* }{ */
198#define LUAI_FUNC extern
199#endif /* } */
200
201#define LUAI_DDEC(dec) LUAI_FUNC dec
202#define LUAI_DDEF /* empty */
203
204/* }================================================================== */
205
206
207/*
208** {==================================================================
209** Compatibility with previous versions
210** ===================================================================
211*/
212
213/*
214@@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.3.
215** You can define it to get all options, or change specific options
216** to fit your specific needs.
217*/
218#if defined(LUA_COMPAT_5_3) /* { */
219
220/*
221@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated
222** functions in the mathematical library.
223** (These functions were already officially removed in 5.3;
224** nevertheless they are still available here.)
225*/
226#define LUA_COMPAT_MATHLIB
227
228/*
229@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for
230** manipulating other integer types (lua_pushunsigned, lua_tounsigned,
231** luaL_checkint, luaL_checklong, etc.)
232** (These macros were also officially removed in 5.3, but they are still
233** available here.)
234*/
235#define LUA_COMPAT_APIINTCASTS
236
237
238/*
239@@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod
240** using '__lt'.
241*/
242#define LUA_COMPAT_LT_LE
243
244
245/*
246@@ The following macros supply trivial compatibility for some
247** changes in the API. The macros themselves document how to
248** change your code to avoid using them.
249** (Once more, these macros were officially removed in 5.3, but they are
250** still available here.)
251*/
252#define lua_strlen(L,i) lua_rawlen(L, (i))
253
254#define lua_objlen(L,i) lua_rawlen(L, (i))
255
256#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
257#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
258
259#endif /* } */
260
261/* }================================================================== */
262
263
264
265/*
266** {==================================================================
267** Configuration for Numbers (low-level part).
268** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_*
269** satisfy your needs.
270** ===================================================================
271*/
272
273/*
274@@ LUAI_UACNUMBER is the result of a 'default argument promotion'
275@@ over a floating number.
276@@ l_floatatt(x) corrects float attribute 'x' to the proper float type
277** by prefixing it with one of FLT/DBL/LDBL.
278@@ LUA_NUMBER_FRMLEN is the length modifier for writing floats.
279@@ LUA_NUMBER_FMT is the format for writing floats.
280@@ lua_number2str converts a float to a string.
281@@ l_mathop allows the addition of an 'l' or 'f' to all math operations.
282@@ l_floor takes the floor of a float.
283@@ lua_str2number converts a decimal numeral to a number.
284*/
285
286
287/* The following definitions are good for most cases here */
288
289#define l_floor(x) (l_mathop(floor)(x))
290
291#define lua_number2str(s,sz,n) \
292 l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n))
293
294/*
295@@ lua_numbertointeger converts a float number with an integral value
296** to an integer, or returns 0 if float is not within the range of
297** a lua_Integer. (The range comparisons are tricky because of
298** rounding. The tests here assume a two-complement representation,
299** where MININTEGER always has an exact representation as a float;
300** MAXINTEGER may not have one, and therefore its conversion to float
301** may have an ill-defined value.)
302*/
303#define lua_numbertointeger(n,p) \
304 ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
305 (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
306 (*(p) = (LUA_INTEGER)(n), 1))
307
308
309/* now the variable definitions */
310
311#define LUA_NUMBER float
312
313#define l_floatatt(n) (FLT_##n)
314
315#define LUAI_UACNUMBER double
316
317#define LUA_NUMBER_FRMLEN ""
318#define LUA_NUMBER_FMT "%.7f"
319
320#define l_mathop(op) op##f
321
322// defined in Lua.cpp
323float strtof_rusefi(const char*, char**);
324
325#define lua_str2number(s,p) strtof_rusefi((s), (p))
326
327
328/*
329@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
330@@ LUAI_UACINT is the result of a 'default argument promotion'
331@@ over a LUA_INTEGER.
332@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
333@@ LUA_INTEGER_FMT is the format for writing integers.
334@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
335@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
336@@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED.
337@@ LUA_UNSIGNEDBITS is the number of bits in a LUA_UNSIGNED.
338@@ lua_integer2str converts an integer to a string.
339*/
340
341
342/* The following definitions are good for most cases here */
343
344#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
345
346#define LUAI_UACINT LUA_INTEGER
347
348#define lua_integer2str(s,sz,n) \
349 l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n))
350
351/*
352** use LUAI_UACINT here to avoid problems with promotions (which
353** can turn a comparison between unsigneds into a signed comparison)
354*/
355#define LUA_UNSIGNED unsigned LUAI_UACINT
356
357
358#define LUA_UNSIGNEDBITS (sizeof(LUA_UNSIGNED) * CHAR_BIT)
359
360
361/* now the variable definitions */
362
363#define LUA_INTEGER int
364#define LUA_INTEGER_FRMLEN ""
365
366#define LUA_MAXINTEGER INT_MAX
367#define LUA_MININTEGER INT_MIN
368
369#define LUA_MAXUNSIGNED UINT_MAX
370
371/*
372** {==================================================================
373** Dependencies with C99 and other C details
374** ===================================================================
375*/
376
377/*
378@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89.
379** (All uses in Lua have only one format item.)
380*/
381#if EFI_UNIT_TEST
382 // Unit tests use normal snprintf
383 #define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i)
384#else
385 // Real FW uses ChibiOS chsnprintf implementation
386 #include <ch.h>
387 #include <hal.h>
388 #include "chprintf.h"
389 #define l_sprintf(s,sz,f,i) chsnprintf(s,sz,f,i)
390#endif
391
392/*
393@@ lua_strx2number converts a hexadecimal numeral to a number.
394** In C99, 'strtod' does that conversion. Otherwise, you can
395** leave 'lua_strx2number' undefined and Lua will provide its own
396** implementation.
397*/
398#if !defined(LUA_USE_C89)
399#define lua_strx2number(s,p) lua_str2number(s,p)
400#endif
401
402
403/*
404@@ lua_pointer2str converts a pointer to a readable string in a
405** non-specified way.
406*/
407#define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p)
408
409
410/*
411@@ lua_number2strx converts a float to a hexadecimal numeral.
412** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that.
413** Otherwise, you can leave 'lua_number2strx' undefined and Lua will
414** provide its own implementation.
415*/
416#if !defined(LUA_USE_C89)
417#define lua_number2strx(L,b,sz,f,n) \
418 ((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n)))
419#endif
420
421
422/*
423** 'strtof' and 'opf' variants for math functions are not valid in
424** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the
425** availability of these variants. ('math.h' is already included in
426** all files that use these macros.)
427*/
428#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF))
429#undef l_mathop /* variants not available */
430#undef lua_str2number
431#define l_mathop(op) (lua_Number)op /* no variant */
432#define lua_str2number(s,p) ((lua_Number)strtod((s), (p)))
433#endif
434
435
436/*
437@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation
438** functions. It must be a numerical type; Lua will use 'intptr_t' if
439** available, otherwise it will use 'ptrdiff_t' (the nearest thing to
440** 'intptr_t' in C89)
441*/
442#define LUA_KCONTEXT ptrdiff_t
443
444#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
445 __STDC_VERSION__ >= 199901L
446#include <stdint.h>
447#if defined(INTPTR_MAX) /* even in C99 this type is optional */
448#undef LUA_KCONTEXT
449#define LUA_KCONTEXT intptr_t
450#endif
451#endif
452
453
454/*
455@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point).
456** Change that if you do not want to use C locales. (Code using this
457** macro must include the header 'locale.h'.)
458*/
459#if !defined(lua_getlocaledecpoint)
460#define lua_getlocaledecpoint() '.'
461#endif
462
463
464/*
465** macros to improve jump prediction, used mostly for error handling
466** and debug facilities. (Some macros in the Lua API use these macros.
467** Define LUA_NOBUILTIN if you do not want '__builtin_expect' in your
468** code.)
469*/
470#if !defined(luai_likely)
471
472#if defined(__GNUC__) && !defined(LUA_NOBUILTIN)
473#define luai_likely(x) (__builtin_expect(((x) != 0), 1))
474#define luai_unlikely(x) (__builtin_expect(((x) != 0), 0))
475#else
476#define luai_likely(x) (x)
477#define luai_unlikely(x) (x)
478#endif
479
480#endif
481
482
483#if defined(LUA_CORE) || defined(LUA_LIB)
484/* shorter names for Lua's own use */
485#define l_likely(x) luai_likely(x)
486#define l_unlikely(x) luai_unlikely(x)
487#endif
488
489
490
491/* }================================================================== */
492
493
494/*
495** {==================================================================
496** Language Variations
497** =====================================================================
498*/
499
500/*
501@@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some
502** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from
503** numbers to strings. Define LUA_NOCVTS2N to turn off automatic
504** coercion from strings to numbers.
505*/
506/* #define LUA_NOCVTN2S */
507/* #define LUA_NOCVTS2N */
508
509
510/*
511@@ LUA_USE_APICHECK turns on several consistency checks on the C API.
512** Define it as a help when debugging C code.
513*/
514#if defined(LUA_USE_APICHECK)
515#include <assert.h>
516#define luai_apicheck(l,e) assert(e)
517#endif
518
519/* }================================================================== */
520
521
522/*
523** {==================================================================
524** Macros that affect the API and must be stable (that is, must be the
525** same when you compile Lua and when you compile code that links to
526** Lua).
527** =====================================================================
528*/
529
530/*
531@@ LUAI_MAXSTACK limits the size of the Lua stack.
532** CHANGE it if you need a different limit. This limit is arbitrary;
533** its only purpose is to stop Lua from consuming unlimited stack
534** space (and to reserve some numbers for pseudo-indices).
535** (It must fit into max(size_t)/32.)
536*/
537#if LUAI_IS32INT
538#define LUAI_MAXSTACK 1000000
539#else
540#define LUAI_MAXSTACK 15000
541#endif
542
543
544/*
545@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
546** a Lua state with very fast access.
547** CHANGE it if you need a different size.
548*/
549#define LUA_EXTRASPACE (sizeof(void *))
550
551
552/*
553@@ LUA_IDSIZE gives the maximum size for the description of the source
554@@ of a function in debug information.
555** CHANGE it if you want a different size.
556*/
557#define LUA_IDSIZE 60
558
559
560/*
561@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
562*/
563#define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number)))
564
565
566/*
567@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure
568** maximum alignment for the other items in that union.
569*/
570#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l
571
572/* }================================================================== */
573
574
575
576
577
578/* =================================================================== */
579
580/*
581** Local configuration. You can use this space to add your redefinitions
582** without modifying the main part of the file.
583*/
584
585
586
587
588
589#endif
590
float strtof_rusefi(const char *, char **)
Definition lua.cpp:412