lkml.org 
[lkml]   [2004]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH] explicitly mark recursion count


On Wed, 2 Jun 2004, Jörn Engel wrote:
> >
> > If we have a good detector that is reliable and easy to run, why not?
>
> Great! So the official format to document recursions is plain english
> for human readers?

Actually, I'd suggest making it a preprocessor directive at the very top
of the function itself. That way I can make sparse parse it too if I ever
want to.

So something like

/*
* This function is part of recursion, but we limit
* the depth with the "depth" parameter to 5
*/
int my_recursive_function(int depth, struct datastruct *arg)
{
declare_recursion_depth(5);
...

where we could either just #define it to some no-op like

#define declare_recursion_depth(x) \
extern void __dummy_function_never_used()

or even do something fancier:

#define declare_recursion_depth(x) \
static __init char recursion[] = __FILE__ ":" __FUNCTION__ "=" #x;

which will generate a nice clean variable that shows up in "objdump" in
all its glory, so that pretty much any tool can trivially parse it.

And for something like sparse or other automated tools, we can trivially
make it be something more appropriate, ie

#define recursion_depth(x) \
__builtin_recursion_depth(x)

or whatever checker-specific thing we want it to be.

And other tools should be equally able to easily pick it up, either by
just looking at the object file or re-defining the macro to suit
themselves.

I think the above syntax is both human-readable and "obviously parseable"
in many trivial ways. Whaddaya think? Works for you?

Linus
-
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: 2009-11-18 23:46    [W:0.111 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site