PebbleOS
Loading...
Searching...
No Matches
Macros
Miscellaneous

Small generic macros. More...

Macros

#define container_of(ptr, type, member)   ((type *)((char *)(ptr) - (size_t)&(((type *)0)->member)))
 Get the structure that contains a member.
 
#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

◆ container_of

#define container_of (   ptr,
  type,
  member 
)    ((type *)((char *)(ptr) - (size_t)&(((type *)0)->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_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.