[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1303931761.18763.101.camel@gandalf.stny.rr.com>
Date: Wed, 27 Apr 2011 15:16:01 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Pekka Enberg <penberg@...nel.org>
Cc: "H. Peter Anvin" <hpa@...or.com>,
Thiago Farina <tfransosi@...il.com>,
linux-kernel@...r.kernel.org,
Alexey Dobriyan <adobriyan@...il.com>,
Rusty Russell <rusty@...tcorp.com.au>,
Ingo Molnar <mingo@...e.hu>,
"David S. Miller" <davem@...emloft.net>,
Al Viro <viro@...iv.linux.org.uk>, Ted Ts'o <tytso@....edu>,
Christoph Hellwig <hch@...radead.org>
Subject: Re: [PATCH] linux/string.h: Introduce streq macro.
On Wed, 2011-04-27 at 21:51 +0300, Pekka Enberg wrote:
> It's the same kind of API extension kstrdup(), for example, is.
> Whether or not we should it do it is a separate matter and I think the
> only reasonable argument for and against is whether it (a) reduces the
> number of bugs,
I did a quick search through the git logs, and found no bug fixes due to
the semantics. At least by the time it got to mainline, they are fixed
(which is a good thing).
> (b) improves code readability significantly,
This is a matter of preference. I think I would prefer it, but obviously
others do not.
> or (c)
> generates better code.
If we implement streq() separately from strcmp() it gets slightly
better:
00000000000001be <strcmp>:
1be: 55 push %rbp
1bf: 48 89 e5 mov %rsp,%rbp
1c2: 8a 07 mov (%rdi),%al
1c4: 8a 16 mov (%rsi),%dl
1c6: 48 ff c7 inc %rdi
1c9: 48 ff c6 inc %rsi
1cc: 38 d0 cmp %dl,%al
1ce: 74 07 je 1d7 <strcmp+0x19>
1d0: 19 c0 sbb %eax,%eax
1d2: 83 c8 01 or $0x1,%eax
1d5: eb 06 jmp 1dd <strcmp+0x1f>
1d7: 84 c0 test %al,%al
1d9: 75 e7 jne 1c2 <strcmp+0x4>
1db: 31 c0 xor %eax,%eax
1dd: c9 leaveq
1de: c3 retq
00000000000001df <streq>:
1df: 55 push %rbp
1e0: 48 89 e5 mov %rsp,%rbp
1e3: 8a 07 mov (%rdi),%al
1e5: 8a 16 mov (%rsi),%dl
1e7: 48 ff c7 inc %rdi
1ea: 48 ff c6 inc %rsi
1ed: 38 d0 cmp %dl,%al
1ef: 75 0b jne 1fc <streq+0x1d>
1f1: 84 c0 test %al,%al
1f3: 75 ee jne 1e3 <streq+0x4>
1f5: b8 01 00 00 00 mov $0x1,%eax
1fa: eb 02 jmp 1fe <streq+0x1f>
1fc: 31 c0 xor %eax,%eax
1fe: c9 leaveq
1ff: c3 retq
-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists