lua
[Ported from github.com/lua/lua] Cast in 'rl_readline_name'
Brought by drakestapleton
lua / luaconf.h
| 1 | /* |
| 2 | ** $Id: luaconf.h $ |
| 3 | ** Configuration file for Lua |
| 4 | ** See Copyright Notice in lua.h |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | #ifndef luaconf_h |
| 9 | #define luaconf_h |
| 10 | |
| 11 | #include <limits.h> |
| 12 | #include <stddef.h> |
| 13 | |
| 14 | |
| 15 | /* |
| 16 | ** =================================================================== |
| 17 | ** General Configuration File for Lua |
| 18 | ** |
| 19 | ** Some definitions here can be changed externally, through the compiler |
| 20 | ** (e.g., with '-D' options): They are commented out or protected |
| 21 | ** by '#if !defined' guards. However, several other definitions |
| 22 | ** should be changed directly here, either because they affect the |
| 23 | ** Lua ABI (by making the changes here, you ensure that all software |
| 24 | ** connected to Lua, such as C libraries, will be compiled with the same |
| 25 | ** configuration); or because they are seldom changed. |
| 26 | ** |
| 27 | ** Search for "@@" to find all configurable definitions. |
| 28 | ** =================================================================== |
| 29 | */ |
| 30 | |
| 31 | |
| 32 | /* |
| 33 | ** {==================================================================== |
| 34 | ** System Configuration: macros to adapt (if needed) Lua to some |
| 35 | ** particular platform, for instance restricting it to C89. |
| 36 | ** ===================================================================== |
| 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 | /* |
| 62 | ** When POSIX DLL ('LUA_USE_DLOPEN') is enabled, the Lua stand-alone |
| 63 | ** application will try to dynamically link a 'readline' facility |
| 64 | ** for its REPL. In that case, LUA_READLINELIB is the name of the |
| 65 | ** library it will look for those facilities. If lua.c cannot open |
| 66 | ** the specified library, it will generate a warning and then run |
| 67 | ** without 'readline'. If that macro is not defined, lua.c will not |
| 68 | ** use 'readline'. |
| 69 | */ |
| 70 | #if defined(LUA_USE_LINUX) |
| 71 | #define LUA_USE_POSIX |
| 72 | #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ |
| 73 | #if !defined(LUA_READLINELIB) |
| 74 | #define LUA_READLINELIB "libreadline.so" |
| 75 | #endif |
| 76 | #endif |
| 77 | |
| 78 | |
| 79 | #if defined(LUA_USE_MACOSX) |
| 80 | #define LUA_USE_POSIX |
| 81 | #define LUA_USE_DLOPEN /* macOS does not need -ldl */ |
| 82 | #define LUA_USE_READLINE /* needs an extra library: -lreadline */ |
| 83 | #endif |
| 84 | |
| 85 | |
| 86 | #if defined(LUA_USE_IOS) |
| 87 | #define LUA_USE_POSIX |
| 88 | #define LUA_USE_DLOPEN |
| 89 | #endif |
| 90 | |
| 91 | |
| 92 | #if defined(LUA_USE_C89) && defined(LUA_USE_POSIX) |
| 93 | #error "POSIX is not compatible with C89" |
| 94 | #endif |
| 95 | |
| 96 | |
| 97 | /* |
| 98 | @@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits. |
| 99 | */ |
| 100 | #define LUAI_IS32INT ((UINT_MAX >> 30) >= 3) |
| 101 | |
| 102 | /* }================================================================== */ |
| 103 | |
| 104 | |
| 105 | |
| 106 | /* |
| 107 | ** {================================================================== |
| 108 | ** Configuration for Number types. These options should not be |
| 109 | ** set externally, because any other code connected to Lua must |
| 110 | ** use the same configuration. |
| 111 | ** =================================================================== |
| 112 | */ |
| 113 | |
| 114 | /* |
| 115 | @@ LUA_INT_TYPE defines the type for Lua integers. |
| 116 | @@ LUA_FLOAT_TYPE defines the type for Lua floats. |
| 117 | ** Lua should work fine with any mix of these options supported |
| 118 | ** by your C compiler. The usual configurations are 64-bit integers |
| 119 | ** and 'double' (the default), 32-bit integers and 'float' (for |
| 120 | ** restricted platforms), and 'long'/'double' (for C compilers not |
| 121 | ** compliant with C99, which may not have support for 'long long'). |
| 122 | */ |
| 123 | |
| 124 | /* predefined options for LUA_INT_TYPE */ |
| 125 | #define LUA_INT_INT 1 |
| 126 | #define LUA_INT_LONG 2 |
| 127 | #define LUA_INT_LONGLONG 3 |
| 128 | |
| 129 | /* predefined options for LUA_FLOAT_TYPE */ |
| 130 | #define LUA_FLOAT_FLOAT 1 |
| 131 | #define LUA_FLOAT_DOUBLE 2 |
| 132 | #define LUA_FLOAT_LONGDOUBLE 3 |
| 133 | |
| 134 | |
| 135 | /* Default configuration ('long long' and 'double', for 64-bit Lua) */ |
| 136 | #define LUA_INT_DEFAULT LUA_INT_LONGLONG |
| 137 | #define LUA_FLOAT_DEFAULT LUA_FLOAT_DOUBLE |
| 138 | |
| 139 | |
| 140 | /* |
| 141 | @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. |
| 142 | */ |
| 143 | /* #define LUA_32BITS */ |
| 144 | |
| 145 | |
| 146 | /* |
| 147 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for |
| 148 | ** C89 ('long' and 'double'); Windows always has '__int64', so it does |
| 149 | ** not need to use this case. |
| 150 | */ |
| 151 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) |
| 152 | #define LUA_C89_NUMBERS 1 |
| 153 | #else |
| 154 | #define LUA_C89_NUMBERS 0 |
| 155 | #endif |
| 156 | |
| 157 | |
| 158 | #if defined(LUA_32BITS) /* { */ |
| 159 | /* |
| 160 | ** 32-bit integers and 'float' |
| 161 | */ |
| 162 | #if LUAI_IS32INT /* use 'int' if big enough */ |
| 163 | #define LUA_INT_TYPE LUA_INT_INT |
| 164 | #else /* otherwise use 'long' */ |
| 165 | #define LUA_INT_TYPE LUA_INT_LONG |
| 166 | #endif |
| 167 | #define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT |
| 168 | |
| 169 | #elif LUA_C89_NUMBERS /* }{ */ |
| 170 | /* |
| 171 | ** largest types available for C89 ('long' and 'double') |
| 172 | */ |
| 173 | #define LUA_INT_TYPE LUA_INT_LONG |
| 174 | #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE |
| 175 | |
| 176 | #else /* }{ */ |
| 177 | /* use defaults */ |
| 178 | |
| 179 | #define LUA_INT_TYPE LUA_INT_DEFAULT |
| 180 | #define LUA_FLOAT_TYPE LUA_FLOAT_DEFAULT |
| 181 | |
| 182 | #endif /* } */ |
| 183 | |
| 184 | |
| 185 | /* }================================================================== */ |
| 186 | |
| 187 | |
| 188 | |
| 189 | /* |
| 190 | ** {================================================================== |
| 191 | ** Configuration for Paths. |
| 192 | ** =================================================================== |
| 193 | */ |
| 194 | |
| 195 | /* |
| 196 | ** LUA_PATH_SEP is the character that separates templates in a path. |
| 197 | ** LUA_PATH_MARK is the string that marks the substitution points in a |
| 198 | ** template. |
| 199 | ** LUA_EXEC_DIR in a Windows path is replaced by the executable's |
| 200 | ** directory. |
| 201 | */ |
| 202 | #define LUA_PATH_SEP ";" |
| 203 | #define LUA_PATH_MARK "?" |
| 204 | #define LUA_EXEC_DIR "!" |
| 205 | |
| 206 | |
| 207 | /* |
| 208 | @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for |
| 209 | ** Lua libraries. |
| 210 | @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for |
| 211 | ** C libraries. |
| 212 | ** CHANGE them if your machine has a non-conventional directory |
| 213 | ** hierarchy or if you want to install your libraries in |
| 214 | ** non-conventional directories. |
| 215 | */ |
| 216 | |
| 217 | #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR |
| 218 | #if defined(_WIN32) /* { */ |
| 219 | /* |
| 220 | ** In Windows, any exclamation mark ('!') in the path is replaced by the |
| 221 | ** path of the directory of the executable file of the current process. |
| 222 | */ |
| 223 | #define LUA_LDIR "!\\lua\\" |
| 224 | #define LUA_CDIR "!\\" |
| 225 | #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" |
| 226 | |
| 227 | #if !defined(LUA_PATH_DEFAULT) |
| 228 | #define LUA_PATH_DEFAULT \ |
| 229 | LUA_LDIR "?.lua;" LUA_LDIR "?\\init.lua;" \ |
| 230 | LUA_CDIR "?.lua;" LUA_CDIR "?\\init.lua;" \ |
| 231 | LUA_SHRDIR "?.lua;" LUA_SHRDIR "?\\init.lua;" \ |
| 232 | ".\\?.lua;" ".\\?\\init.lua" |
| 233 | #endif |
| 234 | |
| 235 | #if !defined(LUA_CPATH_DEFAULT) |
| 236 | #define LUA_CPATH_DEFAULT \ |
| 237 | LUA_CDIR "?.dll;" \ |
| 238 | LUA_CDIR "..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ |
| 239 | LUA_CDIR "loadall.dll;" ".\\?.dll" |
| 240 | #endif |
| 241 | |
| 242 | #else /* }{ */ |
| 243 | |
| 244 | #define LUA_ROOT "/usr/local/" |
| 245 | #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" |
| 246 | #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" |
| 247 | |
| 248 | #if !defined(LUA_PATH_DEFAULT) |
| 249 | #define LUA_PATH_DEFAULT \ |
| 250 | LUA_LDIR "?.lua;" LUA_LDIR "?/init.lua;" \ |
| 251 | LUA_CDIR "?.lua;" LUA_CDIR "?/init.lua;" \ |
| 252 | "./?.lua;" "./?/init.lua" |
| 253 | #endif |
| 254 | |
| 255 | #if !defined(LUA_CPATH_DEFAULT) |
| 256 | #define LUA_CPATH_DEFAULT \ |
| 257 | LUA_CDIR "?.so;" LUA_CDIR "loadall.so;" "./?.so" |
| 258 | #endif |
| 259 | |
| 260 | #endif /* } */ |
| 261 | |
| 262 | |
| 263 | /* |
| 264 | @@ LUA_DIRSEP is the directory separator (for submodules). |
| 265 | ** CHANGE it if your machine does not use "/" as the directory separator |
| 266 | ** and is not Windows. (On Windows Lua automatically uses "\".) |
| 267 | */ |
| 268 | #if !defined(LUA_DIRSEP) |
| 269 | |
| 270 | #if defined(_WIN32) |
| 271 | #define LUA_DIRSEP "\\" |
| 272 | #else |
| 273 | #define LUA_DIRSEP "/" |
| 274 | #endif |
| 275 | |
| 276 | #endif |
| 277 | |
| 278 | |
| 279 | /* |
| 280 | ** LUA_IGMARK is a mark to ignore all after it when building the |
| 281 | ** module name (e.g., used to build the luaopen_ function name). |
| 282 | ** Typically, the suffix after the mark is the module version, |
| 283 | ** as in "mod-v1.2.so". |
| 284 | */ |
| 285 | #define LUA_IGMARK "-" |
| 286 | |
| 287 | /* }================================================================== */ |
| 288 | |
| 289 | |
| 290 | /* |
| 291 | ** {================================================================== |
| 292 | ** Marks for exported symbols in the C code |
| 293 | ** =================================================================== |
| 294 | */ |
| 295 | |
| 296 | /* |
| 297 | @@ LUA_API is a mark for all core API functions. |
| 298 | @@ LUALIB_API is a mark for all auxiliary library functions. |
| 299 | @@ LUAMOD_API is a mark for all standard library opening functions. |
| 300 | ** CHANGE them if you need to define those functions in some special way. |
| 301 | ** For instance, if you want to create one Windows DLL with the core and |
| 302 | ** the libraries, you may want to use the following definition (define |
| 303 | ** LUA_BUILD_AS_DLL to get it). |
| 304 | */ |
| 305 | #if defined(LUA_BUILD_AS_DLL) /* { */ |
| 306 | |
| 307 | #if defined(LUA_CORE) || defined(LUA_LIB) /* { */ |
| 308 | #define LUA_API __declspec(dllexport) |
| 309 | #else /* }{ */ |
| 310 | #define LUA_API __declspec(dllimport) |
| 311 | #endif /* } */ |
| 312 | |
| 313 | #else /* }{ */ |
| 314 | |
| 315 | #define LUA_API extern |
| 316 | |
| 317 | #endif /* } */ |
| 318 | |
| 319 | |
| 320 | /* |
| 321 | ** More often than not the libs go together with the core. |
| 322 | */ |
| 323 | #define LUALIB_API LUA_API |
| 324 | |
| 325 | #if defined(__cplusplus) |
| 326 | /* Lua uses the "C name" when calling open functions */ |
| 327 | #define LUAMOD_API extern "C" |
| 328 | #else |
| 329 | #define LUAMOD_API LUA_API |
| 330 | #endif |
| 331 | |
| 332 | /* }================================================================== */ |
| 333 | |
| 334 | |
| 335 | /* |
| 336 | ** {================================================================== |
| 337 | ** Compatibility with previous versions |
| 338 | ** =================================================================== |
| 339 | */ |
| 340 | |
| 341 | /* |
| 342 | @@ LUA_COMPAT_GLOBAL avoids 'global' being a reserved word |
| 343 | */ |
| 344 | #if !defined(LUA_COMPAT_GLOBAL) |
| 345 | #define LUA_COMPAT_GLOBAL 1 |
| 346 | #endif |
| 347 | |
| 348 | |
| 349 | /* |
| 350 | @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated |
| 351 | ** functions in the mathematical library. |
| 352 | ** (These functions were already officially removed in 5.3; |
| 353 | ** nevertheless they are still available here.) |
| 354 | */ |
| 355 | /* #define LUA_COMPAT_MATHLIB */ |
| 356 | |
| 357 | |
| 358 | /* |
| 359 | @@ The following macros supply trivial compatibility for some |
| 360 | ** changes in the API. The macros themselves document how to |
| 361 | ** change your code to avoid using them. |
| 362 | ** (Once more, these macros were officially removed in 5.3, but they are |
| 363 | ** still available here.) |
| 364 | */ |
| 365 | #define lua_strlen(L,i) lua_rawlen(L, (i)) |
| 366 | |
| 367 | #define lua_objlen(L,i) lua_rawlen(L, (i)) |
| 368 | |
| 369 | #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) |
| 370 | #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) |
| 371 | |
| 372 | /* }================================================================== */ |
| 373 | |
| 374 | |
| 375 | |
| 376 | /* |
| 377 | ** {================================================================== |
| 378 | ** Configuration for Numbers (low-level part). |
| 379 | ** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* |
| 380 | ** satisfy your needs. |
| 381 | ** =================================================================== |
| 382 | */ |
| 383 | |
| 384 | /* |
| 385 | @@ LUAI_UACNUMBER is the result of a 'default argument promotion' |
| 386 | @@ over a floating number. |
| 387 | @@ l_floatatt(x) corrects float attribute 'x' to the proper float type |
| 388 | ** by prefixing it with one of FLT/DBL/LDBL. |
| 389 | @@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. |
| 390 | @@ LUA_NUMBER_FMT is the format for writing floats with the maximum |
| 391 | ** number of digits that respects tostring(tonumber(numeral)) == numeral. |
| 392 | ** (That would be floor(log10(2^n)), where n is the number of bits in |
| 393 | ** the float mantissa.) |
| 394 | @@ LUA_NUMBER_FMT_N is the format for writing floats with the minimum |
| 395 | ** number of digits that ensures tonumber(tostring(number)) == number. |
| 396 | ** (That would be LUA_NUMBER_FMT+2.) |
| 397 | @@ l_mathop allows the addition of an 'l' or 'f' to all math operations. |
| 398 | @@ l_floor takes the floor of a float. |
| 399 | @@ lua_str2number converts a decimal numeral to a number. |
| 400 | */ |
| 401 | |
| 402 | |
| 403 | /* The following definition is good for most cases here */ |
| 404 | |
| 405 | #define l_floor(x) (l_mathop(floor)(x)) |
| 406 | |
| 407 | |
| 408 | /* now the variable definitions */ |
| 409 | |
| 410 | #if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */ |
| 411 | |
| 412 | #define LUA_NUMBER float |
| 413 | |
| 414 | #define l_floatatt(n) (FLT_##n) |
| 415 | |
| 416 | #define LUAI_UACNUMBER double |
| 417 | |
| 418 | #define LUA_NUMBER_FRMLEN "" |
| 419 | #define LUA_NUMBER_FMT "%.7g" |
| 420 | #define LUA_NUMBER_FMT_N "%.9g" |
| 421 | |
| 422 | #define l_mathop(op) op##f |
| 423 | |
| 424 | #define lua_str2number(s,p) strtof((s), (p)) |
| 425 | |
| 426 | |
| 427 | #elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */ |
| 428 | |
| 429 | #define LUA_NUMBER long double |
| 430 | |
| 431 | #define l_floatatt(n) (LDBL_##n) |
| 432 | |
| 433 | #define LUAI_UACNUMBER long double |
| 434 | |
| 435 | #define LUA_NUMBER_FRMLEN "L" |
| 436 | #define LUA_NUMBER_FMT "%.19Lg" |
| 437 | #define LUA_NUMBER_FMT_N "%.21Lg" |
| 438 | |
| 439 | #define l_mathop(op) op##l |
| 440 | |
| 441 | #define lua_str2number(s,p) strtold((s), (p)) |
| 442 | |
| 443 | #elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */ |
| 444 | |
| 445 | #define LUA_NUMBER double |
| 446 | |
| 447 | #define l_floatatt(n) (DBL_##n) |
| 448 | |
| 449 | #define LUAI_UACNUMBER double |
| 450 | |
| 451 | #define LUA_NUMBER_FRMLEN "" |
| 452 | #define LUA_NUMBER_FMT "%.15g" |
| 453 | #define LUA_NUMBER_FMT_N "%.17g" |
| 454 | |
| 455 | #define l_mathop(op) op |
| 456 | |
| 457 | #define lua_str2number(s,p) strtod((s), (p)) |
| 458 | |
| 459 | #else /* }{ */ |
| 460 | |
| 461 | #error "numeric float type not defined" |
| 462 | |
| 463 | #endif /* } */ |
| 464 | |
| 465 | |
| 466 | |
| 467 | /* |
| 468 | @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. |
| 469 | @@ LUAI_UACINT is the result of a 'default argument promotion' |
| 470 | @@ over a LUA_INTEGER. |
| 471 | @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. |
| 472 | @@ LUA_INTEGER_FMT is the format for writing integers. |
| 473 | @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. |
| 474 | @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. |
| 475 | @@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED. |
| 476 | @@ lua_integer2str converts an integer to a string. |
| 477 | */ |
| 478 | |
| 479 | |
| 480 | /* The following definitions are good for most cases here */ |
| 481 | |
| 482 | #define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" |
| 483 | |
| 484 | #define LUAI_UACINT LUA_INTEGER |
| 485 | |
| 486 | #define lua_integer2str(s,sz,n) \ |
| 487 | l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n)) |
| 488 | |
| 489 | /* |
| 490 | ** use LUAI_UACINT here to avoid problems with promotions (which |
| 491 | ** can turn a comparison between unsigneds into a signed comparison) |
| 492 | */ |
| 493 | #define LUA_UNSIGNED unsigned LUAI_UACINT |
| 494 | |
| 495 | |
| 496 | /* now the variable definitions */ |
| 497 | |
| 498 | #if LUA_INT_TYPE == LUA_INT_INT /* { int */ |
| 499 | |
| 500 | #define LUA_INTEGER int |
| 501 | #define LUA_INTEGER_FRMLEN "" |
| 502 | |
| 503 | #define LUA_MAXINTEGER INT_MAX |
| 504 | #define LUA_MININTEGER INT_MIN |
| 505 | |
| 506 | #define LUA_MAXUNSIGNED UINT_MAX |
| 507 | |
| 508 | #elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ |
| 509 | |
| 510 | #define LUA_INTEGER long |
| 511 | #define LUA_INTEGER_FRMLEN "l" |
| 512 | |
| 513 | #define LUA_MAXINTEGER LONG_MAX |
| 514 | #define LUA_MININTEGER LONG_MIN |
| 515 | |
| 516 | #define LUA_MAXUNSIGNED ULONG_MAX |
| 517 | |
| 518 | #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ |
| 519 | |
| 520 | /* use presence of macro LLONG_MAX as proxy for C99 compliance */ |
| 521 | #if defined(LLONG_MAX) /* { */ |
| 522 | /* use ISO C99 stuff */ |
| 523 | |
| 524 | #define LUA_INTEGER long long |
| 525 | #define LUA_INTEGER_FRMLEN "ll" |
| 526 | |
| 527 | #define LUA_MAXINTEGER LLONG_MAX |
| 528 | #define LUA_MININTEGER LLONG_MIN |
| 529 | |
| 530 | #define LUA_MAXUNSIGNED ULLONG_MAX |
| 531 | |
| 532 | #elif defined(LUA_USE_WINDOWS) /* }{ */ |
| 533 | /* in Windows, can use specific Windows types */ |
| 534 | |
| 535 | #define LUA_INTEGER __int64 |
| 536 | #define LUA_INTEGER_FRMLEN "I64" |
| 537 | |
| 538 | #define LUA_MAXINTEGER _I64_MAX |
| 539 | #define LUA_MININTEGER _I64_MIN |
| 540 | |
| 541 | #define LUA_MAXUNSIGNED _UI64_MAX |
| 542 | |
| 543 | #else /* }{ */ |
| 544 | |
| 545 | #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ |
| 546 | or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" |
| 547 | |
| 548 | #endif /* } */ |
| 549 | |
| 550 | #else /* }{ */ |
| 551 | |
| 552 | #error "numeric integer type not defined" |
| 553 | |
| 554 | #endif /* } */ |
| 555 | |
| 556 | /* }================================================================== */ |
| 557 | |
| 558 | |
| 559 | /* |
| 560 | ** {================================================================== |
| 561 | ** Dependencies with C99 and other C details |
| 562 | ** =================================================================== |
| 563 | */ |
| 564 | |
| 565 | /* |
| 566 | @@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89. |
| 567 | ** (All uses in Lua have only one format item.) |
| 568 | */ |
| 569 | #if !defined(LUA_USE_C89) |
| 570 | #define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i) |
| 571 | #else |
| 572 | #define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i)) |
| 573 | #endif |
| 574 | |
| 575 | |
| 576 | /* |
| 577 | @@ lua_strx2number converts a hexadecimal numeral to a number. |
| 578 | ** In C99, 'strtod' does that conversion. Otherwise, you can |
| 579 | ** leave 'lua_strx2number' undefined and Lua will provide its own |
| 580 | ** implementation. |
| 581 | */ |
| 582 | #if !defined(LUA_USE_C89) |
| 583 | #define lua_strx2number(s,p) lua_str2number(s,p) |
| 584 | #endif |
| 585 | |
| 586 | |
| 587 | /* |
| 588 | @@ lua_pointer2str converts a pointer to a readable string in a |
| 589 | ** non-specified way. |
| 590 | */ |
| 591 | #define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p) |
| 592 | |
| 593 | |
| 594 | /* |
| 595 | @@ lua_number2strx converts a float to a hexadecimal numeral. |
| 596 | ** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. |
| 597 | ** Otherwise, you can leave 'lua_number2strx' undefined and Lua will |
| 598 | ** provide its own implementation. |
| 599 | */ |
| 600 | #if !defined(LUA_USE_C89) |
| 601 | #define lua_number2strx(L,b,sz,f,n) \ |
| 602 | ((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n))) |
| 603 | #endif |
| 604 | |
| 605 | |
| 606 | /* |
| 607 | ** 'strtof' and 'opf' variants for math functions are not valid in |
| 608 | ** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the |
| 609 | ** availability of these variants. ('math.h' is already included in |
| 610 | ** all files that use these macros.) |
| 611 | */ |
| 612 | #if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF)) |
| 613 | #undef l_mathop /* variants not available */ |
| 614 | #undef lua_str2number |
| 615 | #define l_mathop(op) (lua_Number)op /* no variant */ |
| 616 | #define lua_str2number(s,p) ((lua_Number)strtod((s), (p))) |
| 617 | #endif |
| 618 | |
| 619 | |
| 620 | /* |
| 621 | @@ LUA_KCONTEXT is the type of the context ('ctx') for continuation |
| 622 | ** functions. It must be a numerical type; Lua will use 'intptr_t' if |
| 623 | ** available, otherwise it will use 'ptrdiff_t' (the nearest thing to |
| 624 | ** 'intptr_t' in C89) |
| 625 | */ |
| 626 | #define LUA_KCONTEXT ptrdiff_t |
| 627 | |
| 628 | #if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ |
| 629 | __STDC_VERSION__ >= 199901L |
| 630 | #include <stdint.h> |
| 631 | #if defined(INTPTR_MAX) /* even in C99 this type is optional */ |
| 632 | #undef LUA_KCONTEXT |
| 633 | #define LUA_KCONTEXT intptr_t |
| 634 | #endif |
| 635 | #endif |
| 636 | |
| 637 | |
| 638 | /* |
| 639 | @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). |
| 640 | ** Change that if you do not want to use C locales. (Code using this |
| 641 | ** macro must include the header 'locale.h'.) |
| 642 | */ |
| 643 | #if !defined(lua_getlocaledecpoint) |
| 644 | #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) |
| 645 | #endif |
| 646 | |
| 647 | |
| 648 | /* |
| 649 | ** macros to improve jump prediction, used mostly for error handling |
| 650 | ** and debug facilities. (Some macros in the Lua API use these macros. |
| 651 | ** Define LUA_NOBUILTIN if you do not want '__builtin_expect' in your |
| 652 | ** code.) |
| 653 | */ |
| 654 | #if !defined(luai_likely) |
| 655 | |
| 656 | #if !defined(LUA_NOBUILTIN) && defined(__GNUC__) && (__GNUC__ >= 3) |
| 657 | #define luai_likely(x) (__builtin_expect(((x) != 0), 1)) |
| 658 | #define luai_unlikely(x) (__builtin_expect(((x) != 0), 0)) |
| 659 | #else |
| 660 | #define luai_likely(x) (x) |
| 661 | #define luai_unlikely(x) (x) |
| 662 | #endif |
| 663 | |
| 664 | #endif |
| 665 | |
| 666 | |
| 667 | |
| 668 | /* }================================================================== */ |
| 669 | |
| 670 | |
| 671 | /* |
| 672 | ** {================================================================== |
| 673 | ** Language Variations |
| 674 | ** ===================================================================== |
| 675 | */ |
| 676 | |
| 677 | /* |
| 678 | @@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some |
| 679 | ** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from |
| 680 | ** numbers to strings. Define LUA_NOCVTS2N to turn off automatic |
| 681 | ** coercion from strings to numbers. |
| 682 | */ |
| 683 | /* #define LUA_NOCVTN2S */ |
| 684 | /* #define LUA_NOCVTS2N */ |
| 685 | |
| 686 | |
| 687 | /* |
| 688 | @@ LUA_USE_APICHECK turns on several consistency checks on the C API. |
| 689 | ** Define it as a help when debugging C code. |
| 690 | */ |
| 691 | /* #define LUA_USE_APICHECK */ |
| 692 | |
| 693 | /* }================================================================== */ |
| 694 | |
| 695 | |
| 696 | /* |
| 697 | ** {================================================================== |
| 698 | ** Macros that affect the API and must be stable (that is, must be the |
| 699 | ** same when you compile Lua and when you compile code that links to |
| 700 | ** Lua). |
| 701 | ** ===================================================================== |
| 702 | */ |
| 703 | |
| 704 | /* |
| 705 | @@ LUA_EXTRASPACE defines the size of a raw memory area associated with |
| 706 | ** a Lua state with very fast access. |
| 707 | ** CHANGE it if you need a different size. |
| 708 | */ |
| 709 | #define LUA_EXTRASPACE (sizeof(void *)) |
| 710 | |
| 711 | |
| 712 | /* |
| 713 | @@ LUA_IDSIZE gives the maximum size for the description of the source |
| 714 | ** of a function in debug information. |
| 715 | ** CHANGE it if you want a different size. |
| 716 | */ |
| 717 | #define LUA_IDSIZE 60 |
| 718 | |
| 719 | |
| 720 | /* |
| 721 | @@ LUAL_BUFFERSIZE is the initial buffer size used by the lauxlib |
| 722 | ** buffer system. |
| 723 | */ |
| 724 | #define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number))) |
| 725 | |
| 726 | |
| 727 | /* |
| 728 | @@ LUAI_MAXALIGN defines fields that ensure proper alignment for |
| 729 | ** memory areas offered by Lua (e.g., userdata memory). |
| 730 | ** Add fields to it if you need alignment for non-ISO objects. |
| 731 | */ |
| 732 | #if defined(LLONG_MAX) |
| 733 | /* use ISO C99 stuff */ |
| 734 | #define LUAI_MAXALIGN long double u; void *s; long long l |
| 735 | #else |
| 736 | /* use only C89 stuff */ |
| 737 | #define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l |
| 738 | #endif |
| 739 | |
| 740 | /* }================================================================== */ |
| 741 | |
| 742 | |
| 743 | |
| 744 | |
| 745 | |
| 746 | /* =================================================================== */ |
| 747 | |
| 748 | /* |
| 749 | ** Local configuration. You can use this space to add your redefinitions |
| 750 | ** without modifying the main part of the file. |
| 751 | */ |
| 752 | |
| 753 | |
| 754 | |
| 755 | #endif |
| 756 |