1 /* -------------------------------- Arctic Core ------------------------------
\r
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
\r
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
\r
6 * This source code is free software; you can redistribute it and/or modify it
\r
7 * under the terms of the GNU General Public License version 2 as published by the
\r
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
\r
10 * This program is distributed in the hope that it will be useful, but
\r
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
\r
14 * -------------------------------- Arctic Core ------------------------------*/
\r
23 #ifndef BYTEORDER_H_
\r
24 #define BYTEORDER_H_
\r
27 // Implements only big endian stuff
\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
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
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
44 #endif /*BYTEORDER_H_*/
\r