PipeWire  0.3.58
Miscellaneous

Helper macros and functions. More...

Files

file  defs.h
 spa/utils/defs.h
 

Data Structures

struct  spa_rectangle
 
struct  spa_point
 
struct  spa_region
 
struct  spa_fraction
 

Macros

#define SPA_FALLTHROUGH   /* FALLTHROUGH */
 SPA_FALLTHROUGH is an annotation to suppress compiler warnings about switch cases that fall through without a break or return statement. More...
 
#define SPA_FLAG_MASK(field, mask, flag)   (((field) & (mask)) == (flag))
 
#define SPA_FLAG_IS_SET(field, flag)   SPA_FLAG_MASK(field,flag,flag)
 
#define SPA_FLAG_SET(field, flag)   ((field) |= (flag))
 
#define SPA_FLAG_CLEAR(field, flag)
 
#define SPA_FLAG_UPDATE(field, flag, val)   ((val) ? SPA_FLAG_SET((field),(flag)) : SPA_FLAG_CLEAR((field),(flag)))
 
#define SPA_DIRECTION_REVERSE(d)   ((d) ^ 1)
 
#define SPA_RECTANGLE(width, height)   ((struct spa_rectangle){ (width), (height) })
 
#define SPA_POINT(x, y)   ((struct spa_point){ (x), (y) })
 
#define SPA_REGION(x, y, width, height)   ((struct spa_region){ SPA_POINT(x,y), SPA_RECTANGLE(width,height) })
 
#define SPA_FRACTION(num, denom)   ((struct spa_fraction){ (num), (denom) })
 
#define SPA_N_ELEMENTS(arr)   (sizeof(arr) / sizeof((arr)[0]))
 
#define SPA_FOR_EACH_ELEMENT(arr, ptr)    for ((ptr) = arr; (void*)(ptr) < SPA_PTROFF(arr, sizeof(arr), void); (ptr)++)
 Array iterator macro. More...
 
#define SPA_ABS(a)
 
#define SPA_MIN(a, b)
 
#define SPA_MAX(a, b)
 
#define SPA_CLAMP(v, low, high)
 
#define SPA_CLAMPF(v, low, high)
 
#define SPA_SWAP(a, b)
 
#define SPA_TYPECHECK(type, x)
 
#define SPA_PTROFF(ptr_, offset_, type_)   ((type_*)((uintptr_t)(ptr_) + (ptrdiff_t)(offset_)))
 Return the address (buffer + offset) as pointer of type. More...
 
#define SPA_PTROFF_ALIGN(ptr_, offset_, alignment_, type_)    SPA_PTR_ALIGN(SPA_PTROFF(ptr_,offset_,type_),alignment_,type_)
 
#define SPA_MEMBER(b, o, t)   SPA_PTROFF(b,o,t)
 Deprecated, use SPA_PTROFF and SPA_PTROFF_ALIGN instead. More...
 
#define SPA_MEMBER_ALIGN(b, o, a, t)   SPA_PTROFF_ALIGN(b,o,a,t)
 
#define SPA_CONTAINER_OF(p, t, m)   ((t*)((uintptr_t)(p) - offsetof(t,m)))
 
#define SPA_PTRDIFF(p1, p2)   ((intptr_t)(p1) - (intptr_t)(p2))
 
#define SPA_PTR_TO_INT(p)   ((int) ((intptr_t) (p)))
 
#define SPA_INT_TO_PTR(u)   ((void*) ((intptr_t) (u)))
 
#define SPA_PTR_TO_UINT32(p)   ((uint32_t) ((uintptr_t) (p)))
 
#define SPA_UINT32_TO_PTR(u)   ((void*) ((uintptr_t) (u)))
 
#define SPA_TIME_INVALID   ((int64_t)INT64_MIN)
 
#define SPA_IDX_INVALID   ((unsigned int)-1)
 
#define SPA_ID_INVALID   ((uint32_t)0xffffffff)
 
#define SPA_NSEC_PER_SEC   (1000000000LL)
 
#define SPA_NSEC_PER_MSEC   (1000000ll)
 
#define SPA_NSEC_PER_USEC   (1000ll)
 
#define SPA_USEC_PER_SEC   (1000000ll)
 
#define SPA_USEC_PER_MSEC   (1000ll)
 
#define SPA_MSEC_PER_SEC   (1000ll)
 
#define SPA_TIMESPEC_TO_NSEC(ts)   ((ts)->tv_sec * SPA_NSEC_PER_SEC + (ts)->tv_nsec)
 
#define SPA_TIMESPEC_TO_USEC(ts)   ((ts)->tv_sec * SPA_USEC_PER_SEC + (ts)->tv_nsec / SPA_NSEC_PER_USEC)
 
#define SPA_TIMEVAL_TO_NSEC(tv)   ((tv)->tv_sec * SPA_NSEC_PER_SEC + (tv)->tv_usec * SPA_NSEC_PER_USEC)
 
#define SPA_TIMEVAL_TO_USEC(tv)   ((tv)->tv_sec * SPA_USEC_PER_SEC + (tv)->tv_usec)
 
#define SPA_PRINTF_FUNC(fmt, arg1)
 
#define SPA_FORMAT_ARG_FUNC(arg1)
 
#define SPA_ALIGNED(align)
 
#define SPA_DEPRECATED
 
#define SPA_EXPORT
 
#define SPA_SENTINEL
 
#define SPA_UNUSED
 
#define SPA_NORETURN
 
#define SPA_WARN_UNUSED_RESULT
 
#define SPA_RESTRICT
 
#define SPA_ROUND_DOWN(num, value)   ((num) - ((num) % (value)))
 
#define SPA_ROUND_UP(num, value)   ((((num) + (value) - 1) / (value)) * (value))
 
#define SPA_MASK_NEGATED(num1, num2)
 
#define SPA_ROUND_DOWN_N(num, align)   SPA_MASK_NEGATED((num), (align) - 1)
 
#define SPA_ROUND_UP_N(num, align)   SPA_ROUND_DOWN_N((num) + ((align) - 1),align)
 
#define SPA_PTR_ALIGNMENT(p, align)   ((intptr_t)(p) & ((align)-1))
 
#define SPA_IS_ALIGNED(p, align)   (SPA_PTR_ALIGNMENT(p,align) == 0)
 
#define SPA_PTR_ALIGN(p, align, type)   ((type*)SPA_ROUND_UP_N((intptr_t)(p), (intptr_t)(align)))
 
#define SPA_LIKELY(x)   (x)
 
#define SPA_UNLIKELY(x)   (x)
 
#define SPA_STRINGIFY_1(...)   #__VA_ARGS__
 
#define SPA_STRINGIFY(...)   SPA_STRINGIFY_1(__VA_ARGS__)
 
#define spa_return_if_fail(expr)
 
#define spa_return_val_if_fail(expr, val)
 
#define spa_assert_se(expr)
 
#define spa_nop()   do {} while (false)
 
#define spa_assert(expr)   spa_assert_se(expr)
 
#define spa_assert_not_reached()
 
#define spa_memzero(x, l)   (memset((x), 0, (l)))
 
#define spa_zero(x)   (spa_memzero(&(x), sizeof(x)))
 
#define spa_memcpy(d, s, n)   memcpy(d,s,n)
 
#define spa_memmove(d, s, n)   memmove(d,s,n)
 
#define spa_aprintf(_fmt, ...)
 

Enumerations

enum  spa_direction { SPA_DIRECTION_INPUT = 0 , SPA_DIRECTION_OUTPUT = 1 }
 

Detailed Description

Helper macros and functions.

Macro Definition Documentation

◆ SPA_FALLTHROUGH

#define SPA_FALLTHROUGH   /* FALLTHROUGH */

SPA_FALLTHROUGH is an annotation to suppress compiler warnings about switch cases that fall through without a break or return statement.

SPA_FALLTHROUGH is only needed on cases that have code:

switch (foo) { case 1: // These cases have no code. No fallthrough annotations are needed. case 2: case 3: foo = 4; // This case has code, so a fallthrough annotation is needed: SPA_FALLTHROUGH; default: return foo; }

◆ SPA_FLAG_MASK

#define SPA_FLAG_MASK (   field,
  mask,
  flag 
)    (((field) & (mask)) == (flag))

◆ SPA_FLAG_IS_SET

#define SPA_FLAG_IS_SET (   field,
  flag 
)    SPA_FLAG_MASK(field,flag,flag)

◆ SPA_FLAG_SET

#define SPA_FLAG_SET (   field,
  flag 
)    ((field) |= (flag))

◆ SPA_FLAG_CLEAR

#define SPA_FLAG_CLEAR (   field,
  flag 
)

◆ SPA_FLAG_UPDATE

#define SPA_FLAG_UPDATE (   field,
  flag,
  val 
)    ((val) ? SPA_FLAG_SET((field),(flag)) : SPA_FLAG_CLEAR((field),(flag)))

◆ SPA_DIRECTION_REVERSE

#define SPA_DIRECTION_REVERSE (   d)    ((d) ^ 1)

◆ SPA_RECTANGLE

◆ SPA_POINT

#define SPA_POINT (   x,
 
)    ((struct spa_point){ (x), (y) })

◆ SPA_REGION

#define SPA_REGION (   x,
  y,
  width,
  height 
)    ((struct spa_region){ SPA_POINT(x,y), SPA_RECTANGLE(width,height) })

◆ SPA_FRACTION

◆ SPA_N_ELEMENTS

#define SPA_N_ELEMENTS (   arr)    (sizeof(arr) / sizeof((arr)[0]))
Examples
local-v4l2.c.

◆ SPA_FOR_EACH_ELEMENT

#define SPA_FOR_EACH_ELEMENT (   arr,
  ptr 
)     for ((ptr) = arr; (void*)(ptr) < SPA_PTROFF(arr, sizeof(arr), void); (ptr)++)

Array iterator macro.

Usage:

struct foo array[16];
struct foo *f;
f->bar = baz;
}
#define SPA_FOR_EACH_ELEMENT(arr, ptr)
Array iterator macro.
Definition: defs.h:155

◆ SPA_ABS

#define SPA_ABS (   a)

◆ SPA_MIN

◆ SPA_MAX

#define SPA_MAX (   a,
 
)

◆ SPA_CLAMP

#define SPA_CLAMP (   v,
  low,
  high 
)

◆ SPA_CLAMPF

#define SPA_CLAMPF (   v,
  low,
  high 
)

◆ SPA_SWAP

#define SPA_SWAP (   a,
 
)

◆ SPA_TYPECHECK

#define SPA_TYPECHECK (   type,
 
)

◆ SPA_PTROFF

#define SPA_PTROFF (   ptr_,
  offset_,
  type_ 
)    ((type_*)((uintptr_t)(ptr_) + (ptrdiff_t)(offset_)))

◆ SPA_PTROFF_ALIGN

#define SPA_PTROFF_ALIGN (   ptr_,
  offset_,
  alignment_,
  type_ 
)     SPA_PTR_ALIGN(SPA_PTROFF(ptr_,offset_,type_),alignment_,type_)

◆ SPA_MEMBER

#define SPA_MEMBER (   b,
  o,
 
)    SPA_PTROFF(b,o,t)

Deprecated, use SPA_PTROFF and SPA_PTROFF_ALIGN instead.

◆ SPA_MEMBER_ALIGN

#define SPA_MEMBER_ALIGN (   b,
  o,
  a,
 
)    SPA_PTROFF_ALIGN(b,o,a,t)

◆ SPA_CONTAINER_OF

#define SPA_CONTAINER_OF (   p,
  t,
 
)    ((t*)((uintptr_t)(p) - offsetof(t,m)))

◆ SPA_PTRDIFF

#define SPA_PTRDIFF (   p1,
  p2 
)    ((intptr_t)(p1) - (intptr_t)(p2))

◆ SPA_PTR_TO_INT

#define SPA_PTR_TO_INT (   p)    ((int) ((intptr_t) (p)))

◆ SPA_INT_TO_PTR

#define SPA_INT_TO_PTR (   u)    ((void*) ((intptr_t) (u)))

◆ SPA_PTR_TO_UINT32

#define SPA_PTR_TO_UINT32 (   p)    ((uint32_t) ((uintptr_t) (p)))

◆ SPA_UINT32_TO_PTR

#define SPA_UINT32_TO_PTR (   u)    ((void*) ((uintptr_t) (u)))

◆ SPA_TIME_INVALID

#define SPA_TIME_INVALID   ((int64_t)INT64_MIN)

◆ SPA_IDX_INVALID

#define SPA_IDX_INVALID   ((unsigned int)-1)

◆ SPA_ID_INVALID

#define SPA_ID_INVALID   ((uint32_t)0xffffffff)

◆ SPA_NSEC_PER_SEC

#define SPA_NSEC_PER_SEC   (1000000000LL)

◆ SPA_NSEC_PER_MSEC

#define SPA_NSEC_PER_MSEC   (1000000ll)

◆ SPA_NSEC_PER_USEC

#define SPA_NSEC_PER_USEC   (1000ll)

◆ SPA_USEC_PER_SEC

#define SPA_USEC_PER_SEC   (1000000ll)

◆ SPA_USEC_PER_MSEC

#define SPA_USEC_PER_MSEC   (1000ll)

◆ SPA_MSEC_PER_SEC

#define SPA_MSEC_PER_SEC   (1000ll)

◆ SPA_TIMESPEC_TO_NSEC

#define SPA_TIMESPEC_TO_NSEC (   ts)    ((ts)->tv_sec * SPA_NSEC_PER_SEC + (ts)->tv_nsec)

◆ SPA_TIMESPEC_TO_USEC

#define SPA_TIMESPEC_TO_USEC (   ts)    ((ts)->tv_sec * SPA_USEC_PER_SEC + (ts)->tv_nsec / SPA_NSEC_PER_USEC)

◆ SPA_TIMEVAL_TO_NSEC

#define SPA_TIMEVAL_TO_NSEC (   tv)    ((tv)->tv_sec * SPA_NSEC_PER_SEC + (tv)->tv_usec * SPA_NSEC_PER_USEC)

◆ SPA_TIMEVAL_TO_USEC

#define SPA_TIMEVAL_TO_USEC (   tv)    ((tv)->tv_sec * SPA_USEC_PER_SEC + (tv)->tv_usec)

◆ SPA_PRINTF_FUNC

#define SPA_PRINTF_FUNC (   fmt,
  arg1 
)

◆ SPA_FORMAT_ARG_FUNC

#define SPA_FORMAT_ARG_FUNC (   arg1)

◆ SPA_ALIGNED

#define SPA_ALIGNED (   align)

◆ SPA_DEPRECATED

#define SPA_DEPRECATED

◆ SPA_EXPORT

#define SPA_EXPORT

◆ SPA_SENTINEL

#define SPA_SENTINEL

◆ SPA_UNUSED

#define SPA_UNUSED

◆ SPA_NORETURN

#define SPA_NORETURN

◆ SPA_WARN_UNUSED_RESULT

#define SPA_WARN_UNUSED_RESULT

◆ SPA_RESTRICT

#define SPA_RESTRICT

◆ SPA_ROUND_DOWN

#define SPA_ROUND_DOWN (   num,
  value 
)    ((num) - ((num) % (value)))

◆ SPA_ROUND_UP

#define SPA_ROUND_UP (   num,
  value 
)    ((((num) + (value) - 1) / (value)) * (value))

◆ SPA_MASK_NEGATED

#define SPA_MASK_NEGATED (   num1,
  num2 
)

◆ SPA_ROUND_DOWN_N

#define SPA_ROUND_DOWN_N (   num,
  align 
)    SPA_MASK_NEGATED((num), (align) - 1)

◆ SPA_ROUND_UP_N

#define SPA_ROUND_UP_N (   num,
  align 
)    SPA_ROUND_DOWN_N((num) + ((align) - 1),align)

◆ SPA_PTR_ALIGNMENT

#define SPA_PTR_ALIGNMENT (   p,
  align 
)    ((intptr_t)(p) & ((align)-1))

◆ SPA_IS_ALIGNED

#define SPA_IS_ALIGNED (   p,
  align 
)    (SPA_PTR_ALIGNMENT(p,align) == 0)

◆ SPA_PTR_ALIGN

#define SPA_PTR_ALIGN (   p,
  align,
  type 
)    ((type*)SPA_ROUND_UP_N((intptr_t)(p), (intptr_t)(align)))

◆ SPA_LIKELY

#define SPA_LIKELY (   x)    (x)

◆ SPA_UNLIKELY

#define SPA_UNLIKELY (   x)    (x)

◆ SPA_STRINGIFY_1

#define SPA_STRINGIFY_1 (   ...)    #__VA_ARGS__

◆ SPA_STRINGIFY

#define SPA_STRINGIFY (   ...)    SPA_STRINGIFY_1(__VA_ARGS__)

◆ spa_return_if_fail

#define spa_return_if_fail (   expr)

◆ spa_return_val_if_fail

#define spa_return_val_if_fail (   expr,
  val 
)

◆ spa_assert_se

#define spa_assert_se (   expr)

◆ spa_nop

#define spa_nop ( )    do {} while (false)

◆ spa_assert

#define spa_assert (   expr)    spa_assert_se(expr)

◆ spa_assert_not_reached

#define spa_assert_not_reached ( )

◆ spa_memzero

#define spa_memzero (   x,
 
)    (memset((x), 0, (l)))

◆ spa_zero

#define spa_zero (   x)    (spa_memzero(&(x), sizeof(x)))

◆ spa_memcpy

#define spa_memcpy (   d,
  s,
 
)    memcpy(d,s,n)

◆ spa_memmove

#define spa_memmove (   d,
  s,
 
)    memmove(d,s,n)

◆ spa_aprintf

Enumeration Type Documentation

◆ spa_direction

Enumerator
SPA_DIRECTION_INPUT 
SPA_DIRECTION_OUTPUT