Commit 5912a1fd authored by sergeyu's avatar sergeyu Committed by Commit bot

Add missing _ASSIGN() macro in NaCl's sys/socket.h

Some macros in sys/socket.h were using _ASSING() macro, which wasn't
defined anywhere.

BUG=402993

Review URL: https://codereview.chromium.org/598223002

Cr-Commit-Position: refs/heads/master@{#296621}
parent 4b6fdb27
...@@ -28,3 +28,4 @@ Local Modifications: ...@@ -28,3 +28,4 @@ Local Modifications:
* Added SOCK_CLOEXEC and SOCK_NONBLOCK socket type flags. * Added SOCK_CLOEXEC and SOCK_NONBLOCK socket type flags.
* Make sure SA_SIGINFO is defined under __native_client__ * Make sure SA_SIGINFO is defined under __native_client__
* Removed ss_len field from sockaddr_storage in sys/socket.h. * Removed ss_len field from sockaddr_storage in sys/socket.h.
* Added _ALIGNBYTES and _ALIGN() in sys/socket.h.
...@@ -59,7 +59,7 @@ typedef _BSD_SA_FAMILY_T_ sa_family_t; ...@@ -59,7 +59,7 @@ typedef _BSD_SA_FAMILY_T_ sa_family_t;
typedef _BSD_SOCKLEN_T_ socklen_t; typedef _BSD_SOCKLEN_T_ socklen_t;
#undef _BSD_SOCKLEN_T_ #undef _BSD_SOCKLEN_T_
#endif #endif
/* /*
* Types * Types
*/ */
...@@ -355,6 +355,18 @@ struct cmsgcred { ...@@ -355,6 +355,18 @@ struct cmsgcred {
gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ gid_t cmcred_groups[CMGROUP_MAX]; /* groups */
}; };
/*
* Round p (pointer or byte index) up to a correctly-aligned value
* for all data types (int, long, ...). The result is unsigned int
* and must be cast to any desired pointer type.
*/
#ifndef _ALIGNBYTES
#define _ALIGNBYTES (sizeof(int) - 1)
#endif
#ifndef _ALIGN
#define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
#endif
/* given pointer to struct cmsghdr, return pointer to data */ /* given pointer to struct cmsghdr, return pointer to data */
#define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ #define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
_ALIGN(sizeof(struct cmsghdr))) _ALIGN(sizeof(struct cmsghdr)))
...@@ -370,7 +382,7 @@ struct cmsgcred { ...@@ -370,7 +382,7 @@ struct cmsgcred {
#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) #define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
/* RFC 2292 additions */ /* RFC 2292 additions */
#define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l)) #define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
#define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l)) #define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment