mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Use macros from bsd headers
This commit is contained in:
parent
1c1aaf6223
commit
833d295a18
31
nx/external/bsd/include/sys/socket.h
vendored
31
nx/external/bsd/include/sys/socket.h
vendored
@ -437,11 +437,20 @@ struct cmsghdr {
|
||||
/* followed by u_char cmsg_data[]; */
|
||||
};
|
||||
|
||||
// socket credential stuff, we don't need this
|
||||
// cmsg macros, uses some obscure macro
|
||||
#define _ALIGNBYTES (sizeof(long) - 1)
|
||||
#define _ALIGN(p) (((unsigned long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
|
||||
|
||||
#define __ALIGNBYTES32 (sizeof(__uint32_t) - 1)
|
||||
#define __ALIGN32(p) ((__size_t)((char *)(__size_t)(p) + __ALIGNBYTES32) &~ __ALIGNBYTES32)
|
||||
/* given pointer to struct cmsghdr, return pointer to data */
|
||||
#define CMSG_DATA(cmsg) \
|
||||
((unsigned char *)(cmsg) + _ALIGN(sizeof(struct cmsghdr)))
|
||||
|
||||
/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
|
||||
#define CMSG_NXTHDR(mhdr, cmsg) \
|
||||
(((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \
|
||||
_ALIGN(sizeof(struct cmsghdr)) > \
|
||||
((char *)(mhdr)->msg_control) + (mhdr)->msg_controllen) ? \
|
||||
(struct cmsghdr *)NULL : \
|
||||
(struct cmsghdr *)((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len)))
|
||||
|
||||
/*
|
||||
* RFC 2292 requires to check msg_controllen, in case that the kernel returns
|
||||
@ -452,17 +461,11 @@ struct cmsghdr {
|
||||
(struct cmsghdr *)(mhdr)->msg_control : \
|
||||
(struct cmsghdr *)NULL)
|
||||
|
||||
/* Length of the contents of a control message of length len */
|
||||
#define CMSG_LEN(len) (_ALIGN(sizeof(struct cmsghdr)) + (len))
|
||||
|
||||
/*
|
||||
* Given pointer to struct cmsghdr, return pointer to next cmsghdr
|
||||
* RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr)
|
||||
*/
|
||||
#define CMSG_NXTHDR(mhdr, cmsg) \
|
||||
(((char *)(cmsg) + __ALIGN32((cmsg)->cmsg_len) + \
|
||||
__ALIGN32(sizeof(struct cmsghdr)) > \
|
||||
((char *)(mhdr)->msg_control) + (mhdr)->msg_controllen) ? \
|
||||
(struct cmsghdr *)NULL : \
|
||||
(struct cmsghdr *)((char *)(cmsg) + __ALIGN32((cmsg)->cmsg_len)))
|
||||
/* Length of the space taken up by a padded control message of length len */
|
||||
#define CMSG_SPACE(len) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(len))
|
||||
|
||||
/* "Socket"-level control message types: */
|
||||
#define SCM_RIGHTS 0x01 /* access rights (array of int) */
|
||||
|
Loading…
Reference in New Issue
Block a user