From: Johan.Adolfsson@axis.com
To: "Davide Libenzi" <davidel@xmailserver.org>,
"Matthew Wilcox" <willy@debian.org>
Cc: "Patrick Mochel" <mochel@osdl.org>, <linux-kernel@vger.kernel.org>
Subject: Re: kobjects, sysfs and the driver model make my head hurt
Date: Mon, 7 Jul 2003 09:05:35 +0200 [thread overview]
Message-ID: <222e01c34456$2a054310$e2070d0a@pcjohana> (raw)
In-Reply-To: <Pine.LNX.4.55.0307060935140.14675@bigblue.dev.mcafeelabs.com>
----- Original Message -----
From: "Davide Libenzi" <davidel@xmailserver.org>
To: "Matthew Wilcox" <willy@debian.org>
Cc: "Patrick Mochel" <mochel@osdl.org>; <linux-kernel@vger.kernel.org>
Sent: Sunday, July 06, 2003 6:42 PM
Subject: Re: kobjects, sysfs and the driver model make my head hurt
> On Sun, 6 Jul 2003, Matthew Wilcox wrote:
>
> > Why on earth does it return the value of its argument?
>
> Maybe for the same reason 'strcpy' returns 'dest'. It allows you to use
> the function in a function parameter :
Another possible benefit (although I'm not sure we should care)
is that if the return variable is the same as the first argument,
the compiler can save an instruction or two on at least some archs.
Simple example:
char *tst(char *p, int i)
{
return p;
}
void tst2(char *p, int i)
{
*p = i;
p = tst(p,i);
p[1]=i;
}
void tst3(char *p, int i)
{
*p = i;
tst(p,i);
p[1]=i;
}
i386 ts2 saves 3 instructions compared to tst3
tst2:
pushl %ebp
movl %esp,%ebp
subl $20,%esp
pushl %ebx
movl 8(%ebp),%eax
movl 12(%ebp),%ebx
movb %bl,(%eax)
addl $-8,%esp
pushl %ebx
pushl %eax
call tst
movb %bl,1(%eax)
movl -24(%ebp),%ebx
leave
ret
.Lfe2:
.size tst2,.Lfe2-tst2
.align 4
.globl tst3
.type tst3,@function
tst3:
pushl %ebp
movl %esp,%ebp
subl $16,%esp
pushl %esi
pushl %ebx
movl 8(%ebp),%esi
movl 12(%ebp),%ebx
movb %bl,(%esi)
addl $-8,%esp
pushl %ebx
pushl %esi
call tst
movb %bl,1(%esi)
leal -24(%ebp),%esp
popl %ebx
popl %esi
leave
ret
.Lfe3:
On CRIS you save one register on stack instead of two
tst2:
Push $srp
subq 4,$sp
movem $r0,[$sp]
move.d $r10,$r9
move.d $r11,$r0
move.b $r11,[$r9]
Jsr tst
move.b $r0,[$r10+1]
movem [$sp+],$r0
Jump [$sp+]
.Lfe2:
.size tst2,.Lfe2-tst2
.align 1
.global tst3
.type tst3,@function
tst3:
Push $srp
subq 8,$sp
movem $r1,[$sp]
move.d $r10,$r0
move.d $r11,$r1
move.b $r11,[$r0+]
Jsr tst
move.b $r1,[$r0]
movem [$sp+],$r1
Jump [$sp+]
.Lfe3:
/Johan
next prev parent reply other threads:[~2003-07-07 6:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-06 16:33 Matthew Wilcox
2003-07-06 16:42 ` Davide Libenzi
2003-07-06 17:03 ` James Morris
2003-07-06 17:15 ` Jeff Garzik
2003-07-07 7:05 ` Johan.Adolfsson [this message]
2003-07-06 16:46 ` Greg KH
2003-07-06 16:54 ` Jeff Garzik
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='222e01c34456$2a054310$e2070d0a@pcjohana' \
--to=johan.adolfsson@axis.com \
--cc=davidel@xmailserver.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@osdl.org \
--cc=willy@debian.org \
/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®