[libc-commits] [libc] [libc] Add struct cmsghdr and associated macros (PR #193756)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Thu Apr 23 07:15:39 PDT 2026


================
@@ -50,4 +50,23 @@
 #define SHUT_WR 1
 #define SHUT_RDWR 2
 
+#define SCM_RIGHTS 1
+
+#define CMSG_ALIGN(len) (((len) + sizeof(size_t) - 1) & ~(sizeof(size_t) - 1))
+#define CMSG_LEN(len) (sizeof(struct cmsghdr) + (len))
+#define CMSG_SPACE(len) (sizeof(struct cmsghdr) + CMSG_ALIGN(len))
+
+#define CMSG_FIRSTHDR(msg)                                                     \
----------------
kaladron wrote:

I'm curious for type safety if we could do something like have these be static inline in the header, and have the define point to those functions so that we satisfy the POSIX needs for this to be a macro.

https://github.com/llvm/llvm-project/pull/193756


More information about the libc-commits mailing list