From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karl Nasrallah Date: Wed, 18 Dec 2019 03:56:03 +0000 Subject: Re: can someone solve string_32.h issue for SH ? Message-Id: <2107393677.694216.1576641363699@mail.yahoo.com> List-Id: References: <339916914.636876.1576627652112.ref@mail.yahoo.com> <339916914.636876.1576627652112@mail.yahoo.com> <87tv5yjssb.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87tv5yjssb.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: kuninori.morimoto.gx@renesas.com Cc: dalias@libc.org, geert@linux-m68k.org, ysato@users.sourceforge.jp, linux-sh@vger.kernel.org, linux-renesas-soc@vger.kernel.org Hello, Though ultimately I do not have a say in that, it would appear that string_32.h is in arch/sh/include/asm and has been there for a very long time. In fact, it appears that x86 also has similar utility functions defined in inline assembly: see arch/x86/include/asm. As straightforward as it would be to make C versions, there may be a reason that they are in inline assembly--optimization would be my guess--and converting it all to C may require an overhaul of the string.h backend (something I would not be much help with given that I am unable to get modern Linux booting on my machine, which is a Sega Dreamcast). I also do not know what the performance implications of switching it all to C would be, if there even are any. Hopefully this information may be useful and my asm version is alright for the time being; I have not been able to unearth much more on the topic of why this is structured the way it is, -Karl Nasrallah -----Original Message----- From: Kuninori Morimoto To: Karl Nasrallah Cc: dalias ; geert ; ysato ; linux-sh ; linux-renesas-soc Sent: Tue, Dec 17, 2019 9:01 pm Subject: Re: can someone solve string_32.h issue for SH ? Hi > You're using r0 explicitly in the asm but I don't see where you're > reserving it for your use. You need it either on the clobbers or bound > to a dummy output with earlyclobber. (snip) >     __asm__ __volatile__ ( >                     "strncpy_start:\n\t" >                             "mov.b @%[src]+,%[r0_reg]\n\t" >                             "cmp/eq #0,%[r0_reg]\n\t" >                             "bt.s strncpy_pad\n\t" >                             "cmp/eq %[dest],%[dest_end]\n\t" >                             "bt.s strncpy_end\n\t" >                             "mov.b %[r0_reg],@%[dest]\n\t" >                             "bra strncpy_start\n\t" >                             "add #1,%[dest]\n\t" >                     "strncpy_pad:\n\t" >                             "bt.s strncpy_end\n\t" >                             "mov.b %[r0_reg],@%[dest]\n\t" >                             "add #1,%[dest]\n\t" >                             "bra strncpy_pad\n\t" >                             "cmp/eq %[dest],%[dest_end]\n\t" >                     "strncpy_end:\n\t" >         : [src] "+r" (__src), [dest] "+r" (__dest), [r0_reg] "+&z" (r0_register) >         : [dest_end] "r" (__dest_end) >         : "t","memory" >     ); Or, can we use general strncpy() instead of SH assemble one ? Thank you for your help !! Best regards --- Kuninori Morimoto From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 820E5C43603 for ; Wed, 18 Dec 2019 03:56:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A7AC2146E for ; Wed, 18 Dec 2019 03:56:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=aol.com header.i=@aol.com header.b="d5lX73Ut" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbfLRD4G (ORCPT ); Tue, 17 Dec 2019 22:56:06 -0500 Received: from sonic302-20.consmr.mail.ne1.yahoo.com ([66.163.186.146]:38690 "EHLO sonic302-20.consmr.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726454AbfLRD4F (ORCPT ); Tue, 17 Dec 2019 22:56:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1576641364; bh=4BwB++bD5VfFZKTliBHkaMvpSnyzxdPPN6Ewh7w1Sjo=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject; b=d5lX73UtBsWhi/9FW+he4jB6pV3CDvDjNYS+xgOFBFEkFuwDNEGbGi4Mo/YWWGtQylHRUq+G65DwaabV1CW2atm6OdeyLSxym5bEk8mKG/O6SDd4a82Kf56q9U8D8GrrosvT2jAgBnLxFXYglN9slnMP72hBLrsyANTs/DBNWmOZVtYWg9w6TdFe+K4VgHiGRtEvE7gG3B/1e/Mcq12r1vOnxKfgANXHQHO6oERIA7OwXntEfe+9bEwyhnHCAYz4kximsC34jzvcp8NenkwPs3UvLenFWbiSb0KBmGM0MHzFg0azu3dN5pSN1CZKIJAf12Ou3xLIGLmb9cjSMYKGdA== X-YMail-OSG: jDXrU.sVM1lCnWa76OhBbNcG1hOuYHQnj3U3KDN6RWqAkemUlpLZ.BSdP9gjszV iTm3N5LA9z95RFW84fqQDCg5XcbGngxdiZA4zUQE_JKqVzHjOyTdtVil0r6C_RGe1WGjJET4wpHV f0ZKjJMunZXpCuLcGIQpod4PUrlyGez5imYmyr2SCrdLXOVVocJTu3fxr49qTpWeCg1EulPGEoqn dB.wbfVqSmVZOpbb5AWDmmhek7Zw7spNdqtq8swLgjviA6KlgdIWZLvr3zN51JehgbN4.PxUt_Dj zdiE_Qp2nPL5.r3_OSKWc8GOofz3zbWpjvVaM.rstKLBWLGcAaRrw7n3Kzp28TDoeUnmuOTqiBEZ k5PlVM6u2pobgmxSpbfVI96N8fY_wK9LSSOByf1zJwoZIwqdbqnfSzNdEp8HYclvUWNlWPlI4N5m GIqnkar0v6pDbhmbPjL0HlfLiq6ZE1KmNZqFNVFOCFwSo1k9S3tTEF0dSnQTzSrEElE9qxgJG8ev GhVMYmR60ZEXMhuDlVy4rfHIYjBGPfIx3BPsa1X6snzc6oqdEq8oDDNaAwe_W8SaNfQTzwa8IMYp GfQ4f_gSQgEmH0UgywmOiGtUgE74CjEiYT_QuDbTbjq6apFSWS9WviEv4llEMJ6KjKYBYiWWkBCH GT_xZkQ_SMKHd5BfbgTjUanv7rDmcyZhuje9Vn5TUe5v9HuyUM9ptyjd3kXge6rXhF3oukAYp.a9 ah01bx2p7oHDLvkM0FXlUy3fL6IuH4xlTOXPqy0kqnniQnCHRRAMAf7jE7ffG9YQgszKJnNVj7Xi S1QgkqGVJVn7xU2USXCQ6epM2O5eSl8ISn.6XKC2n_33onX5LOhY6n1mvvfYULuu13kdHvKyQAfZ vz20bF5iHfxJ1GHfpx9OJofWDNEK6sUwoEZDALeEdwFf1iAA8_NMExOFgYcYL4Y7TUKmaQ0TDBg3 BoS9qGAT4al1FNLrL.EDzpHsngE4A7BtZcAKsLLxU206qPdvxVlE1ClQiDCxk1JWFdX7suiDWza5 PL8URR5k8_sxOA1G3gyuXyLqn0rAg6xFBihgwX0huvF2fv.6MdkEyr8jR7onSHRXx4Bp9PSwVA2x .CUyyIa6TbRL.vOA_INbVSLkPC1yDj9hLqOYv_qEfdEi90lKlR1bei8L_q5AEd.h2nWnPyoHiF5a LNCgt4Ma9IudlqyqEHcr5qNktuf4_EssTQqKEOyvt7CtCh83h0tlV89PrshRDUD5dtBke5oifBBe W1B6_HrV49gGRj5MOl4iECULwQF5xNB_7LIZOT3x3FWnnacbigiHjE8g4Nxy1zEe_LQ-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ne1.yahoo.com with HTTP; Wed, 18 Dec 2019 03:56:04 +0000 Date: Wed, 18 Dec 2019 03:56:03 +0000 (UTC) From: Karl Nasrallah To: kuninori.morimoto.gx@renesas.com Cc: dalias@libc.org, geert@linux-m68k.org, ysato@users.sourceforge.jp, linux-sh@vger.kernel.org, linux-renesas-soc@vger.kernel.org Message-ID: <2107393677.694216.1576641363699@mail.yahoo.com> In-Reply-To: <87tv5yjssb.wl-kuninori.morimoto.gx@renesas.com> References: <339916914.636876.1576627652112.ref@mail.yahoo.com> <339916914.636876.1576627652112@mail.yahoo.com> <87tv5yjssb.wl-kuninori.morimoto.gx@renesas.com> Subject: Re: can someone solve string_32.h issue for SH ? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Mailer: WebService/1.1.14873 aolwebmail Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Hello, Though ultimately I do not have a say in that, it would appear that string_= 32.h is in arch/sh/include/asm and has been there for a very long time. In = fact, it appears that x86 also has similar utility functions defined in inl= ine assembly: see arch/x86/include/asm. As straightforward as it would be t= o make C versions, there may be a reason that they are in inline assembly--= optimization would be my guess--and converting it all to C may require an o= verhaul of the string.h backend (something I would not be much help with gi= ven that I am unable to get modern Linux booting on my machine, which is a = Sega Dreamcast). I also do not know what the performance implications of sw= itching it all to C would be, if there even are any. Hopefully this information may be useful and my asm version is alright for = the time being; I have not been able to unearth much more on the topic of w= hy this is structured the way it is, -Karl Nasrallah -----Original Message----- From: Kuninori Morimoto To: Karl Nasrallah Cc: dalias ; geert ; ysato ; linux-sh ; linux-renesas-soc= Sent: Tue, Dec 17, 2019 9:01 pm Subject: Re: can someone solve string_32.h issue for SH ? Hi > You're using r0 explicitly in the asm but I don't see where you're > reserving it for your use. You need it either on the clobbers or bound > to a dummy output with earlyclobber. (snip) > =C2=A0=C2=A0=C2=A0 __asm__ __volatile__ ( > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 "strncpy_start:\n\t" > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 "cmp/eq %[dest= ],%[dest_end]\n\t" > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 "strncpy_end:\n\t" > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 : [src] "+r" (__src), [dest] "+r" (= __dest), [r0_reg] "+&z" (r0_register) > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 : [dest_end] "r" (__dest_end) > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 : "t","memory" > =C2=A0=C2=A0=C2=A0 ); Or, can we use general strncpy() instead of SH assemble one ? Thank you for your help !! Best regards --- Kuninori Morimoto