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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090817073147.GA2967@localdomain.by>
Date:	Mon, 17 Aug 2009 10:31:47 +0300
From:	Sergey Senozhatsky <sergey.senozhatsky@...il.com>
To:	Jiri Slaby <jirislaby@...il.com>
Cc:	Andi Kleen <andi@...stfloor.org>,
	"Robert P. J. Day" <rpjday@...shcourse.ca>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Make shr to divide by power of 2 (resend)

On (08/17/09 09:15), Jiri Slaby wrote:
> On 08/16/2009 11:14 AM, Sergey Senozhatsky wrote:
> > There are different shr/shl operations in bitblit.c. Like,
> > #1
> > cur_height = vc->vc_font.height >> 1
> > cur_height = (vc->vc_font.height << 1)/3;
> > c |= c >> 1;
> > u32 idx = vc->vc_font.width >> 3;
> > etc.
> > 
> > So, should I convert it to something like:
> 
> Not at all. I was writing about about (X + 7) / 8 [or >> 3] which is
> DIV_ROUND_UP(X, 8).
> 
As far as I can understand: 
DIV_ROUND_UP(61, 8):
(111101 + 111) >> 3 -> 1000 == 8

(int)(61/8) == 7

So, we need not DIV_ROUND_UP but (let it be) DIV_SHR (a,b) (a) >> (b);
In that case cur_height = vc->vc_font.height >> 2 should be cur_height = DIV_SHR(vc->vc_font.height, 1).
And this is kind of obfuscation I think.

> > #2
> > cur_height = DIV_XXX(vc->vc_font.height, 2)
> > cur_height = DIV_XXX( MUL_XXX(vc->vc_font.height, 2), 3); or cur_height = DIV_XXX( (vc->vc_font.height * 2), 3);
> > c |= DIV_XXX(c, 1);
> > u32 idx = DIV_XXX(vc->vc_font.width, 8);
> > 
> > #1 is better-looking I think.
> 
> Agreed. I would write it without shifts though. But we were talking
> about the roundup case not about the shifts all over the code.
> 

	Sergey
Download attachment "signature.asc" of type "application/pgp-signature" (316 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ