loader: Change version calculation to be more consistent.

Use 1000 * major + minor when calculating the version number that
gets set in the Ficl environment or lua loader property. This allows
for more room if the minor number needs to go above 9.

Add loader.version property to lua loader.

Reviewed by:	imp
Obtained from:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D39631
This commit is contained in:
Stephen J. Kiernan 2023-04-17 19:27:54 -04:00
parent 010795fc82
commit a50d73d578
4 changed files with 4 additions and 2 deletions

View File

@ -182,6 +182,7 @@ extern int isapnp_readport;
* Version information
*/
extern char bootprog_info[];
extern unsigned bootprog_rev;
/*
* Interpreter information

View File

@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$");
#include "bootstrap.h"
#include "ficl.h"
extern unsigned bootprog_rev;
INTERP_DEFINE("4th");
/* #define BFORTH_DEBUG */

View File

@ -57,6 +57,6 @@ fi
cat > $tempfile <<EOF
char bootprog_info[] = "$bootprog_info";
unsigned bootprog_rev = ${r%%.*}${r##*.};
unsigned bootprog_rev = ${r%%.*} * 1000 + ${r##*.};
EOF
mv $tempfile vers.c

View File

@ -593,6 +593,8 @@ luaopen_loader(lua_State *L)
lua_setfield(L, -2, "machine_arch");
lua_pushstring(L, LUA_PATH);
lua_setfield(L, -2, "lua_path");
lua_pushinteger(L, bootprog_rev);
lua_setfield(L, -2, "version");
/* Set global printc to loader.printc */
lua_register(L, "printc", lua_printc);
return 1;