cvs commit: src/sys/i386/include endian.h

Robert Watson rwatson at FreeBSD.org
Tue Sep 23 07:33:29 PDT 2003


On Mon, 22 Sep 2003, Peter Wemm wrote:

>   Microoptimization to allow the compiler to evaluate ntohl() etc on
>   known constants at compile time rather than at run time.  We have a number
>   of nasty hacks around the place to cache ntohl() of constants (eg: nfs).
>   This change allows the compiler to compile-time evaluate ntohl(1) as
>   0x01000000 rather than having to emit assembler code to do it.  This
>   has other smaller flow-on effects because the compiler can see that
>   ntohl(constant) itself has a constant value now and can propagate the
>   compile time evaluation.

So should we now be doing a sweep through the tree to remove instances of
this?  I.e.:

        /*
         * To avoid byte-swapping the same value over and over again.
         */
        igmp_all_hosts_group = htonl(INADDR_ALLHOSTS_GROUP);
        igmp_all_rtrs_group = htonl(INADDR_ALLRTRS_GROUP);

Etc?

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert at fledge.watson.org      Network Associates Laboratories




More information about the cvs-src mailing list