- Subject: Re: [PATCH V8 08/13] posix clocks: cleanup the CLOCK_DISPTACH macro
- From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
- Date: Thu, 13 Jan 2011 12:25:42 +0100 (CET)
- Cc: linux-kernel@xxxxxxxxxxxxxxx, linux-api@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx, Alan Cox <alan@xxxxxxxxxxxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, Christoph Lameter <cl@xxxxxxxxx>, David Miller <davem@xxxxxxxxxxxxx>, John Stultz <johnstul@xxxxxxxxxx>, Krzysztof Halasa <khc@xxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Rodolfo Giometti <giometti@xxxxxxxx>
- In-reply-to: <20110113043037.GA17726@xxxxxxxxxxxxxxxxxxxxxx>
- References: <cover.1293820862.git.richard.cochran@xxxxxxxxxx> <503cd1fa268867573001cfc9bb5681ee3b5b32fa.1293820862.git.richard.cochran@xxxxxxxxxx> <alpine.LFD.2.00.1101111224280.12146@xxxxxxxxxxxxxxxxxxxxxxx> <20110113043037.GA17726@xxxxxxxxxxxxxxxxxxxxxx>
- User-agent: Alpine 2.00 (LFD 1167 2008-08-23)
On Thu, 13 Jan 2011, Richard Cochran wrote:
> On Tue, Jan 11, 2011 at 01:57:23PM +0100, Thomas Gleixner wrote:
> >
> > static clockid_t clock_get_array_id(const clockid_t id)
> > {
> > if (id >= 0)
> > return id < MAX_CLOCKS ? id : POSIX_INV_CLOCK_ID;
> >
> > if (clock_is_posix_cpu(id))
> > return POSIX_CPU_CLOCK_ID;
> >
> > return POSIX_INV_CLOCK_ID;
> > }
> >
> > static inline int dispatch_clock_getres(const clockid_t id, struct timespec *ts)
> > {
> > struct k_clock *clk = &posix_clocks[clock_get_array_id(id)];
> >
> > return clk->clock_getres ? clk->clock_getres(id, ts) : -EINVAL;
> > }
>
> I would like to take this idea one step further, like so:
>
> static struct k_clock *clockid_to_kclock(const clockid_t id)
> {
> if (id >= 0)
> return id < MAX_CLOCKS ?
> &posix_clocks[id] : &posix_clocks[POSIX_INV_CLOCK_ID];
> ...
> }
>
> SYSCALL( ... , const clockid_t id, struct timespec *ts)
> {
> struct k_clock *clk = clockid_to_kclock(id);
>
> return clk->clock_getres ? clk->clock_getres(id, ts) : -EINVAL;
> }
>
> What do you think?
Yeah, that's even better!
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Home]
[Linux USB Devel]
[Video for Linux]
[Linux Audio Users]
[Photo]
[Yosemite News]
[Yosemite Photos]
[Free Online Dating]
[Linux Kernel]
[Linux SCSI]
[XFree86]