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

Annotation of prex/dev/lib/htons.c, Revision 1.1.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 htons
                     10:
                     11: uint16_t
                     12: htons(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