from <linux/compiler.h>, we have the "sparse" constructs for testing
contexts for things like synchronization:
...
# define __acquires(x) __attribute__((context(x,0,1)))
# define __releases(x) __attribute__((context(x,1,0)))
# define __acquire(x) __context__(x,1)
# define __release(x) __context__(x,-1)
# define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
...
and from the sparse man page:
"Functions with the extended attribute
__attribute__((context(expression,in_context,out_context))
require the context expression (for instance, a lock) to have the value
in_context (a constant nonnegative integer) when called, and return
with the value out_context (a constant nonnegative integer)."
so, as a random example of usage, we have:
...
static void *aarp_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(aarp_lock)
{
struct aarp_iter_state *iter = seq->private;
read_lock_bh(&aarp_lock);
iter->table = resolved;
iter->bucket = 0;
return *pos ? iter_next(iter, pos) : SEQ_START_TOKEN;
}
...
ok, that sounds reasonable, but what *exactly* is sparse testing in
the above? clearly, it can't just be comparing the "value" of
aarp_lock to either 0 or 1 -- aarp_lock is a *lock* which means it's a
structure, so it can't just have a simple "value" of 0 or 1.
not knowing any better, i'm assuming that what sparse is doing is
creating a separate context for a given object that's independent of
that object, and it's that corresponding context value that's being
tested. is that correct? or how is this working?
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
Have classroom, will lecture.
http://crashcourse.ca Waterloo, Ontario, CANADA
========================================================================
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ