Re: [PATCHSET v2] ->follow_link() without dropping from RCU mode
From: Al Viro
Date: Fri Dec 11 2015 - 21:00:37 EST
On Fri, Dec 11, 2015 at 11:16:24PM +0000, Al Viro wrote:
> #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?
Hmm...
#define set_delayed_type(call, f, arg) \
(sizeof(f(arg),0), \
__set_delayed_type(call, ({ \
void _(void *__) {f((typeof(arg))(unsigned long)__);} \
_;}), (void *)arg))
woult do nicely, but it's a gccism, and the one clang doesn't support ;-/
gcc support goes back at least to 4.1, not sure about the earlier branches
(and not at all sure how flaky it was/is, obviously).
But this thing works for e.g. f being void(char) and arg being char,
and AFAICS generates correct code - we end up with a stub like
_.1765:
movsbl %dil, %edi
jmp f
and its address gets stored in call->fn, which should DTRT on call...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/