Debian Codegraph @

third_party/rust/audioipc2/src/sys/unix/cmsghdr.c

raw
1 #include <sys/socket.h>
2 #include <inttypes.h>
3 #include <string.h>
4
5 const uint8_t*
6 cmsghdr_bytes(size_t* size)
7 {
8 int myfd = 0;
9
10 static union {
11 uint8_t buf[CMSG_SPACE(sizeof(myfd))];
12 struct cmsghdr align;
13 } u;
14
15 u.align.cmsg_len = CMSG_LEN(sizeof(myfd));
16 u.align.cmsg_level = SOL_SOCKET;
17 u.align.cmsg_type = SCM_RIGHTS;
18
19 memcpy(CMSG_DATA(&u.align), &myfd, sizeof(myfd));
20
21 *size = sizeof(u);
22 return (const uint8_t*)&u.buf;
23 }