mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ruth Ivimey-Cook <Ruth.Ivimey-Cook@ivimey.org>
To: root@chaos.analogic.com, Jeff Garzik <jgarzik@pobox.com>
Cc: Linus Torvalds <torvalds@transmeta.com>,
	Rusty Trivial Russell <rusty@rustcorp.com.au>,
	linux-kernel@vger.kernel.org
Subject: Re: [TRIVIAL] kstrdup
Date: Sat, 19 Apr 2003 21:16:41 +0100	[thread overview]
Message-ID: <5.2.0.9.0.20030419211356.024884a8@mailhost.ivimey.org> (raw)
In-Reply-To: <Pine.LNX.4.53.0304181512220.22901@chaos>

At 20:29 18/04/2003, Richard B. Johnson wrote:
> > > A lot of persons who are unfamiliar with tools other than 'C' think
> > > that strcpy() is made like this:
> > >
> > >     while(*dsp++ = *src++)
> > >                    ;
> >
> > In fact, that's basically the kernel's non-arch-specific implementation :)
> >
> >       Jeff
>
>Yep. Naive code looks so 'simple', must be "optimum", no? ;^).


Well, actually on ARM at least it is optimal, given the likely short length 
of strings. To do any better at all you have to assume stringlength of many 
tens of words, which is unlikely. For comparison, this is what armcc 
produces for the above code:

                   strdup PROC
                   |L1.0|
000000  e4d12001          LDRB     a3,[a2],#1            ;1
000004  e4c02001          STRB     a3,[a1],#1            ;1
000008  e3520000          CMP      a3,#0                 ;1
00000c  1afffffb          BNE      |L1.0|                ;1
000010  e1a0f00e          MOV      pc,lr                 ;1


AFAICT there is no better solution.

Ruth


  parent reply	other threads:[~2003-04-19 20:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-18  7:58 Rusty Trivial Russell
2003-04-18  8:10 ` Jeff Garzik
2003-04-18 16:20   ` Linus Torvalds
2003-04-18 16:56     ` Jeff Garzik
2003-04-18 18:00       ` Linus Torvalds
2003-04-18 18:44         ` Jeff Garzik
2003-04-19  4:52         ` Rusty Russell
2003-04-18 18:00       ` Richard B. Johnson
2003-04-18 18:40         ` Jeff Garzik
2003-04-18 19:24           ` H. Peter Anvin
2003-04-18 23:37             ` Alan Cox
2003-04-18 19:29           ` Richard B. Johnson
2003-04-19 11:45             ` Kai Henningsen
2003-04-19 20:16             ` Ruth Ivimey-Cook [this message]
2003-04-19  4:14   ` Rusty Russell
2003-04-19  4:48     ` Jeff Garzik
2003-04-19  8:28       ` Rusty Russell
2003-04-19 12:27       ` Alan Cox
2003-04-19 14:44         ` Bernd Eckenfels
2003-04-20  8:05         ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5.2.0.9.0.20030419211356.024884a8@mailhost.ivimey.org \
    --to=ruth.ivimey-cook@ivimey.org \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=root@chaos.analogic.com \
    --cc=rusty@rustcorp.com.au \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®