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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [mw/] [src/] [include/] [swap.h] - Blame information for rev 673

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
/*
2
 * Copyright (c) 2001 Greg Haerr <greg@censoft.com>
3
 *
4
 * Byte and word swapping header file for big/little endian mapping
5
 */
6
 
7
#include <endian.h>
8
#include <byteswap.h>
9
#if __BYTE_ORDER == __BIG_ENDIAN
10
#define wswap(x)        bswap_16(x)
11
#define dwswap(x)       bswap_32(x)
12
/* read little endian format from buffer*/
13
#define dwread(addr)    ((*(unsigned char *)(addr)) | \
14
                         (*(unsigned char *)(addr+1) << 8) | \
15
                         (*(unsigned char *)(addr+2) << 16) | \
16
                         (*(unsigned char *)(addr+3) << 24))
17
#else
18
/* little endian - no action required*/
19
#define wswap(x)        (x)
20
#define dwswap(x)       (x)
21
#define dwread(addr)    (*(unsigned long *)(addr))
22
#endif
23
 

powered by: WebSVN 2.1.0

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