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