From patchwork Sun Jun 10 03:01:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138131 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2596261lji; Sat, 9 Jun 2018 20:43:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI9b3XmIFwu+Md3U6nOVak4dZqcjfRgpXnEj1aVoy14bmm06faCcxc8HH+exo6lssp9QLeA X-Received: by 2002:ac8:16d6:: with SMTP id y22-v6mr3751548qtk.352.1528602213554; Sat, 09 Jun 2018 20:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602213; cv=none; d=google.com; s=arc-20160816; b=AWOyfauT7fpI2KAqOd0OTOPuPueeQ9q1THt0KUkheMspwSidQ8sr2vZEDBMh/Jt8eV Z6m/5BXUBkAlPfFJ3jWWcFqGK/J2+CoGq3/iTr48SD5APX6nAm5yfI+YFvWbwdaZL05R miqTg+QcjeG7mR6m3x565KIVnzD8M6ZMVJs0iYtVU0NguvhhVjFjMcf+i8u0P2A3L9Fr T86YAWivi+iVrVwGsIll3oFVYwf3Sbe+btc+87cowVQ+8NEy/7/kLY/oi9ou9xLzo//d t7C5+QrKrwawjFairqyhfCp05EdZ6mkOQ0SFkINY+UyAsoS1QryOCHfMe74EiZHxjQzn XbiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Q3zsLN52/w7gqJ6E51v6W4Qx9N3X1e6YhQA4YDsmY/s=; b=PD1WPePfjgKAETkeucfYpKf/Kt7ekb1oGopX2kcXY5+yIdV1NJkm/ShlN4LiN0stoP smOqDg7nfnPnmLZelYQKHpetEirhd7r199FsqrqPxnj5VFfn1kvkibb63Nf/T0LynCMK 6SV49LOHDRJS706ec+HmqDXaN6KsIAhUebHae6OsYbHTjEqbZ/a+J60j0To77/18YYI3 QMeI8XYmyyDMQDioM0Wyk5jHuQRbLLr4/B7cCyrx2N6aiC9aQQh0MD/vH1B0ATDEbxFk C0BXojktnDZskZsrK/KY1hjcVQDxo0JkRcdHm1usRWp1d0iHoo+h06kEhbwGGGPI0b1C oLBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=I94OAC4x; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i5-v6si60505qtc.150.2018.06.09.20.43.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:43:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=I94OAC4x; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrGO-0004VT-T9 for patch@linaro.org; Sat, 09 Jun 2018 23:43:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeo-0003TQ-L8 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqen-0003tU-Eg for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:42 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:40579) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqen-0003t7-69 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:41 -0400 Received: by mail-pf0-x243.google.com with SMTP id z24-v6so8491109pfe.7 for ; Sat, 09 Jun 2018 20:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q3zsLN52/w7gqJ6E51v6W4Qx9N3X1e6YhQA4YDsmY/s=; b=I94OAC4xgHQtXznzD++07GOoGFcKL290APBhTRwGMFgetC3K954WhbgxSWoaMftLc+ IXmg80BaPq6aIVq4BdVKCqv+muEWFZJGZiEa8TFaIhWwFQI5prAMb8U7CaIvF4ElHnEx bLERZVEXf4sXGTziVoKveVQKmKvj4rTZatGig= 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; bh=Q3zsLN52/w7gqJ6E51v6W4Qx9N3X1e6YhQA4YDsmY/s=; b=AUdhmpHYbbxnJybiVtwlTSOk1kv3MpU6PNsZ46/RJna9ZYcKa/q0gqvQkOHSZSyShW jlDLq1wxbw4a17nxtbwtxjc4y7Mv/VaSiYZV3yyKBpnXQBD73k0mZom0wOHFLMPK2uli Q9LyhHc0r7fvbJjgkXjluB50HFyOofzPZZKPmw5J6faIk7P3xcZysLmEF7CHZQEc5ONb R4qT17QBoLOtZXQ0CiGLkRJlX83T0PB0BjBP//Sohjemi7M93da4zyvk1/a9f3JQfsjY 3Dvo3GNQ0mQvI8G4cCmNILaVJDKVQR4UiUgisyRjx92Lb5vsjBmEkpFYrbACSVoI25Ht I2IQ== X-Gm-Message-State: APt69E0jk0rBhdm8fYrBKD2sTqqRUO2g31ZZ1aZ6AOPBXRGXAROtQn2x YDdfu2to/hn2gjB5ZAPRaN2JU2LVEqQ= X-Received: by 2002:a65:6356:: with SMTP id p22-v6mr10456040pgv.20.1528599880003; Sat, 09 Jun 2018 20:04:40 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:34 -1000 Message-Id: <20180610030220.3777-63-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 062/108] linux-user: Split out flock, preadv, pwritev, readv, writev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All targets define preadv and pwritev; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 135 ++++++++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 58 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 362d315ce8..07fa043965 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8043,6 +8043,12 @@ IMPL(fcntl) } #endif +IMPL(flock) +{ + /* The flock constant seems to be the same for every Linux platform. */ + return get_errno(safe_flock(arg1, arg2)); +} + #ifdef TARGET_NR_fork IMPL(fork) { @@ -9221,6 +9227,24 @@ IMPL(ppoll) return ret; } +IMPL(preadv) +{ + struct iovec *vec; + abi_long ret; + + vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); + if (vec != NULL) { + unsigned long low, high; + + target_to_host_low_high(arg4, arg5, &low, &high); + ret = get_errno(safe_preadv(arg1, vec, arg3, low, high)); + unlock_iovec(vec, arg2, arg3, 1); + } else { + ret = -host_to_target_errno(errno); + } + return ret; +} + IMPL(pselect6) { abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; @@ -9322,6 +9346,24 @@ IMPL(pselect6) return ret; } +IMPL(pwritev) +{ + struct iovec *vec; + abi_long ret; + + vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); + if (vec != NULL) { + unsigned long low, high; + + target_to_host_low_high(arg4, arg5, &low, &high); + ret = get_errno(safe_pwritev(arg1, vec, arg3, low, high)); + unlock_iovec(vec, arg2, arg3, 0); + } else { + ret = -host_to_target_errno(errno); + } + return ret; +} + IMPL(read) { abi_long ret; @@ -9381,6 +9423,21 @@ IMPL(readlinkat) return do_readlinkat(arg1, arg2, arg3, arg4); } +IMPL(readv) +{ + struct iovec *vec; + abi_long ret; + + vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); + if (vec != NULL) { + ret = get_errno(safe_readv(arg1, vec, arg3)); + unlock_iovec(vec, arg2, arg3, 1); + } else { + ret = -host_to_target_errno(errno); + } + return ret; +} + IMPL(reboot) { abi_long ret; @@ -10753,6 +10810,21 @@ IMPL(write) return ret; } +IMPL(writev) +{ + struct iovec *vec; + abi_long ret; + + vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); + if (vec != NULL) { + ret = get_errno(safe_writev(arg1, vec, arg3)); + unlock_iovec(vec, arg2, arg3, 0); + } else { + ret = -host_to_target_errno(errno); + } + return ret; +} + /* This is an internal helper for do_syscall so that it is easier * to have a single return point, so that actions, such as logging * of syscall results, can be performed. @@ -10769,64 +10841,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { - case TARGET_NR_flock: - /* NOTE: the flock constant seems to be the same for every - Linux platform */ - return get_errno(safe_flock(arg1, arg2)); - case TARGET_NR_readv: - { - struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); - if (vec != NULL) { - ret = get_errno(safe_readv(arg1, vec, arg3)); - unlock_iovec(vec, arg2, arg3, 1); - } else { - ret = -host_to_target_errno(errno); - } - } - return ret; - case TARGET_NR_writev: - { - struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); - if (vec != NULL) { - ret = get_errno(safe_writev(arg1, vec, arg3)); - unlock_iovec(vec, arg2, arg3, 0); - } else { - ret = -host_to_target_errno(errno); - } - } - return ret; -#if defined(TARGET_NR_preadv) - case TARGET_NR_preadv: - { - struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0); - if (vec != NULL) { - unsigned long low, high; - - target_to_host_low_high(arg4, arg5, &low, &high); - ret = get_errno(safe_preadv(arg1, vec, arg3, low, high)); - unlock_iovec(vec, arg2, arg3, 1); - } else { - ret = -host_to_target_errno(errno); - } - } - return ret; -#endif -#if defined(TARGET_NR_pwritev) - case TARGET_NR_pwritev: - { - struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); - if (vec != NULL) { - unsigned long low, high; - - target_to_host_low_high(arg4, arg5, &low, &high); - ret = get_errno(safe_pwritev(arg1, vec, arg3, low, high)); - unlock_iovec(vec, arg2, arg3, 0); - } else { - ret = -host_to_target_errno(errno); - } - } - return ret; -#endif case TARGET_NR_getsid: return get_errno(getsid(arg1)); #if defined(TARGET_NR_fdatasync) /* Not on alpha (osf_datasync ?) */ @@ -12944,6 +12958,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_fcntl SYSCALL(fcntl); #endif + SYSCALL(flock); #ifdef TARGET_NR_fork SYSCALL(fork); #endif @@ -13076,12 +13091,15 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(poll); #endif SYSCALL(ppoll); + SYSCALL(preadv); SYSCALL(pselect6); + SYSCALL(pwritev); SYSCALL(read); #ifdef TARGET_NR_readlink SYSCALL(readlink); #endif SYSCALL(readlinkat); + SYSCALL(readv); SYSCALL(reboot); #ifdef TARGET_NR_recv SYSCALL(recv); @@ -13250,6 +13268,7 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(waitpid); #endif SYSCALL(write); + SYSCALL(writev); } #undef SYSCALL