lkml.org 
[lkml]   [2004]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] add wait_event_interruptible_exclusive() macro
Christoph wrote:
> In this case a macro is the only sensible way. Check how the arguments
> are used in wait_event_*

Are you referring to such usages as the "&wq" in this line:

> add_wait_queue_exclusive(&wq, &__wait);

If so, then yes, a macro is needed. This is a poor man's implicit pass
by reference. In straight C, not using macros, saying "foo(x)" pushes
the value of 'x' on the stack, not the address of 'x'. This macro
pushes the _address_ of 'x' on the stack (x == wq), but doesn't require
the "address of" operator, "&", as in foo(&x), to be explicitly coded.
Hence, straight C is insufficient to the task.

I don't know if it applies in this case, but one can mix macros with
inlines, to get both this implicit pass by reference, and get some
type checking on the arguments. See my dreaded cpumask patch, in the
latest *-mm patch series, for many examples.

They look like:

#define foo(x) __foo(&(x))

static inline void __foo(int *xp) \
{ \
printk("addr of x is %p\n", xp); \
}

This both provides implicit pass by reference, and checks that the
argument and return types are as intended (to within the range of
C's automatic type conversions ;).

Be aware that I am engaging in drive-by-commenting here, which is
commenting on a phrase that jumped out at me, without any effort to
look around at the larger picture. Damage due to collateral fire is
not uncommon in such cases ;).

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
-
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: 2005-03-22 14:04    [W:0.467 / U:0.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site