]> rtime.felk.cvut.cz Git - arc.git/blob - include/Byteorder.h
Initial commit.
[arc.git] / include / Byteorder.h
1 /* -------------------------------- Arctic Core ------------------------------
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com
3  *
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
5  *
6  * This source code is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 as published by the
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * for more details.
14  * -------------------------------- Arctic Core ------------------------------*/
15
16
17
18
19
20
21
22
23 #ifndef BYTEORDER_H_\r
24 #define BYTEORDER_H_\r
25 \r
26 // NOTE!\r
27 // Implements only big endian stuff\r
28 \r
29 //#define BE_TO_CPU_32(x) ((uint8_t*)(x))[0] + (((uint8_t*)(x))[1]<<8) + (((uint8_t*)(x))[2]<<16) + (((uint8_t*)(x))[3]<<24)\r
30 //#define BIG_ENDIAN\r
31 \r
32 // a,b,c,d -> d,c,b,a\r
33 #define bswap32(x)              (((uint32)(x) >> 24) | (((uint32)(x) >> 8) & 0xff00) | (((uint32)(x) & 0xff00 ) << 8) | (((uint32)(x) & 0xff) << 24) )\r
34 #define bswap16(x)              (((uint16)(x) >> 8) | (((uint16)(x) & 0xff) << 8))\r
35 \r
36 #if 0 //defined(BIG_ENDIAN)\r
37 #define cpu_to_le32(_x) bswap32(_x)\r
38 #define cpu_to_be32(_x)\r
39 #define le32_to_cpu(_x)\r
40 #define be32_to_cpu(_x)\r
41 #endif\r
42 \r
43 \r
44 #endif /*BYTEORDER_H_*/\r