diff --git a/sys/netlink/netlink.h b/sys/netlink/netlink.h --- a/sys/netlink/netlink.h +++ b/sys/netlink/netlink.h @@ -194,11 +194,8 @@ }; -#ifndef roundup2 -#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ -#endif #define NL_ITEM_ALIGN_SIZE sizeof(uint32_t) -#define NL_ITEM_ALIGN(_len) roundup2(_len, NL_ITEM_ALIGN_SIZE) +#define NL_ITEM_ALIGN(_len) __align_up(_len, NL_ITEM_ALIGN_SIZE) #define NL_ITEM_DATA(_ptr, _off) ((void *)((char *)(_ptr) + _off)) #define NL_ITEM_DATA_CONST(_ptr, _off) ((const void *)((const char *)(_ptr) + _off)) @@ -208,25 +205,24 @@ #define NL_ITEM_ITER(_ptr, _len, _LEN_MACRO) \ ((_len) -= _LEN_MACRO(_ptr), NL_ITEM_NEXT(_ptr, _LEN_MACRO)) +/* part of netlink(3) API */ +#define NLMSG_ALIGNTO NL_ITEM_ALIGN_SIZE +#define NLMSG_ALIGN(_len) NL_ITEM_ALIGN(_len) #ifndef _KERNEL /* part of netlink(3) API */ -#define NLMSG_ALIGNTO NL_ITEM_ALIGN_SIZE -#define NLMSG_ALIGN(_len) NL_ITEM_ALIGN(_len) -#define NLMSG_HDRLEN ((int)sizeof(struct nlmsghdr)) -#define NLMSG_LENGTH(_len) ((_len) + NLMSG_HDRLEN) -#define NLMSG_SPACE(_len) NLMSG_ALIGN(NLMSG_LENGTH(_len)) -#define NLMSG_DATA(_hdr) NL_ITEM_DATA(_hdr, NLMSG_HDRLEN) -#define _NLMSG_LEN(_hdr) ((int)(_hdr)->nlmsg_len) +#define NLMSG_HDRLEN (sizeof(struct nlmsghdr)) +#define NLMSG_LENGTH(_len) ((_len) + NLMSG_HDRLEN) +#define NLMSG_SPACE(_len) NLMSG_ALIGN(NLMSG_LENGTH(_len)) +#define NLMSG_DATA(_hdr) NL_ITEM_DATA(_hdr, NLMSG_HDRLEN) +#define _NLMSG_LEN(_hdr) ((_hdr)->nlmsg_len) #define _NLMSG_ALIGNED_LEN(_hdr) NLMSG_ALIGN(_NLMSG_LEN(_hdr)) #define NLMSG_OK(_hdr, _len) NL_ITEM_OK(_hdr, _len, NLMSG_HDRLEN, _NLMSG_LEN) #define NLMSG_PAYLOAD(_hdr,_len) (_NLMSG_LEN(_hdr) - NLMSG_SPACE((_len))) #define NLMSG_NEXT(_hdr, _len) NL_ITEM_ITER(_hdr, _len, _NLMSG_ALIGNED_LEN) #else -#define NLMSG_ALIGNTO 4U -#define NLMSG_ALIGN(len) (((len) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1)) -#define NLMSG_HDRLEN ((int)NLMSG_ALIGN(sizeof(struct nlmsghdr))) +#define NLMSG_HDRLEN (NLMSG_ALIGN(sizeof(struct nlmsghdr))) #endif /*