[vlc-devel] commit: Provide replacement for CMSG_LEN and CMSG_SPACE ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Oct 9 19:50:30 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Thu Oct  9 20:49:49 2008 +0300| [9dd13ebf18681e4ff58af0b52325d12aa1c23d90] | committer: Rémi Denis-Courmont 

Provide replacement for CMSG_LEN and CMSG_SPACE

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9dd13ebf18681e4ff58af0b52325d12aa1c23d90
---

 bin/rootwrap.c         |   10 ++++++++++
 src/network/rootbind.c |   11 +++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/bin/rootwrap.c b/bin/rootwrap.c
index f2c851a..cff9476 100644
--- a/bin/rootwrap.c
+++ b/bin/rootwrap.c
@@ -45,6 +45,16 @@
 #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)
 {
diff --git a/src/network/rootbind.c b/src/network/rootbind.c
index dfdf624..b9c94b5 100644
--- a/src/network/rootbind.c
+++ b/src/network/rootbind.c
@@ -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
  */




More information about the vlc-devel mailing list