[Toybox] PM: code style, was: Re: New Subscriber

Frank Bergmann toybox at tuxad.com
Wed Feb 15 04:45:14 PST 2012


Hi Rob,

On Wed, Feb 15, 2012 at 06:10:38AM -0600, Rob Landley wrote:
> > ... at least it is better readable if you use this nice kernel macros
> > __likely() and unlikely(). ;-)
> 
[...]
> http://lwn.net/Articles/419102/
> http://lwn.net/Articles/404103/
> http://lwn.net/Articles/444336/
> http://lwn.net/Articles/166172/

- I guess my smilies are far too small ;-)
- I just mentioned the kernel macro which uses the gcc-function
  __builtin_expect which is useful if you don't use gcc-profiling and you
  are pretty sure about your optimization (reduce branches by falling
  through a conditional branch in most cases)
- your references are about prefetch, manually prefetches shouldn't be
  done, of course I fully agree

> > Did I wrote "IMHO"? ;-) K&R IMHO doesn't know anything about void. A
> > pointer char* was the universal pointer which may be "converted" (without
> > explicit casting) to any other pointer and vice versa. C99 (and the
> > standard before it) IMHO introduced void at least for this role. And IMHO
> > a non-explicit cast is only allowed for void* and not for char* anymore.
> 
> This is the _compiler_ goign overboard with microoptimizations, if you
> ask me.  I treat it the same way I treat the "may be used uninitialized,
> even though it isn't in this case" warning.  (Which you can apparently
> disable with "int x=x;" in your declarations, which is a syntax
> specifically to tell it to shut up about that, but still way too magic
> for my tastes.)

Full ACK, but you mixed up two points.
You asked me about sort.c, char**, char* and void*. I only said that IMHO
void* may be converted without casting to any other pointer. The
old-fashioned K&R C doesn't know void and uses char* for this "role"
(IMHO).

Frank


 1329309914.0


More information about the Toybox mailing list