OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [linux/] [uClibc/] [libc/] [unistd/] [swab.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
#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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.