Re: [PATCH 0/6] RFC: Typesafe callbacks

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Tejun Heo <htejun@...>
Cc: Linus Torvalds <torvalds@...>, Andrew Morton <akpm@...>, <linux-kernel@...>, Jeff Garzik <jeff@...>
Date: Sunday, January 20, 2008 - 6:17 pm

On Monday 21 January 2008 00:00:52 Tejun Heo wrote:

For everything but timer, you'll get a warning if the data isn't assignable to 
a void *, so you get a warning if you use a non-pointer already.

But it would be cool to allow functions which take an unsigned long.  To do 
this, I think that would need to be a special case for the data arg (which 
we'd really want to wrap in a macro), like:

	/* If fn expects an unsigned long, cast the data.  If not, we'll
	 * get a warning if data is not void * compatible. */
	__builtin_choose_expr(__builtin_compatible_p(typeof(1?(threadfn):NULL),
			      int (*)(unsigned long)),
			      (void *)(unsigned long)(data), (data))


Hmm, u64 on 32-bit platforms?  I think that will fail the above test: the type 
of the function ptr will be "int (*)(u64)" and so you'll end up passing data 
(a u64) to a void * argument, which will elicit a warning...

I'll test this out and see what I can make...

Thanks!
Rusty.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/6] RFC: Typesafe callbacks, Rusty Russell, (Sun Jan 20, 5:46 am)
Re: [PATCH 0/6] RFC: Typesafe callbacks, Tejun Heo, (Sun Jan 20, 8:56 am)
Re: [PATCH 0/6] RFC: Typesafe callbacks, Tejun Heo, (Sun Jan 20, 9:00 am)
Re: [PATCH 0/6] RFC: Typesafe callbacks, Rusty Russell, (Sun Jan 20, 6:17 pm)
Re: [PATCH 0/6] RFC: Typesafe callbacks, Rusty Russell, (Mon Jan 21, 7:33 am)
Re: [PATCH 0/6] RFC: Typesafe callbacks, Tejun Heo, (Mon Jan 21, 8:38 am)
Re: [PATCH 0/6] RFC: Typesafe callbacks, Rusty Russell, (Mon Jan 21, 7:27 pm)
Re: [PATCH 0/6] RFC: Typesafe callbacks, Andi Kleen, (Tue Jan 22, 12:20 am)
Re: [PATCH 0/6] RFC: Typesafe callbacks, Linus Torvalds, (Mon Jan 21, 7:57 pm)
Re: [PATCH 0/6] RFC: Typesafe callbacks, Rusty Russell, (Tue Jan 22, 3:16 am)
Re: [PATCH 0/6] RFC: Typesafe callbacks, Linus Torvalds, (Tue Jan 22, 11:53 am)
[PATCH 1/6] typesafe: Convert stop_machine and callers, Rusty Russell, (Sun Jan 20, 5:47 am)
[PATCH 2/6] typesafe: kthread_create and kthread_run, Rusty Russell, (Sun Jan 20, 5:48 am)
Re: [PATCH 2/6] typesafe: kthread_create and kthread_run, Jan Engelhardt, (Sun Jan 20, 7:25 am)
Re: [PATCH 2/6] typesafe: kthread_create and kthread_run, Johannes Weiner, (Sun Jan 20, 12:24 pm)
Re: [PATCH 2/6] typesafe: kthread_create and kthread_run, Rusty Russell, (Sun Jan 20, 6:04 pm)
[PATCH 3/6] typesafe: convert kthread users, Rusty Russell, (Sun Jan 20, 5:50 am)
[PATCH 5/6] typesafe: request_irq and devm_request_irq, Rusty Russell, (Sun Jan 20, 5:54 am)
[PATCH 6/6] typesafe: timers, Rusty Russell, (Sun Jan 20, 5:57 am)