Page MenuHomeFreeBSD

lua: reduce diffs between luaconf.h copies
ClosedPublic

Authored by emaste on Jan 25 2023, 10:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 14 2024, 9:17 PM
Unknown Object (File)
Mar 11 2024, 7:10 AM
Unknown Object (File)
Mar 11 2024, 7:10 AM
Unknown Object (File)
Mar 7 2024, 10:23 PM
Unknown Object (File)
Jan 8 2024, 8:50 PM
Unknown Object (File)
Jan 3 2024, 6:55 PM
Unknown Object (File)
Dec 22 2023, 7:49 PM
Unknown Object (File)
Dec 20 2023, 7:37 AM
Subscribers

Details

Summary

Upstream luaconf.h is contrib/lua/src/luaconf.h.dist, while userland lua and loader lua have copies in lib/liblua/luaconf.h and stand/liblua/luaconf.h.

Adjust whitespace, VCS tags, etc. to match upstream's version, for ease of comparison.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

After this change userland luaconf.h vs upstream is:

--- contrib/lua/src/luaconf.h.dist      2023-01-25 16:40:13.062497000 -0500
+++ lib/liblua/luaconf.h        2023-01-25 17:00:32.223331000 -0500
@@ -69,6 +69,13 @@
 #define LUA_USE_DLOPEN         /* MacOS does not need -ldl */
 #endif
 
+/* Local modifications: need io.popen */
+#ifdef __FreeBSD__
+#define LUA_USE_POSIX
+#ifndef BOOTSTRAPPING
+#define LUA_USE_DLOPEN
+#endif
+#endif
 
 /*
 @@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits.
@@ -213,9 +220,9 @@
 
 #else                  /* }{ */
 
-#define LUA_ROOT       "/usr/local/"
-#define LUA_LDIR       LUA_ROOT "share/lua/" LUA_VDIR "/"
-#define LUA_CDIR       LUA_ROOT "lib/lua/" LUA_VDIR "/"
+#define LUA_ROOT       "/usr/"
+#define LUA_LDIR       LUA_ROOT "share/flua/"
+#define LUA_CDIR       LUA_ROOT "lib/flua/"
 
 #if !defined(LUA_PATH_DEFAULT)
 #define LUA_PATH_DEFAULT  \

while loader is a little more extensive:

--- contrib/lua/src/luaconf.h.dist      2023-01-25 16:40:13.062497000 -0500
+++ stand/liblua/luaconf.h      2023-01-25 17:00:34.114426000 -0500
@@ -213,9 +213,9 @@
 
 #else                  /* }{ */
 
-#define LUA_ROOT       "/usr/local/"
-#define LUA_LDIR       LUA_ROOT "share/lua/" LUA_VDIR "/"
-#define LUA_CDIR       LUA_ROOT "lib/lua/" LUA_VDIR "/"
+#define LUA_ROOT       LUA_PATH "/" LUA_VDIR "/"
+#define LUA_LDIR       LUA_ROOT "share/"
+#define LUA_CDIR       LUA_ROOT "lib/"
 
 #if !defined(LUA_PATH_DEFAULT)
 #define LUA_PATH_DEFAULT  \
@@ -412,9 +412,7 @@
 ** 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))
+      (*(p) = (LUA_INTEGER)(n), 1)
 
 
 /* now the variable definitions */
@@ -465,6 +463,32 @@
 
 #define lua_str2number(s,p)    strtod((s), (p))
 
+#elif LUA_FLOAT_TYPE == LUA_FLOAT_INT64        /* }{ int64 */
+
+#include "lstd.h"
+
+#include <machine/_inttypes.h>
+
+#define panic lua_panic
+/* Hack to use int64 as the LUA_NUMBER from ZFS code, kinda */
+
+#define LUA_NUMBER     int64_t
+
+#define l_mathlim(n)           (LUA_FLOAT_INT_HACK_##n)
+#define LUA_FLOAT_INT_HACK_MANT_DIG    32
+#define LUA_FLOAT_INT_HACK_MAX_10_EXP  32
+
+#define LUAI_UACNUMBER int64_t
+
+#define LUA_NUMBER_FRMLEN      ""
+#define LUA_NUMBER_FMT         "%" PRId64
+
+#define l_mathop(x)            (lstd_ ## x)
+
+#define lua_str2number(s,p)    strtoll((s), (p), 0)
+
+#define lua_getlocaledecpoint()                '.'
+
 #else                                          /* }{ */
 
 #error "numeric float type not defined"
@@ -732,14 +756,14 @@
 /*
 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
 */
-#define LUAL_BUFFERSIZE   ((int)(16 * sizeof(void*) * sizeof(lua_Number)))
+#define LUAL_BUFFERSIZE                128
 
 
 /*
 @@ LUAI_MAXALIGN defines fields that, when used in a union, ensure
 ** maximum alignment for the other items in that union.
 */
-#define LUAI_MAXALIGN  lua_Number n; double u; void *s; lua_Integer i; long l
+#define LUAI_MAXALIGN  lua_Number n; void *s; lua_Integer i; long l
 
 /* }================================================================== */
 
lib/liblua/luaconf.h
214

I'm not sure what the deal was with this

You could likely do this with #ifdef LUA_LOADER #ifdef LUA_FLUA to a large degere.
This was originally done this way due to the extreme pain svn induced, so might be OK to move to a more traditional model now.
addliteral had one change
[15:14:00] <@bsdimp__> and quotefloat was commented out entirely.
[15:14:21] <@bsdimp__> addliteral comment out the call to quotefloat
[15:15:22] <@bsdimp__> and str_format had the 'f' case commented out
[15:16:03] <@bsdimp__> and getoption had 'f' and 'd' cases commented out
[15:16:58] <@bsdimp__> and in str_pack I think you'll hit the changes that are in conflict for the Kfloat case
[15:17:14] <@bsdimp__> similar, but simpler in str_unpack
[15:17:55] <@bsdimp__> and we define l_intfitsf in luaconf.h so comment out its definition in lvm.c
[15:18:17] <@bsdimp__> so that should be it... good luck :)
[15:18:49] <@bsdimp__> I think a merge will catch all of these except the pack/unpack ones since things there changed a bit in a way that would confligt

is what I had to say on IRC as far as rolling the versions forward. The tl;dr: the above changes were needed when we can't use float/double *at*all* and the default lua code just avoids using them, but when float is completely disabled, we need to not reference them at all. Also, it helps with the size of the BIOS boot loader.

lib/liblua/luaconf.h
214

Yea, this is clearly a bug in our config,so I'd drop the change.

You could likely do this with #ifdef LUA_LOADER #ifdef LUA_FLUA to a large degere.

Yeah, I'm thinking of something like that. This change is a small improvement independent of that work IMO.

I actually like the idea of this being completely stock, with the suggested change.
but this commit, as is, is ready to go.

Unless you want me to push the alternative in https://reviews.freebsd.org/D38207

stand/liblua/luaconf.h
782

If we add #include "luaconf.local.h"
here, then we have no weird build magic. We can add whatever we need in the flua or loader cases w/o the need for #ifdef LUA_LOADER or #ifdef LUA_FLUA. And I think we can cope with all the weirdness we need to there.
Again, a bit orthogonal to this commit.

This revision is now accepted and ready to land.Jan 26 2023, 5:17 PM
This revision was automatically updated to reflect the committed changes.