X-Spam-Check-By: sourceware.org From: "Dave Korn" To: References: <20070121143731 DOT GC25379 AT ns1 DOT anodized DOT com> <009401c73d79$4cf91d40$a501a8c0 AT CAM DOT ARTIMI DOT COM> Subject: RE: cygwin source question Date: Mon, 22 Jan 2007 10:42:19 -0000 Message-ID: <00b401c73e11$fdc39d10$a501a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On 22 January 2007 08:19, Yitzchak Scott-Thoennes wrote: > > Some people prefer (expr) ? 1 : 0, which looks a lot worse to me than > !!(expr). > Compiles to the exact same thing at -O0 and at -O2, as it happens... /tmp $ gcc -x c -S -o - - int foo (int argc) { return (argc == 23) ? 1 : 0; } int bar (int argc) { return !!(argc == 23); } .file "" .text .globl _foo .def _foo; .scl 2; .type 32; .endef _foo: pushl %ebp movl %esp, %ebp cmpl $23, 8(%ebp) sete %al movzbl %al, %eax popl %ebp ret .globl _bar .def _bar; .scl 2; .type 32; .endef _bar: pushl %ebp movl %esp, %ebp cmpl $23, 8(%ebp) sete %al movzbl %al, %eax popl %ebp ret @_______. . ( /"\ ||--||(___) '" '"'---' /tmp $ gcc -O0 -x c -S -o - - int foo (int argc) { return (argc == 23) ? 1 : 0; } int bar (int argc) { return !!(argc == 23); } .file "" .text .globl _foo .def _foo; .scl 2; .type 32; .endef _foo: pushl %ebp movl %esp, %ebp cmpl $23, 8(%ebp) sete %al movzbl %al, %eax popl %ebp ret .globl _bar .def _bar; .scl 2; .type 32; .endef _bar: pushl %ebp movl %esp, %ebp cmpl $23, 8(%ebp) sete %al movzbl %al, %eax popl %ebp ret @_______. . ( /"\ ||--||(___) '" '"'---' /tmp $ gcc -O2 -x c -S -o - - int foo (int argc) { return (argc == 23) ? 1 : 0; } int bar (int argc) { return !!(argc == 23); } .file "" .text .p2align 4,,15 .globl _foo .def _foo; .scl 2; .type 32; .endef _foo: pushl %ebp xorl %eax, %eax movl %esp, %ebp cmpl $23, 8(%ebp) popl %ebp sete %al ret .p2align 4,,15 .globl _bar .def _bar; .scl 2; .type 32; .endef _bar: pushl %ebp xorl %eax, %eax movl %esp, %ebp cmpl $23, 8(%ebp) popl %ebp sete %al ret @_______. . ( /"\ ||--||(___) '" '"'---' /tmp $ ... so no reason not to choose whichever you like the best. cheers, DaveK -- Can't think of a witty .sigline today.... -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/