[glib] GSocket: define CMSG_LEN and CMSG_SPACE if the system doesn't



commit 1504a77655ec5291b8bccb321bc7e349dd2d53d3
Author: Dan Winship <danw gnome org>
Date:   Thu Feb 25 11:40:31 2010 -0500

    GSocket: define CMSG_LEN and CMSG_SPACE if the system doesn't
    
    https://bugzilla.gnome.org/show_bug.cgi?id=589989

 gio/gnetworkingprivate.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/gio/gnetworkingprivate.h b/gio/gnetworkingprivate.h
index 4477032..7c0fef0 100644
--- a/gio/gnetworkingprivate.h
+++ b/gio/gnetworkingprivate.h
@@ -68,6 +68,17 @@
 #define _PATH_RESCONF "/etc/resolv.conf"
 #endif
 
+#ifndef CMSG_LEN
+/* CMSG_LEN and CMSG_SPACE are defined by RFC 2292, but missing on
+ * some older platforms.
+ */
+#define CMSG_LEN(len) ((size_t)CMSG_DATA((struct cmsghdr *)NULL) + (len))
+
+/* CMSG_SPACE must add at least as much padding as CMSG_NXTHDR()
+ * adds. We overestimate here.
+ */
+#define ALIGN_TO_SIZEOF(len, obj) (((len) + sizeof (obj) - 1) & ~(sizeof (obj) - 1))
+#define CMSG_SPACE(len) ALIGN_TO_SIZEOF (CMSG_LEN (len), struct cmsghdr)
 #endif
 
 G_BEGIN_DECLS



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]