openbsd-ports/net/libtorrent/patches/patch-scripts_checks_m4
dcoppa 2e45be0d32 Add a comment explaining why this patch is needed (for future
reference).
While here, fix pthread linking.

From a discussion with ajacoutot@
2012-12-10 15:05:12 +00:00

74 lines
2.4 KiB
Plaintext

$OpenBSD: patch-scripts_checks_m4,v 1.5 2012/12/10 15:05:12 dcoppa Exp $
When USE_SYSTRACE is set to Yes, systrace causes the check to fail
and KQUEUE_SOCKET_ONLY is wrongly set to 1:
---8<---
checking for kqueue support... yes
checking whether kqueue supports pipes and ptys... systrace: deny user: dcoppa, prog: /home/dcoppa/ports/pobj/libtorrent-0.12.9/libtorrent-0.12.9/conftest, pid: 17964(0)[16449], policy: /usr/bin/env, filters: 241, syscall: native-fswrite(5), filename: /dev/ptm
no
checking for fallocate... no
---8<---
$ grep KQUEUE_SOCKET_ONLY $(make show=WRKBUILD)/config.h
#define KQUEUE_SOCKET_ONLY 1
--- scripts/checks.m4.orig Fri Apr 6 15:17:41 2012
+++ scripts/checks.m4 Fri Apr 6 15:19:11 2012
@@ -93,51 +93,12 @@ AC_DEFUN([TORRENT_CHECK_KQUEUE], [
])
])
-AC_DEFUN([TORRENT_CHECK_KQUEUE_SOCKET_ONLY], [
- AC_MSG_CHECKING(whether kqueue supports pipes and ptys)
-
- AC_RUN_IFELSE(
- [[#include <fcntl.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/event.h>
- #include <sys/time.h>
- int main() {
- struct kevent ev[2], ev_out[2];
- struct timespec ts = { 0, 0 };
- int pfd[2], pty[2], kfd, n;
- char buffer[9001];
- if (pipe(pfd) == -1) return 1;
- if (fcntl(pfd[1], F_SETFL, O_NONBLOCK) == -1) return 2;
- while ((n = write(pfd[1], buffer, sizeof(buffer))) == sizeof(buffer));
- if ((pty[0]=posix_openpt(O_RDWR | O_NOCTTY)) == -1) return 3;
- if ((pty[1]=grantpt(pty[0])) == -1) return 4;
- EV_SET(ev+0, pfd[1], EVFILT_WRITE, EV_ADD | EV_ENABLE, 0, 0, NULL);
- EV_SET(ev+1, pty[1], EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, NULL);
- if ((kfd = kqueue()) == -1) return 5;
- if ((n = kevent(kfd, ev, 2, NULL, 0, NULL)) == -1) return 6;
- if (ev_out[0].flags & EV_ERROR) return 7;
- if (ev_out[1].flags & EV_ERROR) return 8;
- read(pfd[0], buffer, sizeof(buffer));
- if ((n = kevent(kfd, NULL, 0, ev_out, 2, &ts)) < 1) return 9;
- return 0;
- }
- ]],
- [
- AC_MSG_RESULT(yes)
- ], [
- AC_DEFINE(KQUEUE_SOCKET_ONLY, 1, kqueue only supports sockets.)
- AC_MSG_RESULT(no)
- ])
-])
-
AC_DEFUN([TORRENT_WITH_KQUEUE], [
AC_ARG_WITH(kqueue,
[ --with-kqueue enable kqueue. [[default=no]]],
[
if test "$withval" = "yes"; then
TORRENT_CHECK_KQUEUE
- TORRENT_CHECK_KQUEUE_SOCKET_ONLY
fi
])
])