xref: /original-bsd/lib/libc/string/swab.c (revision 61b6c03f)
1 #if defined(LIBC_SCCS) && !defined(lint)
2 static char sccsid[] = "@(#)swab.c	5.3 (Berkeley) 03/09/86";
3 #endif LIBC_SCCS and not lint
4 
5 /*
6  * Swab bytes
7  * Jeffrey Mogul, Stanford
8  */
9 
10 swab(from, to, n)
11 	register char *from, *to;
12 	register int n;
13 {
14 	register unsigned long temp;
15 
16 	n >>= 1; n++;
17 #define	STEP	temp = *from++,*to++ = *from++,*to++ = temp
18 	/* round to multiple of 8 */
19 	while ((--n) & 07)
20 		STEP;
21 	n >>= 3;
22 	while (--n >= 0) {
23 		STEP; STEP; STEP; STEP;
24 		STEP; STEP; STEP; STEP;
25 	}
26 }
27