aboutsummaryrefslogtreecommitdiff
path: root/libc/libc-test/src/cmsg.c
blob: a8b1c371736c84f55e46210e0644225b2b909f66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <sys/param.h>
#include <sys/socket.h>

// Since the cmsg(3) macros are macros instead of functions, they aren't
// available to FFI.  libc must reimplement them, which is error-prone.  This
// file provides FFI access to the actual macros so they can be tested against
// the Rust reimplementations.

struct cmsghdr *cmsg_firsthdr(struct msghdr *msgh) {
	return CMSG_FIRSTHDR(msgh);
}

struct cmsghdr *cmsg_nxthdr(struct msghdr *msgh, struct cmsghdr *cmsg) {
	return CMSG_NXTHDR(msgh, cmsg);
}

size_t cmsg_space(size_t length) {
	return CMSG_SPACE(length);
}

size_t cmsg_len(size_t length) {
	return CMSG_LEN(length);
}

unsigned char *cmsg_data(struct cmsghdr *cmsg) {
	return CMSG_DATA(cmsg);
}