From nobody Mon May 20 04:08:34 2024 X-Original-To: dev-commits-src-main@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 4VjPFH256gz5LhG1; Mon, 20 May 2024 04:08:35 +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 4VjPFH0Dsjz4ClW; Mon, 20 May 2024 04:08:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716178115; 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=P+gaWZu9nIV2fCRR4XJou4su42oPaYW3F+0tiexcdac=; b=KzBN0jhhyrr8D5gYC784vUFXqYLBXO8/+VI1GqkNRwSbzMkmQqMnZlxrO3UWSmbfmjS9+k lsGtlvvu7PCvzmltPkV2bxGnphghNme7RlqEMfbYQCSVx27e+q6CECQHezPQLnqXTaEyLx o1xeMSIWOQWt1nCxcf1I+EAMHjYybcX6BbGHfSG8egVlJjpySGag5F7Zm/nP/ZPWP4/B8B qHmUKm9b9kkmIYayDsBK0OQPKDFxL0Zac6qj3mwaPL7Gs6osAo8UNF/z99XGRjYeYHvQtL rErgwCmK8gqG9+tSabFFmw1hP97lLAcDjmSa3Ovwy0pfbmNBOkI6tRzaUZVS0g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716178115; a=rsa-sha256; cv=none; b=XmAccClcqMm6OCukjU3rLyrKOrz5xHYshy+oqKdoWVpcF/+7hx5cL5TjeccDFQwdV1n1qk ZE0taAQuRKqKhVmebCxct4Yfgnz1oAaiKdHC1wbMaAtRzCKknhbHw+SQpKj+tnTSdieH/1 Wcpj3Je19V6mV0QGfqKcGX14Xpv/z+yI3QzeHn8o8lvB4B/CmbtQOfdVrZX2ROD9X66fxj 6EppqdknSRkK9O3LKMZ8juXqNuYMXJtNkgXBekR/NxoUGpe6+VmpWpZyRc+fLkFH4Iwhzk 5M4rdIsd8vSby8d83B3EiKOljWzyH/5Z3rc01h+Woolq96TLowNvmmTrWKHXQQ== 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=1716178115; 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=P+gaWZu9nIV2fCRR4XJou4su42oPaYW3F+0tiexcdac=; b=h5dJiiSs2VT4Y9BUmwCVbiECqqwMQRi7OZcQj+ffKViyZ/ScLn8JXsx/8di5uSJ5J76hKP 4TB1Qguw34MBNf8dZEmScH3hDGTHbFLzPzbzme0+eeLkhdfWUsh74pOj4aq0U097JfPV4O Rvk3JaUrXkv8l8nXSRFM/QC2dJVmTF4s76xeh+OT3yJlhsI2VFbPE5CGiDzaTMKGZ4+Kbn d0vL7fjmqwtvdDoyKpNW2PgJoWjaAZQOiy76wXsPjy8ehf/xO0FDVpA845WWMN0gUlLRm+ 0IQxXQFzBEId0y+6f51V1tn27YsrgTGFuDvyXEJzviYvrJ23SrI6l1h7O5a2qQ== 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 4VjPFG6y0hzNHH; Mon, 20 May 2024 04:08:34 +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 44K48YXJ081098; Mon, 20 May 2024 04:08:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44K48Yaa081095; Mon, 20 May 2024 04:08:34 GMT (envelope-from git) Date: Mon, 20 May 2024 04:08:34 GMT Message-Id: <202405200408.44K48Yaa081095@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: 68344c9c6c69 - main - loader: separate lang init from scripting init List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 68344c9c6c69fc604b402eee420285356f7a677f Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=68344c9c6c69fc604b402eee420285356f7a677f commit 68344c9c6c69fc604b402eee420285356f7a677f Author: Warner Losh AuthorDate: 2024-05-19 17:48:14 +0000 Commit: Warner Losh CommitDate: 2024-05-20 04:05:40 +0000 loader: separate lang init from scripting init Create interp_preinit() to initialize the scripting language to run scripts. Make sure you can call it multiple times, but only the first one has effect, After it's call, you can run scripts in the scripting language. At the moment, no functional change. Sponsored by: Netflix --- stand/common/bootstrap.h | 3 ++- stand/common/interp.c | 1 + stand/common/interp_forth.c | 13 +++++++++++-- stand/common/interp_lua.c | 23 +++++++++++++++++++++-- stand/common/interp_simple.c | 5 +++++ 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h index b7d6e538f9be..79ce0b023b7a 100644 --- a/stand/common/bootstrap.h +++ b/stand/common/bootstrap.h @@ -54,7 +54,8 @@ bool interp_has_builtin_cmd(const char *cmd); /* Called by interp.c for interp_*.c embedded interpreters */ int interp_include(const char *); /* Execute commands from filename */ -void interp_init(void); /* Initialize interpreater */ +void interp_preinit(void); /* Initialize interpreater execution engine */ +void interp_init(void); /* Initialize interpreater and run main script */ int interp_run(const char *); /* Run a single command */ /* interp_backslash.c */ diff --git a/stand/common/interp.c b/stand/common/interp.c index c6ac01ea099b..5d20822e037d 100644 --- a/stand/common/interp.c +++ b/stand/common/interp.c @@ -60,6 +60,7 @@ interact(void) * we need to switch interpreters. */ interp_identifier = bootprog_interp; + interp_preinit(); interp_init(); printf("\n"); diff --git a/stand/common/interp_forth.c b/stand/common/interp_forth.c index 854addb22d5c..388a20e319b3 100644 --- a/stand/common/interp_forth.c +++ b/stand/common/interp_forth.c @@ -337,12 +337,21 @@ bf_run(const char *line) return (result); } +static bool preinit_run = false; + void -interp_init(void) +interp_preinit(void) { - + if (preinit_run) + return; setenv("script.lang", "forth", 1); bf_init(); + preinit_run = true; +} + +void +interp_init(void) +{ /* Read our default configuration. */ interp_include("/boot/loader.rc"); } diff --git a/stand/common/interp_lua.c b/stand/common/interp_lua.c index aa759aa99ec1..2a61bb9d04af 100644 --- a/stand/common/interp_lua.c +++ b/stand/common/interp_lua.c @@ -96,17 +96,21 @@ static const luaL_Reg loadedlibs[] = { {NULL, NULL} }; +static bool preinit_done = false; + void -interp_init(void) +interp_preinit(void) { lua_State *luap; struct interp_lua_softc *softc = &lua_softc; - const char *filename; const luaL_Reg *lib; lua_init_md_t **fnpp; TSENTER(); + if (preinit_done) + return; + setenv("script.lang", "lua", 1); LDBG("creating context"); @@ -126,6 +130,21 @@ interp_init(void) LUA_FOREACH_SET(fnpp) (*fnpp)(luap); + preinit_done = true; + + TSEXIT(); +} + +void +interp_init(void) +{ + lua_State *luap; + struct interp_lua_softc *softc = &lua_softc; + const char *filename; + + TSENTER(); + + luap = softc->luap; filename = getenv("loader_lua"); if (filename == NULL) filename = LOADER_LUA; diff --git a/stand/common/interp_simple.c b/stand/common/interp_simple.c index d675da0aa61e..437739a3bcc4 100644 --- a/stand/common/interp_simple.c +++ b/stand/common/interp_simple.c @@ -34,6 +34,11 @@ INTERP_DEFINE("simp"); +void +interp_preinit(void) +{ +} + void interp_init(void) {