xref: /rust-libc-0.2.174/libc-test/src/cmsg.c (revision 38cf5b15)
1*38cf5b15SAlan Somers #include <sys/param.h>
2*38cf5b15SAlan Somers #include <sys/socket.h>
3*38cf5b15SAlan Somers 
4*38cf5b15SAlan Somers // Since the cmsg(3) macros are macros instead of functions, they aren't
5*38cf5b15SAlan Somers // available to FFI.  libc must reimplement them, which is error-prone.  This
6*38cf5b15SAlan Somers // file provides FFI access to the actual macros so they can be tested against
7*38cf5b15SAlan Somers // the Rust reimplementations.
8*38cf5b15SAlan Somers 
cmsg_firsthdr(struct msghdr * msgh)9*38cf5b15SAlan Somers struct cmsghdr *cmsg_firsthdr(struct msghdr *msgh) {
10*38cf5b15SAlan Somers 	return CMSG_FIRSTHDR(msgh);
11*38cf5b15SAlan Somers }
12*38cf5b15SAlan Somers 
cmsg_nxthdr(struct msghdr * msgh,struct cmsghdr * cmsg)13*38cf5b15SAlan Somers struct cmsghdr *cmsg_nxthdr(struct msghdr *msgh, struct cmsghdr *cmsg) {
14*38cf5b15SAlan Somers 	return CMSG_NXTHDR(msgh, cmsg);
15*38cf5b15SAlan Somers }
16*38cf5b15SAlan Somers 
cmsg_space(size_t length)17*38cf5b15SAlan Somers size_t cmsg_space(size_t length) {
18*38cf5b15SAlan Somers 	return CMSG_SPACE(length);
19*38cf5b15SAlan Somers }
20*38cf5b15SAlan Somers 
cmsg_len(size_t length)21*38cf5b15SAlan Somers size_t cmsg_len(size_t length) {
22*38cf5b15SAlan Somers 	return CMSG_LEN(length);
23*38cf5b15SAlan Somers }
24*38cf5b15SAlan Somers 
cmsg_data(struct cmsghdr * cmsg)25*38cf5b15SAlan Somers unsigned char *cmsg_data(struct cmsghdr *cmsg) {
26*38cf5b15SAlan Somers 	return CMSG_DATA(cmsg);
27*38cf5b15SAlan Somers }
28*38cf5b15SAlan Somers 
29