Sturk 1.0.2
Publish-subscribe C implementation.
Loading...
Searching...
No Matches
arith.h File Reference

Basic arithmetic operations. More...

#include <stddef.h>
Include dependency graph for arith.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ST_MAX(x, y)   (((x) > (y)) ? (x) : (y))
 Compute the maximum of two values.
 
#define ST_MIN(x, y)   (((x) < (y)) ? (x) : (y))
 Compute the minimum of two values.
 
#define st_container_of(ptr, type, member)
 Cast a member of a structure out to the containing structure.
 

Detailed Description

Basic arithmetic operations.

Macro Definition Documentation

◆ st_container_of

#define st_container_of (   ptr,
  type,
  member 
)
Value:
({ \
const __typeof__(((type*)0)->member)* _ptr = (ptr); \
\
(type*)((char*)_ptr - offsetof(type, member)); \
})

Cast a member of a structure out to the containing structure.

Parameters
[in]ptrThe pointer to the member.
[in]typeThe type of the container struct this is embedded in.
[in]memberThe name of the member within the struct.
Returns
Pointer to the member's container.
Note
Compile with the GNU extension to enable a type check for the ptr.

◆ ST_MAX

#define ST_MAX (   x,
 
)    (((x) > (y)) ? (x) : (y))

Compute the maximum of two values.

This macro returns the maximum of x and y.

Returns
maximum of x and y.
Note
Side effects: x and y evaluated twice.

◆ ST_MIN

#define ST_MIN (   x,
 
)    (((x) < (y)) ? (x) : (y))

Compute the minimum of two values.

This macro returns the minimum of x and y.

Returns
minimum of x and y.
Note
Side effects: x and y evaluated twice.