lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 13 Jan 2011 12:25:42 +0100 (CET)
From:	Thomas Gleixner <tglx@...utronix.de>
To:	Richard Cochran <richardcochran@...il.com>
cc:	linux-kernel@...r.kernel.org, linux-api@...r.kernel.org,
	netdev@...r.kernel.org, Alan Cox <alan@...rguk.ukuu.org.uk>,
	Arnd Bergmann <arnd@...db.de>,
	Christoph Lameter <cl@...ux.com>,
	David Miller <davem@...emloft.net>,
	John Stultz <johnstul@...ibm.com>,
	Krzysztof Halasa <khc@...waw.pl>,
	Peter Zijlstra <peterz@...radead.org>,
	Rodolfo Giometti <giometti@...ux.it>
Subject: Re: [PATCH V8 08/13] posix clocks: cleanup the CLOCK_DISPTACH
 macro

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 netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ