tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: type behavior of sys/endian.h

On Sun, Jul 12, 2009 at 04:54:11PM +0000, David Holland wrote:
> So it seems to me that the BE definition of ntohl ought to be
>    #define    ntohl(x)        ((uint32_t)(x))
> and similarly for all the other various nops in sys/endian.h.
> Or maybe they should be made inline functions instead so they don't
> fail silently if passed pointers.

So we have two approach:
(1) Cast the value directly.
(2) Use inline functions.

When doing (2), fxp(4) doesn't compile as the follow construct triggers
a gcc warning:
with mask being some signed small constant. This even happens if mask is
unsigned or already of the correct width.

When doing (1), the supposed issue of "What happens if I use a pointer?"
problem exists. Given the use of bus_dma and bus_space, this is highly
likely to be a real bug. It will also show up by building on different
system type (LP64 vs ILP32).

I think the burden of artifical casts for (2) is worse than the gain from


Home | Main Index | Thread Index | Old Index