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

2008-01-22 Thread Linus Torvalds
On Tue, 22 Jan 2008, Rusty Russell wrote: > > If we can stomach it the effect is nice, but the version which simply > allows pointer correctness (rather than trying to do unsigned long too) is > less bletcherous. I'd suggest trying to get by with just the pointer version for now. But we

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

2008-01-21 Thread Rusty Russell
On Tuesday 22 January 2008 10:57:03 Linus Torvalds wrote: > On Tue, 22 Jan 2008, Rusty Russell wrote: > > Attempt to create callbacks which take unsigned long as well as > > correct pointer types. > > I bow down before you. > > I thought I had done some rather horrible things with gcc built-ins and

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

2008-01-21 Thread Andi Kleen
Rusty Russell <[EMAIL PROTECTED]> writes: > === > Attempt to create callbacks which take unsigned long as well as > correct pointer types. FWIW i had something similar using the gcc union extension at some point for ioctls because I was tired for all the ugly casts from unsigned long arg to void *

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

2008-01-21 Thread Linus Torvalds
On Tue, 22 Jan 2008, Rusty Russell wrote: > > Attempt to create callbacks which take unsigned long as well as > correct pointer types. I bow down before you. I thought I had done some rather horrible things with gcc built-ins and macros, but I hereby hand over my crown to you. As my daughter

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

2008-01-21 Thread Rusty Russell
On Monday 21 January 2008 23:38:47 Tejun Heo wrote: > Rusty Russell wrote: > > On Monday 21 January 2008 09:17:30 Rusty Russell wrote: > >> But it would be cool to allow functions which take an unsigned long. > >> I'll test this out and see what I can make... > > > > I think this comes under "too u

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

2008-01-21 Thread Tejun Heo
Rusty Russell wrote: > On Monday 21 January 2008 09:17:30 Rusty Russell wrote: >> On Monday 21 January 2008 00:00:52 Tejun Heo wrote: >>> What should be do are >>> >>> * Check that the threadfn's argument fits into void *. >> For everything but timer, you'll get a warning if the data isn't assignab

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

2008-01-21 Thread Rusty Russell
On Monday 21 January 2008 09:17:30 Rusty Russell wrote: > On Monday 21 January 2008 00:00:52 Tejun Heo wrote: > > What should be do are > > > > * Check that the threadfn's argument fits into void *. > > For everything but timer, you'll get a warning if the data isn't assignable > to a void *, so yo

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

2008-01-20 Thread Rusty Russell
On Monday 21 January 2008 00:00:52 Tejun Heo wrote: > What should be do are > > * Check that the threadfn's argument fits into void *. 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 c

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

2008-01-20 Thread Tejun Heo
Tejun Heo wrote: > * Passing NULL as data to callback which takes non-void pointer > triggers warning. I think this should be allowed. Something like > the following? Please ignore the last sentence. > * Allowing non-pointer integral types which fit into pointer would be > nice. It's oft

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

2008-01-20 Thread Tejun Heo
Rusty Russell wrote: > Hi all, > >Converting to and from void * for callback functions loses type safety: > everywhere else we expect the compiler to catch incorrect pointer types > handed to functions. > >It's pretty simple to create typesafe callback functions using typeof, and > wit

[PATCH 0/6] RFC: Typesafe callbacks

2008-01-20 Thread Rusty Russell
Hi all, Converting to and from void * for callback functions loses type safety: everywhere else we expect the compiler to catch incorrect pointer types handed to functions. It's pretty simple to create typesafe callback functions using typeof, and with a little gcc trickery we can allow