annotate src/lua/luaconf.h @ 45:6803cb8a6ebf

fix columns in configure.ac, and remove generated makefiles.
author Robert McIntyre <rlm@mit.edu>
date Thu, 21 Mar 2013 17:21:54 +0000
parents 27763b933818
children
rev   line source
rlm@1 1 /*
rlm@1 2 ** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
rlm@1 3 ** Configuration file for Lua
rlm@1 4 ** See Copyright Notice in lua.h
rlm@1 5 */
rlm@1 6
rlm@1 7
rlm@1 8 #ifndef lconfig_h
rlm@1 9 #define lconfig_h
rlm@1 10
rlm@1 11 #include <limits.h>
rlm@1 12 #include <stddef.h>
rlm@1 13
rlm@1 14
rlm@1 15 /*
rlm@1 16 ** ==================================================================
rlm@1 17 ** Search for "@@" to find all configurable definitions.
rlm@1 18 ** ===================================================================
rlm@1 19 */
rlm@1 20
rlm@1 21
rlm@1 22 /*
rlm@1 23 @@ LUA_ANSI controls the use of non-ansi features.
rlm@1 24 ** CHANGE it (define it) if you want Lua to avoid the use of any
rlm@1 25 ** non-ansi feature or library.
rlm@1 26 */
rlm@1 27 #if defined(__STRICT_ANSI__)
rlm@1 28 #define LUA_ANSI
rlm@1 29 #endif
rlm@1 30
rlm@1 31
rlm@1 32 #if !defined(LUA_ANSI) && defined(_WIN32)
rlm@1 33 #define LUA_WIN
rlm@1 34 #endif
rlm@1 35
rlm@1 36 #if defined(LUA_USE_LINUX)
rlm@1 37 #define LUA_USE_POSIX
rlm@1 38 #define LUA_USE_DLOPEN /* needs an extra library: -ldl */
rlm@1 39 #define LUA_USE_READLINE /* needs some extra libraries */
rlm@1 40 #endif
rlm@1 41
rlm@1 42 #if defined(LUA_USE_MACOSX)
rlm@1 43 #define LUA_USE_POSIX
rlm@1 44 #define LUA_DL_DYLD /* does not need extra library */
rlm@1 45 #endif
rlm@1 46
rlm@1 47
rlm@1 48
rlm@1 49 /*
rlm@1 50 @@ LUA_USE_POSIX includes all functionallity listed as X/Open System
rlm@1 51 @* Interfaces Extension (XSI).
rlm@1 52 ** CHANGE it (define it) if your system is XSI compatible.
rlm@1 53 */
rlm@1 54 #if defined(LUA_USE_POSIX)
rlm@1 55 #define LUA_USE_MKSTEMP
rlm@1 56 #define LUA_USE_ISATTY
rlm@1 57 #define LUA_USE_POPEN
rlm@1 58 #define LUA_USE_ULONGJMP
rlm@1 59 #endif
rlm@1 60
rlm@1 61
rlm@1 62 /*
rlm@1 63 @@ LUA_PATH and LUA_CPATH are the names of the environment variables that
rlm@1 64 @* Lua check to set its paths.
rlm@1 65 @@ LUA_INIT is the name of the environment variable that Lua
rlm@1 66 @* checks for initialization code.
rlm@1 67 ** CHANGE them if you want different names.
rlm@1 68 */
rlm@1 69 #define LUA_PATH "LUA_PATH"
rlm@1 70 #define LUA_CPATH "LUA_CPATH"
rlm@1 71 #define LUA_INIT "LUA_INIT"
rlm@1 72
rlm@1 73
rlm@1 74 /*
rlm@1 75 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
rlm@1 76 @* Lua libraries.
rlm@1 77 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
rlm@1 78 @* C libraries.
rlm@1 79 ** CHANGE them if your machine has a non-conventional directory
rlm@1 80 ** hierarchy or if you want to install your libraries in
rlm@1 81 ** non-conventional directories.
rlm@1 82 */
rlm@1 83 #if defined(_WIN32)
rlm@1 84 /*
rlm@1 85 ** In Windows, any exclamation mark ('!') in the path is replaced by the
rlm@1 86 ** path of the directory of the executable file of the current process.
rlm@1 87 */
rlm@1 88 #define LUA_LDIR "!\\lua\\"
rlm@1 89 #define LUA_CDIR "!\\"
rlm@1 90 #define LUA_PATH_DEFAULT \
rlm@1 91 ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
rlm@1 92 LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
rlm@1 93 #define LUA_CPATH_DEFAULT \
rlm@1 94 ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
rlm@1 95
rlm@1 96 #else
rlm@1 97 #define LUA_ROOT "/usr/local/"
rlm@1 98 #define LUA_LDIR LUA_ROOT "share/lua/5.1/"
rlm@1 99 #define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
rlm@1 100 #define LUA_PATH_DEFAULT \
rlm@1 101 "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
rlm@1 102 LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
rlm@1 103 #define LUA_CPATH_DEFAULT \
rlm@1 104 "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
rlm@1 105 #endif
rlm@1 106
rlm@1 107
rlm@1 108 /*
rlm@1 109 @@ LUA_DIRSEP is the directory separator (for submodules).
rlm@1 110 ** CHANGE it if your machine does not use "/" as the directory separator
rlm@1 111 ** and is not Windows. (On Windows Lua automatically uses "\".)
rlm@1 112 */
rlm@1 113 #if defined(_WIN32)
rlm@1 114 #define LUA_DIRSEP "\\"
rlm@1 115 #else
rlm@1 116 #define LUA_DIRSEP "/"
rlm@1 117 #endif
rlm@1 118
rlm@1 119
rlm@1 120 /*
rlm@1 121 @@ LUA_PATHSEP is the character that separates templates in a path.
rlm@1 122 @@ LUA_PATH_MARK is the string that marks the substitution points in a
rlm@1 123 @* template.
rlm@1 124 @@ LUA_EXECDIR in a Windows path is replaced by the executable's
rlm@1 125 @* directory.
rlm@1 126 @@ LUA_IGMARK is a mark to ignore all before it when bulding the
rlm@1 127 @* luaopen_ function name.
rlm@1 128 ** CHANGE them if for some reason your system cannot use those
rlm@1 129 ** characters. (E.g., if one of those characters is a common character
rlm@1 130 ** in file/directory names.) Probably you do not need to change them.
rlm@1 131 */
rlm@1 132 #define LUA_PATHSEP ";"
rlm@1 133 #define LUA_PATH_MARK "?"
rlm@1 134 #define LUA_EXECDIR "!"
rlm@1 135 #define LUA_IGMARK "-"
rlm@1 136
rlm@1 137
rlm@1 138 /*
rlm@1 139 @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
rlm@1 140 ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
rlm@1 141 ** machines, ptrdiff_t gives a good choice between int or long.)
rlm@1 142 */
rlm@1 143 #define LUA_INTEGER ptrdiff_t
rlm@1 144
rlm@1 145
rlm@1 146 /*
rlm@1 147 @@ LUA_API is a mark for all core API functions.
rlm@1 148 @@ LUALIB_API is a mark for all standard library functions.
rlm@1 149 ** CHANGE them if you need to define those functions in some special way.
rlm@1 150 ** For instance, if you want to create one Windows DLL with the core and
rlm@1 151 ** the libraries, you may want to use the following definition (define
rlm@1 152 ** LUA_BUILD_AS_DLL to get it).
rlm@1 153 */
rlm@1 154 #if defined(LUA_BUILD_AS_DLL)
rlm@1 155
rlm@1 156 #if defined(LUA_CORE) || defined(LUA_LIB)
rlm@1 157 #define LUA_API __declspec(dllexport)
rlm@1 158 #else
rlm@1 159 #define LUA_API __declspec(dllimport)
rlm@1 160 #endif
rlm@1 161
rlm@1 162 #else
rlm@1 163
rlm@1 164 #define LUA_API extern
rlm@1 165
rlm@1 166 #endif
rlm@1 167
rlm@1 168 /* more often than not the libs go together with the core */
rlm@1 169 #define LUALIB_API LUA_API
rlm@1 170
rlm@1 171
rlm@1 172 /*
rlm@1 173 @@ LUAI_FUNC is a mark for all extern functions that are not to be
rlm@1 174 @* exported to outside modules.
rlm@1 175 @@ LUAI_DATA is a mark for all extern (const) variables that are not to
rlm@1 176 @* be exported to outside modules.
rlm@1 177 ** CHANGE them if you need to mark them in some special way. Elf/gcc
rlm@1 178 ** (versions 3.2 and later) mark them as "hidden" to optimize access
rlm@1 179 ** when Lua is compiled as a shared library.
rlm@1 180 */
rlm@1 181 #if defined(luaall_c)
rlm@1 182 #define LUAI_FUNC static
rlm@1 183 #define LUAI_DATA /* empty */
rlm@1 184
rlm@1 185 #elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
rlm@1 186 defined(__ELF__)
rlm@1 187 #define LUAI_FUNC __attribute__((visibility("hidden"))) extern
rlm@1 188 #define LUAI_DATA LUAI_FUNC
rlm@1 189
rlm@1 190 #else
rlm@1 191 #define LUAI_FUNC extern
rlm@1 192 #define LUAI_DATA extern
rlm@1 193 #endif
rlm@1 194
rlm@1 195
rlm@1 196
rlm@1 197 /*
rlm@1 198 @@ LUA_QL describes how error messages quote program elements.
rlm@1 199 ** CHANGE it if you want a different appearance.
rlm@1 200 */
rlm@1 201 #define LUA_QL(x) "'" x "'"
rlm@1 202 #define LUA_QS LUA_QL("%s")
rlm@1 203
rlm@1 204
rlm@1 205 /*
rlm@1 206 @@ LUA_IDSIZE gives the maximum size for the description of the source
rlm@1 207 @* of a function in debug information.
rlm@1 208 ** CHANGE it if you want a different size.
rlm@1 209 */
rlm@1 210 #define LUA_IDSIZE 60
rlm@1 211
rlm@1 212
rlm@1 213 /*
rlm@1 214 ** {==================================================================
rlm@1 215 ** Stand-alone configuration
rlm@1 216 ** ===================================================================
rlm@1 217 */
rlm@1 218
rlm@1 219 #if defined(lua_c) || defined(luaall_c)
rlm@1 220
rlm@1 221 /*
rlm@1 222 @@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
rlm@1 223 @* is, whether we're running lua interactively).
rlm@1 224 ** CHANGE it if you have a better definition for non-POSIX/non-Windows
rlm@1 225 ** systems.
rlm@1 226 */
rlm@1 227 #if defined(LUA_USE_ISATTY)
rlm@1 228 #include <unistd.h>
rlm@1 229 #define lua_stdin_is_tty() isatty(0)
rlm@1 230 #elif defined(LUA_WIN)
rlm@1 231 #include <io.h>
rlm@1 232 #include <stdio.h>
rlm@1 233 #define lua_stdin_is_tty() _isatty(_fileno(stdin))
rlm@1 234 #else
rlm@1 235 #define lua_stdin_is_tty() 1 /* assume stdin is a tty */
rlm@1 236 #endif
rlm@1 237
rlm@1 238
rlm@1 239 /*
rlm@1 240 @@ LUA_PROMPT is the default prompt used by stand-alone Lua.
rlm@1 241 @@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
rlm@1 242 ** CHANGE them if you want different prompts. (You can also change the
rlm@1 243 ** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
rlm@1 244 */
rlm@1 245 #define LUA_PROMPT "> "
rlm@1 246 #define LUA_PROMPT2 ">> "
rlm@1 247
rlm@1 248
rlm@1 249 /*
rlm@1 250 @@ LUA_PROGNAME is the default name for the stand-alone Lua program.
rlm@1 251 ** CHANGE it if your stand-alone interpreter has a different name and
rlm@1 252 ** your system is not able to detect that name automatically.
rlm@1 253 */
rlm@1 254 #define LUA_PROGNAME "lua"
rlm@1 255
rlm@1 256
rlm@1 257 /*
rlm@1 258 @@ LUA_MAXINPUT is the maximum length for an input line in the
rlm@1 259 @* stand-alone interpreter.
rlm@1 260 ** CHANGE it if you need longer lines.
rlm@1 261 */
rlm@1 262 #define LUA_MAXINPUT 512
rlm@1 263
rlm@1 264
rlm@1 265 /*
rlm@1 266 @@ lua_readline defines how to show a prompt and then read a line from
rlm@1 267 @* the standard input.
rlm@1 268 @@ lua_saveline defines how to "save" a read line in a "history".
rlm@1 269 @@ lua_freeline defines how to free a line read by lua_readline.
rlm@1 270 ** CHANGE them if you want to improve this functionality (e.g., by using
rlm@1 271 ** GNU readline and history facilities).
rlm@1 272 */
rlm@1 273 #if defined(LUA_USE_READLINE)
rlm@1 274 #include <stdio.h>
rlm@1 275 #include <readline/readline.h>
rlm@1 276 #include <readline/history.h>
rlm@1 277 #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
rlm@1 278 #define lua_saveline(L,idx) \
rlm@1 279 if (lua_strlen(L,idx) > 0) /* non-empty line? */ \
rlm@1 280 add_history(lua_tostring(L, idx)); /* add it to history */
rlm@1 281 #define lua_freeline(L,b) ((void)L, free(b))
rlm@1 282 #else
rlm@1 283 #define lua_readline(L,b,p) \
rlm@1 284 ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
rlm@1 285 fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
rlm@1 286 #define lua_saveline(L,idx) { (void)L; (void)idx; }
rlm@1 287 #define lua_freeline(L,b) { (void)L; (void)b; }
rlm@1 288 #endif
rlm@1 289
rlm@1 290 #endif
rlm@1 291
rlm@1 292 /* }================================================================== */
rlm@1 293
rlm@1 294
rlm@1 295 /*
rlm@1 296 @@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles
rlm@1 297 @* as a percentage.
rlm@1 298 ** CHANGE it if you want the GC to run faster or slower (higher values
rlm@1 299 ** mean larger pauses which mean slower collection.) You can also change
rlm@1 300 ** this value dynamically.
rlm@1 301 */
rlm@1 302 #define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */
rlm@1 303
rlm@1 304
rlm@1 305 /*
rlm@1 306 @@ LUAI_GCMUL defines the default speed of garbage collection relative to
rlm@1 307 @* memory allocation as a percentage.
rlm@1 308 ** CHANGE it if you want to change the granularity of the garbage
rlm@1 309 ** collection. (Higher values mean coarser collections. 0 represents
rlm@1 310 ** infinity, where each step performs a full collection.) You can also
rlm@1 311 ** change this value dynamically.
rlm@1 312 */
rlm@1 313 #define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */
rlm@1 314
rlm@1 315
rlm@1 316
rlm@1 317 /*
rlm@1 318 @@ LUA_COMPAT_GETN controls compatibility with old getn behavior.
rlm@1 319 ** CHANGE it (define it) if you want exact compatibility with the
rlm@1 320 ** behavior of setn/getn in Lua 5.0.
rlm@1 321 */
rlm@1 322 #undef LUA_COMPAT_GETN
rlm@1 323
rlm@1 324 /*
rlm@1 325 @@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib.
rlm@1 326 ** CHANGE it to undefined as soon as you do not need a global 'loadlib'
rlm@1 327 ** function (the function is still available as 'package.loadlib').
rlm@1 328 */
rlm@1 329 #undef LUA_COMPAT_LOADLIB
rlm@1 330
rlm@1 331 /*
rlm@1 332 @@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
rlm@1 333 ** CHANGE it to undefined as soon as your programs use only '...' to
rlm@1 334 ** access vararg parameters (instead of the old 'arg' table).
rlm@1 335 */
rlm@1 336 #define LUA_COMPAT_VARARG
rlm@1 337
rlm@1 338 /*
rlm@1 339 @@ LUA_COMPAT_MOD controls compatibility with old math.mod function.
rlm@1 340 ** CHANGE it to undefined as soon as your programs use 'math.fmod' or
rlm@1 341 ** the new '%' operator instead of 'math.mod'.
rlm@1 342 */
rlm@1 343 #define LUA_COMPAT_MOD
rlm@1 344
rlm@1 345 /*
rlm@1 346 @@ LUA_COMPAT_LSTR controls compatibility with old long string nesting
rlm@1 347 @* facility.
rlm@1 348 ** CHANGE it to 2 if you want the old behaviour, or undefine it to turn
rlm@1 349 ** off the advisory error when nesting [[...]].
rlm@1 350 */
rlm@1 351 #define LUA_COMPAT_LSTR 1
rlm@1 352
rlm@1 353 /*
rlm@1 354 @@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name.
rlm@1 355 ** CHANGE it to undefined as soon as you rename 'string.gfind' to
rlm@1 356 ** 'string.gmatch'.
rlm@1 357 */
rlm@1 358 #define LUA_COMPAT_GFIND
rlm@1 359
rlm@1 360 /*
rlm@1 361 @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
rlm@1 362 @* behavior.
rlm@1 363 ** CHANGE it to undefined as soon as you replace to 'luaL_register'
rlm@1 364 ** your uses of 'luaL_openlib'
rlm@1 365 */
rlm@1 366 #define LUA_COMPAT_OPENLIB
rlm@1 367
rlm@1 368
rlm@1 369
rlm@1 370 /*
rlm@1 371 @@ luai_apicheck is the assert macro used by the Lua-C API.
rlm@1 372 ** CHANGE luai_apicheck if you want Lua to perform some checks in the
rlm@1 373 ** parameters it gets from API calls. This may slow down the interpreter
rlm@1 374 ** a bit, but may be quite useful when debugging C code that interfaces
rlm@1 375 ** with Lua. A useful redefinition is to use assert.h.
rlm@1 376 */
rlm@1 377 #if defined(LUA_USE_APICHECK)
rlm@1 378 #include <assert.h>
rlm@1 379 #define luai_apicheck(L,o) { (void)L; assert(o); }
rlm@1 380 #else
rlm@1 381 #define luai_apicheck(L,o) { (void)L; }
rlm@1 382 #endif
rlm@1 383
rlm@1 384
rlm@1 385 /*
rlm@1 386 @@ LUAI_BITSINT defines the number of bits in an int.
rlm@1 387 ** CHANGE here if Lua cannot automatically detect the number of bits of
rlm@1 388 ** your machine. Probably you do not need to change this.
rlm@1 389 */
rlm@1 390 /* avoid overflows in comparison */
rlm@1 391 #if INT_MAX-20 < 32760
rlm@1 392 #define LUAI_BITSINT 16
rlm@1 393 #elif INT_MAX > 2147483640L
rlm@1 394 /* int has at least 32 bits */
rlm@1 395 #define LUAI_BITSINT 32
rlm@1 396 #else
rlm@1 397 #error "you must define LUA_BITSINT with number of bits in an integer"
rlm@1 398 #endif
rlm@1 399
rlm@1 400
rlm@1 401 /*
rlm@1 402 @@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
rlm@1 403 @@ LUAI_INT32 is an signed integer with at least 32 bits.
rlm@1 404 @@ LUAI_UMEM is an unsigned integer big enough to count the total
rlm@1 405 @* memory used by Lua.
rlm@1 406 @@ LUAI_MEM is a signed integer big enough to count the total memory
rlm@1 407 @* used by Lua.
rlm@1 408 ** CHANGE here if for some weird reason the default definitions are not
rlm@1 409 ** good enough for your machine. (The definitions in the 'else'
rlm@1 410 ** part always works, but may waste space on machines with 64-bit
rlm@1 411 ** longs.) Probably you do not need to change this.
rlm@1 412 */
rlm@1 413 #if LUAI_BITSINT >= 32
rlm@1 414 #define LUAI_UINT32 unsigned int
rlm@1 415 #define LUAI_INT32 int
rlm@1 416 #define LUAI_MAXINT32 INT_MAX
rlm@1 417 #define LUAI_UMEM size_t
rlm@1 418 #define LUAI_MEM ptrdiff_t
rlm@1 419 #else
rlm@1 420 /* 16-bit ints */
rlm@1 421 #define LUAI_UINT32 unsigned long
rlm@1 422 #define LUAI_INT32 long
rlm@1 423 #define LUAI_MAXINT32 LONG_MAX
rlm@1 424 #define LUAI_UMEM unsigned long
rlm@1 425 #define LUAI_MEM long
rlm@1 426 #endif
rlm@1 427
rlm@1 428
rlm@1 429 /*
rlm@1 430 @@ LUAI_MAXCALLS limits the number of nested calls.
rlm@1 431 ** CHANGE it if you need really deep recursive calls. This limit is
rlm@1 432 ** arbitrary; its only purpose is to stop infinite recursion before
rlm@1 433 ** exhausting memory.
rlm@1 434 */
rlm@1 435 #define LUAI_MAXCALLS 20000
rlm@1 436
rlm@1 437
rlm@1 438 /*
rlm@1 439 @@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function
rlm@1 440 @* can use.
rlm@1 441 ** CHANGE it if you need lots of (Lua) stack space for your C
rlm@1 442 ** functions. This limit is arbitrary; its only purpose is to stop C
rlm@1 443 ** functions to consume unlimited stack space. (must be smaller than
rlm@1 444 ** -LUA_REGISTRYINDEX)
rlm@1 445 */
rlm@1 446 #define LUAI_MAXCSTACK 8000
rlm@1 447
rlm@1 448
rlm@1 449
rlm@1 450 /*
rlm@1 451 ** {==================================================================
rlm@1 452 ** CHANGE (to smaller values) the following definitions if your system
rlm@1 453 ** has a small C stack. (Or you may want to change them to larger
rlm@1 454 ** values if your system has a large C stack and these limits are
rlm@1 455 ** too rigid for you.) Some of these constants control the size of
rlm@1 456 ** stack-allocated arrays used by the compiler or the interpreter, while
rlm@1 457 ** others limit the maximum number of recursive calls that the compiler
rlm@1 458 ** or the interpreter can perform. Values too large may cause a C stack
rlm@1 459 ** overflow for some forms of deep constructs.
rlm@1 460 ** ===================================================================
rlm@1 461 */
rlm@1 462
rlm@1 463
rlm@1 464 /*
rlm@1 465 @@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
rlm@1 466 @* syntactical nested non-terminals in a program.
rlm@1 467 */
rlm@1 468 #define LUAI_MAXCCALLS 200
rlm@1 469
rlm@1 470
rlm@1 471 /*
rlm@1 472 @@ LUAI_MAXVARS is the maximum number of local variables per function
rlm@1 473 @* (must be smaller than 250).
rlm@1 474 */
rlm@1 475 #define LUAI_MAXVARS 200
rlm@1 476
rlm@1 477
rlm@1 478 /*
rlm@1 479 @@ LUAI_MAXUPVALUES is the maximum number of upvalues per function
rlm@1 480 @* (must be smaller than 250).
rlm@1 481 */
rlm@1 482 #define LUAI_MAXUPVALUES 60
rlm@1 483
rlm@1 484
rlm@1 485 /*
rlm@1 486 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
rlm@1 487 */
rlm@1 488 #define LUAL_BUFFERSIZE BUFSIZ
rlm@1 489
rlm@1 490 /* }================================================================== */
rlm@1 491
rlm@1 492
rlm@1 493
rlm@1 494
rlm@1 495 /*
rlm@1 496 ** {==================================================================
rlm@1 497 @@ LUA_NUMBER is the type of numbers in Lua.
rlm@1 498 ** CHANGE the following definitions only if you want to build Lua
rlm@1 499 ** with a number type different from double. You may also need to
rlm@1 500 ** change lua_number2int & lua_number2integer.
rlm@1 501 ** ===================================================================
rlm@1 502 */
rlm@1 503
rlm@1 504 #define LUA_NUMBER_DOUBLE
rlm@1 505 #define LUA_NUMBER double
rlm@1 506
rlm@1 507 /*
rlm@1 508 @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
rlm@1 509 @* over a number.
rlm@1 510 */
rlm@1 511 #define LUAI_UACNUMBER double
rlm@1 512
rlm@1 513
rlm@1 514 /*
rlm@1 515 @@ LUA_NUMBER_SCAN is the format for reading numbers.
rlm@1 516 @@ LUA_NUMBER_FMT is the format for writing numbers.
rlm@1 517 @@ lua_number2str converts a number to a string.
rlm@1 518 @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
rlm@1 519 @@ lua_str2number converts a string to a number.
rlm@1 520 */
rlm@1 521 #define LUA_NUMBER_SCAN "%lf"
rlm@1 522 #define LUA_NUMBER_FMT "%.14g"
rlm@1 523 #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
rlm@1 524 #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
rlm@1 525 #define lua_str2number(s,p) strtod((s), (p))
rlm@1 526
rlm@1 527
rlm@1 528 /*
rlm@1 529 @@ The luai_num* macros define the primitive operations over numbers.
rlm@1 530 */
rlm@1 531 #if defined(LUA_CORE)
rlm@1 532 #include <math.h>
rlm@1 533 #define luai_numadd(a,b) ((a)+(b))
rlm@1 534 #define luai_numsub(a,b) ((a)-(b))
rlm@1 535 #define luai_nummul(a,b) ((a)*(b))
rlm@1 536 #define luai_numdiv(a,b) ((a)/(b))
rlm@1 537 #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
rlm@1 538 #define luai_numpow(a,b) (pow(a,b))
rlm@1 539 #define luai_numunm(a) (-(a))
rlm@1 540 #define luai_numeq(a,b) ((a)==(b))
rlm@1 541 #define luai_numlt(a,b) ((a)<(b))
rlm@1 542 #define luai_numle(a,b) ((a)<=(b))
rlm@1 543 #define luai_numisnan(a) (!luai_numeq((a), (a)))
rlm@1 544 #endif
rlm@1 545
rlm@1 546
rlm@1 547 /*
rlm@1 548 @@ lua_number2int is a macro to convert lua_Number to int.
rlm@1 549 @@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
rlm@1 550 ** CHANGE them if you know a faster way to convert a lua_Number to
rlm@1 551 ** int (with any rounding method and without throwing errors) in your
rlm@1 552 ** system. In Pentium machines, a naive typecast from double to int
rlm@1 553 ** in C is extremely slow, so any alternative is worth trying.
rlm@1 554 */
rlm@1 555
rlm@1 556 /* On a Pentium, resort to a trick */
rlm@1 557 #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
rlm@1 558 (defined(__i386) || defined (_M_IX86) || defined(__i386__))
rlm@1 559
rlm@1 560 /* On a Microsoft compiler, use assembler */
rlm@1 561 #if 0//defined(_MSC_VER) // nitsuja: the "using assembly" method doesn't correctly handle integers between 0xFF000000 and and 0xFFFFFFFF, while the other branch does handle it correctly and it's not slower.
rlm@1 562
rlm@1 563 #define lua_number2int(i,d) __asm fld d __asm fistp i
rlm@1 564 #define lua_number2integer(i,n) lua_number2int(i, n)
rlm@1 565
rlm@1 566 /* the next trick should work on any Pentium, but sometimes clashes
rlm@1 567 with a DirectX idiosyncrasy */
rlm@1 568 #else
rlm@1 569
rlm@1 570 union luai_Cast { double l_d; long l_l; };
rlm@1 571 #define lua_number2int(i,d) \
rlm@1 572 { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
rlm@1 573 #define lua_number2integer(i,n) lua_number2int(i, n)
rlm@1 574
rlm@1 575 #endif
rlm@1 576
rlm@1 577
rlm@1 578 /* this option always works, but may be slow */
rlm@1 579 #else
rlm@1 580 #define lua_number2int(i,d) ((i)=(int)(d))
rlm@1 581 #define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
rlm@1 582
rlm@1 583 #endif
rlm@1 584
rlm@1 585 /* }================================================================== */
rlm@1 586
rlm@1 587
rlm@1 588 /*
rlm@1 589 @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
rlm@1 590 ** CHANGE it if your system requires alignments larger than double. (For
rlm@1 591 ** instance, if your system supports long doubles and they must be
rlm@1 592 ** aligned in 16-byte boundaries, then you should add long double in the
rlm@1 593 ** union.) Probably you do not need to change this.
rlm@1 594 */
rlm@1 595 #define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
rlm@1 596
rlm@1 597
rlm@1 598 /*
rlm@1 599 @@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
rlm@1 600 ** CHANGE them if you prefer to use longjmp/setjmp even with C++
rlm@1 601 ** or if want/don't to use _longjmp/_setjmp instead of regular
rlm@1 602 ** longjmp/setjmp. By default, Lua handles errors with exceptions when
rlm@1 603 ** compiling as C++ code, with _longjmp/_setjmp when asked to use them,
rlm@1 604 ** and with longjmp/setjmp otherwise.
rlm@1 605 */
rlm@1 606 #if defined(__cplusplus)
rlm@1 607 /* C++ exceptions */
rlm@1 608 #define LUAI_THROW(L,c) throw(c)
rlm@1 609 #define LUAI_TRY(L,c,a) try { a } catch(...) \
rlm@1 610 { if ((c)->status == 0) (c)->status = -1; }
rlm@1 611 #define luai_jmpbuf int /* dummy variable */
rlm@1 612
rlm@1 613 #elif defined(LUA_USE_ULONGJMP)
rlm@1 614 /* in Unix, try _longjmp/_setjmp (more efficient) */
rlm@1 615 #define LUAI_THROW(L,c) _longjmp((c)->b, 1)
rlm@1 616 #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
rlm@1 617 #define luai_jmpbuf jmp_buf
rlm@1 618
rlm@1 619 #else
rlm@1 620 /* default handling with long jumps */
rlm@1 621 #define LUAI_THROW(L,c) longjmp((c)->b, 1)
rlm@1 622 #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
rlm@1 623 #define luai_jmpbuf jmp_buf
rlm@1 624
rlm@1 625 #endif
rlm@1 626
rlm@1 627
rlm@1 628 /*
rlm@1 629 @@ LUA_MAXCAPTURES is the maximum number of captures that a pattern
rlm@1 630 @* can do during pattern-matching.
rlm@1 631 ** CHANGE it if you need more captures. This limit is arbitrary.
rlm@1 632 */
rlm@1 633 #define LUA_MAXCAPTURES 32
rlm@1 634
rlm@1 635
rlm@1 636 /*
rlm@1 637 @@ lua_tmpnam is the function that the OS library uses to create a
rlm@1 638 @* temporary name.
rlm@1 639 @@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam.
rlm@1 640 ** CHANGE them if you have an alternative to tmpnam (which is considered
rlm@1 641 ** insecure) or if you want the original tmpnam anyway. By default, Lua
rlm@1 642 ** uses tmpnam except when POSIX is available, where it uses mkstemp.
rlm@1 643 */
rlm@1 644 #if defined(loslib_c) || defined(luaall_c)
rlm@1 645
rlm@1 646 #if defined(LUA_USE_MKSTEMP)
rlm@1 647 #include <unistd.h>
rlm@1 648 #define LUA_TMPNAMBUFSIZE 32
rlm@1 649 #define lua_tmpnam(b,e) { \
rlm@1 650 strcpy(b, "/tmp/lua_XXXXXX"); \
rlm@1 651 e = mkstemp(b); \
rlm@1 652 if (e != -1) close(e); \
rlm@1 653 e = (e == -1); }
rlm@1 654
rlm@1 655 #else
rlm@1 656 #define LUA_TMPNAMBUFSIZE L_tmpnam
rlm@1 657 #define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
rlm@1 658 #endif
rlm@1 659
rlm@1 660 #endif
rlm@1 661
rlm@1 662
rlm@1 663 /*
rlm@1 664 @@ lua_popen spawns a new process connected to the current one through
rlm@1 665 @* the file streams.
rlm@1 666 ** CHANGE it if you have a way to implement it in your system.
rlm@1 667 */
rlm@1 668 #if defined(LUA_USE_POPEN)
rlm@1 669
rlm@1 670 #define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
rlm@1 671 #define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
rlm@1 672
rlm@1 673 #elif defined(LUA_WIN)
rlm@1 674
rlm@1 675 #define lua_popen(L,c,m) ((void)L, _popen(c,m))
rlm@1 676 #define lua_pclose(L,file) ((void)L, (_pclose(file) != -1))
rlm@1 677
rlm@1 678 #else
rlm@1 679
rlm@1 680 #define lua_popen(L,c,m) ((void)((void)c, m), \
rlm@1 681 luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
rlm@1 682 #define lua_pclose(L,file) ((void)((void)L, file), 0)
rlm@1 683
rlm@1 684 #endif
rlm@1 685
rlm@1 686 /*
rlm@1 687 @@ LUA_DL_* define which dynamic-library system Lua should use.
rlm@1 688 ** CHANGE here if Lua has problems choosing the appropriate
rlm@1 689 ** dynamic-library system for your platform (either Windows' DLL, Mac's
rlm@1 690 ** dyld, or Unix's dlopen). If your system is some kind of Unix, there
rlm@1 691 ** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for
rlm@1 692 ** it. To use dlopen you also need to adapt the src/Makefile (probably
rlm@1 693 ** adding -ldl to the linker options), so Lua does not select it
rlm@1 694 ** automatically. (When you change the makefile to add -ldl, you must
rlm@1 695 ** also add -DLUA_USE_DLOPEN.)
rlm@1 696 ** If you do not want any kind of dynamic library, undefine all these
rlm@1 697 ** options.
rlm@1 698 ** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD.
rlm@1 699 */
rlm@1 700 #if defined(LUA_USE_DLOPEN)
rlm@1 701 #define LUA_DL_DLOPEN
rlm@1 702 #endif
rlm@1 703
rlm@1 704 #if defined(LUA_WIN)
rlm@1 705 #define LUA_DL_DLL
rlm@1 706 #endif
rlm@1 707
rlm@1 708
rlm@1 709 /*
rlm@1 710 @@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
rlm@1 711 @* (the data goes just *before* the lua_State pointer).
rlm@1 712 ** CHANGE (define) this if you really need that. This value must be
rlm@1 713 ** a multiple of the maximum alignment required for your machine.
rlm@1 714 */
rlm@1 715 #define LUAI_EXTRASPACE 0
rlm@1 716
rlm@1 717
rlm@1 718 /*
rlm@1 719 @@ luai_userstate* allow user-specific actions on threads.
rlm@1 720 ** CHANGE them if you defined LUAI_EXTRASPACE and need to do something
rlm@1 721 ** extra when a thread is created/deleted/resumed/yielded.
rlm@1 722 */
rlm@1 723 #define luai_userstateopen(L) ((void)L)
rlm@1 724 #define luai_userstateclose(L) ((void)L)
rlm@1 725 #define luai_userstatethread(L,L1) ((void)L)
rlm@1 726 #define luai_userstatefree(L) ((void)L)
rlm@1 727 #define luai_userstateresume(L,n) ((void)L)
rlm@1 728 #define luai_userstateyield(L,n) ((void)L)
rlm@1 729
rlm@1 730
rlm@1 731 /*
rlm@1 732 @@ LUA_INTFRMLEN is the length modifier for integer conversions
rlm@1 733 @* in 'string.format'.
rlm@1 734 @@ LUA_INTFRM_T is the integer type correspoding to the previous length
rlm@1 735 @* modifier.
rlm@1 736 ** CHANGE them if your system supports long long or does not support long.
rlm@1 737 */
rlm@1 738
rlm@1 739 #if defined(LUA_USELONGLONG)
rlm@1 740
rlm@1 741 #define LUA_INTFRMLEN "ll"
rlm@1 742 #define LUA_INTFRM_T long long
rlm@1 743
rlm@1 744 #else
rlm@1 745
rlm@1 746 #define LUA_INTFRMLEN "l"
rlm@1 747 #define LUA_INTFRM_T long
rlm@1 748
rlm@1 749 #endif
rlm@1 750
rlm@1 751
rlm@1 752
rlm@1 753 /* =================================================================== */
rlm@1 754
rlm@1 755 /*
rlm@1 756 ** Local configuration. You can use this space to add your redefinitions
rlm@1 757 ** without modifying the main part of the file.
rlm@1 758 */
rlm@1 759
rlm@1 760
rlm@1 761
rlm@1 762 #endif
rlm@1 763