From patchwork Tue Oct 6 09:44:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 1377316 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=W7tXJLLN; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=cxvW8cm8; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C5CHs5yh0z9sT6 for ; Tue, 6 Oct 2020 20:45:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IPYyAsuQtzcDqJhz6EcRK6irOrsXliDY5xwBxVmakJ0=; b=W7tXJLLNtg/2MCoQvMReMvQmK oBmL6ZxpdDXQRZaO1ZR2sWs+451Bj+ZisRnvdFzF5/mzfIRpftLXElg9exgaFLbi50O6pju7qZb4e a6b8IsRIadKC72v/u4zjFvmSn1x6VIzlARhfn1rps3/oqVhJzgJXDdEReaGMSJX9pQlfzfTXhYd5I lEOBHsJI/TzPPpN5WLGD3sCnC3hn0/1xp2JuKSkmbmluZtnGrfkyCaKFKgxSCnxYcLbZXNs7wr6MJ i2yyEVREEIx91ucNrb7Mz/uGeyu2vtedtVXTryOY8NNaylZv+cQhdOfwLGT+7jxRRfkDUQ/00vxpx uI3CVzm/g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPjWw-0008NF-IR; Tue, 06 Oct 2020 09:45:10 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPjWt-0008M5-Eh for linux-um@lists.infradead.org; Tue, 06 Oct 2020 09:45:08 +0000 Received: by mail-pf1-x441.google.com with SMTP id e10so8132873pfj.1 for ; Tue, 06 Oct 2020 02:45:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bfz1YZ5dIoN2aGR7YJ8XQT/WwiC9kxrzNC++l1jbOuI=; b=cxvW8cm8JXCSsB77mHpkG90iYna+vvl/bxfaG9GOp8LUL/5OTf4zu+4YBT9J+spHTR 5LVQC2Shsnht7t3HCLEAs9joxOBy5aBMhN5oHYtc96YTVJXOO2QpXcMGaG3qtewaAtkz XZSYaddfkGZ/vZqMbiZkoUw81Qk9rc+6BpbjIc6wkDW1dYK7HkkieIIE503fwg2yKTCz WLlvzz7a9eysSa2RjiZf3Cit40DVH2UhwrnGUlxhia02lCmi7t/QrxFlxd5SH6bGB5iA s5l08juAWB55buEw6955mqbuRZfsAb3WeCMMP3+9XoRgt+ySAQbUWZrDv0WzrUDicUL8 sCNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bfz1YZ5dIoN2aGR7YJ8XQT/WwiC9kxrzNC++l1jbOuI=; b=GZ7cHSTq3+L0oZ/fb1wPNWZ8cYZrwQ/1cw9oQlVYbyJ3W8mGbrvu8Z0KUBadiYBmjv DEC/7+QqJkEMth5gHLJ08uLmNplbU0ypnsAqSrXt7whFQ5P80V/LZlyNUcG7XJRdf3Hc /qCj281koAcmNm98EyZmhcuKfl87zMpqCqGRqtv2D5+1jnqua4WQ8E6URGpSnJ2Bxgse nMoWpIJVzvHdSVzqyUqGPcDkqktnJQ4aJG1JbKkJuWarsaQ93UjQB+JfPd83zbQt8YuO +DGgzIWjgiH6Ur//f2Uqk8i6EMUgiNZ/GABBTo13Xo91uY+mCeHSsnio192tiOPVgDW6 gT/A== X-Gm-Message-State: AOAM530UU7XVzfecqw0XZd72qQLyhxKIGpr70ILLtH5zSWGgw6LMR38d f8cTWe7vHKCqCQSFbqVCtrQ= X-Google-Smtp-Source: ABdhPJxp+VgOeK6IOBqA5KJH7DWJ7aLshWZY0GhcvSUPMT2RLzqI4UXNNoxCW1ir+rOFhynEUPxEdw== X-Received: by 2002:a63:595a:: with SMTP id j26mr3479617pgm.406.1601977504088; Tue, 06 Oct 2020 02:45:04 -0700 (PDT) Received: from earth-mac.local (219x123x138x129.ap219.ftth.ucom.ne.jp. [219.123.138.129]) by smtp.gmail.com with ESMTPSA id i17sm2829224pfa.29.2020.10.06.02.45.03 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Oct 2020 02:45:03 -0700 (PDT) Received: by earth-mac.local (Postfix, from userid 501) id 077F620390F49A; Tue, 6 Oct 2020 18:45:01 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org, jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com Subject: [RFC v7 04/21] um: host: implement os_initcalls and os_exitcalls Date: Tue, 6 Oct 2020 18:44:13 +0900 Message-Id: X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201006_054507_549597_BDD04F87 X-CRM114-Status: GOOD ( 12.23 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:441 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [thehajime[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tavi.purdila@gmail.com, linux-kernel-library@freelists.org, linux-arch@vger.kernel.org, Octavian Purdila , retrage01@gmail.com Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Octavian Purdila This patch implements the init and exit calls for host code. It uses the automatic __start_
and __stop_
variables that are defined by gcc / ld when using custom sections. Note that this patch should be merged with "um: move arch/um/os-Linux dir to tools/um" but for now it is separate to make the review easier. Signed-off-by: Octavian Purdila --- tools/um/uml/util.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/um/uml/util.c b/tools/um/uml/util.c index ecf2f390fad2..4011b36fee7e 100644 --- a/tools/um/uml/util.c +++ b/tools/um/uml/util.c @@ -186,3 +186,29 @@ void os_warn(const char *fmt, ...) vfprintf(stderr, fmt, list); va_end(list); } + +extern void (*__start_os_exitcalls)(void); +extern void (*__stop_os_exitcalls)(void); + +void os_exitcalls(void) +{ + exitcall_t *call; + + call = &__stop_os_exitcalls; + while (--call >= &__start_os_exitcalls) + (*call)(); +} + +extern int (*__start_os_initcalls)(void); +extern int (*__stop_os_initcalls)(void); + +int os_initcalls(void) +{ + initcall_t *call; + + call = &__stop_os_initcalls; + while (--call >= &__start_os_initcalls) + (*call)(); + + return 0; +}