Re: [PATCH 4/6] Implement a general log2 facility in the kernel



On Wed, Sep 13, 2006 at 10:31:36AM -0600, Matthew Wilcox wrote:
On Wed, Sep 13, 2006 at 06:17:34PM +0200, Adrian Bunk wrote:
On Wed, Sep 13, 2006 at 02:03:00PM +0100, David Howells wrote:
From: David Howells <dhowells@xxxxxxxxxx>

This facility provides three entry points:

log2() Log base 2 of u32
...

Considering that several arch maintainers have vetoed my patch to revert
the -ffreestanding removal Andi sneaked in with his usual trick to hide
generic patches as "x86_64 patch", such a usage of a libc function name
with a signature different from the one defined in ISO/IEC 9899:1999 is
a namespace violation that mustn't happen.

log2 is only defined if math.h gets included. If we're including math.h
at any point in the kernel itself (excluding the bootloader and similar),
we're already screwed six ways from sunday.

Adrian's point is that gcc without -ffreestanding may decide to implement
log2() itself by issuing the appropriate floating point instructions
rather than using a function call into a library to do this operation.

Therefore, re-using "log2()" is about as bad as re-using the "strcmp()"
name to implement a function which copies strings.

And, sure enough, try throwing this at a compiler:

int log2(int foo)
{
return foo;
}

you get:

t.c:2: warning: conflicting types for built-in function 'log2'

but not if you use -ffreestanding.

Don't re-use C standard library identifiers (or use -ffreestanding.)

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
-
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/



Relevant Pages

  • Re: [PATCH] module_author: dont advice putting in an email address
    ... Adrian Bunk had a valid argument against it and it's one of the arguments that exist against MODULE_AUTHOR as well; the address would live on "forever" as part of Linux installs. ... Then the dog eats my foo and I can't maintain it anymore since I can't test; off goes a patch removing MODULE_MAINTAINER from the source and/or the MAINTAINERS file but I can't do anything about all the existing installs that proudly announce my address as a contact for foo. ... The advice of putting in an email address is generally bad advice. ...
    (Linux-Kernel)
  • Re: CONFIG_HIGHPTE vs. sub-page page tables.
    ... must be defined for every architecture. ... The patch was posted multiple times on linux-arch and it has been part ... Plenty of time for the arch maintainers to notice. ... the person posting the changes does all the footwork to make ...
    (Linux-Kernel)
  • Re: a relatively major problem with ext2.
    ... On 3/9/05, Peter Edwards wrote: ... The patch still applies in today's ... # rm -rf foo ...
    (freebsd-current)
  • Re: make -U
    ... > that make couldn't unset variables using make -U. ... > a small patch that adds -U functionality, ... > .ifdef FOO ... and affects all makefiles wishing to ...
    (freebsd-arch)
  • Re: [PATCH 9/36] drivers edac new intel 5000X mc driver
    ... Here's a small patch against v.3 that will catch this. ... already has checks for reporting the foo ** bar style cast format ... it is hard to tell them from the foo * foo multiply form, ...
    (Linux-Kernel)