12add0d91Sopenharmony_ci#include <sys/param.h>
22add0d91Sopenharmony_ci#include <sys/socket.h>
32add0d91Sopenharmony_ci
42add0d91Sopenharmony_ci// Since the cmsg(3) macros are macros instead of functions, they aren't
52add0d91Sopenharmony_ci// available to FFI.  libc must reimplement them, which is error-prone.  This
62add0d91Sopenharmony_ci// file provides FFI access to the actual macros so they can be tested against
72add0d91Sopenharmony_ci// the Rust reimplementations.
82add0d91Sopenharmony_ci
92add0d91Sopenharmony_cistruct cmsghdr *cmsg_firsthdr(struct msghdr *msgh) {
102add0d91Sopenharmony_ci	return CMSG_FIRSTHDR(msgh);
112add0d91Sopenharmony_ci}
122add0d91Sopenharmony_ci
132add0d91Sopenharmony_cistruct cmsghdr *cmsg_nxthdr(struct msghdr *msgh, struct cmsghdr *cmsg) {
142add0d91Sopenharmony_ci	return CMSG_NXTHDR(msgh, cmsg);
152add0d91Sopenharmony_ci}
162add0d91Sopenharmony_ci
172add0d91Sopenharmony_cisize_t cmsg_space(size_t length) {
182add0d91Sopenharmony_ci	return CMSG_SPACE(length);
192add0d91Sopenharmony_ci}
202add0d91Sopenharmony_ci
212add0d91Sopenharmony_cisize_t cmsg_len(size_t length) {
222add0d91Sopenharmony_ci	return CMSG_LEN(length);
232add0d91Sopenharmony_ci}
242add0d91Sopenharmony_ci
252add0d91Sopenharmony_ciunsigned char *cmsg_data(struct cmsghdr *cmsg) {
262add0d91Sopenharmony_ci	return CMSG_DATA(cmsg);
272add0d91Sopenharmony_ci}
282add0d91Sopenharmony_ci
29