lkml.org 
[lkml]   [2007]   [Sep]   [28]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
FromKyle Moffett <>
SubjectRe: [RFC] New kernel-message logging API (take 2)
DateFri, 28 Sep 2007 03:44:24 -0400
On Sep 28, 2007, at 03:31:11, Geert Uytterhoeven wrote:
> Can't you store the loglevel in the kprint_block and check it in  
> all successive kprint_*() macros? If gcc knows it's constant, it  
> can optimize the non-wanted code away. As other fields in struct  
> kprint_block cannot be constant (they store internal state), you  
> have to split it like:
>
>     struct kprint_block {
> 	    int loglevel;
> 	    struct real_kprint_block real;  /* internal state */
>     }
>
> and pass &block.real() instead of &block to all successive internal  
> functions.  I haven't tried this, so let's hope gcc is actually  
> smart enough...

Well actually, I believe you could just do:

struct kprint_block {
	const int loglevel;
	[...];
};
Then cast away the constness to actually set it initially:
*((int *)&block.loglevel) = LOGLEVEL;

Cheers,
Kyle Moffett

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

\
 
 \ /
  Last update: 2007-09-28 09:47    [from the cache]
©2003-2008