The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
luaconf.h
Go to the documentation of this file.
1 /*
2 ** Configuration file for Lua
3 ** See Copyright Notice in lua.h
4 */
5 
6 
7 #ifndef lconfig_h
8 #define lconfig_h
9 
10 #include <limits.h>
11 #include <stddef.h>
12 
13 /*
14  * Wesnoth definitions for compatibility
15  */
16 #define LUA_COMPAT_MODULE
17 
18 // todo: remove after 1.11.2
19 #define LUA_COMPAT_ALL
20 
21 /*
22 ** ==================================================================
23 ** Search for "@@" to find all configurable definitions.
24 ** ===================================================================
25 */
26 
27 
28 /*
29 @@ LUA_ANSI controls the use of non-ansi features.
30 ** CHANGE it (define it) if you want Lua to avoid the use of any
31 ** non-ansi feature or library.
32 */
33 
34 
35 #if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE)
36 #define LUA_WIN /* enable goodies for regular Windows platforms */
37 #endif
38 
39 #if defined(LUA_WIN)
40 #define LUA_DL_DLL
41 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
42 #endif
43 
44 
45 
46 #if defined(LUA_USE_LINUX)
47 #define LUA_USE_POSIX
48 #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
49 #define LUA_USE_READLINE /* needs some extra libraries */
50 #define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
51 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
52 #define LUA_USE_LONGLONG /* assume support for long long */
53 #endif
54 
55 #if defined(LUA_USE_MACOSX)
56 #define LUA_USE_POSIX
57 #define LUA_USE_DLOPEN /* does not need -ldl */
58 #define LUA_USE_READLINE /* needs an extra library: -lreadline */
59 #define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */
60 #define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */
61 #define LUA_USE_LONGLONG /* assume support for long long */
62 #endif
63 
64 
65 
66 /*
67 @@ LUA_USE_POSIX includes all functionality listed as X/Open System
68 @* Interfaces Extension (XSI).
69 ** CHANGE it (define it) if your system is XSI compatible.
70 */
71 #if defined(LUA_USE_POSIX)
72 #define LUA_USE_MKSTEMP
73 #define LUA_USE_ISATTY
74 #define LUA_USE_POPEN
75 #define LUA_USE_ULONGJMP
76 #define LUA_USE_GMTIME_R
77 #endif
78 
79 
80 
81 /*
82 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
83 @* Lua libraries.
84 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
85 @* C libraries.
86 ** CHANGE them if your machine has a non-conventional directory
87 ** hierarchy or if you want to install your libraries in
88 ** non-conventional directories.
89 */
90 #if defined(_WIN32) /* { */
91 /*
92 ** In Windows, any exclamation mark ('!') in the path is replaced by the
93 ** path of the directory of the executable file of the current process.
94 */
95 #define LUA_LDIR "!\\lua\\"
96 #define LUA_CDIR "!\\"
97 #define LUA_PATH_DEFAULT \
98  LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
99  LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua"
100 #define LUA_CPATH_DEFAULT \
101  LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll"
102 
103 #else /* }{ */
104 
105 #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
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 #define LUA_PATH_DEFAULT \
110  LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
111  LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua"
112 #define LUA_CPATH_DEFAULT \
113  LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
114 #endif /* } */
115 
116 
117 /*
118 @@ LUA_DIRSEP is the directory separator (for submodules).
119 ** CHANGE it if your machine does not use "/" as the directory separator
120 ** and is not Windows. (On Windows Lua automatically uses "\".)
121 */
122 #if defined(_WIN32)
123 #define LUA_DIRSEP "\\"
124 #else
125 #define LUA_DIRSEP "/"
126 #endif
127 
128 
129 /*
130 @@ LUA_ENV is the name of the variable that holds the current
131 @@ environment, used to access global names.
132 ** CHANGE it if you do not like this name.
133 */
134 #define LUA_ENV "_ENV"
135 
136 
137 /*
138 @@ LUA_API is a mark for all core API functions.
139 @@ LUALIB_API is a mark for all auxiliary library functions.
140 @@ LUAMOD_API is a mark for all standard library opening functions.
141 ** CHANGE them if you need to define those functions in some special way.
142 ** For instance, if you want to create one Windows DLL with the core and
143 ** the libraries, you may want to use the following definition (define
144 ** LUA_BUILD_AS_DLL to get it).
145 */
146 #if defined(LUA_BUILD_AS_DLL) /* { */
147 
148 #if defined(LUA_CORE) || defined(LUA_LIB) /* { */
149 #define LUA_API __declspec(dllexport)
150 #else /* }{ */
151 #define LUA_API __declspec(dllimport)
152 #endif /* } */
153 
154 #else /* }{ */
155 
156 #define LUA_API extern
157 
158 #endif /* } */
159 
160 
161 /* more often than not the libs go together with the core */
162 #define LUALIB_API LUA_API
163 #define LUAMOD_API LUALIB_API
164 
165 
166 /*
167 @@ LUAI_FUNC is a mark for all extern functions that are not to be
168 @* exported to outside modules.
169 @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
170 @* that are not to be exported to outside modules (LUAI_DDEF for
171 @* definitions and LUAI_DDEC for declarations).
172 ** CHANGE them if you need to mark them in some special way. Elf/gcc
173 ** (versions 3.2 and later) mark them as "hidden" to optimize access
174 ** when Lua is compiled as a shared library. Not all elf targets support
175 ** this attribute. Unfortunately, gcc does not offer a way to check
176 ** whether the target offers that support, and those without support
177 ** give a warning about it. To avoid these warnings, change to the
178 ** default definition.
179 */
180 #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
181  defined(__ELF__) /* { */
182 #define LUAI_FUNC __attribute__((visibility("hidden"))) extern
183 #define LUAI_DDEC LUAI_FUNC
184 #define LUAI_DDEF /* empty */
185 
186 #else /* }{ */
187 #define LUAI_FUNC extern
188 #define LUAI_DDEC extern
189 #define LUAI_DDEF /* empty */
190 #endif /* } */
191 
192 
193 
194 /*
195 @@ LUA_QL describes how error messages quote program elements.
196 ** CHANGE it if you want a different appearance.
197 */
198 #define LUA_QL(x) "'" x "'"
199 #define LUA_QS LUA_QL("%s")
200 
201 
202 /*
203 @@ LUA_IDSIZE gives the maximum size for the description of the source
204 @* of a function in debug information.
205 ** CHANGE it if you want a different size.
206 */
207 #define LUA_IDSIZE 60
208 
209 
210 /*
211 @@ luai_writestring/luai_writeline define how 'print' prints its results.
212 ** They are only used in libraries and the stand-alone program. (The #if
213 ** avoids including 'stdio.h' everywhere.)
214 */
215 #if defined(LUA_LIB) || defined(lua_c)
216 #include <stdio.h>
217 inline void fwrite_wrapper(const void * ptr, size_t size, size_t count, FILE * stream ) {
218  size_t i = fwrite(ptr, size, count, stream);
219  if (i != count * size) {
220  puts("error in fwrite by lua, unexpected amount of bytes written");
221  }
222 }
223 
224 #define luai_writestring(s,l) fwrite_wrapper((s), sizeof(char), (l), stdout)
225 #define luai_writeline() (luai_writestring("\n", 1), fflush(stdout))
226 #endif
227 
228 /*
229 @@ luai_writestringerror defines how to print error messages.
230 ** (A format string with one argument is enough for Lua...)
231 */
232 #define luai_writestringerror(s,p) \
233  (fprintf(stderr, (s), (p)), fflush(stderr))
234 
235 
236 /*
237 @@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is,
238 ** strings that are internalized. (Cannot be smaller than reserved words
239 ** or tags for metamethods, as these strings must be internalized;
240 ** #("function") = 8, #("__newindex") = 10.)
241 */
242 #define LUAI_MAXSHORTLEN 40
243 
244 
245 
246 /*
247 ** {==================================================================
248 ** Compatibility with previous versions
249 ** ===================================================================
250 */
251 
252 /*
253 @@ LUA_COMPAT_ALL controls all compatibility options.
254 ** You can define it to get all options, or change specific options
255 ** to fit your specific needs.
256 */
257 #if defined(LUA_COMPAT_ALL) /* { */
258 
259 /*
260 @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
261 ** You can replace it with 'table.unpack'.
262 */
263 #define LUA_COMPAT_UNPACK
264 
265 /*
266 @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
267 ** You can replace it with 'package.searchers'.
268 */
269 #define LUA_COMPAT_LOADERS
270 
271 /*
272 @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
273 ** You can call your C function directly (with light C functions).
274 */
275 #define lua_cpcall(L,f,u) \
276  (lua_pushcfunction(L, (f)), \
277  lua_pushlightuserdata(L,(u)), \
278  lua_pcall(L,1,0,0))
279 
280 
281 /*
282 @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
283 ** You can rewrite 'log10(x)' as 'log(x, 10)'.
284 */
285 #define LUA_COMPAT_LOG10
286 
287 /*
288 @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
289 ** library. You can rewrite 'loadstring(s)' as 'load(s)'.
290 */
291 #define LUA_COMPAT_LOADSTRING
292 
293 /*
294 @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
295 */
296 #define LUA_COMPAT_MAXN
297 
298 /*
299 @@ The following macros supply trivial compatibility for some
300 ** changes in the API. The macros themselves document how to
301 ** change your code to avoid using them.
302 */
303 #define lua_strlen(L,i) lua_rawlen(L, (i))
304 
305 #define lua_objlen(L,i) lua_rawlen(L, (i))
306 
307 #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
308 #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
309 
310 /*
311 @@ LUA_COMPAT_MODULE controls compatibility with previous
312 ** module functions 'module' (Lua) and 'luaL_register' (C).
313 */
314 #define LUA_COMPAT_MODULE
315 
316 #endif /* } */
317 
318 /* }================================================================== */
319 
320 
321 
322 /*
323 @@ LUAI_BITSINT defines the number of bits in an int.
324 ** CHANGE here if Lua cannot automatically detect the number of bits of
325 ** your machine. Probably you do not need to change this.
326 */
327 /* avoid overflows in comparison */
328 #if INT_MAX-20 < 32760 /* { */
329 #define LUAI_BITSINT 16
330 #elif INT_MAX > 2147483640L /* }{ */
331 /* int has at least 32 bits */
332 #define LUAI_BITSINT 32
333 #else /* }{ */
334 #error "you must define LUA_BITSINT with number of bits in an integer"
335 #endif /* } */
336 
337 
338 /*
339 @@ LUA_INT32 is an signed integer with exactly 32 bits.
340 @@ LUAI_UMEM is an unsigned integer big enough to count the total
341 @* memory used by Lua.
342 @@ LUAI_MEM is a signed integer big enough to count the total memory
343 @* used by Lua.
344 ** CHANGE here if for some weird reason the default definitions are not
345 ** good enough for your machine. Probably you do not need to change
346 ** this.
347 */
348 #if LUAI_BITSINT >= 32 /* { */
349 #define LUA_INT32 int
350 #define LUAI_UMEM size_t
351 #define LUAI_MEM ptrdiff_t
352 #else /* }{ */
353 /* 16-bit ints */
354 #define LUA_INT32 long
355 #define LUAI_UMEM unsigned long
356 #define LUAI_MEM long
357 #endif /* } */
358 
359 
360 /*
361 @@ LUAI_MAXSTACK limits the size of the Lua stack.
362 ** CHANGE it if you need a different limit. This limit is arbitrary;
363 ** its only purpose is to stop Lua to consume unlimited stack
364 ** space (and to reserve some numbers for pseudo-indices).
365 */
366 #if LUAI_BITSINT >= 32
367 #define LUAI_MAXSTACK 1000000
368 #else
369 #define LUAI_MAXSTACK 15000
370 #endif
371 
372 /* reserve some space for error handling */
373 #define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000)
374 
375 
376 
377 
378 /*
379 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
380 ** CHANGE it if it uses too much C-stack space.
381 */
382 #define LUAL_BUFFERSIZE BUFSIZ
383 
384 
385 
386 
387 /*
388 ** {==================================================================
389 @@ LUA_NUMBER is the type of numbers in Lua.
390 ** CHANGE the following definitions only if you want to build Lua
391 ** with a number type different from double. You may also need to
392 ** change lua_number2int & lua_number2integer.
393 ** ===================================================================
394 */
395 
396 #define LUA_NUMBER_DOUBLE
397 #define LUA_NUMBER double
398 
399 /*
400 @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
401 @* over a number.
402 */
403 #define LUAI_UACNUMBER double
404 
405 
406 /*
407 @@ LUA_NUMBER_SCAN is the format for reading numbers.
408 @@ LUA_NUMBER_FMT is the format for writing numbers.
409 @@ lua_number2str converts a number to a string.
410 @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
411 */
412 #define LUA_NUMBER_SCAN "%lf"
413 #define LUA_NUMBER_FMT "%.14g"
414 #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
415 #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
416 
417 
418 /*
419 @@ l_mathop allows the addition of an 'l' or 'f' to all math operations
420 */
421 #define l_mathop(x) (x)
422 
423 
424 /*
425 @@ lua_str2number converts a decimal numeric string to a number.
426 @@ lua_strx2number converts an hexadecimal numeric string to a number.
427 ** In C99, 'strtod' does both conversions. C89, however, has no function
428 ** to convert floating hexadecimal strings to numbers. For these
429 ** systems, you can leave 'lua_strx2number' undefined and Lua will
430 ** provide its own implementation.
431 */
432 #define lua_str2number(s,p) strtod((s), (p))
433 
434 #if defined(LUA_USE_STRTODHEX)
435 #define lua_strx2number(s,p) strtod((s), (p))
436 #endif
437 
438 
439 /*
440 @@ The luai_num* macros define the primitive operations over numbers.
441 */
442 
443 /* the following operations need the math library */
444 #if defined(lobject_c) || defined(lvm_c)
445 #include <math.h>
446 #define luai_nummod(L,a,b) ((a) - l_mathop(floor)((a)/(b))*(b))
447 #define luai_numpow(L,a,b) (l_mathop(pow)(a,b))
448 #endif
449 
450 /* these are quite standard operations */
451 #if defined(LUA_CORE)
452 #define luai_numadd(L,a,b) ((a)+(b))
453 #define luai_numsub(L,a,b) ((a)-(b))
454 #define luai_nummul(L,a,b) ((a)*(b))
455 #define luai_numdiv(L,a,b) ((a)/(b))
456 #define luai_numunm(L,a) (-(a))
457 #define luai_numeq(a,b) ((a)==(b))
458 #define luai_numlt(L,a,b) ((a)<(b))
459 #define luai_numle(L,a,b) ((a)<=(b))
460 #define luai_numisnan(L,a) (!luai_numeq((a), (a)))
461 #endif
462 
463 
464 
465 /*
466 @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
467 ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
468 ** machines, ptrdiff_t gives a good choice between int or long.)
469 */
470 #define LUA_INTEGER ptrdiff_t
471 
472 /*
473 @@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
474 ** It must have at least 32 bits.
475 */
476 #define LUA_UNSIGNED unsigned LUA_INT32
477 
478 
479 
480 /*
481 ** Some tricks with doubles
482 */
483 
484 #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */
485 /*
486 ** The next definitions activate some tricks to speed up the
487 ** conversion from doubles to integer types, mainly to LUA_UNSIGNED.
488 **
489 @@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a
490 ** DirectX idiosyncrasy.
491 **
492 @@ LUA_IEEE754TRICK uses a trick that should work on any machine
493 ** using IEEE754 with a 32-bit integer type.
494 **
495 @@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be
496 ** defined when LUA_INTEGER is a 32-bit integer.
497 **
498 @@ LUA_IEEEENDIAN is the endianness of doubles in your machine
499 ** (0 for little endian, 1 for big endian); if not defined, Lua will
500 ** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK).
501 **
502 @@ LUA_NANTRICK controls the use of a trick to pack all types into
503 ** a single double value, using NaN values to represent non-number
504 ** values. The trick only works on 32-bit machines (ints and pointers
505 ** are 32-bit values) with numbers represented as IEEE 754-2008 doubles
506 ** with conventional endianess (12345678 or 87654321), in CPUs that do
507 ** not produce signaling NaN values (all NaNs are quiet).
508 */
509 
510 /* Microsoft compiler on a Pentium (32 bit) ? */
511 #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */
512 
513 /* We currently don't use direct3d so we can use LUA_IEEE754TRICK on windows too. */
514 #define LUA_IEEE754TRICK
515 #define LUA_IEEELL
516 #define LUA_IEEEENDIAN 0
517 #define LUA_NANTRICK
518 
519 
520 /* pentium 32 bits? */
521 #elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */
522 
523 #define LUA_IEEE754TRICK
524 #define LUA_IEEELL
525 #define LUA_IEEEENDIAN 0
526 #define LUA_NANTRICK
527 
528 /* pentium 64 bits? */
529 #elif defined(__x86_64) /* }{ */
530 
531 #define LUA_IEEE754TRICK
532 #define LUA_IEEEENDIAN 0
533 #define LUA_IEEELL
534 
535 #elif defined(__POWERPC__) || defined(__ppc__) /* }{ */
536 
537 #define LUA_IEEE754TRICK
538 #define LUA_IEEEENDIAN 1
539 #define LUA_IEEELL
540 
541 #else /* }{ */
542 
543 /* assume IEEE754 and a 32-bit integer type */
544 #define LUA_IEEE754TRICK
545 #define LUA_IEEELL
546 
547 #endif /* } */
548 
549 #endif /* } */
550 
551 #if defined(__STDC_IEC_559__) && !defined(LUA_IEEE754TRICK)
552 #define LUA_IEEE754TRICK
553 #define LUA_IEEELL
554 #endif
555 
556 #ifndef LUA_IEEE754TRICK
557 /* We need a same floating point calculations on all clients to prevent OOS */
558 #error IEEE754 Support is required to play build wesnoth
559 #endif
560 /* }================================================================== */
561 
562 
563 
564 
565 /* =================================================================== */
566 
567 /*
568 ** Local configuration. You can use this space to add your redefinitions
569 ** without modifying the main part of the file.
570 */
571 
572 #define LUA_KERNEL_BASE_OFFSET sizeof(void*)
573 #define LUAI_EXTRASPACE LUA_KERNEL_BASE_OFFSET
574 
575 #endif
576 
GLuint GLuint stream
Definition: glew.h:5239
GLuint GLuint GLsizei count
Definition: glew.h:1221
size_t i
Definition: function.cpp:1057
GLsizeiptr size
Definition: glew.h:1649