PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches
Miscellaneous

Small generic macros. More...

Macros

#define PBL_CONTAINER_OF(ptr, type, member)   ((type *)((char *)(ptr) - offsetof(type, member)))
 Get the structure that contains a member.
 
#define PBL_STRINGIFY(a)   PBL_STRINGIFY_NX(a)
 Turn the expansion of the argument into a string literal.
 
#define PBL_SWAP(a, b)
 Swap the values of two lvalues of the same type.
 
#define PBL_FOURCC(a, b, c, d)
 Pack four characters into a uint32_t, the first one in the most significant byte.
 

Detailed Description

Small generic macros.

Macro Definition Documentation

◆ PBL_CONTAINER_OF

#define PBL_CONTAINER_OF (   ptr,
  type,
  member 
)    ((type *)((char *)(ptr) - offsetof(type, member)))

Get the structure that contains a member.

Parameters
ptrPointer to the member.
typeType of the containing structure.
memberName of the member within type.
Returns
Pointer to the containing structure.

◆ PBL_FOURCC

#define PBL_FOURCC (   a,
  b,
  c,
  d 
)
Value:
((uint32_t)(((uint32_t)(uint8_t)(a) << 24) | ((uint32_t)(uint8_t)(b) << 16) | \
((uint32_t)(uint8_t)(c) << 8) | (uint32_t)(uint8_t)(d)))

Pack four characters into a uint32_t, the first one in the most significant byte.

Parameters
aFirst character.
bSecond character.
cThird character.
dFourth character.

◆ PBL_STRINGIFY

#define PBL_STRINGIFY (   a)    PBL_STRINGIFY_NX(a)

Turn the expansion of the argument into a string literal.

Parameters
aArgument.

◆ PBL_SWAP

#define PBL_SWAP (   a,
  b 
)
Value:
do { \
typeof(a) _pbl_swap_tmp = (a); \
(a) = (b); \
(b) = _pbl_swap_tmp; \
} while (0)

Swap the values of two lvalues of the same type.

Parameters
aFirst lvalue, evaluated more than once.
bSecond lvalue, evaluated more than once.