X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/6d2010ae8f7a6078e10b361c6962983bab233e0f..d26ffc64f583ab2d29df48f13518685602bc8832:/osfmk/i386/endian.h diff --git a/osfmk/i386/endian.h b/osfmk/i386/endian.h index 62dedd9e9..d9bed4649 100644 --- a/osfmk/i386/endian.h +++ b/osfmk/i386/endian.h @@ -55,9 +55,7 @@ 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 @@ -70,11 +68,15 @@ unsigned short htons(unsigned short); 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