From patchwork Mon May 29 19:54:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 100398 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1737827vqr; Mon, 29 May 2023 13:00:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6hgYgCljPyy/ZsiybWrxVtj3FbPGkpeYbOAA9Sxq9eSeFkpnJhkzjmv6Jb0BbYJlEYNqEQ X-Received: by 2002:a17:902:e548:b0:1b0:fed:5cbe with SMTP id n8-20020a170902e54800b001b00fed5cbemr290175plf.30.1685390417132; Mon, 29 May 2023 13:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685390417; cv=none; d=google.com; s=arc-20160816; b=QumhfMgjMN7s4jJ7n3QxVlY2FGh4Ws1VfC0jyy0Alhi1TPpdGP/SHId04EuVDccBaD N2IkTucqb/mxGr1L6fCnohOCboiIbfzYnxUlmOwE4ggwur47ns5ydy3kvqJpMnO7GS26 nFK4/JD7HQcg9Da0d4vjD6spV/tKOgJdj8tEHTFeZyfUVnZ/fg6nY8UMUF03DVTHENQH bO4WsDGWjzQ3XS3K4lFTKzbfGTPgZwyZfhWECCg52oCQ1uxVB5CSKBzsiGADPXWRjI1Y 6P1OvyIPhuvoc/3f8/ZxqmgTz9mDAOh6oWjNmJvTjy3ZhJrGdNsnE1OGIDMvY/OdGZ5z 8IYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=sx0EbduvWhbezU6TciToFvF89MJJ/Tzy3kJoGGSAEAI=; b=fZrVhdVj8EN7w7hEShF+i0a/x2Ud5WsPedO65QcgTAG+5cqU4YfN7x7RT6GI68fQBd a2G5xzPEZ5UAXRL679WehafRRs7HQuehKN1Aei4R8Vgx3rDGSPfQqOnJl6LVme0/DSre 0MgohlGcHD9exKF6DpmxIEDFc8FvT4f/SDbYS1OgEVu9Vb2pPuYSYEJDr7XLaFj1LlXk bObZRoAVI6bRSYj8qowOETKBEPME6NyaX4Qd0HUalVPcP6uRHYtMhj7zCRPFiQZmRgzR fZ3V2mWYJwIN/okGuRMeZCWFNzESkBXOy0ji66/Z+C1xrzip3HZzro6OR6J07n2Zpm/V 2FDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a17090322cd00b001aadd1e0384si9955320plg.192.2023.05.29.13.00.04; Mon, 29 May 2023 13:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229802AbjE2TzJ (ORCPT + 99 others); Mon, 29 May 2023 15:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbjE2TzH (ORCPT ); Mon, 29 May 2023 15:55:07 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 615CCF4; Mon, 29 May 2023 12:55:03 -0700 (PDT) X-QQ-mid: bizesmtp74t1685390094tpc5r986 Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:54:53 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: uGhnJwy6xZISo/AEbiO2R7D9Bkp1qAC1x25dTn245rn0AypFebeWwalodNjhE EL0Hxl2tTtRKwyjA9hWn6rJEMWZwJ13M7sTzYmfFM1VAENq33hSqeuCTSPxUjmRP8In5z0j jE3PPH0La2QBf3gtfL4qavbfPRbU9RB/PQuJibgW2/x+jjWS9xtIWSHbLtt65NMZEKdLaN8 dkZK4Ia/D7JyiFc+a1Kz4je5B5SnuVU37OtBIhZa6tgmgd8wfgtSuev0V/BKN+5P6bH/hRU 5o3Ae2l3mwfoTcHHys8UBybwBk03+OCAL3pFbxALn8Bt+8SyD8qmmeKLiKKhfao3WsglZUh Asti4FqiHE3VbrkVNKSBjtA3A/Az2xVvvEmvGiv9bla+QGTOev9aF8pmMHpuQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 5796279202276383086 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 07/13] tools/nolibc: sys_lseek: add pure 64bit lseek Date: Tue, 30 May 2023 03:54:23 +0800 Message-Id: <2f5c3338898da65210ad3f62d7b7773a96f6d251.1685387484.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767259941901444979?= X-GMAIL-MSGID: =?utf-8?q?1767259941901444979?= use sys_llseek instead of sys_lseek to add 64bit seek even in 32bit platforms. This code is based on sysdeps/unix/sysv/linux/lseek.c of glibc and src/unistd/lseek.c of musl. Signed-off-by: Zhangjin Wu Signed-off-by: Willy Tarreau --- tools/include/nolibc/sys.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 98cfa2f6d021..d0720af84b6d 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -672,7 +672,17 @@ int link(const char *old, const char *new) static __attribute__((unused)) off_t sys_lseek(int fd, off_t offset, int whence) { +#if defined(__NR_llseek) || defined(__NR__llseek) +#ifndef __NR__llseek +#define __NR__llseek __NR_llseek +#endif + off_t result; + return my_syscall5(__NR__llseek, fd, offset >> 32, offset, &result, whence) ?: result; +#elif defined(__NR_lseek) return my_syscall3(__NR_lseek, fd, offset, whence); +#else +#error None of __NR_lseek, __NR_llseek nor __NR__llseek defined, cannot implement sys_lseek() +#endif } static __attribute__((unused))