Check if we need to define _XOPEN_SOURCE for struct msghdr.msg_control
authorAlan Coopersmith <alan.coopersmith@oracle.com>
Fri, 8 Nov 2013 04:23:27 +0000 (20:23 -0800)
committerAlan Coopersmith <alan.coopersmith@oracle.com>
Fri, 8 Nov 2013 04:25:04 +0000 (20:25 -0800)
Required to expose the structure members in Solaris headers, since it
was an XPG4/UNIX95 addition to the Solaris ABI.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
configure.ac

index d054a43..87804ba 100644 (file)
@@ -90,6 +90,40 @@ xauto)
        ;;
 esac
 
+# XPG4v2/UNIX95 added msg_control - check to see if we need to define
+# _XOPEN_SOURCE to get it (such as on Solaris)
+AC_CHECK_MEMBER([struct msghdr.msg_control], [], [],
+                 [
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>
+                 ])
+# First try for Solaris in C99 compliant mode, which requires XPG6/UNIX03
+if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
+    unset ac_cv_member_struct_msghdr_msg_control
+    AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=600])
+    AC_CHECK_MEMBER([struct msghdr.msg_control],
+                    [AC_DEFINE([_XOPEN_SOURCE], [600],
+                       [Defined if needed to expose struct msghdr.msg_control])
+                    ], [], [
+#define _XOPEN_SOURCE 600
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>
+                     ])
+fi
+# If that didn't work, fall back to XPG5/UNIX98 with C89
+if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
+    unset ac_cv_member_struct_msghdr_msg_control
+    AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=500])
+    AC_CHECK_MEMBER([struct msghdr.msg_control],
+                    [AC_DEFINE([_XOPEN_SOURCE], [500],
+                       [Defined if needed to expose struct msghdr.msg_control])
+                    ], [sendfds="no"], [
+#define _XOPEN_SOURCE 500
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>
+                     ])
+fi
+
 case x$sendfds in
 xyes)
         AC_DEFINE([HAVE_SENDMSG],1,[Define if your platform supports sendmsg])