swab.c (102639) | swab.c (138659) |
---|---|
1/* 2 * Copyright (c) 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Jeffrey Mogul. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 24 unchanged lines hidden (view full) --- 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#if defined(LIBC_SCCS) && !defined(lint) 38static char sccsid[] = "@(#)swab.c 8.1 (Berkeley) 6/4/93"; 39#endif /* LIBC_SCCS and not lint */ 40#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Jeffrey Mogul. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 24 unchanged lines hidden (view full) --- 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#if defined(LIBC_SCCS) && !defined(lint) 38static char sccsid[] = "@(#)swab.c 8.1 (Berkeley) 6/4/93"; 39#endif /* LIBC_SCCS and not lint */ 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: head/lib/libc/string/swab.c 102639 2002-08-30 20:33:05Z robert $"); | 41__FBSDID("$FreeBSD: head/lib/libc/string/swab.c 138659 2004-12-10 15:24:40Z trhodes $"); |
42 | 42 |
43#include <string.h> | 43#include <unistd.h> |
44 45void | 44 45void |
46swab(const void * __restrict from, void * __restrict to, size_t len) | 46swab(const void * __restrict from, void * __restrict to, ssize_t len) |
47{ 48 unsigned long temp; 49 int n; 50 char *fp, *tp; 51 52 n = len >> 1; 53 fp = (char *)from; 54 tp = (char *)to; 55#define STEP temp = *fp++,*tp++ = *fp++,*tp++ = temp 56 /* round to multiple of 8 */ 57 for (; n & 0x7; --n) 58 STEP; 59 for (n >>= 3; n > 0; --n) { 60 STEP; STEP; STEP; STEP; 61 STEP; STEP; STEP; STEP; 62 } 63} | 47{ 48 unsigned long temp; 49 int n; 50 char *fp, *tp; 51 52 n = len >> 1; 53 fp = (char *)from; 54 tp = (char *)to; 55#define STEP temp = *fp++,*tp++ = *fp++,*tp++ = temp 56 /* round to multiple of 8 */ 57 for (; n & 0x7; --n) 58 STEP; 59 for (n >>= 3; n > 0; --n) { 60 STEP; STEP; STEP; STEP; 61 STEP; STEP; STEP; STEP; 62 } 63} |