Re: [RFC] timers, pointers to functions and type safety

From: Arnd Bergmann
Date: Sat Dec 02 2006 - 05:48:28 EST


On Friday 01 December 2006 18:21, Al Viro wrote:
>  There is a tempting
> possibility to do that gradually, with all intermediates still in working
> state, provided that on all platforms currently supported by the kernel
> unsigned long and void * are indeed passed the same way (again, only for
> current kernel targets and existing gcc versions).  Namely, we could
>         * introduce SETUP_TIMER variant with cast to void (*)(unsigned long)
>         * switch to its use, converting callback instances to take pointers
> at the same time.  That would be done in reasonably sized groups.
>         * once it's over, flip ->function to void (*)(void *), ->data to
> void * and update SETUP_TIMER accordingly; deal with remaining few instances
> of ->function.

Another alternative might be to define an intermediate version of
timer_list that avoids adding new macros, like

struct timer_list {
struct list_head entry;
­ unsigned long expires;

­ void (*function)(union { unsigned long l; void *p; }
__attribute__((transparent_union)));
­ union {
unsigned long data __deprecated;
void *obj;
};

­ struct tvec_t_base_s *base;
};

Unfortunately, this relies more on gcc specific behavior than we
may want, and it makes it possible to abuse in new ways, like defining
a function to take an unsigned long argument, but passing the data
as void *obj.

Arnd <><
-
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/