]> git.zerfleddert.de Git - proxmark3-svn/blame - client/hid-flasher/proxendian.h
fix #532. looks at length of parameters.
[proxmark3-svn] / client / hid-flasher / proxendian.h
CommitLineData
e9281ae8
JH
1//-----------------------------------------------------------------------------
2// Copyright (C) 2010 Hector Martin "marcan" <marcan@marcansoft.com>
3//
4// This code is licensed to you under the terms of the GNU GPL, version 2 or,
5// at your option, any later version. See the LICENSE.txt file for the text of
6// the license.
7//-----------------------------------------------------------------------------
8// Endianness convenience functions
9//-----------------------------------------------------------------------------
10
11#ifndef PROXENDIAN_H__
12#define PROXENDIAN_H__
13
14#include <stdint.h>
15
c44c2f04 16#ifdef _WIN32
e9281ae8
JH
17# define HOST_LITTLE_ENDIAN
18#else
19# include <sys/types.h>
20
21# if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
22# error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
23# endif
24
25# if BYTE_ORDER == LITTLE_ENDIAN
26# define HOST_LITTLE_ENDIAN
27# endif
28#endif
29
30#ifdef HOST_LITTLE_ENDIAN
31# define le16(x) (x)
32# define le32(x) (x)
33#else
34
35static inline uint16_t le16(uint16_t v)
36{
37 return (v>>8) | (v<<8);
38}
39
40static inline uint32_t le32(uint32_t v)
41{
42 return (le16(v)<<16) | (le16(v>>16));
43}
44#endif // HOST_LITTLE_ENDIAN
45
46#endif // PROXENDIAN_H__
Impressum, Datenschutz