mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
added PACKED attribute for structures and reorganize include folder
This commit is contained in:
parent
19469fc676
commit
20d13d5509
18 changed files with 204 additions and 183 deletions
|
@ -20,100 +20,12 @@
|
|||
#include <time.h>
|
||||
#include "ui.h" // PrintAndLog
|
||||
#include "commonutil.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define PACKED
|
||||
#else
|
||||
#define PACKED __attribute__((packed))
|
||||
#endif
|
||||
#include "common.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
#ifndef ROTR
|
||||
# define ROTR(x,n) (((uintmax_t)(x) >> (n)) | ((uintmax_t)(x) << ((sizeof(x) * 8) - (n))))
|
||||
#endif
|
||||
#ifndef ROTL
|
||||
# define ROTL(x,n) (((uintmax_t)(x) << (n)) | ((uintmax_t)(x) >> ((sizeof(x) * 8) - (n))))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
# define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
// endian change for 64bit
|
||||
#ifdef __GNUC__
|
||||
#ifndef BSWAP_64
|
||||
#define BSWAP_64(x) __builtin_bswap64(x)
|
||||
#endif
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
#ifndef BSWAP_64
|
||||
#define BSWAP_64(x) _byteswap_uint64(x)
|
||||
#endif
|
||||
#else
|
||||
#ifndef BSWAP_64
|
||||
#define BSWAP_64(x) \
|
||||
(((uint64_t)(x) << 56) | \
|
||||
(((uint64_t)(x) << 40) & 0xff000000000000ULL) | \
|
||||
(((uint64_t)(x) << 24) & 0xff0000000000ULL) | \
|
||||
(((uint64_t)(x) << 8) & 0xff00000000ULL) | \
|
||||
(((uint64_t)(x) >> 8) & 0xff000000ULL) | \
|
||||
(((uint64_t)(x) >> 24) & 0xff0000ULL) | \
|
||||
(((uint64_t)(x) >> 40) & 0xff00ULL) | \
|
||||
((uint64_t)(x) >> 56))
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// endian change for 32bit
|
||||
#ifdef __GNUC__
|
||||
#ifndef BSWAP_32
|
||||
#define BSWAP_32(x) __builtin_bswap32(x)
|
||||
#endif
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
#ifndef BSWAP_32
|
||||
#define BSWAP_32(x) _byteswap_ulong(x)
|
||||
#endif
|
||||
#else
|
||||
#ifndef BSWAP_32
|
||||
# define BSWAP_32(x) \
|
||||
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
|
||||
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define EVEN 0
|
||||
#define ODD 1
|
||||
|
||||
// Nibble logic
|
||||
#ifndef NIBBLE_HIGH
|
||||
# define NIBBLE_HIGH(b) ( (b & 0xF0) >> 4 )
|
||||
#endif
|
||||
#ifndef NIBBLE_LOW
|
||||
# define NIBBLE_LOW(b) ( b & 0x0F )
|
||||
#endif
|
||||
#ifndef CRUMB
|
||||
# define CRUMB(b,p) (((b & (0x3 << p) ) >> p ) & 0xF)
|
||||
#endif
|
||||
#ifndef SWAP_NIBBLE
|
||||
# define SWAP_NIBBLE(b) ( (NIBBLE_LOW(b)<< 4) | NIBBLE_HIGH(b))
|
||||
#endif
|
||||
|
||||
// Binary Encoded Digit
|
||||
#ifndef BCD2DEC
|
||||
# define BCD2DEC(bcd) HornerScheme(bcd, 0x10, 10)
|
||||
#endif
|
||||
#ifndef DEC2BCD
|
||||
# define DEC2BCD(dec) HornerScheme(dec, 10, 0x10)
|
||||
#endif
|
||||
|
||||
// used for save/load files
|
||||
#ifndef FILE_PATH_SIZE
|
||||
# define FILE_PATH_SIZE 1000
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue