comparison configure.in @ 8578:729576bb91d8 HEAD

Some versions of Mac OS X have buggy CMSG_* macros, avoid using them. Patch by Apple.
author Timo Sirainen <tss@iki.fi>
date Fri, 19 Dec 2008 10:02:49 +0200
parents 9ec2882243a6
children 7c12e20f1eee
comparison
equal deleted inserted replaced
8577:164569761647 8578:729576bb91d8
1128 #include <sys/stat.h> 1128 #include <sys/stat.h>
1129 #include <unistd.h> 1129 #include <unistd.h>
1130 #include <fcntl.h> 1130 #include <fcntl.h>
1131 #include "fdpass.h" 1131 #include "fdpass.h"
1132 1132
1133 int nopen(void)
1134 {
1135 int i, n;
1136 struct stat sb;
1137 for (i = n = 0; i < 256; i++)
1138 if (fstat(i, &sb) == 0) n++;
1139 return n;
1140 }
1133 int main(void) 1141 int main(void)
1134 { 1142 {
1135 int fd[2], send_fd, recv_fd, status; 1143 int fd[2], send_fd, recv_fd, status, n1, n2;
1136 struct stat st, st2; 1144 struct stat st, st2;
1137 char data; 1145 char data;
1138 1146
1139 send_fd = creat("conftest.fdpass", 0600); 1147 send_fd = creat("conftest.fdpass", 0600);
1140 if (send_fd == -1) return 2; 1148 if (send_fd == -1) return 2;
1141 unlink("conftest.fdpass"); 1149 unlink("conftest.fdpass");
1142 if (fstat(send_fd, &st) < 0) return 2; 1150 if (fstat(send_fd, &st) < 0) return 2;
1143 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) return 2; 1151 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) return 2;
1152 n1 = nopen();
1144 1153
1145 switch (fork()) { 1154 switch (fork()) {
1146 case -1: 1155 case -1:
1147 return 2; 1156 return 2;
1148 case 0: 1157 case 0:
1155 return 2; 1164 return 2;
1156 if (status != 0) 1165 if (status != 0)
1157 return status; 1166 return status;
1158 if (fd_read(fd[1], &data, 1, &recv_fd) != 1) return 1; 1167 if (fd_read(fd[1], &data, 1, &recv_fd) != 1) return 1;
1159 if (fstat(recv_fd, &st2) < 0) return 2; 1168 if (fstat(recv_fd, &st2) < 0) return 2;
1160 return st.st_ino == st2.st_ino ? 0 : 1; 1169 /* nopen check is for making sure that only a single fd
1170 was received */
1171 n2 = nopen();
1172 return st.st_ino == st2.st_ino && n2 == n1 + 1 ? 0 : 1;
1161 } 1173 }
1162 } 1174 }
1163 ], [ 1175 ], [
1164 CFLAGS=$old_cflags 1176 CFLAGS=$old_cflags
1165 if test $i = 2; then 1177 if test $i = 2; then
1173 CFLAGS=$old_cflags 1185 CFLAGS=$old_cflags
1174 i_cv_fd_passing=no 1186 i_cv_fd_passing=no
1175 ]) 1187 ])
1176 done 1188 done
1177 ]); 1189 ]);
1190
1191 case "$host_os" in
1192 darwin[[1-9]].*)
1193 if test "$i_cv_fd_passing" = "yes"; then
1194 i_cv_fd_passing=buggy_cmsg_macros
1195 fi
1196 ;;
1197 esac
1178 1198
1179 if test $i_cv_fd_passing = buggy_cmsg_macros; then 1199 if test $i_cv_fd_passing = buggy_cmsg_macros; then
1180 AC_DEFINE(BUGGY_CMSG_MACROS,, Define if you have buggy CMSG macros) 1200 AC_DEFINE(BUGGY_CMSG_MACROS,, Define if you have buggy CMSG macros)
1181 fi 1201 fi
1182 1202