From nobody Fri Feb 16 04:00:28 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 4TbdWK3rJKz59ZGq; Fri, 16 Feb 2024 04:00:29 +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 4TbdWK1SYfz4HNd; Fri, 16 Feb 2024 04:00:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708056029; 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=p4z/ddsiMDmZ87DQplUCTHjptwiY31LyQBhkJANy3TI=; b=abTGCOsw1okEKkj+8YK/6AqgrgkX/G7OLbLhbRKvigYL283/67QrEb+o3IFk0T6j0nNcZi s23rGTFWS22UUBq9L2nY7QUI/0uAdRTxpLM2YjVAmzN0dR2VMJYQBHDs3opUboiBoat5tB +6le1akefH3rUNzy3prmXPj8OippuD7blJdrYRFOFGUv6SOiRKH6wvLsGPw+gnZXDEDVJK DJ9zwKOWJ/FVKHJ6f0Mv2FNfM0PsM4pV5YXGlvbRpGKm7+s6jC0nf6i0abIJa7eH4TmVN5 rmXm2aCcpKJsOTcxsM/WE5Vn/V8i2U4qSQwP+mS2orZ2twlhZ3/KVX7DJbGpsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708056029; 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=p4z/ddsiMDmZ87DQplUCTHjptwiY31LyQBhkJANy3TI=; b=qNRAlmfR2Pwu+4OAarccf93HbR6GzfAhEzgL6w3jSxf8NwSVx4w9vNLB3X9A4pwNs/nYBn SlH1LhClwPaTjrzS3ogKT08AePrKaPhE+kV4nsb2X3YKsQi5XjBVhq6NPC3EcbYT+B/NVv A5Jf3zFV3vYxg8wTbHmr8rp7F3wND87V7Fqc28WY35W8FPAF9dAA9xvdkoJfXpS+VzfNzJ I1qDqcPEpvI94XF+PmBjofBKJdsdpaovpq2Gacn8Lk2yg1scU4tyY3oyRb6ePDASXtkWYE 4Qqp9/9w+pEXX9A0qf5PrKwSbPUlGG9I0w34DZ/Kai1Hw1S7Hw/MzumxR6ko6g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708056029; a=rsa-sha256; cv=none; b=kYCOqNHQmrZH6zKXQ4Bspl99/XizzSfrfLDGIUF1uW31ZCzHH0HjyFqwkVevWVdfig1tdv gFuDtANpKGhpLK7kYQfGkKpVLVNpbOIL3fMmLlTm/ZGY8ZPj9qglgzj1Xz6m31PXBMWYjd 1dsEV5rMYpJVwPNvXD0M1doeyVbBktfePX1zYQrG/sfRxSA2tYOosGWf/3LZiJhxFpKbf5 Bo99jplaKc8EZF/XQxJ85ofUKayRy5HX4sgrTQNU2aOcb9edH+glga/cspzuvZWBsThk6p A9zRmX7NzTIm5Oh8jiw7Mem4gzsCoxhcTd35OH4iVdZPPHzP17fbtMcYM8pLDg== 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 4TbdWK02FNz18mZ; Fri, 16 Feb 2024 04:00:29 +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 41G40SeN019113; Fri, 16 Feb 2024 04:00:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41G40S0w019110; Fri, 16 Feb 2024 04:00:28 GMT (envelope-from git) Date: Fri, 16 Feb 2024 04:00:28 GMT Message-Id: <202402160400.41G40S0w019110@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: 0921a771da8a - main - 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: 0921a771da8a9117edf26352a8a047bacbfcee45 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=0921a771da8a9117edf26352a8a047bacbfcee45 commit 0921a771da8a9117edf26352a8a047bacbfcee45 Author: Warner Losh AuthorDate: 2024-02-16 03:53:47 +0000 Commit: Warner Losh CommitDate: 2024-02-16 03:59:23 +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 --- 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);