diff --git a/src/sdk/include/sys/param.h b/src/sdk/include/sys/param.h new file mode 100644 index 0000000..530b703 --- /dev/null +++ b/src/sdk/include/sys/param.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * Provided under the BSD-3 clause + */ + +#ifndef _SYS_PARAM_H_ +#define _SYS_PARAM_H_ 1 + +/* Pointer offset macros */ +#define PTR_OFFSET(p, off) ((void *)(char *)(p) + (off)) +#define PTR_NOFFSET(p, off) ((void *)(char *)(p) - (off)) + +/* Bit related macros */ +#define BIT(n) (1 << (n)) +#define ISSET(v, f) ((v) & (f)) + +/* Align up/down a value */ +#define ALIGN_DOWN(value, align) ((value) & ~((align)-1)) +#define ALIGN_UP(value, align) (((value) + (align)-1) & ~((align)-1)) + +/* Bitmap helper macros */ +#define SETBIT(a, b) ((a)[(b) >> 3] |= BIT(b % 8)) +#define CLRBIT(a, b) ((a)[(b) >> 3] &= ~BIT(b % 8)) +#define TESTBIT(a, b) (ISSET((a)[(b) >> 3], BIT(b % 8))) + +/* Min/max macros */ +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#define MAX(a,b) (((a) > (b)) ? (a) : (b)) + +/* Get number of array elements */ +#define NELEM(a) (sizeof(a) / sizeof(a[0])) + +#endif /* !_SYS_PARAM_H_ */