Return to ntohs.c CVS log | Up to [local] / prex-old / dev / lib |
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: }