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 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...


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