Re: multiple definitions of ROUNDUP macro

From: Brooks Davis (brooks_at_one-eyed-alien.net)
Date: 04/13/04

  • Next message: Christophe Prevotaux: "4Gbps in PCI-X"
    Date: Tue, 13 Apr 2004 08:35:08 -0700
    To: Luigi Rizzo <rizzo@icir.org>
    
    
    

    On Tue, Apr 13, 2004 at 01:47:20AM -0700, Luigi Rizzo wrote:
    > The ROUNDUP macro, used to account for the space occupied by a sockaddr
    > when passed through a routing socket, is defined in a zillion places:
    >
    > src/usr.sbin/IPXrouted/startup.c:#define ROUNDUP(a) \
    > src/usr.sbin/arp/arp.c:#define ROUNDUP(a) \
    > src/usr.sbin/ndp/ndp.c:#define ROUNDUP(a) \
    > src/usr.sbin/ppp/defs.h:#define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (sizeof(longsrc/usr.sbin/route6d/route6d.c:#define ROUNDUP(a) \
    > src/usr.sbin/rwhod/rwhod.c:#define ROUNDUP(a) \
    > src/sys/net/route.c.orig:#define ROUNDUP(a) (a>0 ? (1 + (((a) - 1) | (sizeof(lonsrc/sys/net/rtsock.c:#define ROUNDUP(a) \
    >
    > A similar macro, ADVANCE, has similar problems.
    > This is confusing at best, and a likely source of trouble.
    >
    > If there are no objections I would like to replace it with a
    > centralised macro (possibly with a suitable name) which takes
    > a sockaddr * as argument and returns the rounded-up size of the
    > object as a result.

    Sounds good. BDE suggested the roundup/roundup2 macros in sys/param.h
    when I was removing some macros from net/if.c.

    > BTW, i notice that the rounding is to multiples of "sizeof(long)",
    > and i wonder if this is intentional, especially on 64-bit
    > architectures.

    Our wordsize is long on all architectures so that makes sense to me.

    -- Brooks

    -- 
    Any statement of the form "X is the one, true Y" is FALSE.
    PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4
    
    



  • Next message: Christophe Prevotaux: "4Gbps in PCI-X"

    Relevant Pages

    • Re: [RFC][PATCH 3/9] actual generic PAGE_SIZE infrastructure
      ... Define ASM_CONSTmacro to help using constants in both assembly ... require that architectures enable GENERIC_PAGE_SIZE in ... and makes the series bisect-safe. ... That would cause severe userland compile failures. ...
      (Linux-Kernel)
    • Re: How Common Lisp sucks
      ... What if you use different macros of different libraries in ... Should code generated by a macro be all the same, ... extension it cannot possibly cause problems for any existing correct ... It is to demonstrate that people WILL RAISE those aesthetic objections, ...
      (comp.lang.lisp)
    • [RFC][PATCH 3/9] actual generic PAGE_SIZE infrastructure
      ... Define ASM_CONSTmacro to help using constants in both assembly ... require that architectures enable GENERIC_PAGE_SIZE in ... and makes the series bisect-safe. ... config SELECT_MEMORY_MODEL ...
      (Linux-Kernel)
    • Re: How to replace bus_to_virt()?
      ... It appears there are already architectures which do not define a bus_to_virtfuntion or macro. ... If there isn't a direct replacement, is there at least a way to detect at compile time whether bus_to_virtexists? ...
      (Linux-Kernel)
    • replace "memset(...,0,PAGE_SIZE)" calls with "clear_page()"?
      ... the majority of architectures appear to define the clear_pagemacro ...
      (Linux-Kernel)