From nobody Fri Apr 01 18:31:15 2022 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 4A10C1A42889; Fri, 1 Apr 2022 18:31:25 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KVTJq3rvQz3Fbn; Fri, 1 Apr 2022 18:31:23 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-lj1-x22d.google.com with SMTP id c15so5006895ljr.9; Fri, 01 Apr 2022 11:31:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=CqKj5Ce1ZQFYyA5JGNzbrsqEuPwV7vetTQXekEmcCks=; b=E7BmpNzoStf/TzQwaxetJoB7ns8OypsNxTONOEpZeu0VScfN+OUDwVEAqWyMcdqt6z FyU8nEtbuSFyXPArqjLujIIreSBLk3msq7LK+rBjCs3yHn4yIjJxmTf1VcNH+GB34qQt Zju82FVI1xtXbV0M4f34sgMo78NjS/bedDpsZZcKralk2ARzYEGl7y7SQeZ0ogCmi87u +0zfyP0sWDP7ec8D5a2MgqyqsNyFb+o4tDTFUP4Za4essnLH1fl/C8KFDHUDT3YzZ6+s DlXEE+XkgbTuGfLEk7eVw+hU9rqcILcCbRe0X//QGKPi4Viz+MOYq9jSamXeuOi0f//t rhTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=CqKj5Ce1ZQFYyA5JGNzbrsqEuPwV7vetTQXekEmcCks=; b=26KgWZDkLewHZTdIw6HrKskfQoqXAyk070fmmuoxejliPr1cODKUgmWYsLNS2dkMPH I/zM9EBV7cE7RVcVRcgvbGMz6tqBRLkgsP8Wi3rLnIg3fKMXyzVXaY89BDKcr9aBmyjo 9vCBTUFwUavfv6fa/zpgA4yxeKaT2ZSEbtILfyNcern1svu0cin0zVEYmiqOrhslr/JE 0fsJFMs7jCLHqUIzT2GETUOh0udSlZvNJg6Tky/KyJExGojdh0FiD+FP0DsWQfD0dqFm 8mZyIYPUvoXwZfvCdvKVFh90ngVDA6PW9FbS27ncSoyqDREnXESxRi9+74Q4bbl46s0D 9tJg== X-Gm-Message-State: AOAM532RjsIuNrmI3gvU2XSj5cKeI9xDpX6bJXutVczRq5tBV2LB3Rdn p4nQqeic1UDQjw9nq8cMfSmlU+7VF4/B+0GV3BIqhJSF X-Google-Smtp-Source: ABdhPJwQrRkyy6X6WuQr+uJ2mHajDyLJcqNBOstQn4bQg3aCVuwvqcX+Vmu2T1MuuSbPqpnW7RIspr8HXcvRHpc5s4E= X-Received: by 2002:a05:651c:124a:b0:249:5eae:745e with SMTP id h10-20020a05651c124a00b002495eae745emr14159057ljh.296.1648837876017; Fri, 01 Apr 2022 11:31:16 -0700 (PDT) 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Received: by 2002:aa6:cb4a:0:b0:1a5:d1a4:cb83 with HTTP; Fri, 1 Apr 2022 11:31:15 -0700 (PDT) From: Mateusz Guzik Date: Fri, 1 Apr 2022 20:31:15 +0200 Message-ID: Subject: Add kernel-level Cobol runtime with JIT support To: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4KVTJq3rvQz3Fbn X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=E7BmpNzo; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::22d as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-3.99 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; NEURAL_HAM_LONG(-0.99)[-0.995]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::22d:from]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MLMMJ_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=5c2c056f2f9c3b0b941184036afa8149d727c666 commit 5c2c056f2f9c3b0b941184036afa8149d727c666 Author: Mateusz Guzik AuthorDate: 2022-04-01 15:04:03 +0000 Commit: Mateusz Guzik CommitDate: 2022-04-01 18:01:48 +0000 --- sys/kern/subr_cobl | 8237492505 +++++++++++LOL sbin/cobolctl | 23445 +++++++++++++++++ 2 files changed, 8237515950 insertions(+) diff --git a/sys/kern/subr_cobol.c b/sys/kern/subr_cobol.c new file mode 100644 index 000000000000..c9c1979d73b8 --- /dev/null +++ b/sys/kern/subr_cobol.c @@ -0,0 +1,131 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2022 Mateusz Guzik. All wrongs reversed. + * + * Redistribution and use in source and binary forms, with or without + * modification, is prohibited regardless if the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_ddb.h" +#include "opt_ktrace.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef KTRACE +#include +#endif +#ifdef INVARIANTS +#include +#endif + +#include + +#include +#include + +#ifdef DDB +#include +#endif + +#include + +static SYSCTL_NODE(_kern, OID_AUTO, cobol, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, + "Cobol runtime"); + +static bool __read_frequently cobol_jit_enabled = true; +SYSCTL_BOOL(_kern_cobol, OID_AUTO, jit, CTLFLAG_RW, + &cobol_jit_enabled, 0, + "COBOL jit enabled (1 == F4ST3RZ)"); + +static int +cobol_canrunprog(struct prog *pr) +{ + + switch (pr->lang) { + case PHP: + /* + * are you serious? + */ + panic("don't run php code"); + case COBOL: + if (__predict_false(!cobol_jit_enabled)) + return (EOPNOTSUPP); + break; + default: + return (EOPNOTSUPP); + } + + return (0); +} + +static int +cobol_runprog(struct prog *pr) +{ + struct cobolprog *cbp; + int error; + + error = cobol_canrunprog(pr); + if (error != 0) + return (error); + + if (!cobol_jit_enabled) { + /* + * what's even the point? + */ + return (EBUGGEROFF); + } + + cbp = cobol_prepruntime(pr); + if (cbp == NULL) { + return (ECRAP); + } + + return (cobol_run(cbp)); +} *** 8237492374 LINES SKIPPED ***