From owner-cvs-src@FreeBSD.ORG Thu Nov 1 05:53:54 2007 Return-Path: Delivered-To: cvs-src@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 055E616A420 for ; Thu, 1 Nov 2007 05:53:54 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id 6284813C4B0 for ; Thu, 1 Nov 2007 05:53:53 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: (qmail invoked by alias); 01 Nov 2007 03:06:40 -0000 Received: from p54A3EA53.dip.t-dialin.net (EHLO tron.homeunix.org) [84.163.234.83] by mail.gmx.net (mp040) with SMTP; 01 Nov 2007 04:06:40 +0100 X-Authenticated: #1673122 X-Provags-ID: V01U2FsdGVkX1/1v412n1n12+xBU8UnuV9fLZ7Ew05M0djm38I4i8 3uNYCMz87L7vNv Message-ID: <472942BF.1080807@gmx.de> Date: Thu, 01 Nov 2007 04:06:39 +0100 From: Christoph Mallon User-Agent: Thunderbird 2.0.0.6 (X11/20070806) MIME-Version: 1.0 To: Andrey Chernov , Christoph Mallon , Juli Mallett , src-committers@FreeBSD.ORG, cvs-src@FreeBSD.ORG, cvs-all@FreeBSD.ORG References: <200710272232.l9RMWSbK072082@repoman.freebsd.org> <20071030200331.GA29309@toxic.magnesium.net> <20071031215526.GC89932@nagual.pp.ru> <47292F79.9030102@gmx.de> <20071101023803.GA94332@nagual.pp.ru> In-Reply-To: <20071101023803.GA94332@nagual.pp.ru> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 Cc: Subject: Re: cvs commit: src/include _ctype.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Nov 2007 05:53:54 -0000 Andrey Chernov wrote: > On Thu, Nov 01, 2007 at 02:44:25AM +0100, Christoph Mallon wrote: >> Also the example is still unrealistic: You usually don't multiply chars by >> two. Lets try something more realistic: an ASCII filter >> >> int filter_ascii0(int c) >> { >> return c < 0 || c >= 128 ? '?' : c; >> } >> >> int filter_ascii1(int c) >> { >> return c & ~0x7F ? '?' : c; >> } > > We don't need that reaslistic examples, we need only what __isctype() > does, and it just returns 0 or 1, not 'c'. Sorry, I don't understand what you want to tell me. I showed, that your example is invalid (because of undefined behaviour) and unrealistic, therefore I provided a better example on how this condition is used. But, of course, let's look at __isctype() in both variants: #include <_ctype.h> int my__isctype0(__ct_rune_t _c, unsigned long _f) { return (_c & ~0x7F) ? 0 : !!(_DefaultRuneLocale.__runetype[_c] & _f); } int my__isctype1(__ct_rune_t _c, unsigned long _f) { return (_c < 0 || _c >= 128) ? 0 : !!(_DefaultRuneLocale.__runetype[_c] & _f); } 00000000 : 0: 8b 4c 24 04 mov 0x4(%esp),%ecx 4: 31 d2 xor %edx,%edx 6: f7 c1 80 ff ff ff test $0xffffff80,%ecx c: 75 13 jne 21 e: 8b 44 24 08 mov 0x8(%esp),%eax 12: 85 04 8d 34 00 00 00 test %eax,0x34(,%ecx,4) 19: b8 01 00 00 00 mov $0x1,%eax 1e: 0f 45 d0 cmovne %eax,%edx 21: 89 d0 mov %edx,%eax 23: c3 ret 24: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 2a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000030 : 30: 8b 4c 24 04 mov 0x4(%esp),%ecx 34: 31 d2 xor %edx,%edx 36: 83 f9 7f cmp $0x7f,%ecx 39: 77 13 ja 4e 3b: 8b 44 24 08 mov 0x8(%esp),%eax 3f: 85 04 8d 34 00 00 00 test %eax,0x34(,%ecx,4) 46: b8 01 00 00 00 mov $0x1,%eax 4b: 0f 45 d0 cmovne %eax,%edx 4e: 89 d0 mov %edx,%eax 50: c3 ret Here, again, the value of _c does not die at the condition, so a test instruction is used, which results in the expected difference of three bytes. Christoph