From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id LNTmCbIN0GDLLwAAWB0awg (envelope-from ) for ; Sun, 20 Jun 2021 23:55:30 -0400 Received: by simark.ca (Postfix, from userid 112) id 1B9821F1F2; Sun, 20 Jun 2021 23:55:30 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 549F81E01F for ; Sun, 20 Jun 2021 23:55:29 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6C09A384803D for ; Mon, 21 Jun 2021 03:55:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C09A384803D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624247728; bh=thYMQJQNXuFpYij/UCOJ1Gxpc4E0HjBOeYW4DbyB6Ik=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VWPwm7Bx2xWfb63WRnCIgtNdQuLDQOXZkeo0PLeoJaX213fBm5lZiyqTr5rjSdsxp QxZuZuTTNH/vzc84NWmJTvfcB/y+c4jW8qeiZQZSLvlBGBElo+wYlxhepzhYBOFpD+ Xw0JBDYpooPF1S/N+FfKt7w3tGrGhqrXQ2uYjD3s= Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 9BBA13848422 for ; Mon, 21 Jun 2021 03:55:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9BBA13848422 Received: from vapier.lan (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 88FE3335C56 for ; Mon, 21 Jun 2021 03:55:07 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH 1/3] sim: callback: add a getpid interface Date: Sun, 20 Jun 2021 23:55:03 -0400 Message-Id: <20210621035505.29431-1-vapier@gentoo.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mike Frysinger via Gdb-patches Reply-To: Mike Frysinger Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Rather than hit the OS interface directly, use the existing callback layer so the instantiator can decide behavior. --- include/sim/callback.h | 1 + sim/common/callback.c | 13 +++++++++++++ sim/common/syscall.c | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/sim/callback.h b/include/sim/callback.h index 4c162bc145ea..a6c536b1be1c 100644 --- a/include/sim/callback.h +++ b/include/sim/callback.h @@ -91,6 +91,7 @@ struct host_callback_struct int (*to_lstat) (host_callback *, const char *, struct stat *); int (*ftruncate) (host_callback *, int, int64_t); int (*truncate) (host_callback *, const char *, int64_t); + int (*getpid) (host_callback *); int (*pipe) (host_callback *, int *); /* Called by the framework when a read call has emptied a pipe buffer. */ diff --git a/sim/common/callback.c b/sim/common/callback.c index f2587a452540..071e7b149b97 100644 --- a/sim/common/callback.c +++ b/sim/common/callback.c @@ -556,6 +556,17 @@ os_truncate (host_callback *p, const char *file, int64_t len) #endif } +static int +os_getpid (host_callback *p) +{ + int result; + + result = getpid (); + /* POSIX says getpid always succeeds. */ + p->last_errno = 0; + return result; +} + static int os_pipe (host_callback *p, int *filedes) { @@ -737,6 +748,8 @@ host_callback default_callback = os_ftruncate, os_truncate, + os_getpid, + os_pipe, os_pipe_empty, os_pipe_nonempty, diff --git a/sim/common/syscall.c b/sim/common/syscall.c index 4e76d2008a30..7ef34b95e9cf 100644 --- a/sim/common/syscall.c +++ b/sim/common/syscall.c @@ -579,7 +579,8 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc) break; case CB_SYS_getpid: - result = getpid (); + /* POSIX says getpid always succeeds. */ + result = (*cb->getpid) (cb); break; case CB_SYS_time : -- 2.31.1