xref: /original-bsd/lib/libc/string/swab.c (revision aba77441)
1 #ifndef lint
2 static char sccsid[] = "@(#)swab.c	5.2 (Berkeley) 06/05/85";
3 #endif 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