libdl: first execute all destructors, then munmap library
[uclibc-ng.git] / libc / unistd / swab.c
blob70ea464c2c287253406fbfc49d480b3f2a10fee4
1 #include <unistd.h>
2 #include <sys/types.h>
3 #include <byteswap.h>
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)
13 const unsigned short *from = source, *from_end = from + (count >> 1);
14 unsigned short junk;
15 unsigned short *to = dest;
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);