2020-04-16 11:09:22 +02:00
|
|
|
/*
|
|
|
|
* OneLinerMacros.h
|
|
|
|
*
|
|
|
|
* Created on: 16 Apr 2020
|
|
|
|
* Author: jief
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDE_ONELINERMACROS_H_
|
|
|
|
#define INCLUDE_ONELINERMACROS_H_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Decimal powers: */
|
2021-02-06 18:16:46 +01:00
|
|
|
#define Kilo (1000ULL)
|
|
|
|
#define Mega (Kilo * Kilo)
|
|
|
|
#define Giga (Kilo * Mega)
|
|
|
|
#define Tera (Kilo * Giga)
|
|
|
|
#define Peta (Kilo * Tera)
|
2020-04-16 11:09:22 +02:00
|
|
|
|
|
|
|
#define bit(n) (1UL << (n))
|
|
|
|
#define _Bit(n) (1ULL << (n))
|
|
|
|
#define _HBit(n) (1ULL << ((n)+32))
|
|
|
|
|
|
|
|
#define bitmask(h,l) ((bit(h)|(bit(h)-1)) & ~(bit(l)-1))
|
|
|
|
#define bitfield(x,h,l) RShiftU64(((x) & bitmask((h),(l))), (l))
|
|
|
|
#define quad(hi,lo) ((LShiftU64((hi), 32) | (lo)))
|
|
|
|
|
|
|
|
#define REG8(base, reg) ((volatile UINT8 *)(UINTN)(base))[(reg)]
|
|
|
|
#define REG16(base, reg) ((volatile UINT16 *)(UINTN)(base))[(reg) >> 1]
|
|
|
|
//#define REG32(base, reg) ((volatile UINT32 *)(UINTN)(base))[(reg) >> 2]
|
|
|
|
#define REG32(base, reg) (*(volatile UINT32 *)((UINTN)base + reg))
|
|
|
|
#define WRITEREG32(base, reg, value) REG32((base), (reg)) = value
|
|
|
|
|
2021-03-27 19:53:30 +01:00
|
|
|
|
|
|
|
#define CONCAT2(x, y) x ## y
|
|
|
|
#define CONCAT(x, y) CONCAT2(x, y)
|
|
|
|
#define STRINGIZE(x) #x
|
|
|
|
|
2021-04-06 23:45:58 +02:00
|
|
|
#define NOP do { int i=0 ; (void)i; } while (0) // for debugging
|
|
|
|
|
2021-03-27 19:53:30 +01:00
|
|
|
|
2021-02-06 18:16:46 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2021-04-03 12:55:25 +02:00
|
|
|
#include "remove_ref.h"
|
2020-04-16 11:09:22 +02:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define __typeof__(x) decltype(x)
|
|
|
|
#endif
|
2021-02-06 18:16:46 +01:00
|
|
|
#define __typeof_am__(x) _typeofam_remove_ref<decltype(x)>::type
|
2020-04-16 11:09:22 +02:00
|
|
|
|
2021-02-06 18:16:46 +01:00
|
|
|
#endif
|
2020-04-16 11:09:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* INCLUDE_ONELINERMACROS_H_ */
|