luaconf.h.dist revision 344220
1178354Ssam/* 2178354Ssam** $Id: luaconf.h,v 1.259 2016/12/22 13:08:50 roberto Exp $ 3178354Ssam** Configuration file for Lua 4178354Ssam** See Copyright Notice in lua.h 5178354Ssam*/ 6178354Ssam 7178354Ssam 8178354Ssam#ifndef luaconf_h 9178354Ssam#define luaconf_h 10178354Ssam 11178354Ssam#include <limits.h> 12178354Ssam#include <stddef.h> 13178354Ssam 14178354Ssam 15178354Ssam/* 16178354Ssam** =================================================================== 17178354Ssam** Search for "@@" to find all configurable definitions. 18178354Ssam** =================================================================== 19178354Ssam*/ 20178354Ssam 21178354Ssam 22178354Ssam/* 23178354Ssam** {==================================================================== 24178354Ssam** System Configuration: macros to adapt (if needed) Lua to some 25178354Ssam** particular platform, for instance compiling it with 32-bit numbers or 26178354Ssam** restricting it to C89. 27178354Ssam** ===================================================================== 28178354Ssam*/ 29178354Ssam 30178354Ssam/* 31178354Ssam@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You 32178354Ssam** can also define LUA_32BITS in the make file, but changing here you 33178354Ssam** ensure that all software connected to Lua will be compiled with the 34178354Ssam** same configuration. 35178354Ssam*/ 36178354Ssam/* #define LUA_32BITS */ 37178354Ssam 38178354Ssam 39178354Ssam/* 40178354Ssam@@ LUA_USE_C89 controls the use of non-ISO-C89 features. 41178354Ssam** Define it if you want Lua to avoid the use of a few C99 features 42178354Ssam** or Windows-specific features on Windows. 43178354Ssam*/ 44178354Ssam/* #define LUA_USE_C89 */ 45178354Ssam 46178354Ssam 47178354Ssam/* 48178354Ssam** By default, Lua on Windows use (some) specific Windows features 49178354Ssam*/ 50178354Ssam#if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE) 51178354Ssam#define LUA_USE_WINDOWS /* enable goodies for regular Windows */ 52178354Ssam#endif 53178354Ssam 54178354Ssam 55178354Ssam#if defined(LUA_USE_WINDOWS) 56178354Ssam#define LUA_DL_DLL /* enable support for DLL */ 57178354Ssam#define LUA_USE_C89 /* broadly, Windows is C89 */ 58178354Ssam#endif 59178354Ssam 60178354Ssam 61178354Ssam#if defined(LUA_USE_LINUX) 62178354Ssam#define LUA_USE_POSIX 63178354Ssam#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ 64178354Ssam#define LUA_USE_READLINE /* needs some extra libraries */ 65178354Ssam#endif 66178354Ssam 67178354Ssam 68178354Ssam#if defined(LUA_USE_MACOSX) 69178354Ssam#define LUA_USE_POSIX 70178354Ssam#define LUA_USE_DLOPEN /* MacOS does not need -ldl */ 71178354Ssam#define LUA_USE_READLINE /* needs an extra library: -lreadline */ 72178354Ssam#endif 73178354Ssam 74178354Ssam 75178354Ssam/* 76178354Ssam@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for 77178354Ssam** C89 ('long' and 'double'); Windows always has '__int64', so it does 78178354Ssam** not need to use this case. 79178354Ssam*/ 80178354Ssam#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) 81178354Ssam#define LUA_C89_NUMBERS 82178354Ssam#endif 83178354Ssam 84178354Ssam 85178354Ssam 86178354Ssam/* 87178354Ssam@@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. 88178354Ssam*/ 89178354Ssam/* avoid undefined shifts */ 90178354Ssam#if ((INT_MAX >> 15) >> 15) >= 1 91178354Ssam#define LUAI_BITSINT 32 92178354Ssam#else 93178354Ssam/* 'int' always must have at least 16 bits */ 94178354Ssam#define LUAI_BITSINT 16 95178354Ssam#endif 96178354Ssam 97178354Ssam 98178354Ssam/* 99178354Ssam@@ LUA_INT_TYPE defines the type for Lua integers. 100178354Ssam@@ LUA_FLOAT_TYPE defines the type for Lua floats. 101178354Ssam** Lua should work fine with any mix of these options (if supported 102178354Ssam** by your C compiler). The usual configurations are 64-bit integers 103178354Ssam** and 'double' (the default), 32-bit integers and 'float' (for 104178354Ssam** restricted platforms), and 'long'/'double' (for C compilers not 105178354Ssam** compliant with C99, which may not have support for 'long long'). 106178354Ssam*/ 107178354Ssam 108178354Ssam/* predefined options for LUA_INT_TYPE */ 109178354Ssam#define LUA_INT_INT 1 110178354Ssam#define LUA_INT_LONG 2 111178354Ssam#define LUA_INT_LONGLONG 3 112178354Ssam 113178354Ssam/* predefined options for LUA_FLOAT_TYPE */ 114178354Ssam#define LUA_FLOAT_FLOAT 1 115178354Ssam#define LUA_FLOAT_DOUBLE 2 116178354Ssam#define LUA_FLOAT_LONGDOUBLE 3 117178354Ssam 118178354Ssam#if defined(LUA_32BITS) /* { */ 119178354Ssam/* 120178354Ssam** 32-bit integers and 'float' 121178354Ssam*/ 122178354Ssam#if LUAI_BITSINT >= 32 /* use 'int' if big enough */ 123178354Ssam#define LUA_INT_TYPE LUA_INT_INT 124178354Ssam#else /* otherwise use 'long' */ 125178354Ssam#define LUA_INT_TYPE LUA_INT_LONG 126178354Ssam#endif 127178354Ssam#define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT 128178354Ssam 129178354Ssam#elif defined(LUA_C89_NUMBERS) /* }{ */ 130178354Ssam/* 131178354Ssam** largest types available for C89 ('long' and 'double') 132178354Ssam*/ 133178354Ssam#define LUA_INT_TYPE LUA_INT_LONG 134178354Ssam#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE 135178354Ssam 136178354Ssam#endif /* } */ 137178354Ssam 138178354Ssam 139178354Ssam/* 140178354Ssam** default configuration for 64-bit Lua ('long long' and 'double') 141178354Ssam*/ 142178354Ssam#if !defined(LUA_INT_TYPE) 143178354Ssam#define LUA_INT_TYPE LUA_INT_LONGLONG 144178354Ssam#endif 145178354Ssam 146178354Ssam#if !defined(LUA_FLOAT_TYPE) 147178354Ssam#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE 148178354Ssam#endif 149178354Ssam 150178354Ssam/* }================================================================== */ 151178354Ssam 152178354Ssam 153178354Ssam 154178354Ssam 155178354Ssam/* 156178354Ssam** {================================================================== 157178354Ssam** Configuration for Paths. 158178354Ssam** =================================================================== 159178354Ssam*/ 160178354Ssam 161178354Ssam/* 162178354Ssam** LUA_PATH_SEP is the character that separates templates in a path. 163178354Ssam** LUA_PATH_MARK is the string that marks the substitution points in a 164178354Ssam** template. 165178354Ssam** LUA_EXEC_DIR in a Windows path is replaced by the executable's 166178354Ssam** directory. 167178354Ssam*/ 168178354Ssam#define LUA_PATH_SEP ";" 169178354Ssam#define LUA_PATH_MARK "?" 170178354Ssam#define LUA_EXEC_DIR "!" 171178354Ssam 172178354Ssam 173178354Ssam/* 174178354Ssam@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for 175178354Ssam** Lua libraries. 176178354Ssam@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for 177178354Ssam** C libraries. 178178354Ssam** CHANGE them if your machine has a non-conventional directory 179178354Ssam** hierarchy or if you want to install your libraries in 180178354Ssam** non-conventional directories. 181178354Ssam*/ 182178354Ssam#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR 183178354Ssam#if defined(_WIN32) /* { */ 184178354Ssam/* 185178354Ssam** In Windows, any exclamation mark ('!') in the path is replaced by the 186178354Ssam** path of the directory of the executable file of the current process. 187178354Ssam*/ 188178354Ssam#define LUA_LDIR "!\\lua\\" 189178354Ssam#define LUA_CDIR "!\\" 190178354Ssam#define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" 191178354Ssam#define LUA_PATH_DEFAULT \ 192178354Ssam LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ 193178354Ssam LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ 194178354Ssam LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ 195178354Ssam ".\\?.lua;" ".\\?\\init.lua" 196178354Ssam#define LUA_CPATH_DEFAULT \ 197178354Ssam LUA_CDIR"?.dll;" \ 198178354Ssam LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ 199178354Ssam LUA_CDIR"loadall.dll;" ".\\?.dll" 200178354Ssam 201178354Ssam#else /* }{ */ 202178354Ssam 203178354Ssam#define LUA_ROOT "/usr/local/" 204178354Ssam#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" 205178354Ssam#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" 206178354Ssam#define LUA_PATH_DEFAULT \ 207178354Ssam LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ 208178354Ssam LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ 209178354Ssam "./?.lua;" "./?/init.lua" 210178354Ssam#define LUA_CPATH_DEFAULT \ 211178354Ssam LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" 212178354Ssam#endif /* } */ 213178354Ssam 214178354Ssam 215178354Ssam/* 216178354Ssam@@ LUA_DIRSEP is the directory separator (for submodules). 217178354Ssam** CHANGE it if your machine does not use "/" as the directory separator 218178354Ssam** and is not Windows. (On Windows Lua automatically uses "\".) 219178354Ssam*/ 220178354Ssam#if defined(_WIN32) 221178354Ssam#define LUA_DIRSEP "\\" 222178354Ssam#else 223178354Ssam#define LUA_DIRSEP "/" 224178354Ssam#endif 225178354Ssam 226178354Ssam/* }================================================================== */ 227178354Ssam 228178354Ssam 229178354Ssam/* 230178354Ssam** {================================================================== 231178354Ssam** Marks for exported symbols in the C code 232178354Ssam** =================================================================== 233178354Ssam*/ 234178354Ssam 235178354Ssam/* 236178354Ssam@@ LUA_API is a mark for all core API functions. 237178354Ssam@@ LUALIB_API is a mark for all auxiliary library functions. 238178354Ssam@@ LUAMOD_API is a mark for all standard library opening functions. 239178354Ssam** CHANGE them if you need to define those functions in some special way. 240178354Ssam** For instance, if you want to create one Windows DLL with the core and 241178354Ssam** the libraries, you may want to use the following definition (define 242178354Ssam** LUA_BUILD_AS_DLL to get it). 243178354Ssam*/ 244178354Ssam#if defined(LUA_BUILD_AS_DLL) /* { */ 245178354Ssam 246178354Ssam#if defined(LUA_CORE) || defined(LUA_LIB) /* { */ 247178354Ssam#define LUA_API __declspec(dllexport) 248178354Ssam#else /* }{ */ 249178354Ssam#define LUA_API __declspec(dllimport) 250178354Ssam#endif /* } */ 251178354Ssam 252178354Ssam#else /* }{ */ 253178354Ssam 254178354Ssam#define LUA_API extern 255178354Ssam 256178354Ssam#endif /* } */ 257178354Ssam 258178354Ssam 259178354Ssam/* more often than not the libs go together with the core */ 260178354Ssam#define LUALIB_API LUA_API 261178354Ssam#define LUAMOD_API LUALIB_API 262178354Ssam 263178354Ssam 264178354Ssam/* 265178354Ssam@@ LUAI_FUNC is a mark for all extern functions that are not to be 266178354Ssam** exported to outside modules. 267178354Ssam@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables 268178354Ssam** that are not to be exported to outside modules (LUAI_DDEF for 269178354Ssam** definitions and LUAI_DDEC for declarations). 270178354Ssam** CHANGE them if you need to mark them in some special way. Elf/gcc 271178354Ssam** (versions 3.2 and later) mark them as "hidden" to optimize access 272178354Ssam** when Lua is compiled as a shared library. Not all elf targets support 273178354Ssam** this attribute. Unfortunately, gcc does not offer a way to check 274178354Ssam** whether the target offers that support, and those without support 275178354Ssam** give a warning about it. To avoid these warnings, change to the 276178354Ssam** default definition. 277178354Ssam*/ 278178354Ssam#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ 279178354Ssam defined(__ELF__) /* { */ 280178354Ssam#define LUAI_FUNC __attribute__((visibility("hidden"))) extern 281178354Ssam#else /* }{ */ 282178354Ssam#define LUAI_FUNC extern 283178354Ssam#endif /* } */ 284178354Ssam 285178354Ssam#define LUAI_DDEC LUAI_FUNC 286178354Ssam#define LUAI_DDEF /* empty */ 287178354Ssam 288178354Ssam/* }================================================================== */ 289178354Ssam 290178354Ssam 291178354Ssam/* 292178354Ssam** {================================================================== 293178354Ssam** Compatibility with previous versions 294178354Ssam** =================================================================== 295178354Ssam*/ 296178354Ssam 297178354Ssam/* 298178354Ssam@@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2. 299178354Ssam@@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1. 300178354Ssam** You can define it to get all options, or change specific options 301178354Ssam** to fit your specific needs. 302178354Ssam*/ 303178354Ssam#if defined(LUA_COMPAT_5_2) /* { */ 304178354Ssam 305178354Ssam/* 306178354Ssam@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated 307178354Ssam** functions in the mathematical library. 308178354Ssam*/ 309178354Ssam#define LUA_COMPAT_MATHLIB 310178354Ssam 311178354Ssam/* 312178354Ssam@@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'. 313178354Ssam*/ 314178354Ssam#define LUA_COMPAT_BITLIB 315178354Ssam 316178354Ssam/* 317178354Ssam@@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod. 318178354Ssam*/ 319178354Ssam#define LUA_COMPAT_IPAIRS 320178354Ssam 321178354Ssam/* 322178354Ssam@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for 323178354Ssam** manipulating other integer types (lua_pushunsigned, lua_tounsigned, 324178354Ssam** luaL_checkint, luaL_checklong, etc.) 325178354Ssam*/ 326178354Ssam#define LUA_COMPAT_APIINTCASTS 327178354Ssam 328178354Ssam#endif /* } */ 329178354Ssam 330178354Ssam 331178354Ssam#if defined(LUA_COMPAT_5_1) /* { */ 332178354Ssam 333178354Ssam/* Incompatibilities from 5.2 -> 5.3 */ 334178354Ssam#define LUA_COMPAT_MATHLIB 335178354Ssam#define LUA_COMPAT_APIINTCASTS 336178354Ssam 337178354Ssam/* 338178354Ssam@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. 339178354Ssam** You can replace it with 'table.unpack'. 340178354Ssam*/ 341178354Ssam#define LUA_COMPAT_UNPACK 342178354Ssam 343178354Ssam/* 344178354Ssam@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. 345178354Ssam** You can replace it with 'package.searchers'. 346178354Ssam*/ 347178354Ssam#define LUA_COMPAT_LOADERS 348178354Ssam 349178354Ssam/* 350178354Ssam@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. 351178354Ssam** You can call your C function directly (with light C functions). 352178354Ssam*/ 353178354Ssam#define lua_cpcall(L,f,u) \ 354178354Ssam (lua_pushcfunction(L, (f)), \ 355178354Ssam lua_pushlightuserdata(L,(u)), \ 356178354Ssam lua_pcall(L,1,0,0)) 357178354Ssam 358178354Ssam 359178354Ssam/* 360178354Ssam@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. 361178354Ssam** You can rewrite 'log10(x)' as 'log(x, 10)'. 362178354Ssam*/ 363178354Ssam#define LUA_COMPAT_LOG10 364178354Ssam 365178354Ssam/* 366178354Ssam@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base 367178354Ssam** library. You can rewrite 'loadstring(s)' as 'load(s)'. 368178354Ssam*/ 369178354Ssam#define LUA_COMPAT_LOADSTRING 370178354Ssam 371178354Ssam/* 372178354Ssam@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. 373178354Ssam*/ 374178354Ssam#define LUA_COMPAT_MAXN 375178354Ssam 376178354Ssam/* 377178354Ssam@@ The following macros supply trivial compatibility for some 378178354Ssam** changes in the API. The macros themselves document how to 379178354Ssam** change your code to avoid using them. 380178354Ssam*/ 381178354Ssam#define lua_strlen(L,i) lua_rawlen(L, (i)) 382178354Ssam 383178354Ssam#define lua_objlen(L,i) lua_rawlen(L, (i)) 384178354Ssam 385178354Ssam#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) 386178354Ssam#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) 387178354Ssam 388178354Ssam/* 389178354Ssam@@ LUA_COMPAT_MODULE controls compatibility with previous 390178354Ssam** module functions 'module' (Lua) and 'luaL_register' (C). 391178354Ssam*/ 392178354Ssam#define LUA_COMPAT_MODULE 393178354Ssam 394178354Ssam#endif /* } */ 395178354Ssam 396178354Ssam 397178354Ssam/* 398178354Ssam@@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a 399178354Ssam@@ a float mark ('.0'). 400178354Ssam** This macro is not on by default even in compatibility mode, 401178354Ssam** because this is not really an incompatibility. 402178354Ssam*/ 403178354Ssam/* #define LUA_COMPAT_FLOATSTRING */ 404178354Ssam 405178354Ssam/* }================================================================== */ 406178354Ssam 407178354Ssam 408178354Ssam 409178354Ssam/* 410178354Ssam** {================================================================== 411178354Ssam** Configuration for Numbers. 412178354Ssam** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* 413178354Ssam** satisfy your needs. 414178354Ssam** =================================================================== 415178354Ssam*/ 416178354Ssam 417178354Ssam/* 418178354Ssam@@ LUA_NUMBER is the floating-point type used by Lua. 419178354Ssam@@ LUAI_UACNUMBER is the result of a 'default argument promotion' 420178354Ssam@@ over a floating number. 421178354Ssam@@ l_mathlim(x) corrects limit name 'x' to the proper float type 422178354Ssam** by prefixing it with one of FLT/DBL/LDBL. 423178354Ssam@@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. 424178354Ssam@@ LUA_NUMBER_FMT is the format for writing floats. 425178354Ssam@@ lua_number2str converts a float to a string. 426178354Ssam@@ l_mathop allows the addition of an 'l' or 'f' to all math operations. 427178354Ssam@@ l_floor takes the floor of a float. 428178354Ssam@@ lua_str2number converts a decimal numeric string to a number. 429178354Ssam*/ 430178354Ssam 431178354Ssam 432178354Ssam/* The following definitions are good for most cases here */ 433178354Ssam 434178354Ssam#define l_floor(x) (l_mathop(floor)(x)) 435178354Ssam 436178354Ssam#define lua_number2str(s,sz,n) \ 437178354Ssam l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n)) 438178354Ssam 439178354Ssam/* 440178354Ssam@@ lua_numbertointeger converts a float number to an integer, or 441178354Ssam** returns 0 if float is not within the range of a lua_Integer. 442178354Ssam** (The range comparisons are tricky because of rounding. The tests 443178354Ssam** here assume a two-complement representation, where MININTEGER always 444178354Ssam** has an exact representation as a float; MAXINTEGER may not have one, 445178354Ssam** and therefore its conversion to float may have an ill-defined value.) 446178354Ssam*/ 447178354Ssam#define lua_numbertointeger(n,p) \ 448178354Ssam ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ 449178354Ssam (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ 450178354Ssam (*(p) = (LUA_INTEGER)(n), 1)) 451178354Ssam 452178354Ssam 453178354Ssam/* now the variable definitions */ 454178354Ssam 455178354Ssam#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */ 456178354Ssam 457178354Ssam#define LUA_NUMBER float 458178354Ssam 459178354Ssam#define l_mathlim(n) (FLT_##n) 460178354Ssam 461178354Ssam#define LUAI_UACNUMBER double 462178354Ssam 463178354Ssam#define LUA_NUMBER_FRMLEN "" 464178354Ssam#define LUA_NUMBER_FMT "%.7g" 465178354Ssam 466178354Ssam#define l_mathop(op) op##f 467178354Ssam 468178354Ssam#define lua_str2number(s,p) strtof((s), (p)) 469178354Ssam 470178354Ssam 471178354Ssam#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */ 472178354Ssam 473178354Ssam#define LUA_NUMBER long double 474178354Ssam 475178354Ssam#define l_mathlim(n) (LDBL_##n) 476178354Ssam 477178354Ssam#define LUAI_UACNUMBER long double 478178354Ssam 479178354Ssam#define LUA_NUMBER_FRMLEN "L" 480178354Ssam#define LUA_NUMBER_FMT "%.19Lg" 481178354Ssam 482178354Ssam#define l_mathop(op) op##l 483178354Ssam 484178354Ssam#define lua_str2number(s,p) strtold((s), (p)) 485178354Ssam 486178354Ssam#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */ 487178354Ssam 488178354Ssam#define LUA_NUMBER double 489178354Ssam 490178354Ssam#define l_mathlim(n) (DBL_##n) 491178354Ssam 492178354Ssam#define LUAI_UACNUMBER double 493178354Ssam 494178354Ssam#define LUA_NUMBER_FRMLEN "" 495178354Ssam#define LUA_NUMBER_FMT "%.14g" 496178354Ssam 497183247Ssam#define l_mathop(op) op 498178354Ssam 499178354Ssam#define lua_str2number(s,p) strtod((s), (p)) 500183247Ssam 501183247Ssam#else /* }{ */ 502183247Ssam 503183247Ssam#error "numeric float type not defined" 504183247Ssam 505178354Ssam#endif /* } */ 506178354Ssam 507178354Ssam 508178354Ssam 509178354Ssam/* 510178354Ssam@@ LUA_INTEGER is the integer type used by Lua. 511178354Ssam** 512178354Ssam@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. 513178354Ssam** 514178354Ssam@@ LUAI_UACINT is the result of a 'default argument promotion' 515178354Ssam@@ over a lUA_INTEGER. 516178354Ssam@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. 517178354Ssam@@ LUA_INTEGER_FMT is the format for writing integers. 518178354Ssam@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. 519178354Ssam@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. 520178354Ssam@@ lua_integer2str converts an integer to a string. 521178354Ssam*/ 522178354Ssam 523178354Ssam 524178354Ssam/* The following definitions are good for most cases here */ 525178354Ssam 526178354Ssam#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" 527178354Ssam 528178354Ssam#define LUAI_UACINT LUA_INTEGER 529178354Ssam 530178354Ssam#define lua_integer2str(s,sz,n) \ 531178354Ssam l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n)) 532178354Ssam 533178354Ssam/* 534178354Ssam** use LUAI_UACINT here to avoid problems with promotions (which 535178354Ssam** can turn a comparison between unsigneds into a signed comparison) 536178354Ssam*/ 537178354Ssam#define LUA_UNSIGNED unsigned LUAI_UACINT 538178354Ssam 539178354Ssam 540178354Ssam/* now the variable definitions */ 541178354Ssam 542178354Ssam#if LUA_INT_TYPE == LUA_INT_INT /* { int */ 543178354Ssam 544178354Ssam#define LUA_INTEGER int 545178354Ssam#define LUA_INTEGER_FRMLEN "" 546178354Ssam 547178354Ssam#define LUA_MAXINTEGER INT_MAX 548178354Ssam#define LUA_MININTEGER INT_MIN 549178354Ssam 550178354Ssam#elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ 551178354Ssam 552178354Ssam#define LUA_INTEGER long 553178354Ssam#define LUA_INTEGER_FRMLEN "l" 554178354Ssam 555178354Ssam#define LUA_MAXINTEGER LONG_MAX 556178354Ssam#define LUA_MININTEGER LONG_MIN 557178354Ssam 558178354Ssam#elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ 559178354Ssam 560178354Ssam/* use presence of macro LLONG_MAX as proxy for C99 compliance */ 561178354Ssam#if defined(LLONG_MAX) /* { */ 562178354Ssam/* use ISO C99 stuff */ 563178354Ssam 564178354Ssam#define LUA_INTEGER long long 565178354Ssam#define LUA_INTEGER_FRMLEN "ll" 566178354Ssam 567178354Ssam#define LUA_MAXINTEGER LLONG_MAX 568178354Ssam#define LUA_MININTEGER LLONG_MIN 569178354Ssam 570178354Ssam#elif defined(LUA_USE_WINDOWS) /* }{ */ 571178354Ssam/* in Windows, can use specific Windows types */ 572178354Ssam 573178354Ssam#define LUA_INTEGER __int64 574178354Ssam#define LUA_INTEGER_FRMLEN "I64" 575178354Ssam 576178354Ssam#define LUA_MAXINTEGER _I64_MAX 577178354Ssam#define LUA_MININTEGER _I64_MIN 578178354Ssam 579178354Ssam#else /* }{ */ 580178354Ssam 581178354Ssam#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ 582178354Ssam or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" 583178354Ssam 584178354Ssam#endif /* } */ 585178354Ssam 586178354Ssam#else /* }{ */ 587178354Ssam 588178354Ssam#error "numeric integer type not defined" 589178354Ssam 590178354Ssam#endif /* } */ 591178354Ssam 592178354Ssam/* }================================================================== */ 593178354Ssam 594178354Ssam 595178354Ssam/* 596178354Ssam** {================================================================== 597178354Ssam** Dependencies with C99 and other C details 598183247Ssam** =================================================================== 599183247Ssam*/ 600178354Ssam 601178354Ssam/* 602178354Ssam@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89. 603183247Ssam** (All uses in Lua have only one format item.) 604178354Ssam*/ 605178354Ssam#if !defined(LUA_USE_C89) 606178354Ssam#define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i) 607178354Ssam#else 608178354Ssam#define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i)) 609178354Ssam#endif 610178354Ssam 611178354Ssam 612178354Ssam/* 613178354Ssam@@ lua_strx2number converts an hexadecimal numeric string to a number. 614178354Ssam** In C99, 'strtod' does that conversion. Otherwise, you can 615178354Ssam** leave 'lua_strx2number' undefined and Lua will provide its own 616178354Ssam** implementation. 617178354Ssam*/ 618178354Ssam#if !defined(LUA_USE_C89) 619178354Ssam#define lua_strx2number(s,p) lua_str2number(s,p) 620178354Ssam#endif 621178354Ssam 622178354Ssam 623178354Ssam/* 624178354Ssam@@ lua_number2strx converts a float to an hexadecimal numeric string. 625178354Ssam** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. 626178354Ssam** Otherwise, you can leave 'lua_number2strx' undefined and Lua will 627178354Ssam** provide its own implementation. 628178354Ssam*/ 629178354Ssam#if !defined(LUA_USE_C89) 630178354Ssam#define lua_number2strx(L,b,sz,f,n) \ 631178354Ssam ((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n))) 632178354Ssam#endif 633178354Ssam 634178354Ssam 635178354Ssam/* 636178354Ssam** 'strtof' and 'opf' variants for math functions are not valid in 637178354Ssam** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the 638178354Ssam** availability of these variants. ('math.h' is already included in 639178354Ssam** all files that use these macros.) 640178354Ssam*/ 641178354Ssam#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF)) 642178354Ssam#undef l_mathop /* variants not available */ 643178354Ssam#undef lua_str2number 644178354Ssam#define l_mathop(op) (lua_Number)op /* no variant */ 645178354Ssam#define lua_str2number(s,p) ((lua_Number)strtod((s), (p))) 646178354Ssam#endif 647178354Ssam 648178354Ssam 649178354Ssam/* 650178354Ssam@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation 651178354Ssam** functions. It must be a numerical type; Lua will use 'intptr_t' if 652178354Ssam** available, otherwise it will use 'ptrdiff_t' (the nearest thing to 653178354Ssam** 'intptr_t' in C89) 654178354Ssam*/ 655178354Ssam#define LUA_KCONTEXT ptrdiff_t 656178354Ssam 657178354Ssam#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ 658178354Ssam __STDC_VERSION__ >= 199901L 659178354Ssam#include <stdint.h> 660178354Ssam#if defined(INTPTR_MAX) /* even in C99 this type is optional */ 661178354Ssam#undef LUA_KCONTEXT 662178354Ssam#define LUA_KCONTEXT intptr_t 663178354Ssam#endif 664178354Ssam#endif 665178354Ssam 666178354Ssam 667178354Ssam/* 668178354Ssam@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). 669178354Ssam** Change that if you do not want to use C locales. (Code using this 670178354Ssam** macro must include header 'locale.h'.) 671178354Ssam*/ 672178354Ssam#if !defined(lua_getlocaledecpoint) 673178354Ssam#define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) 674178354Ssam#endif 675178354Ssam 676178354Ssam/* }================================================================== */ 677178354Ssam 678178354Ssam 679178354Ssam/* 680178354Ssam** {================================================================== 681178354Ssam** Language Variations 682178354Ssam** ===================================================================== 683178354Ssam*/ 684178354Ssam 685178354Ssam/* 686178354Ssam@@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some 687178354Ssam** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from 688178354Ssam** numbers to strings. Define LUA_NOCVTS2N to turn off automatic 689178354Ssam** coercion from strings to numbers. 690178354Ssam*/ 691178354Ssam/* #define LUA_NOCVTN2S */ 692178354Ssam/* #define LUA_NOCVTS2N */ 693178354Ssam 694178354Ssam 695178354Ssam/* 696178354Ssam@@ LUA_USE_APICHECK turns on several consistency checks on the C API. 697178354Ssam** Define it as a help when debugging C code. 698178354Ssam*/ 699178354Ssam#if defined(LUA_USE_APICHECK) 700178354Ssam#include <assert.h> 701178354Ssam#define luai_apicheck(l,e) assert(e) 702178354Ssam#endif 703178354Ssam 704178354Ssam/* }================================================================== */ 705178354Ssam 706178354Ssam 707178354Ssam/* 708178354Ssam** {================================================================== 709178354Ssam** Macros that affect the API and must be stable (that is, must be the 710178354Ssam** same when you compile Lua and when you compile code that links to 711178354Ssam** Lua). You probably do not want/need to change them. 712178354Ssam** ===================================================================== 713178354Ssam*/ 714178354Ssam 715178354Ssam/* 716178354Ssam@@ LUAI_MAXSTACK limits the size of the Lua stack. 717178354Ssam** CHANGE it if you need a different limit. This limit is arbitrary; 718178354Ssam** its only purpose is to stop Lua from consuming unlimited stack 719178354Ssam** space (and to reserve some numbers for pseudo-indices). 720178354Ssam*/ 721178354Ssam#if LUAI_BITSINT >= 32 722178354Ssam#define LUAI_MAXSTACK 1000000 723178354Ssam#else 724178354Ssam#define LUAI_MAXSTACK 15000 725178354Ssam#endif 726178354Ssam 727178354Ssam 728178354Ssam/* 729178354Ssam@@ LUA_EXTRASPACE defines the size of a raw memory area associated with 730178354Ssam** a Lua state with very fast access. 731178354Ssam** CHANGE it if you need a different size. 732178354Ssam*/ 733178354Ssam#define LUA_EXTRASPACE (sizeof(void *)) 734178354Ssam 735178354Ssam 736178354Ssam/* 737178354Ssam@@ LUA_IDSIZE gives the maximum size for the description of the source 738178354Ssam@@ of a function in debug information. 739178354Ssam** CHANGE it if you want a different size. 740178354Ssam*/ 741178354Ssam#define LUA_IDSIZE 60 742178354Ssam 743178354Ssam 744178354Ssam/* 745178354Ssam@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. 746178354Ssam** CHANGE it if it uses too much C-stack space. (For long double, 747178354Ssam** 'string.format("%.99f", -1e4932)' needs 5034 bytes, so a 748178354Ssam** smaller buffer would force a memory allocation for each call to 749178354Ssam** 'string.format'.) 750178354Ssam*/ 751178354Ssam#if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE 752178354Ssam#define LUAL_BUFFERSIZE 8192 753178354Ssam#else 754178354Ssam#define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer))) 755178354Ssam#endif 756178354Ssam 757178354Ssam/* }================================================================== */ 758178354Ssam 759178354Ssam 760178354Ssam/* 761178354Ssam@@ LUA_QL describes how error messages quote program elements. 762178354Ssam** Lua does not use these macros anymore; they are here for 763178354Ssam** compatibility only. 764178354Ssam*/ 765178354Ssam#define LUA_QL(x) "'" x "'" 766178354Ssam#define LUA_QS LUA_QL("%s") 767178354Ssam 768178354Ssam 769178354Ssam 770178354Ssam 771178354Ssam/* =================================================================== */ 772178354Ssam 773178354Ssam/* 774178354Ssam** Local configuration. You can use this space to add your redefinitions 775178354Ssam** without modifying the main part of the file. 776178354Ssam*/ 777178354Ssam 778178354Ssam 779178354Ssam 780178354Ssam 781178354Ssam 782178354Ssam#endif 783178354Ssam 784178354Ssam