tech-net archive

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

Re: routing socket rouding?



>> There is a macro, historically ROUNDUP defined in various .c files,
>> RT_ROUNDUP in <net/route.h> in 5.1 and presumably later, [...]

>> So, I'm curious: does anyone know what this macro turned into on a
>> system with sizeof(long) not a power of two but with anything like
>> the BSD routing socket, if such a system exists?

> ROUNDUP (or ROUND_UP) macro was replaced by ALIGN on some platforms,
> ie:

>   http://lkml.org/lkml/2007/4/1/50

(a) That appears to be dealing with PCI support, not routing socket
support.  It's the routing socket macro I'm curious about.  (The
ROUND_UP macro being replaced does appear to assume the grain size
being rounded up to is a pwoer of two, so it's related, but since it
doesn't show the definition of the ALIGN it's being replaced with, the
message is pretty much content-free for my purposes.)

(b) The ROUND_UP macro affected by that patch is not the one used by
the routing socket code; it returns zero when passed zero, whereas the
routing socket's ROUNDUP / RT_ROUNDUP returns sizeof(long) when passed
zero.

(c) Your citing this in response to my question implies that Linux runs
on something with sizeof(long) not a power of two.  Now I'm also
curious what CPU (and/or machine) that is.

> and it appears to assume 2's compliment arithmetic....

Well, two's complement (not "compliment") versus alternatives is
relevant only when dealing with negative values.  I don't think
anything in the routing socket code can ever pass a negative value to
ROUNDUP/RT_ROUNDUP; they mostly are sa_len values, and sa_len is
unsigned.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index