bde at zeta.org.au
Mon Jul 14 20:54:26 PDT 2003
On Mon, 14 Jul 2003, Nate Lawson wrote:
> 3. It appears bus_alloc_resource() takes a range of values. If I know the
> exact value to use, I request it via "value, value" instead of "0, ~0".
> Is this correct?
It's correct if you really know the values, unlike "0, ~0". The maximum
value for a resource is ULONG_MAX. This is also a magic value in
conjunction with a value of 0 for the start of a resource and a value
of 1 for the count (see the man page). ULONG_MAX can be spelled ~0ul
to abbreviate and obfuscate the code a little. ULONG_MAX can't be
spelled ~0, but this is what the man page description says to use for
the magic value. ~0 is -1 on 2's complement machines and -0 on 1's
complement machines. It just happens to become ULONG_MAX on some
machines including 2's complement ones after bogus type conversions
when it is passed to bus_alloc_resource. Most drivers use the bogus
version of course. The examples in the man page are correct although
the description isn't.
More information about the freebsd-current