From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED, URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1693573593; bh=Yh7Bhhmj/N2hz2kgioBCdiLSuNHPhfwNfuEtq7aDPuA=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=MNzOqLab6Kv48mCwiH4BHhFBK/849CuzdybHQUl1gg48XQ+s+83rumFh0PrIwo6qF 2ZmEPdaOoeR1WG5ncfR5HplqgF/0omGKgT6nLFPo4aCNLY8uhSqbpufMzrB77T4hPd Q8UY/c1lY9OrzPr7/Ca76TiaSOGdV/FDWo2eeNkfe0nmuNnrVBGP4AU7aZSvIXrPw1 y5fehwuszH53w0mlFzesRB43jJqJlK8ZeQJ0+tJkqWxuFMJpVjHs815w8spA19/QpN IkToA8wYAaOm1iA8RGo7FCo2QCqloqtztHLJ89vd6BY3YbpKZJbwHv/jNn9VOGnJ9A 4xsV8q6ByR3ig== Received: from biznet-home.integral.gnuweeb.org (unknown [182.253.126.208]) by gnuweeb.org (Postfix) with ESMTPSA id 727FC24B374; Fri, 1 Sep 2023 20:06:30 +0700 (WIB) Date: Fri, 1 Sep 2023 20:06:25 +0700 From: Ammar Faizi To: Willy Tarreau Cc: David Laight , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Nicholas Rosenberg , Alviro Iskandar Setiawan , Michael William Jonathan , GNU/Weeb Mailing List , Linux Kernel Mailing List Subject: Re: [RFC PATCH v1 0/5] nolibc x86-64 string functions Message-ID: References: <20230830135726.1939997-1-ammarfaizi2@gnuweeb.org> <5a821292d96a4dbc84c96ccdc6b5b666@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bpl: hUx9VaHkTWcLO7S8CQCslj6OzqBx2hfLChRz45nPESx5VSB/xuJQVOKOB1zSXE3yc9ntP27bV1M1 List-Id: On Fri, Sep 01, 2023 at 01:46:44PM +0200, Willy Tarreau wrote: > On Fri, Sep 01, 2023 at 11:34:18AM +0000, David Laight wrote: > > Isn't that completely broken? > > > > You need to select between forwards and backwards moves. > > Since forwards moves are preferred it is best to do > > if (dst - src < len) > > backards_copy() > > else > > formwards_copy() > > > > David > > You're completely right indeed, reminds me about the copy_up/copy_down > that were not used anymore :-) I'm an idiot, will fix that. Another attempt as suggested below: __asm__ ( ".section .text.nolibc_memmove\n" ".weak memmove\n" "memmove:\n" " movq %rdx, %rcx\n" " movq %rdi, %rdx\n" " movq %rdi, %rax\n" " subq %rsi, %rdx\n" " cmpq %rcx, %rdx\n" " jnb .Lforward_copy\n" " leaq -1(%rdi, %rcx, 1), %rdi\n" " leaq -1(%rsi, %rcx, 1), %rsi\n" " std\n" ".Lforward_copy:\n" " rep movsb\n" " cld\n" " ret\n" ); -- Ammar Faizi