X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/8f6c56a50524aa785f7e596d52dddfb331e18961..d26ffc64f583ab2d29df48f13518685602bc8832:/osfmk/i386/endian.h diff --git a/osfmk/i386/endian.h b/osfmk/i386/endian.h index 88fbc2cd5..d9bed4649 100644 --- a/osfmk/i386/endian.h +++ b/osfmk/i386/endian.h @@ -50,14 +50,12 @@ */ #if !defined(ntohs) -unsigned short ntohs(unsigned short); -extern __inline__ +static __inline__ unsigned short ntohs(unsigned short); +static __inline__ unsigned short ntohs(unsigned short w_int) { - register unsigned short w = w_int; - __asm__ volatile("xchgb %h1,%b1" : "=q" (w) : "0" (w)); - return (w); /* zero-extend for compat */ + return ((w_int << 8) | (w_int >> 8)); } #endif @@ -67,14 +65,18 @@ unsigned short htons(unsigned short); #endif #if !defined(ntohl) -unsigned long ntohl(unsigned long); -extern __inline__ +static __inline__ unsigned long ntohl(unsigned long); +static __inline__ unsigned long -ntohl(register unsigned long value) +ntohl(unsigned long value) { - register unsigned long l = value; +#if defined(__clang__) + return (unsigned long)__builtin_bswap32((unsigned int)value); +#else + unsigned long l = value; __asm__ volatile("bswap %0" : "=r" (l) : "0" (l)); return l; +#endif } #endif