lua/luaconf.h

Go to the documentation of this file.
00001 /*
00002 ** $Id: luaconf.h,v 1.170 2011/12/06 16:58:36 roberto Exp $
00003 ** Configuration file for Lua
00004 ** See Copyright Notice in lua.h
00005 */
00006 
00007 
00008 #ifndef lconfig_h
00009 #define lconfig_h
00010 
00011 #include <limits.h>
00012 #include <stddef.h>
00013 
00014 /*
00015  * Wesnoth definitions for compatibility
00016  */
00017 #define LUA_COMPAT_MODULE
00018 
00019 // todo: remove after 1.11.2
00020 #define LUA_COMPAT_ALL
00021 
00022 /*
00023 ** ==================================================================
00024 ** Search for "@@" to find all configurable definitions.
00025 ** ===================================================================
00026 */
00027 
00028 
00029 /*
00030 @@ LUA_ANSI controls the use of non-ansi features.
00031 ** CHANGE it (define it) if you want Lua to avoid the use of any
00032 ** non-ansi feature or library.
00033 */
00034 #if !defined(LUA_ANSI) && defined(__STRICT_ANSI__)
00035 #define LUA_ANSI
00036 #endif
00037 
00038 
00039 #if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE)
00040 #define LUA_WIN     /* enable goodies for regular Windows platforms */
00041 #endif
00042 
00043 #if defined(LUA_WIN)
00044 #define LUA_DL_DLL
00045 #define LUA_USE_AFORMAT     /* assume 'printf' handles 'aA' specifiers */
00046 #endif
00047 
00048 
00049 
00050 #if defined(LUA_USE_LINUX)
00051 #define LUA_USE_POSIX
00052 #define LUA_USE_DLOPEN      /* needs an extra library: -ldl */
00053 #define LUA_USE_READLINE    /* needs some extra libraries */
00054 #define LUA_USE_STRTODHEX   /* assume 'strtod' handles hexa formats */
00055 #define LUA_USE_AFORMAT     /* assume 'printf' handles 'aA' specifiers */
00056 #define LUA_USE_LONGLONG    /* assume support for long long */
00057 #endif
00058 
00059 #if defined(LUA_USE_MACOSX)
00060 #define LUA_USE_POSIX
00061 #define LUA_USE_DLOPEN      /* does not need -ldl */
00062 #define LUA_USE_READLINE    /* needs an extra library: -lreadline */
00063 #define LUA_USE_STRTODHEX   /* assume 'strtod' handles hexa formats */
00064 #define LUA_USE_AFORMAT     /* assume 'printf' handles 'aA' specifiers */
00065 #define LUA_USE_LONGLONG    /* assume support for long long */
00066 #endif
00067 
00068 
00069 
00070 /*
00071 @@ LUA_USE_POSIX includes all functionality listed as X/Open System
00072 @* Interfaces Extension (XSI).
00073 ** CHANGE it (define it) if your system is XSI compatible.
00074 */
00075 #if defined(LUA_USE_POSIX)
00076 #define LUA_USE_MKSTEMP
00077 #define LUA_USE_ISATTY
00078 #define LUA_USE_POPEN
00079 #define LUA_USE_ULONGJMP
00080 #define LUA_USE_GMTIME_R
00081 #endif
00082 
00083 
00084 
00085 /*
00086 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
00087 @* Lua libraries.
00088 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
00089 @* C libraries.
00090 ** CHANGE them if your machine has a non-conventional directory
00091 ** hierarchy or if you want to install your libraries in
00092 ** non-conventional directories.
00093 */
00094 #if defined(_WIN32) /* { */
00095 /*
00096 ** In Windows, any exclamation mark ('!') in the path is replaced by the
00097 ** path of the directory of the executable file of the current process.
00098 */
00099 #define LUA_LDIR    "!\\lua\\"
00100 #define LUA_CDIR    "!\\"
00101 #define LUA_PATH_DEFAULT  \
00102         LUA_LDIR"?.lua;"  LUA_LDIR"?\\init.lua;" \
00103         LUA_CDIR"?.lua;"  LUA_CDIR"?\\init.lua;" ".\\?.lua"
00104 #define LUA_CPATH_DEFAULT \
00105         LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll"
00106 
00107 #else           /* }{ */
00108 
00109 #define LUA_VDIR    LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
00110 #define LUA_ROOT    "/usr/local/"
00111 #define LUA_LDIR    LUA_ROOT "share/lua/" LUA_VDIR
00112 #define LUA_CDIR    LUA_ROOT "lib/lua/" LUA_VDIR
00113 #define LUA_PATH_DEFAULT  \
00114         LUA_LDIR"?.lua;"  LUA_LDIR"?/init.lua;" \
00115         LUA_CDIR"?.lua;"  LUA_CDIR"?/init.lua;" "./?.lua"
00116 #define LUA_CPATH_DEFAULT \
00117         LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
00118 #endif          /* } */
00119 
00120 
00121 /*
00122 @@ LUA_DIRSEP is the directory separator (for submodules).
00123 ** CHANGE it if your machine does not use "/" as the directory separator
00124 ** and is not Windows. (On Windows Lua automatically uses "\".)
00125 */
00126 #if defined(_WIN32)
00127 #define LUA_DIRSEP  "\\"
00128 #else
00129 #define LUA_DIRSEP  "/"
00130 #endif
00131 
00132 
00133 /*
00134 @@ LUA_ENV is the name of the variable that holds the current
00135 @@ environment, used to access global names.
00136 ** CHANGE it if you do not like this name.
00137 */
00138 #define LUA_ENV     "_ENV"
00139 
00140 
00141 /*
00142 @@ LUA_API is a mark for all core API functions.
00143 @@ LUALIB_API is a mark for all auxiliary library functions.
00144 @@ LUAMOD_API is a mark for all standard library opening functions.
00145 ** CHANGE them if you need to define those functions in some special way.
00146 ** For instance, if you want to create one Windows DLL with the core and
00147 ** the libraries, you may want to use the following definition (define
00148 ** LUA_BUILD_AS_DLL to get it).
00149 */
00150 #if defined(LUA_BUILD_AS_DLL)   /* { */
00151 
00152 #if defined(LUA_CORE) || defined(LUA_LIB)   /* { */
00153 #define LUA_API __declspec(dllexport)
00154 #else                       /* }{ */
00155 #define LUA_API __declspec(dllimport)
00156 #endif                      /* } */
00157 
00158 #else               /* }{ */
00159 
00160 #define LUA_API     extern
00161 
00162 #endif              /* } */
00163 
00164 
00165 /* more often than not the libs go together with the core */
00166 #define LUALIB_API  LUA_API
00167 #define LUAMOD_API  LUALIB_API
00168 
00169 
00170 /*
00171 @@ LUAI_FUNC is a mark for all extern functions that are not to be
00172 @* exported to outside modules.
00173 @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
00174 @* that are not to be exported to outside modules (LUAI_DDEF for
00175 @* definitions and LUAI_DDEC for declarations).
00176 ** CHANGE them if you need to mark them in some special way. Elf/gcc
00177 ** (versions 3.2 and later) mark them as "hidden" to optimize access
00178 ** when Lua is compiled as a shared library. Not all elf targets support
00179 ** this attribute. Unfortunately, gcc does not offer a way to check
00180 ** whether the target offers that support, and those without support
00181 ** give a warning about it. To avoid these warnings, change to the
00182 ** default definition.
00183 */
00184 #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
00185     defined(__ELF__)        /* { */
00186 #define LUAI_FUNC   __attribute__((visibility("hidden"))) extern
00187 #define LUAI_DDEC   LUAI_FUNC
00188 #define LUAI_DDEF   /* empty */
00189 
00190 #else               /* }{ */
00191 #define LUAI_FUNC   extern
00192 #define LUAI_DDEC   extern
00193 #define LUAI_DDEF   /* empty */
00194 #endif              /* } */
00195 
00196 
00197 
00198 /*
00199 @@ LUA_QL describes how error messages quote program elements.
00200 ** CHANGE it if you want a different appearance.
00201 */
00202 #define LUA_QL(x)   "'" x "'"
00203 #define LUA_QS      LUA_QL("%s")
00204 
00205 
00206 /*
00207 @@ LUA_IDSIZE gives the maximum size for the description of the source
00208 @* of a function in debug information.
00209 ** CHANGE it if you want a different size.
00210 */
00211 #define LUA_IDSIZE  60
00212 
00213 
00214 /*
00215 @@ luai_writestring/luai_writeline define how 'print' prints its results.
00216 ** They are only used in libraries and the stand-alone program. (The #if
00217 ** avoids including 'stdio.h' everywhere.)
00218 */
00219 #if defined(LUA_LIB) || defined(lua_c)
00220 #include <stdio.h>
00221 inline void fwrite_wrapper(const void * ptr, size_t size, size_t count, FILE * stream ) {
00222     size_t i = fwrite(ptr, size, count, stream);
00223     if (i != count * size) {
00224         puts("error in fwrite by lua, unexpected amount of bytes written");
00225     }
00226 }
00227 
00228 #define luai_writestring(s,l)   fwrite_wrapper((s), sizeof(char), (l), stdout)
00229 #define luai_writeline()    (luai_writestring("\n", 1), fflush(stdout))
00230 #endif
00231 
00232 /*
00233 @@ luai_writestringerror defines how to print error messages.
00234 ** (A format string with one argument is enough for Lua...)
00235 */
00236 #define luai_writestringerror(s,p) \
00237     (fprintf(stderr, (s), (p)), fflush(stderr))
00238 
00239 
00240 
00241 
00242 
00243 /*
00244 ** {==================================================================
00245 ** Compatibility with previous versions
00246 ** ===================================================================
00247 */
00248 
00249 /*
00250 @@ LUA_COMPAT_ALL controls all compatibility options.
00251 ** You can define it to get all options, or change specific options
00252 ** to fit your specific needs.
00253 */
00254 #if defined(LUA_COMPAT_ALL) /* { */
00255 
00256 /*
00257 @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'.
00258 ** You can replace it with 'table.unpack'.
00259 */
00260 #define LUA_COMPAT_UNPACK
00261 
00262 /*
00263 @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'.
00264 ** You can replace it with 'package.searchers'.
00265 */
00266 #define LUA_COMPAT_LOADERS
00267 
00268 /*
00269 @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall.
00270 ** You can call your C function directly (with light C functions).
00271 */
00272 #define lua_cpcall(L,f,u)  \
00273     (lua_pushcfunction(L, (f)), \
00274      lua_pushlightuserdata(L,(u)), \
00275      lua_pcall(L,1,0,0))
00276 
00277 
00278 /*
00279 @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library.
00280 ** You can rewrite 'log10(x)' as 'log(x, 10)'.
00281 */
00282 #define LUA_COMPAT_LOG10
00283 
00284 /*
00285 @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base
00286 ** library. You can rewrite 'loadstring(s)' as 'load(s)'.
00287 */
00288 #define LUA_COMPAT_LOADSTRING
00289 
00290 /*
00291 @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library.
00292 */
00293 #define LUA_COMPAT_MAXN
00294 
00295 /*
00296 @@ The following macros supply trivial compatibility for some
00297 ** changes in the API. The macros themselves document how to
00298 ** change your code to avoid using them.
00299 */
00300 #define lua_strlen(L,i)     lua_rawlen(L, (i))
00301 
00302 #define lua_objlen(L,i)     lua_rawlen(L, (i))
00303 
00304 #define lua_equal(L,idx1,idx2)      lua_compare(L,(idx1),(idx2),LUA_OPEQ)
00305 #define lua_lessthan(L,idx1,idx2)   lua_compare(L,(idx1),(idx2),LUA_OPLT)
00306 
00307 /*
00308 @@ LUA_COMPAT_MODULE controls compatibility with previous
00309 ** module functions 'module' (Lua) and 'luaL_register' (C).
00310 */
00311 #define LUA_COMPAT_MODULE
00312 
00313 #endif              /* } */
00314 
00315 /* }================================================================== */
00316 
00317 
00318 
00319 /*
00320 @@ LUAI_BITSINT defines the number of bits in an int.
00321 ** CHANGE here if Lua cannot automatically detect the number of bits of
00322 ** your machine. Probably you do not need to change this.
00323 */
00324 /* avoid overflows in comparison */
00325 #if INT_MAX-20 < 32760      /* { */
00326 #define LUAI_BITSINT    16
00327 #elif INT_MAX > 2147483640L /* }{ */
00328 /* int has at least 32 bits */
00329 #define LUAI_BITSINT    32
00330 #else               /* }{ */
00331 #error "you must define LUA_BITSINT with number of bits in an integer"
00332 #endif              /* } */
00333 
00334 
00335 /*
00336 @@ LUA_INT32 is an signed integer with exactly 32 bits.
00337 @@ LUAI_UMEM is an unsigned integer big enough to count the total
00338 @* memory used by Lua.
00339 @@ LUAI_MEM is a signed integer big enough to count the total memory
00340 @* used by Lua.
00341 ** CHANGE here if for some weird reason the default definitions are not
00342 ** good enough for your machine. Probably you do not need to change
00343 ** this.
00344 */
00345 #if LUAI_BITSINT >= 32      /* { */
00346 #define LUA_INT32   int
00347 #define LUAI_UMEM   size_t
00348 #define LUAI_MEM    ptrdiff_t
00349 #else               /* }{ */
00350 /* 16-bit ints */
00351 #define LUA_INT32   long
00352 #define LUAI_UMEM   unsigned long
00353 #define LUAI_MEM    long
00354 #endif              /* } */
00355 
00356 
00357 /*
00358 @@ LUAI_MAXSTACK limits the size of the Lua stack.
00359 ** CHANGE it if you need a different limit. This limit is arbitrary;
00360 ** its only purpose is to stop Lua to consume unlimited stack
00361 ** space (and to reserve some numbers for pseudo-indices).
00362 */
00363 #if LUAI_BITSINT >= 32
00364 #define LUAI_MAXSTACK       1000000
00365 #else
00366 #define LUAI_MAXSTACK       15000
00367 #endif
00368 
00369 /* reserve some space for error handling */
00370 #define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000)
00371 
00372 
00373 
00374 
00375 /*
00376 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
00377 ** CHANGE it if it uses too much C-stack space.
00378 */
00379 #define LUAL_BUFFERSIZE     BUFSIZ
00380 
00381 
00382 
00383 
00384 /*
00385 ** {==================================================================
00386 @@ LUA_NUMBER is the type of numbers in Lua.
00387 ** CHANGE the following definitions only if you want to build Lua
00388 ** with a number type different from double. You may also need to
00389 ** change lua_number2int & lua_number2integer.
00390 ** ===================================================================
00391 */
00392 
00393 #define LUA_NUMBER_DOUBLE
00394 #define LUA_NUMBER  double
00395 
00396 /*
00397 @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
00398 @* over a number.
00399 */
00400 #define LUAI_UACNUMBER  double
00401 
00402 
00403 /*
00404 @@ LUA_NUMBER_SCAN is the format for reading numbers.
00405 @@ LUA_NUMBER_FMT is the format for writing numbers.
00406 @@ lua_number2str converts a number to a string.
00407 @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
00408 */
00409 #define LUA_NUMBER_SCAN     "%lf"
00410 #define LUA_NUMBER_FMT      "%.14g"
00411 #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
00412 #define LUAI_MAXNUMBER2STR  32 /* 16 digits, sign, point, and \0 */
00413 
00414 
00415 /*
00416 @@ lua_str2number converts a decimal numeric string to a number.
00417 @@ lua_strx2number converts an hexadecimal numeric string to a number.
00418 ** In C99, 'strtod' do both conversions. C89, however, has no function
00419 ** to convert floating hexadecimal strings to numbers. For these
00420 ** systems, you can leave 'lua_strx2number' undefined and Lua will
00421 ** provide its own implementation.
00422 */
00423 #define lua_str2number(s,p) strtod((s), (p))
00424 
00425 #if defined(LUA_USE_STRTODHEX)
00426 #define lua_strx2number(s,p)    strtod((s), (p))
00427 #endif
00428 
00429 
00430 /*
00431 @@ The luai_num* macros define the primitive operations over numbers.
00432 */
00433 
00434 /* the following operations need the math library */
00435 #if defined(lobject_c) || defined(lvm_c)
00436 #include <math.h>
00437 #define luai_nummod(L,a,b)  ((a) - floor((a)/(b))*(b))
00438 #define luai_numpow(L,a,b)  (pow(a,b))
00439 #endif
00440 
00441 /* these are quite standard operations */
00442 #if defined(LUA_CORE)
00443 #define luai_numadd(L,a,b)  ((a)+(b))
00444 #define luai_numsub(L,a,b)  ((a)-(b))
00445 #define luai_nummul(L,a,b)  ((a)*(b))
00446 #define luai_numdiv(L,a,b)  ((a)/(b))
00447 #define luai_numunm(L,a)    (-(a))
00448 #define luai_numeq(a,b)     ((a)==(b))
00449 #define luai_numlt(L,a,b)   ((a)<(b))
00450 #define luai_numle(L,a,b)   ((a)<=(b))
00451 #define luai_numisnan(L,a)  (!luai_numeq((a), (a)))
00452 #endif
00453 
00454 
00455 
00456 /*
00457 @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
00458 ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
00459 ** machines, ptrdiff_t gives a good choice between int or long.)
00460 */
00461 #define LUA_INTEGER ptrdiff_t
00462 
00463 /*
00464 @@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
00465 ** It must have at least 32 bits.
00466 */
00467 #define LUA_UNSIGNED    unsigned LUA_INT32
00468 
00469 
00470 #if defined(LUA_CORE)       /* { */
00471 
00472 #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI)    /* { */
00473 
00474 /* On a Microsoft compiler on a Pentium, use assembler to avoid clashes
00475    with a DirectX idiosyncrasy */
00476 #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86)   /* { */
00477 
00478 #define MS_ASMTRICK
00479 
00480 #else               /* }{ */
00481 /* the next definition uses a trick that should work on any machine
00482    using IEEE754 with a 32-bit integer type */
00483 
00484 #define LUA_IEEE754TRICK
00485 
00486 /*
00487 @@ LUA_IEEEENDIAN is the endianness of doubles in your machine
00488 ** (0 for little endian, 1 for big endian); if not defined, Lua will
00489 ** check it dynamically.
00490 */
00491 /* check for known architectures */
00492 #if defined(__i386__) || defined(__i386) || defined(__X86__) || \
00493     defined (__x86_64)
00494 #define LUA_IEEEENDIAN  0
00495 #elif defined(__POWERPC__) || defined(__ppc__)
00496 #define LUA_IEEEENDIAN  1
00497 #endif
00498 
00499 #endif              /* } */
00500 
00501 #endif          /* } */
00502 
00503 #endif          /* } */
00504 
00505 /* }================================================================== */
00506 
00507 
00508 /*
00509 @@ LUA_NANTRICK_LE/LUA_NANTRICK_BE controls the use of a trick to
00510 ** pack all types into a single double value, using NaN values to
00511 ** represent non-number values. The trick only works on 32-bit machines
00512 ** (ints and pointers are 32-bit values) with numbers represented as
00513 ** IEEE 754-2008 doubles with conventional endianess (12345678 or
00514 ** 87654321), in CPUs that do not produce signaling NaN values (all NaNs
00515 ** are quiet).
00516 */
00517 #if defined(LUA_CORE) && \
00518     defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI)    /* { */
00519 
00520 /* little-endian architectures that satisfy those conditions */
00521 #if defined(__i386__) || defined(__i386) || defined(__X86__) || \
00522     defined(_M_IX86)
00523 
00524 #define LUA_NANTRICK_LE
00525 
00526 #endif
00527 
00528 #endif                          /* } */
00529 
00530 
00531 
00532 
00533 /* =================================================================== */
00534 
00535 /*
00536 ** Local configuration. You can use this space to add your redefinitions
00537 ** without modifying the main part of the file.
00538 */
00539 
00540 
00541 
00542 #endif
00543 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:05 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs