projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make all bucket and overflow addresses unsigned
[unix-history]
/
usr
/
src
/
lib
/
libc
/
string
/
swab.c
diff --git
a/usr/src/lib/libc/string/swab.c
b/usr/src/lib/libc/string/swab.c
index
f649306
..
6f9c243
100644
(file)
--- a/
usr/src/lib/libc/string/swab.c
+++ b/
usr/src/lib/libc/string/swab.c
@@
-1,17
+1,39
@@
-/* @(#)swab.c 4.1 (Berkeley) %G% */
/*
/*
- * Swap bytes in 16-bit [half-]words
- * for going between the 11 and the interdata
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jeffrey Mogul.
+ *
+ * %sccs.include.redist.c%
*/
*/
-swab(pf, pt, n)
-register short *pf, *pt;
-register n;
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)swab.c 5.10 (Berkeley) %G%";
+#endif /* LIBC_SCCS and not lint */
+
+#include <string.h>
+
+void
+swab(from, to, len)
+ const void *from;
+ void *to;
+ size_t len;
{
{
+ register unsigned long temp;
+ register int n;
+ register char *fp, *tp;
- n /= 2;
+ n = (len >> 1) + 1;
+ fp = (char *)from;
+ tp = (char *)to;
+#define STEP temp = *fp++,*tp++ = *fp++,*tp++ = temp
+ /* round to multiple of 8 */
+ while ((--n) & 07)
+ STEP;
+ n >>= 3;
while (--n >= 0) {
while (--n >= 0) {
-
*pt++ = (*pf << 8) + ((*pf >> 8) & 0377)
;
-
pf++
;
+
STEP; STEP; STEP; STEP
;
+
STEP; STEP; STEP; STEP
;
}
}
}
}