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