Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753986Ab1D0T00 (ORCPT ); Wed, 27 Apr 2011 15:26:26 -0400 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.122]:37301 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751771Ab1D0T0Y (ORCPT ); Wed, 27 Apr 2011 15:26:24 -0400 X-Authority-Analysis: v=1.1 cv=pN6kzQkhXdmdOr6Akjoh3kGBD/S3UyPMKQp53EJY+ro= c=1 sm=0 a=i38SgkEfDKkA:10 a=5SG0PmZfjMsA:10 a=Q9fys5e9bTEA:10 a=OPBmh+XkhLl+Enan7BmTLg==:17 a=olKWhAQIiWJiAothbJ0A:9 a=xcnoRvYnU_7DFB1sL1kA:7 a=PUjeQqilurYA:10 a=OPBmh+XkhLl+Enan7BmTLg==:117 X-Cloudmark-Score: 0 X-Originating-IP: 67.242.120.143 Subject: Re: [PATCH] linux/string.h: Introduce streq macro. From: Steven Rostedt To: Pekka Enberg Cc: "H. Peter Anvin" , Thiago Farina , linux-kernel@vger.kernel.org, Alexey Dobriyan , Rusty Russell , Ingo Molnar , "David S. Miller" , Al Viro , "Ted Ts'o" , Christoph Hellwig In-Reply-To: <1303931761.18763.101.camel@gandalf.stny.rr.com> References: <1303926576.18763.75.camel@gandalf.stny.rr.com> <4DB86163.2070201@zytor.com> <1303931761.18763.101.camel@gandalf.stny.rr.com> Content-Type: text/plain; charset="ISO-8859-15" Date: Wed, 27 Apr 2011 15:26:22 -0400 Message-ID: <1303932382.18763.104.camel@gandalf.stny.rr.com> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2311 Lines: 63 On Wed, 2011-04-27 at 15:16 -0400, Steven Rostedt wrote: > On Wed, 2011-04-27 at 21:51 +0300, Pekka Enberg wrote: > 00000000000001df : > 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 > 1f1: 84 c0 test %al,%al > 1f3: 75 ee jne 1e3 > 1f5: b8 01 00 00 00 mov $0x1,%eax > 1fa: eb 02 jmp 1fe > 1fc: 31 c0 xor %eax,%eax > 1fe: c9 leaveq > 1ff: c3 retq I just noticed that 5 byte move instruction. So changing the function to bool, makes it a little nicer: bool streq(const char *cs, const char *ct) { unsigned char c1, c2; while (1) { c1 = *cs++; c2 = *ct++; if (c1 != c2) return false; if (!c1) break; } return true; } 00000000000001df : 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 08 jne 1f9 1f1: 84 c0 test %al,%al 1f3: 75 ee jne 1e3 1f5: b0 01 mov $0x1,%al 1f7: eb 02 jmp 1fb 1f9: 31 c0 xor %eax,%eax 1fb: c9 leaveq 1fc: c3 retq -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/