15#ifndef LAZULI_COMMON_H
16#define LAZULI_COMMON_H
27#define _EXTERN_C_DECL_BEGIN extern "C" {
32#define _EXTERN_C_DECL_END }
39#define _EXTERN_C_DECL_BEGIN
44#define _EXTERN_C_DECL_END
53#define UNUSED(X) ((void)(X))
65#define STATIC_ASSERT(C, M) extern char _static_assertion_##M[(C) ? 1 : -1]
70#define NULL ((void *)0)
94#define false ((bool)0)
118#define ALLOW_ARITHM(X) ((uint8_t *)(X))
127 uint8_t_MUST_be_1_byte_long_to_allow_arithmetic_on_void_pointers);
136#define STATIC_CHECK_TYPE(V, T) UNUSED(1 ? (T*)0 : &(V))
145#define SET_BITS(V, T, X) \
147 STATIC_CHECK_TYPE(V, T); \
158#define CLEAR_BITS(V, T, X) \
160 STATIC_CHECK_TYPE(V, T); \
171#define INDIRECT_T(X, T) ((volatile T *)(X))
179#define INDIRECT(X) INDIRECT_T(X, uint8_t)
187#define DIRECT_T(X, T) (*INDIRECT_T(X, T))
194#define DIRECT(X) DIRECT_T(X, uint8_t)
201#define LO8(X) ((uint8_t)(X))
208#define HI8(X) LO8((X) >> 8U)
216#define MIN(A, B) (((A) < (B)) ? (A) : (B))
224#define MAX(A, B) (((A) < (B)) ? (B) : (A))
231#define ABS(A) (((A) < 0) ? (-(A)) : (A))
239#define OFFSET_OF(M, T) \
240 ((size_t)(&(((T*)0)->M)))
251#define CONTAINER_OF(P, M, T) \
252 ((T*) ((uint8_t*) (1 ? (P) : &(((T*)0)->M)) - OFFSET_OF(M, T)))
266#define ELEMENTS_COUNT(X) ((size_t)(sizeof(X) / sizeof((X)[0])))
273#define DEPENDENCY_ON_MODULE(X) \
274 STATIC_ASSERT(LZ_CONFIG_MODULE_ ## X ## _USED, Module_ ## X ## _must_be_used)
unsigned int uint16_t
Represents a unsigned integer type with width of exactly 16 bits.
unsigned char uint8_t
Represents a unsigned integer type with width of exactly 8 bits.
uint8_t bool
Boolean type.
#define STATIC_ASSERT(C, M)
Perform an assertion at compile time.
uint8_t u_read_write_atomic_t
Represents an unsigned integer that can be read and written atomically.
uint16_t size_t
Represents the size of an object.
int ptrdiff_t
Represents the difference between two pointers.
Basic type definitions and useful macros usable in ASM source files.