lkml.org 
[lkml]   [2015]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCHSET v2] ->follow_link() without dropping from RCU mode
On Fri, Dec 11, 2015 at 08:49:24AM +0100, Rasmus Villemoes wrote:

> union delayed_call_fn {
> void (*fn)(void *);
> void (*kfree_like)(const void *);
> } __attribute__((__transparent_union__));
>
> void
> set_delayed_call(struct delayed_call *call, union delayed_call_fn u, void *arg)
> {
> call->fn = u.fn;
> call->arg = arg;
> }

Yecchhhh... If we are into that kind of gccisms, I'd rather use
__builtin_choose_expr/__builtin_types_compatible_p. At least that is
used elsewhere in the kernel; __transparent_union__ kludge isn't. Sure, it
means having set_delayed_call() a macro, but IMO it's less nasty that way...

FWIW, another possibility is to have
#define CLOSURE_CALLBACK(f,type) \
static inline void __closure_##f(void *p) {return f((type)p);}

#define set_delayed_type(call, f, arg) \
sizeof(f(arg),0), \
__set_delayed_type(call, __closure_##f, (void *)arg)

That could be reused for timers with typechecking - we have a lot of timer
callbacks that start with casting the argument (unsigned long, not void *,
but that's not a big deal) to whatever it is that callback really wants,
with setup_timer() callers explicitly casting that whatever the callback
really wants to unsigned long. Which, of course, defeats the typechecking
by both cc(1) and sparse(1)...

I still hope for better solution, though... Comments?


\
 
 \ /
  Last update: 2015-12-12 01:01    [W:0.103 / U:0.736 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site