lua

A copy of the Lua development repository
Log | Files | Refs | README

luaconf.h (22616B)


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