[BACK]Return to ntohs.c CVS log [TXT][DIR] Up to [local] / prex / dev / lib

Annotation of prex/dev/lib/ntohs.c, Revision 1.1

1.1     ! nbrk        1: /*
        !             2:  * Written by J.T. Conklin <jtc@NetBSD.org>.
        !             3:  * Public domain.
        !             4:  */
        !             5:
        !             6: #include <driver.h>
        !             7: #include <sys/types.h>
        !             8:
        !             9: #undef ntohs
        !            10:
        !            11: uint16_t
        !            12: ntohs(uint16_t x)
        !            13: {
        !            14: #if BYTE_ORDER == LITTLE_ENDIAN
        !            15:        u_char *s = (u_char *) &x;
        !            16:        return (uint16_t)(s[0] << 8 | s[1]);
        !            17: #else
        !            18:        return x;
        !            19: #endif
        !            20: }

CVSweb