1 /* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Jeffrey Mogul. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11 #if defined(LIBC_SCCS) && !defined(lint) 12 static char sccsid[] = "@(#)swab.c 5.6 (Berkeley) 06/01/90"; 13 #endif /* LIBC_SCCS and not lint */ 14 15 #include <string.h> 16 17 void 18 swab(from, to, n) 19 register char *from, *to; 20 register int n; 21 { 22 register unsigned long temp; 23 24 n >>= 1; n++; 25 #define STEP temp = *from++,*to++ = *from++,*to++ = temp 26 /* round to multiple of 8 */ 27 while ((--n) & 07) 28 STEP; 29 n >>= 3; 30 while (--n >= 0) { 31 STEP; STEP; STEP; STEP; 32 STEP; STEP; STEP; STEP; 33 } 34 } 35