]> git.sesse.net Git - vlc/commitdiff
Provide replacement for CMSG_LEN and CMSG_SPACE
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Thu, 9 Oct 2008 17:49:49 +0000 (20:49 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Thu, 9 Oct 2008 17:50:27 +0000 (20:50 +0300)
bin/rootwrap.c
src/network/rootbind.c

index f2c851a3544347ea5cdc522cf29a62f3f68c49e8..cff9476b5d8770b0ef197ce83be47002b55e8cd2 100644 (file)
 #ifndef AF_LOCAL
 # define AF_LOCAL AF_UNIX
 #endif
+/* Required yet non-standard cmsg functions */
+#ifndef CMSG_ALIGN
+# define CMSG_ALIGN(len) (((len) + sizeof(intptr_t)-1) & ~(sizeof(intptr_t)-1))
+#endif
+#ifndef CMSG_SPACE
+# define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len))
+#endif
+#ifndef CMSG_LEN
+# define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
+#endif
 
 static inline int is_allowed_port (uint16_t port)
 {
index dfdf6241f993c5d796a2241615d0f461c843646b..b9c94b55eac5f34d95e198425e98ac2a4fcd8fb9 100644 (file)
@@ -45,6 +45,17 @@ int rootwrap_bind (int, int, int, const struct sockaddr *, size_t);
 #include <netinet/in.h>
 #include <pthread.h>
 
+/* Required yet non-standard cmsg functions */
+#ifndef CMSG_ALIGN
+# define CMSG_ALIGN(len) (((len) + sizeof(intptr_t)-1) & ~(sizeof(intptr_t)-1))
+#endif
+#ifndef CMSG_SPACE
+# define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len))
+#endif
+#ifndef CMSG_LEN
+# define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
+#endif
+
 /**
  * Receive a file descriptor from another process
  */