lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Greetings,

My name is Warner Losh and I integrated a google summer of code project that changed FreeBSD's boot loader to use lua as its scripting language. This has gone great for years, but some of my changes have caused a little bit of heart-ache in upgrades.

I took the ZFS (before it was OpenZFS) patches to lua that implemented LUA_FLOAT_TYPE as an int64, cleaned them up and have a small number of changes to the base to make them work. The FreeBSD boot loader must run in environment where one must never touch the floating point unit, and software floating libraries are too large to be included.

The changes to make this happen are surprisingly small. Of course, one can't use fractional numbers in the lua scripts in our boot loader with this, but that's OK. We don't need that aspect of the language to work.

I'd like to get these patches upstreamed. What's the most current way to do this? Should I publish a git branch somewhere? Should I post the patches to the mailing list? Should I go somewhere else? For context (and in case this changes the answer), the patches are rather short:

% git diff vendor/lua/5.4.2 HEAD:contrib/lua --stat
 src/lstrlib.c | 27 +++++++++++++++++++++++++--
 src/luaconf.h |  2 +-
 src/lvm.c     |  7 +++++++
 3 files changed, 33 insertions(+), 3 deletions(-)
with another 15-ish lines that would be in the luaconf.h file had the one change here been to add a #include "luaconf.local.h" where the boot loader #undefs and #defines live.

The question I have is stylistic or maybe what's the best way to upstream. Nearly all the patches are of the form:

@@ -1121,6 +1121,7 @@ static void addquoted (luaL_Buffer *b, const char *s, size_t len) {
 }


+#if LUA_FLOAT_TYPE != LUA_FLOAT_INT64
 /*
 ** Serialize a floating-point number in such a way that it can be
 ** scanned back by Lua. Use hexadecimal format for "common" numbers
@@ -1149,7 +1150,7 @@ static int quotefloat (lua_State *L, char *buff, lua_Number n) {
   /* 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)) {

which avoids using float or double. These are the only places where LUA_FLOAT_TYPE is tested in the main code. So maybe a better condition would be something like

#ifndef LUA_NO_FLOAT

instead. That could then be defined in our luaconf.h file and our implementation wouldn't have to go upstream. Or we can upstream it and define LUA_NO_FLOAT as part of it. That would seem to fit better with the other #ifdefs in the code, but I'm unfamiliar with the design patterns preferred by the project.

What can people suggest?

Warner