Re: [linux-usb-devel] Re: [BUG/PATCH/RFC] Oops while completing async USB via usbdevio

From: linux-os (Dick Johnson)
Date: Tue Oct 11 2005 - 12:59:35 EST



On Tue, 11 Oct 2005, Paul Jackson wrote:

> Alan asked:
>> But why do people go to the
>> effort of confusing readers by using "^" instead of "!="?
>
> My guess - eor (^) was quicker than not-equal (!=) on a PDP-11.
>
> That code fragment for checking uid's has been around a -long-
> time, if my memory serves me.
>
> It's gotten to be like the infamous "!!" boolean conversion
> operator, a bit of vernacular that would be harder to read if
> recoded using modern coding style.
>
> --
> I won't rest till it's the best ...
> Programmer, Linux Scalability
> Paul Jackson <pj@xxxxxxx> 1.925.600.0401

Also, at one time, people used to spend a lot of time
minimizing the number of CPU cycles used in the code.

For instance, when it's appropriate, using XOR makes the
resulting generated code simpler and usually faster:

int funct0(int i)
{
return i ^ 1;
}
int funct1(int i)
{
return (i != 1);
}

int main()
{
int i;
for(i=0; i< 100; i++)
{
if(funct0(i))
printf("Yep %d\n", i);
if(funct1(i))
printf("Yep %d\n", i);
}
return 0;
}

gcc -O2 -fomit-frame-pointer ...

Here, funct0 clearly uses less code.

Disassembly of section .text:

00000000 <funct0>:
0: 8b 44 24 04 mov 0x4(%esp),%eax
4: 83 f0 01 xor $0x1,%eax
7: c3 ret

00000008 <funct1>:
8: 31 c0 xor %eax,%eax
a: 83 7c 24 04 01 cmpl $0x1,0x4(%esp)
f: 0f 95 c0 setne %al
12: c3 ret
13: 90 nop

00000014 <main>:
[SNIPPED...]




Cheers,
Dick Johnson
Penguin : Linux version 2.6.13 on an i686 machine (5589.44 BogoMips).
Warning : 98.36% of all statistics are fiction.
.

****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@xxxxxxxxxxxx - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/