sdk: Add sys/param.h

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-03-25 08:46:48 -04:00
parent 8ca5cc6b58
commit c90d339586

View File

@@ -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_ */