Return to htonl.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 htonl ! 10: ! 11: uint32_t ! 12: htonl(x) ! 13: uint32_t x; ! 14: { ! 15: #if BYTE_ORDER == LITTLE_ENDIAN ! 16: u_char *s = (u_char *)&x; ! 17: return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]); ! 18: #else ! 19: return x; ! 20: #endif ! 21: }