Re: memset as memzero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Sat, 22 Sep 2007, Arjan van de Ven wrote:
> 
> it doesn't add value.... memset with a constant 0 is just as fast
> (since the compiler knows it's 0) than any wrapper around it, and the
> syntax around it is otherwise the same.

Indeed.

The reason we have "clear_page()" is not because the value we're writing 
is constant - that doesn't really help/change anything at all. We could 
have had a "fill_page()" that sets the value to any random byte, it's just 
that zero is the only value that we really care about.

So the reason we have "clear_page()" is because the *size* and *alignment* 
is constant and known at compile time, and unlike the value you write, 
that actually matters.

So "memzero()" would never really make sense as anything but a syntactic 
wrapper around "memset(x,0,size)". 

			Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux