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: <4005.1158166252@warthog.cambridge.redhat.com>
Date:	Wed, 13 Sep 2006 17:50:52 +0100
From:	David Howells <dhowells@...hat.com>
To:	"Luck, Tony" <tony.luck@...el.com>
Cc:	David Howells <dhowells@...hat.com>, torvalds@...l.org,
	akpm@...l.org, linux-kernel@...r.kernel.org,
	linux-arch@...r.kernel.org
Subject: Re: [PATCH 4/6] Implement a general log2 facility in the kernel 

Luck, Tony <tony.luck@...el.com> wrote:

> > This facility provides three entry points:
> > 
> > 	log2()		Log base 2 of u32
> > 	ll_log2()	Log base 2 of u64
> > 	long_log2()	Log base 2 of unsigned long
> 
> The names are rather counter-intuitive. "ll" sounds like "long long", so
> why does it opearte on *unsigned* 64-bit?  Ditto for "long_log2()".
> Perhaps they should be log2_u32(), log2_u64(), etc.

Well, given that you can't represent a log of a negative number, I'm not sure
it matters.

Note that long_log2() already exists and is of arch-dependent size.

> Even better if someone can come up with the right pre-processor magic
> using sizeof/typeof so that you could just use "log2(any type)"

I then end up with 32 of these per usage if I pass in a definite 32-bit value:

	warning: comparison is always false due to limited range of data type

because of the:

		n >= (1ULL << 63) ? 63 :	\
		n >= (1ULL << 62) ? 62 :	\
		n >= (1ULL << 61) ? 61 :	\
	...

in ll_log2().

David
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ