From nobody Wed Feb 8 18:01:35 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PBnr62pdYz3nk0S; Wed, 8 Feb 2023 18:01:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PBnr62WV7z3mgv; Wed, 8 Feb 2023 18:01:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675879302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jYpVsMu9L2oE+fapa7pueNit4wuonUVlOXwzZWsNrP8=; b=aWeJYdi3eAVJCPaqQv+imqEAMvdLIjHNmjUOAYWCmzJ91FKb4khAJIgkdQAUiftQhwFMO9 Q8lY1ddbCZod050hYZcCpAaNUQ1E8GYvheXp93MrceuEkQdlOTrTggOtAKzI2Q0JwuLAyW VoKtDWms03jFTaU4NmIRTiRQRToGUcZuZy/YzecEoXtjpbsxB/YshyaPqa+AnmnoI/G3yM 2tXMk5mtcGDrxxgEuO7HqtyOzKd9dDSTW1WlJ1AnXazcGMjQVpspq0jB0TVTAgtbXfmqkw Jik6mthL88z/yOLmuhreessaA3v7i7iBRbuu+HYrrNqjvVP8zbPuNwyR0aOK9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675879302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jYpVsMu9L2oE+fapa7pueNit4wuonUVlOXwzZWsNrP8=; b=fsDdvZFmGs4nPjfaXfRFO90j+8mFZmnDG4MHqELzQgjIacuBRyv0XNR8fUs4iHexR/bXPk 4fiktsuDEEIJOdqO33ojAG/wq+1vJDH4XiHC7mdeZtYPENSYC1GtZ1cPfw/Qoage+2kN5Y uEeeCmdx7W5WKm3rqlYTj1s8ggBiVC4MHh7IsK1h6d3p1K04A6OJOUBO1hwNi2fk2NjWyz XqxXTeWKgeNW7A1B3RUdJELVc1HjM9K2DP0mwwZp9HVDx5262ES+zvqqCoY9MGRe5wIIom DapvMa3LHpG69/6ToDZmSRmiWBYwhnp3mwkD1eUXjWeOu3JT2NQTq8OQzrh34Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675879302; a=rsa-sha256; cv=none; b=sOz1HiUJ4ok6lvNMuKRsI58DOGL8zFbzhkjaBD2cj3EEbEXUdXpHLShJS3DpCSbdhR3U8O Pg7uGzw05KjJ5P0woDrXRL4sqPSA1D1YsigEvkaijVDlVEkE1U7/tQoWkp5aFuXuS3/ad3 VOdo7QJ+8E8MiNpEaxTpq4tJj13nUheicTgG1XSJInP3orMxdJ3IIi/vtgm/MdNb77k6Eu 7dBi2ka8ywPIUbqopZ6615kQJr/3gnyrslkiU1t82mCAXOro7VrzbBnr6A/70oosxjBE6R vsE8by2wPwtDxitLJ491MBj03g7X3yBt56dJ4Cwa8MxXgBZ6ZBIug/uyRBYdKg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PBnr61K1Hz164x; Wed, 8 Feb 2023 18:01:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 318I1gsA006026; Wed, 8 Feb 2023 18:01:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 318I1ZR6003504; Wed, 8 Feb 2023 18:01:35 GMT (envelope-from git) Date: Wed, 8 Feb 2023 18:01:35 GMT Message-Id: <202302081801.318I1ZR6003504@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 8c784bb8cf36 - main - lua: Update to 5.4.4 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8c784bb8cf36911b828652f0bf7e88f443abec50 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=8c784bb8cf36911b828652f0bf7e88f443abec50 commit 8c784bb8cf36911b828652f0bf7e88f443abec50 Merge: 87d405eab911 755d9301ca89 Author: Warner Losh AuthorDate: 2023-02-07 22:07:08 +0000 Commit: Warner Losh CommitDate: 2023-02-08 17:33:26 +0000 lua: Update to 5.4.4 Merge commit '755d9301ca89f02956fd17858b9d4d821ab5c972' from the vendor branch. This updates us from lua 5.4.2 to 5.4.4. In addition, it switches around how we flavor liblua for the boot loader and flua. This is done to reduce diffs with upstream and make it easier to import new versions (the current method has too many conflicts to resolve by hand): we include luaconf.local.h from luaconf.h (the only change to this file is now that #include at the end). We then define what we need to: for flua (which does very little) and one for stand (which creates the new FLOAT type out of int64). Sponsored by: Netflix contrib/lua/Makefile | 2 +- contrib/lua/README | 2 +- contrib/lua/doc/contents.html | 7 +- contrib/lua/doc/manual.html | 237 ++++++++----- contrib/lua/doc/readme.html | 8 +- contrib/lua/src/lapi.c | 107 ++++-- contrib/lua/src/lapi.h | 2 + contrib/lua/src/lauxlib.c | 75 ++-- contrib/lua/src/lauxlib.h | 31 +- contrib/lua/src/lbaselib.c | 40 ++- contrib/lua/src/lcode.c | 69 ++-- contrib/lua/src/lcorolib.c | 19 +- contrib/lua/src/ldblib.c | 11 +- contrib/lua/src/ldebug.c | 218 ++++++++---- contrib/lua/src/ldebug.h | 11 + contrib/lua/src/ldo.c | 490 ++++++++++++++++--------- contrib/lua/src/ldo.h | 7 +- contrib/lua/src/lfunc.c | 170 +++++---- contrib/lua/src/lfunc.h | 13 +- contrib/lua/src/lgc.c | 55 +-- contrib/lua/src/lgc.h | 10 + contrib/lua/src/liolib.c | 35 +- contrib/lua/src/llex.c | 31 +- contrib/lua/src/llimits.h | 30 +- contrib/lua/src/lmathlib.c | 9 +- contrib/lua/src/lmem.c | 33 +- contrib/lua/src/loadlib.c | 17 +- contrib/lua/src/lobject.c | 10 +- contrib/lua/src/lobject.h | 18 +- contrib/lua/src/lopcodes.h | 35 +- contrib/lua/src/loslib.c | 8 +- contrib/lua/src/lparser.c | 76 ++-- contrib/lua/src/lparser.h | 6 +- contrib/lua/src/lstate.c | 66 ++-- contrib/lua/src/lstate.h | 49 ++- contrib/lua/src/lstring.c | 8 +- contrib/lua/src/lstrlib.c | 269 ++++++++------ contrib/lua/src/ltable.c | 144 +++++--- contrib/lua/src/ltable.h | 8 +- contrib/lua/src/ltablib.c | 16 +- contrib/lua/src/ltm.c | 5 +- contrib/lua/src/lua.c | 63 +++- contrib/lua/src/lua.h | 11 +- contrib/lua/src/luac.c | 7 +- contrib/lua/src/luaconf.h | 786 +++++++++++++++++++++++++++++++++++++++++ contrib/lua/src/luaconf.h.dist | 115 +++--- contrib/lua/src/lualib.h | 6 - contrib/lua/src/lutf8lib.c | 11 +- contrib/lua/src/lvm.c | 132 +++---- contrib/lua/src/lvm.h | 6 +- lib/liblua/luaconf.local.h | 25 ++ stand/liblua/luaconf.local.h | 73 ++++ stand/lua.mk | 1 - 53 files changed, 2622 insertions(+), 1071 deletions(-) diff --cc contrib/lua/Makefile index 36447a0f61c7,000000000000..fef1af4821e6 mode 100644,000000..100644 --- a/contrib/lua/Makefile +++ b/contrib/lua/Makefile @@@ -1,106 -1,0 +1,106 @@@ +# Makefile for installing Lua +# See doc/readme.html for installation and customization instructions. + +# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + +# Your platform. See PLATS for possible values. +PLAT= guess + +# Where to install. The installation starts in the src and doc directories, +# so take care if INSTALL_TOP is not an absolute path. See the local target. +# You may want to make INSTALL_LMOD and INSTALL_CMOD consistent with +# LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h. +INSTALL_TOP= /usr/local +INSTALL_BIN= $(INSTALL_TOP)/bin +INSTALL_INC= $(INSTALL_TOP)/include +INSTALL_LIB= $(INSTALL_TOP)/lib +INSTALL_MAN= $(INSTALL_TOP)/man/man1 +INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V +INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V + +# How to install. If your install program does not support "-p", then +# you may have to run ranlib on the installed liblua.a. +INSTALL= install -p +INSTALL_EXEC= $(INSTALL) -m 0755 +INSTALL_DATA= $(INSTALL) -m 0644 +# +# If you don't have "install" you can use "cp" instead. +# INSTALL= cp -p +# INSTALL_EXEC= $(INSTALL) +# INSTALL_DATA= $(INSTALL) + +# Other utilities. +MKDIR= mkdir -p +RM= rm -f + +# == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= + +# Convenience platforms targets. +PLATS= guess aix bsd c89 freebsd generic linux linux-readline macosx mingw posix solaris + +# What to install. +TO_BIN= lua luac +TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp +TO_LIB= liblua.a +TO_MAN= lua.1 luac.1 + +# Lua version and release. +V= 5.4 - R= $V.2 ++R= $V.4 + +# Targets start here. +all: $(PLAT) + +$(PLATS) help test clean: + @cd src && $(MAKE) $@ + +install: dummy + cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) + cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN) + cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC) + cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB) + cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN) + +uninstall: + cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN) + cd src && cd $(INSTALL_INC) && $(RM) $(TO_INC) + cd src && cd $(INSTALL_LIB) && $(RM) $(TO_LIB) + cd doc && cd $(INSTALL_MAN) && $(RM) $(TO_MAN) + +local: + $(MAKE) install INSTALL_TOP=../install + +# make may get confused with install/ if it does not support .PHONY. +dummy: + +# Echo config parameters. +echo: + @cd src && $(MAKE) -s echo + @echo "PLAT= $(PLAT)" + @echo "V= $V" + @echo "R= $R" + @echo "TO_BIN= $(TO_BIN)" + @echo "TO_INC= $(TO_INC)" + @echo "TO_LIB= $(TO_LIB)" + @echo "TO_MAN= $(TO_MAN)" + @echo "INSTALL_TOP= $(INSTALL_TOP)" + @echo "INSTALL_BIN= $(INSTALL_BIN)" + @echo "INSTALL_INC= $(INSTALL_INC)" + @echo "INSTALL_LIB= $(INSTALL_LIB)" + @echo "INSTALL_MAN= $(INSTALL_MAN)" + @echo "INSTALL_LMOD= $(INSTALL_LMOD)" + @echo "INSTALL_CMOD= $(INSTALL_CMOD)" + @echo "INSTALL_EXEC= $(INSTALL_EXEC)" + @echo "INSTALL_DATA= $(INSTALL_DATA)" + +# Echo pkg-config data. +pc: + @echo "version=$R" + @echo "prefix=$(INSTALL_TOP)" + @echo "libdir=$(INSTALL_LIB)" + @echo "includedir=$(INSTALL_INC)" + +# Targets that do not create files (not all makes understand .PHONY). +.PHONY: all $(PLATS) help test clean install uninstall local dummy echo pc + +# (end of Makefile) diff --cc contrib/lua/src/lcode.c index 14d41f1a7ef4,06425a1db800..97e3c72857a5 --- a/contrib/lua/src/lcode.c +++ b/contrib/lua/src/lcode.c @@@ -601,8 -601,21 +601,28 @@@ static int luaK_intK (FuncState *fs, lu */ static int luaK_numberK (FuncState *fs, lua_Number r) { TValue o; + lua_Integer ik; setfltvalue(&o, r); ++#ifndef LUA_AVOID_FLOAT + if (!luaV_flttointeger(r, &ik, F2Ieq)) /* not an integral value? */ + return addk(fs, &o, &o); /* use number itself as key */ + else { /* must build an alternative key */ + const int nbm = l_floatatt(MANT_DIG); + const lua_Number q = l_mathop(ldexp)(l_mathop(1.0), -nbm + 1); + const lua_Number k = (ik == 0) ? q : r + r*q; /* new key */ + TValue kv; + setfltvalue(&kv, k); + /* result is not an integral value, unless value is too large */ + lua_assert(!luaV_flttointeger(k, &ik, F2Ieq) || + l_mathop(fabs)(r) >= l_mathop(1e6)); + return addk(fs, &kv, &o); + } ++#else ++ /* ++ ** When we're avoiding floats, allow any collision since floats are ints. ++ */ + return addk(fs, &o, &o); /* use number itself as key */ ++#endif } diff --cc contrib/lua/src/lstrlib.c index ed88abdb4db2,0b4fdbb7b5bf..2b5cd64b6ed9 --- a/contrib/lua/src/lstrlib.c +++ b/contrib/lua/src/lstrlib.c @@@ -1121,7 -1142,6 +1142,7 @@@ static void addquoted (luaL_Buffer *b, } - #if LUA_FLOAT_TYPE != LUA_FLOAT_INT64 ++#ifndef LUA_AVOID_FLOAT /* ** Serialize a floating-point number in such a way that it can be ** scanned back by Lua. Use hexadecimal format for "common" numbers @@@ -1150,8 -1170,8 +1171,9 @@@ static int quotefloat (lua_State *L, ch /* for the fixed representations */ return l_sprintf(buff, MAX_ITEM, "%s", s); } +#endif + static void addliteral (lua_State *L, luaL_Buffer *b, int arg) { switch (lua_type(L, arg)) { case LUA_TSTRING: { @@@ -1163,7 -1183,6 +1185,7 @@@ case LUA_TNUMBER: { char *buff = luaL_prepbuffsize(b, MAX_ITEM); int nb; - #if LUA_FLOAT_TYPE != LUA_FLOAT_INT64 ++#ifndef LUA_AVOID_FLOAT if (!lua_isinteger(L, arg)) /* float? */ nb = quotefloat(L, buff, lua_tonumber(L, arg)); else { /* integers */ @@@ -1264,14 -1319,13 +1325,15 @@@ static int str_format (lua_State *L) nb = lua_number2strx(L, buff, maxitem, form, luaL_checknumber(L, arg)); break; - #if LUA_FLOAT_TYPE != LUA_FLOAT_INT64 ++#ifndef LUA_AVOID_FLOAT case 'f': maxitem = MAX_ITEMF; /* extra space for '%f' */ buff = luaL_prepbuffsize(&b, maxitem); /* FALLTHROUGH */ +#endif case 'e': case 'E': case 'g': case 'G': { lua_Number n = luaL_checknumber(L, arg); + checkformat(L, form, L_FMTFLAGSF, 1); addlenmod(form, LUA_NUMBER_FRMLEN); nb = l_sprintf(buff, maxitem, form, (LUAI_UACNUMBER)n); break; @@@ -1397,7 -1428,9 +1436,11 @@@ typedef struct Header typedef enum KOption { Kint, /* signed integers */ Kuint, /* unsigned integers */ - Kfloat, /* floating-point numbers */ ++#ifndef LUA_AVOID_FLOAT + Kfloat, /* single-precision floating-point numbers */ - Knumber, /* Lua "native" floating-point numbers */ + Kdouble, /* double-precision floating-point numbers */ ++#endif ++ Knumber, /* Lua "native" floating-point numbers */ Kchar, /* fixed-length strings */ Kstring, /* strings with prefixed length */ Kzstr, /* zero-terminated strings */ @@@ -1465,11 -1500,9 +1510,11 @@@ static KOption getoption (Header *h, co case 'j': *size = sizeof(lua_Integer); return Kint; case 'J': *size = sizeof(lua_Integer); return Kuint; case 'T': *size = sizeof(size_t); return Kuint; - #if LUA_FLOAT_TYPE != LUA_FLOAT_INT64 ++#ifndef LUA_AVOID_FLOAT case 'f': *size = sizeof(float); return Kfloat; - case 'd': *size = sizeof(double); return Kfloat; - case 'n': *size = sizeof(lua_Number); return Knumber; + case 'd': *size = sizeof(double); return Kdouble; +#endif - case 'n': *size = sizeof(lua_Number); return Kfloat; ++ case 'n': *size = sizeof(lua_Number); return Knumber; case 'i': *size = getnumlimit(h, fmt, sizeof(int)); return Kint; case 'I': *size = getnumlimit(h, fmt, sizeof(int)); return Kuint; case 's': *size = getnumlimit(h, fmt, sizeof(size_t)); return Kstring; @@@ -1595,22 -1632,30 +1644,34 @@@ static int str_pack (lua_State *L) packint(&b, (lua_Unsigned)n, h.islittle, size, 0); break; } - case Kfloat: { /* floating-point options */ - Ftypes u; - char *buff = luaL_prepbuffsize(&b, size); - lua_Number n = luaL_checknumber(L, arg); /* get argument */ - #if LUA_FLOAT_TYPE != LUA_FLOAT_INT64 - if (size == sizeof(u.f)) u.f = (float)n; /* copy it into 'u' */ - else if (size == sizeof(u.d)) u.d = (double)n; - else u.n = n; - #else - u.n = n; ++#ifndef LUA_AVOID_FLOAT + case Kfloat: { /* C float */ + float f = (float)luaL_checknumber(L, arg); /* get argument */ + char *buff = luaL_prepbuffsize(&b, sizeof(f)); + /* move 'f' to final result, correcting endianness if needed */ + copywithendian(buff, (char *)&f, sizeof(f), h.islittle); + luaL_addsize(&b, size); + break; + } +#endif - /* move 'u' to final result, correcting endianness if needed */ - copywithendian(buff, (char *)&u, size, h.islittle); + case Knumber: { /* Lua float */ + lua_Number f = luaL_checknumber(L, arg); /* get argument */ + char *buff = luaL_prepbuffsize(&b, sizeof(f)); + /* move 'f' to final result, correcting endianness if needed */ + copywithendian(buff, (char *)&f, sizeof(f), h.islittle); + luaL_addsize(&b, size); + break; + } ++#ifndef LUA_AVOID_FLOAT + case Kdouble: { /* C double */ + double f = (double)luaL_checknumber(L, arg); /* get argument */ + char *buff = luaL_prepbuffsize(&b, sizeof(f)); + /* move 'f' to final result, correcting endianness if needed */ + copywithendian(buff, (char *)&f, sizeof(f), h.islittle); luaL_addsize(&b, size); break; } ++#endif case Kchar: { /* fixed-size string */ size_t len; const char *s = luaL_checklstring(L, arg, &len); @@@ -1732,20 -1777,24 +1793,28 @@@ static int str_unpack (lua_State *L) lua_pushinteger(L, res); break; } ++#ifndef LUA_AVOID_FLOAT case Kfloat: { - Ftypes u; - lua_Number num; - copywithendian((char *)&u, data + pos, size, h.islittle); - #if LUA_FLOAT_TYPE != LUA_FLOAT_INT64 - if (size == sizeof(u.f)) num = (lua_Number)u.f; - else if (size == sizeof(u.d)) num = (lua_Number)u.d; - else num = u.n; - #else - num = u.n; + float f; + copywithendian((char *)&f, data + pos, sizeof(f), h.islittle); + lua_pushnumber(L, (lua_Number)f); + break; + } +#endif - lua_pushnumber(L, num); + case Knumber: { + lua_Number f; + copywithendian((char *)&f, data + pos, sizeof(f), h.islittle); + lua_pushnumber(L, f); break; } ++#ifndef LUA_AVOID_FLOAT + case Kdouble: { + double f; + copywithendian((char *)&f, data + pos, sizeof(f), h.islittle); + lua_pushnumber(L, (lua_Number)f); + break; + } ++#endif case Kchar: { lua_pushlstring(L, data + pos, size); break; diff --cc contrib/lua/src/luaconf.h index 000000000000,d42d14b7d5f1..eab6318aaaef mode 000000,100644..100644 --- a/contrib/lua/src/luaconf.h +++ b/contrib/lua/src/luaconf.h @@@ -1,0 -1,786 +1,786 @@@ + /* + ** $Id: luaconf.h $ + ** Configuration file for Lua + ** See Copyright Notice in lua.h + */ + + + #ifndef luaconf_h + #define luaconf_h + + #include + #include + + + /* + ** =================================================================== + ** General Configuration File for Lua + ** + ** Some definitions here can be changed externally, through the compiler + ** (e.g., with '-D' options): They are commented out or protected + ** by '#if !defined' guards. However, several other definitions + ** should be changed directly here, either because they affect the + ** Lua ABI (by making the changes here, you ensure that all software + ** connected to Lua, such as C libraries, will be compiled with the same + ** configuration); or because they are seldom changed. + ** + ** Search for "@@" to find all configurable definitions. + ** =================================================================== + */ + + + /* + ** {==================================================================== + ** System Configuration: macros to adapt (if needed) Lua to some + ** particular platform, for instance restricting it to C89. + ** ===================================================================== + */ + + /* + @@ LUA_USE_C89 controls the use of non-ISO-C89 features. + ** Define it if you want Lua to avoid the use of a few C99 features + ** or Windows-specific features on Windows. + */ + /* #define LUA_USE_C89 */ + + + /* + ** By default, Lua on Windows use (some) specific Windows features + */ + #if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE) + #define LUA_USE_WINDOWS /* enable goodies for regular Windows */ + #endif + + + #if defined(LUA_USE_WINDOWS) + #define LUA_DL_DLL /* enable support for DLL */ + #define LUA_USE_C89 /* broadly, Windows is C89 */ + #endif + + + #if defined(LUA_USE_LINUX) + #define LUA_USE_POSIX + #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ + #endif + + + #if defined(LUA_USE_MACOSX) + #define LUA_USE_POSIX + #define LUA_USE_DLOPEN /* MacOS does not need -ldl */ + #endif + + + /* + @@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits. + */ + #define LUAI_IS32INT ((UINT_MAX >> 30) >= 3) + + /* }================================================================== */ + + + + /* + ** {================================================================== + ** Configuration for Number types. These options should not be + ** set externally, because any other code connected to Lua must + ** use the same configuration. + ** =================================================================== + */ + + /* + @@ LUA_INT_TYPE defines the type for Lua integers. + @@ LUA_FLOAT_TYPE defines the type for Lua floats. + ** Lua should work fine with any mix of these options supported + ** by your C compiler. The usual configurations are 64-bit integers + ** and 'double' (the default), 32-bit integers and 'float' (for + ** restricted platforms), and 'long'/'double' (for C compilers not + ** compliant with C99, which may not have support for 'long long'). + */ + + /* predefined options for LUA_INT_TYPE */ + #define LUA_INT_INT 1 + #define LUA_INT_LONG 2 + #define LUA_INT_LONGLONG 3 + + /* predefined options for LUA_FLOAT_TYPE */ + #define LUA_FLOAT_FLOAT 1 + #define LUA_FLOAT_DOUBLE 2 + #define LUA_FLOAT_LONGDOUBLE 3 + + + /* Default configuration ('long long' and 'double', for 64-bit Lua) */ + #define LUA_INT_DEFAULT LUA_INT_LONGLONG + #define LUA_FLOAT_DEFAULT LUA_FLOAT_DOUBLE + + + /* + @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. + */ + #define LUA_32BITS 0 + + + /* + @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for + ** C89 ('long' and 'double'); Windows always has '__int64', so it does + ** not need to use this case. + */ + #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) + #define LUA_C89_NUMBERS 1 + #else + #define LUA_C89_NUMBERS 0 + #endif + + + #if LUA_32BITS /* { */ + /* + ** 32-bit integers and 'float' + */ + #if LUAI_IS32INT /* use 'int' if big enough */ + #define LUA_INT_TYPE LUA_INT_INT + #else /* otherwise use 'long' */ + #define LUA_INT_TYPE LUA_INT_LONG + #endif + #define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT + + #elif LUA_C89_NUMBERS /* }{ */ + /* + ** largest types available for C89 ('long' and 'double') + */ + #define LUA_INT_TYPE LUA_INT_LONG + #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE + + #else /* }{ */ + /* use defaults */ + + #define LUA_INT_TYPE LUA_INT_DEFAULT + #define LUA_FLOAT_TYPE LUA_FLOAT_DEFAULT + + #endif /* } */ + + + /* }================================================================== */ + + + + /* + ** {================================================================== + ** Configuration for Paths. + ** =================================================================== + */ + + /* + ** LUA_PATH_SEP is the character that separates templates in a path. + ** LUA_PATH_MARK is the string that marks the substitution points in a + ** template. + ** LUA_EXEC_DIR in a Windows path is replaced by the executable's + ** directory. + */ + #define LUA_PATH_SEP ";" + #define LUA_PATH_MARK "?" + #define LUA_EXEC_DIR "!" + + + /* + @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for + ** Lua libraries. + @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for + ** C libraries. + ** CHANGE them if your machine has a non-conventional directory + ** hierarchy or if you want to install your libraries in + ** non-conventional directories. + */ + + #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR + #if defined(_WIN32) /* { */ + /* + ** In Windows, any exclamation mark ('!') in the path is replaced by the + ** path of the directory of the executable file of the current process. + */ + #define LUA_LDIR "!\\lua\\" + #define LUA_CDIR "!\\" + #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" + + #if !defined(LUA_PATH_DEFAULT) + #define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ + LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ + ".\\?.lua;" ".\\?\\init.lua" + #endif + + #if !defined(LUA_CPATH_DEFAULT) + #define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.dll;" \ + LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ + LUA_CDIR"loadall.dll;" ".\\?.dll" + #endif + + #else /* }{ */ + + #define LUA_ROOT "/usr/local/" + #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" + #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" + + #if !defined(LUA_PATH_DEFAULT) + #define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ + "./?.lua;" "./?/init.lua" + #endif + + #if !defined(LUA_CPATH_DEFAULT) + #define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" + #endif + + #endif /* } */ + + + /* + @@ LUA_DIRSEP is the directory separator (for submodules). + ** CHANGE it if your machine does not use "/" as the directory separator + ** and is not Windows. (On Windows Lua automatically uses "\".) + */ + #if !defined(LUA_DIRSEP) + + #if defined(_WIN32) + #define LUA_DIRSEP "\\" + #else + #define LUA_DIRSEP "/" + #endif + + #endif + + /* }================================================================== */ + + + /* + ** {================================================================== + ** Marks for exported symbols in the C code + ** =================================================================== + */ + + /* + @@ LUA_API is a mark for all core API functions. + @@ LUALIB_API is a mark for all auxiliary library functions. + @@ LUAMOD_API is a mark for all standard library opening functions. + ** CHANGE them if you need to define those functions in some special way. + ** For instance, if you want to create one Windows DLL with the core and + ** the libraries, you may want to use the following definition (define + ** LUA_BUILD_AS_DLL to get it). + */ + #if defined(LUA_BUILD_AS_DLL) /* { */ + + #if defined(LUA_CORE) || defined(LUA_LIB) /* { */ + #define LUA_API __declspec(dllexport) + #else /* }{ */ + #define LUA_API __declspec(dllimport) + #endif /* } */ + + #else /* }{ */ + + #define LUA_API extern + + #endif /* } */ + + + /* + ** More often than not the libs go together with the core. + */ + #define LUALIB_API LUA_API + #define LUAMOD_API LUA_API + + + /* + @@ LUAI_FUNC is a mark for all extern functions that are not to be + ** exported to outside modules. + @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables, + ** none of which to be exported to outside modules (LUAI_DDEF for + ** definitions and LUAI_DDEC for declarations). + ** CHANGE them if you need to mark them in some special way. Elf/gcc + ** (versions 3.2 and later) mark them as "hidden" to optimize access + ** when Lua is compiled as a shared library. Not all elf targets support + ** this attribute. Unfortunately, gcc does not offer a way to check + ** whether the target offers that support, and those without support + ** give a warning about it. To avoid these warnings, change to the + ** default definition. + */ + #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) /* { */ + #define LUAI_FUNC __attribute__((visibility("internal"))) extern + #else /* }{ */ + #define LUAI_FUNC extern + #endif /* } */ + + #define LUAI_DDEC(dec) LUAI_FUNC dec + #define LUAI_DDEF /* empty */ + + /* }================================================================== */ + + + /* + ** {================================================================== + ** Compatibility with previous versions + ** =================================================================== + */ + + /* + @@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.3. + ** You can define it to get all options, or change specific options + ** to fit your specific needs. + */ + #if defined(LUA_COMPAT_5_3) /* { */ + + /* + @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated + ** functions in the mathematical library. + ** (These functions were already officially removed in 5.3; + ** nevertheless they are still available here.) + */ + #define LUA_COMPAT_MATHLIB + + /* + @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for + ** manipulating other integer types (lua_pushunsigned, lua_tounsigned, + ** luaL_checkint, luaL_checklong, etc.) + ** (These macros were also officially removed in 5.3, but they are still + ** available here.) + */ + #define LUA_COMPAT_APIINTCASTS + + + /* + @@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod + ** using '__lt'. + */ + #define LUA_COMPAT_LT_LE + + + /* + @@ The following macros supply trivial compatibility for some + ** changes in the API. The macros themselves document how to + ** change your code to avoid using them. + ** (Once more, these macros were officially removed in 5.3, but they are + ** still available here.) + */ + #define lua_strlen(L,i) lua_rawlen(L, (i)) + + #define lua_objlen(L,i) lua_rawlen(L, (i)) + + #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) + #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) + + #endif /* } */ + + /* }================================================================== */ + + + + /* + ** {================================================================== + ** Configuration for Numbers (low-level part). + ** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* + ** satisfy your needs. + ** =================================================================== + */ + + /* + @@ LUAI_UACNUMBER is the result of a 'default argument promotion' + @@ over a floating number. + @@ l_floatatt(x) corrects float attribute 'x' to the proper float type + ** by prefixing it with one of FLT/DBL/LDBL. + @@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. + @@ LUA_NUMBER_FMT is the format for writing floats. + @@ lua_number2str converts a float to a string. + @@ l_mathop allows the addition of an 'l' or 'f' to all math operations. + @@ l_floor takes the floor of a float. + @@ lua_str2number converts a decimal numeral to a number. + */ + + + /* The following definitions are good for most cases here */ + + #define l_floor(x) (l_mathop(floor)(x)) + + #define lua_number2str(s,sz,n) \ + l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n)) + + /* + @@ lua_numbertointeger converts a float number with an integral value + ** to an integer, or returns 0 if float is not within the range of + ** a lua_Integer. (The range comparisons are tricky because of + ** rounding. The tests here assume a two-complement representation, + ** where MININTEGER always has an exact representation as a float; + ** MAXINTEGER may not have one, and therefore its conversion to float + ** may have an ill-defined value.) + */ + #define lua_numbertointeger(n,p) \ + ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ + (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ + (*(p) = (LUA_INTEGER)(n), 1)) + + + /* now the variable definitions */ + + #if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */ + + #define LUA_NUMBER float + + #define l_floatatt(n) (FLT_##n) + + #define LUAI_UACNUMBER double + + #define LUA_NUMBER_FRMLEN "" + #define LUA_NUMBER_FMT "%.7g" + + #define l_mathop(op) op##f + + #define lua_str2number(s,p) strtof((s), (p)) + + + #elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */ + + #define LUA_NUMBER long double + + #define l_floatatt(n) (LDBL_##n) + + #define LUAI_UACNUMBER long double + + #define LUA_NUMBER_FRMLEN "L" + #define LUA_NUMBER_FMT "%.19Lg" + + #define l_mathop(op) op##l + + #define lua_str2number(s,p) strtold((s), (p)) + + #elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */ + + #define LUA_NUMBER double + + #define l_floatatt(n) (DBL_##n) + + #define LUAI_UACNUMBER double + + #define LUA_NUMBER_FRMLEN "" + #define LUA_NUMBER_FMT "%.14g" + + #define l_mathop(op) op + + #define lua_str2number(s,p) strtod((s), (p)) + + #else /* }{ */ + + #error "numeric float type not defined" + + #endif /* } */ + + + + /* + @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. + @@ LUAI_UACINT is the result of a 'default argument promotion' + @@ over a LUA_INTEGER. + @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. + @@ LUA_INTEGER_FMT is the format for writing integers. + @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. + @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. + @@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED. + @@ lua_integer2str converts an integer to a string. + */ + + + /* The following definitions are good for most cases here */ + + #define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" + + #define LUAI_UACINT LUA_INTEGER + + #define lua_integer2str(s,sz,n) \ + l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n)) + + /* + ** use LUAI_UACINT here to avoid problems with promotions (which + ** can turn a comparison between unsigneds into a signed comparison) + */ + #define LUA_UNSIGNED unsigned LUAI_UACINT + + + /* now the variable definitions */ + + #if LUA_INT_TYPE == LUA_INT_INT /* { int */ + + #define LUA_INTEGER int + #define LUA_INTEGER_FRMLEN "" + + #define LUA_MAXINTEGER INT_MAX + #define LUA_MININTEGER INT_MIN + + #define LUA_MAXUNSIGNED UINT_MAX + + #elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ + + #define LUA_INTEGER long + #define LUA_INTEGER_FRMLEN "l" + + #define LUA_MAXINTEGER LONG_MAX + #define LUA_MININTEGER LONG_MIN + + #define LUA_MAXUNSIGNED ULONG_MAX + + #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ + + /* use presence of macro LLONG_MAX as proxy for C99 compliance */ + #if defined(LLONG_MAX) /* { */ + /* use ISO C99 stuff */ + + #define LUA_INTEGER long long + #define LUA_INTEGER_FRMLEN "ll" + + #define LUA_MAXINTEGER LLONG_MAX + #define LUA_MININTEGER LLONG_MIN + + #define LUA_MAXUNSIGNED ULLONG_MAX + + #elif defined(LUA_USE_WINDOWS) /* }{ */ + /* in Windows, can use specific Windows types */ + + #define LUA_INTEGER __int64 + #define LUA_INTEGER_FRMLEN "I64" + + #define LUA_MAXINTEGER _I64_MAX + #define LUA_MININTEGER _I64_MIN + + #define LUA_MAXUNSIGNED _UI64_MAX + + #else /* }{ */ + + #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ + or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" + + #endif /* } */ + + #else /* }{ */ + + #error "numeric integer type not defined" + + #endif /* } */ + + /* }================================================================== */ + + + /* + ** {================================================================== + ** Dependencies with C99 and other C details + ** =================================================================== + */ + + /* + @@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89. + ** (All uses in Lua have only one format item.) + */ + #if !defined(LUA_USE_C89) + #define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i) + #else + #define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i)) + #endif + + + /* + @@ lua_strx2number converts a hexadecimal numeral to a number. *** 1188 LINES SKIPPED ***