Discussion:
highbit() vs uint64_t on i386
Andriy Gapon
2014-01-12 16:55:16 UTC
Permalink
It seems that highbit() is defined to take a u_long argument.
On the other hand it seems to be used on uint64_t variables at several places in
metaslab and related code. I am not sure if illumos supports i386 platform, but
a FreeBSD user has reported a crash caused by this mismatch.
--
Andriy Gapon
George Wilson
2014-01-12 17:09:19 UTC
Permalink
Andriy,

I'm working on a change that will introduce highbit64() to take a
uint64_t and will work on both 32 and 64-bit platforms.

- George
Post by Andriy Gapon
It seems that highbit() is defined to take a u_long argument.
On the other hand it seems to be used on uint64_t variables at several places in
metaslab and related code. I am not sure if illumos supports i386 platform, but
a FreeBSD user has reported a crash caused by this mismatch.
Saso Kiselkov
2014-01-12 17:13:19 UTC
Permalink
Post by Andriy Gapon
It seems that highbit() is defined to take a u_long argument.
On the other hand it seems to be used on uint64_t variables at several places in
metaslab and related code. I am not sure if illumos supports i386 platform, but
a FreeBSD user has reported a crash caused by this mismatch.
This is most definitely a bug. Thankfully, George seems to be looking
into this already. Right off the top of my head the easiest solution I
can think of is something like this:

#define highbit64(x) ((x) ? (sizeof (x) * 8 - __builtin_clzll(x)) : 0)
--
Saso
Loading...