]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/unistd/swab.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / unistd / swab.c
1 #include <unistd.h>
2 #include <sys/types.h>
3 #include <byteswap.h>
4
5 /* Updated implementation based on byteswap.h from Miles Bader
6  * <miles@gnu.org>.  This should be much faster on arches with machine
7  * specific, optimized definitions in include/bits/byteswap.h (i.e. on
8  * x86, use the bswap instruction on i486 and better boxes).  For
9  * platforms that lack such support, this should be no slower than it
10  * was before... */
11 void swab (const void *source, void *dest, ssize_t count)
12 {
13     const unsigned short *from = source, *from_end = from + (count >> 1);
14     unsigned short junk;
15     unsigned short *to = dest;
16
17     while (from < from_end) {
18         /* Don't put '*from++'into the bswap_16() macros
19          * or mad things will happen on macro expansion */
20         junk=*from++;
21         *to++ = bswap_16 (junk);
22     }
23 }