1 /*
2 * Copyright (c) 1994 William F. Jolitz.
3 * 386BSD Copyright Restrictions Apply. All Other Rights Reserved.
4 *
5 * $Id: ntohl.h,v 1.1 94/06/08 12:38:56 bill Exp Locker: bill $
6 * Network to Host Long byte order conversion.
7 */
8
9 __INLINE unsigned long
ntohl(unsigned long wd)10 ntohl(unsigned long wd)
11 { unsigned long rv;
12
13 #if defined(i486)
14 /* note: constrain to only eax register to simplify "emulation" on 386 */
15 asm ("bswap %0" : /*"=r"*/ "=a" (rv) : "0" (wd));
16 #else
17 asm ("xchgb %b0, %h0 ; roll $16, %0 ; xchgb %b0, %h0"
18 : "=q" (rv) : "0" (wd));
19 #endif
20 return (rv);
21 }
22