From nobody Tue Apr 16 20:12:49 2024 X-Original-To: dev-commits-src-all@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 4VJwFZ3LsHz5H0H6; Tue, 16 Apr 2024 20:12:50 +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 4VJwFZ18LWz4tDl; Tue, 16 Apr 2024 20:12:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298370; 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=zw1HrUWI9uZNPqeduoXMywwsSV8JlPalLiCbyow0RXI=; b=oITvKBx439djDDxW1VWWbUVoD7VzQiGS2gjN9i9R7rP1yHSAw/ysxVEqg5PLEoPMjm3qD7 w+Sx3J5njYvONTIIinKyT5xL03NNvmZcYYYy+E4TL9MhMlKVZvp4RRKTPk/D9yEIbchTqP Xm5JagqbE3UmR2cUDa4G9g1rw0Iq4xp5djFKRQUlSL+yGECxFQDvbGS+waqs1v3agwOb4c OLJiQhwABaKEm9PQBqRGQx7ZRGhECbi5eB7NtbbmRqy93i71HtNHvmyFWHelUJPQSu+4tl qkivWoCxc5priPx7V8bCxfiQtCCDU2Zyrq2hQe4uc0RNFhomEWCbYeZGdd1xHg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713298370; a=rsa-sha256; cv=none; b=hrtvVl2NkXDo9E1WoTc98km/PWNggK/o4d7cOkcBo4mv8JOFw2AaxY2WFMCedfe4iQ/xSS mQgsHg6yT13xmNBheONAv7QRwJAMbVDO2cpAQjt8ip9G9IXShTnXCzmqbPVs8BhCfnRRmX CZLdkxdqVcBmkPwKL3DJBDW7QxGXhS89/+4B8aSJpqa/RU0gy62sr8phYVKXxw6eeqFxiJ +SxUN0wxZie25teWC5+r4UZ3jDbphoZHee99PZXh9l3N89X5tJyGjGHmq8sjTPCT95/KZD zA1rxXTAVBUuUWvEO944ZbXMmWSOh5YAgDEs1EGYt2CTfM4b23B1f36OpjsjxQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298370; 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=zw1HrUWI9uZNPqeduoXMywwsSV8JlPalLiCbyow0RXI=; b=SLoEif4Fa0sKgJn/ftjsFuwZWgVRHOTXLCQo7DRJpawFEjm8j2lwgMxmGOxGgPJ0INmW31 ADUBcZqutCBoV6KS79Pm/GyDqE2ZwgASqJqHlB0XbAa5Mqp9M924TojAAskRKidsbRnvsj UFLaci48Fyn39VVZWx9UEIG4F7+cIjBNhaVlsk16pqynab7aZf5u97kgn9+XrvwWCTtGTP PBbC+9wKbkrCGrMXWhotfJpGVPluoKhGaQnseJpkCrKEbqJXfoBW6EvbjLll3K7JW4BB7A lNmdCR3meGVU5daQKkhabeY2KVVf9FoqQstD/JKEqQy2kuntD/PE6YMbRAfYkQ== 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 4VJwFZ0cytzxb1; Tue, 16 Apr 2024 20:12:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43GKCn97038006; Tue, 16 Apr 2024 20:12:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43GKCnEC038003; Tue, 16 Apr 2024 20:12:49 GMT (envelope-from git) Date: Tue, 16 Apr 2024 20:12:49 GMT Message-Id: <202404162012.43GKCnEC038003@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 94e1374b55c7 - stable/14 - loader: Move to using linker sets to bring in optional bits List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 94e1374b55c7c3ac484bbe0631591545a5536c8d Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=94e1374b55c7c3ac484bbe0631591545a5536c8d commit 94e1374b55c7c3ac484bbe0631591545a5536c8d Author: Warner Losh AuthorDate: 2024-02-16 03:53:47 +0000 Commit: Warner Losh CommitDate: 2024-04-16 19:54:24 +0000 loader: Move to using linker sets to bring in optional bits The graphics stuff is optional. When it is pulled into the system, we use a linker set to initialize the lua bindings for it now. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43906 (cherry picked from commit 0921a771da8a9117edf26352a8a047bacbfcee45) --- stand/common/interp_lua.c | 29 +++-------------------------- stand/liblua/gfx_utils.c | 27 +++++++++++++++++++++++++++ stand/liblua/lutils.h | 9 +++++++++ 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/stand/common/interp_lua.c b/stand/common/interp_lua.c index a347526b67c9..11595b78a7bd 100644 --- a/stand/common/interp_lua.c +++ b/stand/common/interp_lua.c @@ -97,31 +97,6 @@ static const luaL_Reg loadedlibs[] = { {NULL, NULL} }; -static void -interp_init_md(lua_State *L) -{ - luaL_requiref(L, "gfx", luaopen_gfx, 1); - lua_pop(L, 1); /* Remove lib */ - - /* - * Add in the comparability references in the loader table. Doing it with - * a pseudo-embedded script is easier than the raw calls. - */ - if (luaL_dostring(L, - "loader.fb_bezier = gfx.fb_bezier\n" - "loader.fb_drawrect = gfx.fb_drawrect\n" - "loader.fb_line = gfx.fb_line\n" - "loader.fb_putimage = gfx.fb_putimage\n" - "loader.fb_setpixel = gfx.fb_setpixel\n" - "loader.term_drawrect = gfx.term_drawrect\n" - "loader.term_putimage = gfx.term_putimage") != 0) { - lua_pop(L, 1); - const char *errstr = lua_tostring(L, -1); - errstr = errstr == NULL ? "unknown" : errstr; - printf("Error adding compat loader bindings: %s.\n", errstr); - } -} - void interp_init(void) { @@ -129,6 +104,7 @@ interp_init(void) struct interp_lua_softc *softc = &lua_softc; const char *filename; const luaL_Reg *lib; + lua_init_md_t **fnpp; TSENTER(); @@ -148,7 +124,8 @@ interp_init(void) lua_pop(luap, 1); /* remove lib */ } - interp_init_md(luap); + LUA_FOREACH_SET(fnpp) + (*fnpp)(luap); filename = getenv("loader_lua"); if (filename == NULL) diff --git a/stand/liblua/gfx_utils.c b/stand/liblua/gfx_utils.c index d2d22738c929..8d2aaacbd688 100644 --- a/stand/liblua/gfx_utils.c +++ b/stand/liblua/gfx_utils.c @@ -245,3 +245,30 @@ void gfx_interp_md(void) { } + +static void +gfx_init_md(lua_State *L) +{ + luaL_requiref(L, "gfx", luaopen_gfx, 1); + lua_pop(L, 1); /* Remove lib */ + + /* + * Add in the compatibility references in the loader table. Doing it with + * a pseudo-embedded script is easier than the raw calls. + */ + if (luaL_dostring(L, + "loader.fb_bezier = gfx.fb_bezier\n" + "loader.fb_drawrect = gfx.fb_drawrect\n" + "loader.fb_line = gfx.fb_line\n" + "loader.fb_putimage = gfx.fb_putimage\n" + "loader.fb_setpixel = gfx.fb_setpixel\n" + "loader.term_drawrect = gfx.term_drawrect\n" + "loader.term_putimage = gfx.term_putimage") != 0) { + lua_pop(L, 1); + const char *errstr = lua_tostring(L, -1); + errstr = errstr == NULL ? "unknown" : errstr; + printf("Error adding compat loader bindings: %s.\n", errstr); + } +} + +LUA_COMPILE_SET(gfx_init_md); diff --git a/stand/liblua/lutils.h b/stand/liblua/lutils.h index c1fd6af496e5..522abfd3d0d4 100644 --- a/stand/liblua/lutils.h +++ b/stand/liblua/lutils.h @@ -30,3 +30,12 @@ int luaopen_gfx(lua_State *); int luaopen_loader(lua_State *); int luaopen_io(lua_State *); int luaopen_pager(lua_State *); + +#include + +typedef void lua_init_md_t(lua_State *); +#define LUA_COMPILE_SET(func) \ + DATA_SET(Xficl_compile_set, func) /* XXX linker set know by ldscrips */ +#define LUA_FOREACH_SET(s) \ + SET_FOREACH((s), Xficl_compile_set) +SET_DECLARE(Xficl_compile_set, lua_init_md_t);