aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvanilla <vanilla@FreeBSD.org>2017-02-06 22:47:24 +0800
committervanilla <vanilla@FreeBSD.org>2017-02-06 22:47:24 +0800
commitd25d4cd06465e8e35e38a46b43d2463c64eb7379 (patch)
treefe1368181cd14cf8ca4cb721406502578d90f744
parent24e94e72e601c956bc9f9b2a2cab62ebeb10c90a (diff)
downloadfreebsd-ports-gnome-d25d4cd06465e8e35e38a46b43d2463c64eb7379.tar.gz
freebsd-ports-gnome-d25d4cd06465e8e35e38a46b43d2463c64eb7379.tar.zst
freebsd-ports-gnome-d25d4cd06465e8e35e38a46b43d2463c64eb7379.zip
Enable cpu affinity function.
-rw-r--r--devel/pecl-swoole/Makefile1
-rw-r--r--devel/pecl-swoole/files/patch-config.m418
-rw-r--r--devel/pecl-swoole/files/patch-include_swoole.h20
-rw-r--r--devel/pecl-swoole/files/patch-src_network_Server.c16
-rw-r--r--devel/pecl-swoole/files/patch-swoole__process.c15
5 files changed, 68 insertions, 2 deletions
diff --git a/devel/pecl-swoole/Makefile b/devel/pecl-swoole/Makefile
index c778c292c245..38829bbea260 100644
--- a/devel/pecl-swoole/Makefile
+++ b/devel/pecl-swoole/Makefile
@@ -3,6 +3,7 @@
PORTNAME= swoole
PORTVERSION= 1.9.5
+PORTREVISION= 1
CATEGORIES= devel net
MASTER_SITES= http://pecl.php.net/get/
PKGNAMEPREFIX= pecl-
diff --git a/devel/pecl-swoole/files/patch-config.m4 b/devel/pecl-swoole/files/patch-config.m4
index c90dfa42b320..9d5e05d598d0 100644
--- a/devel/pecl-swoole/files/patch-config.m4
+++ b/devel/pecl-swoole/files/patch-config.m4
@@ -1,6 +1,20 @@
---- config.m4.orig 2017-02-05 15:08:47 UTC
+--- config.m4.orig 2017-01-24 02:05:48 UTC
+++ config.m4
-@@ -178,7 +178,7 @@ if test "$PHP_SWOOLE" != "no"; then
+@@ -85,7 +85,13 @@ AC_DEFUN([AC_SWOOLE_CPU_AFFINITY],
+ AC_MSG_CHECKING([for cpu affinity])
+ AC_TRY_COMPILE(
+ [
++ #ifdef __FreeBSD__
++ #include <sys/types.h>
++ #include <sys/cpuset.h>
++ typedef cpuset_t cpu_set_t;
++ #else
+ #include <sched.h>
++ #endif
+ ], [
+ cpu_set_t cpu_set;
+ CPU_ZERO(&cpu_set);
+@@ -178,7 +184,7 @@ if test "$PHP_SWOOLE" != "no"; then
AC_CHECK_LIB(c, poll, AC_DEFINE(HAVE_POLL, 1, [have poll]))
AC_CHECK_LIB(c, sendfile, AC_DEFINE(HAVE_SENDFILE, 1, [have sendfile]))
AC_CHECK_LIB(c, kqueue, AC_DEFINE(HAVE_KQUEUE, 1, [have kqueue]))
diff --git a/devel/pecl-swoole/files/patch-include_swoole.h b/devel/pecl-swoole/files/patch-include_swoole.h
new file mode 100644
index 000000000000..2a661b1dd492
--- /dev/null
+++ b/devel/pecl-swoole/files/patch-include_swoole.h
@@ -0,0 +1,20 @@
+--- include/swoole.h.orig 2017-01-24 02:05:48 UTC
++++ include/swoole.h
+@@ -40,7 +40,17 @@ extern "C" {
+ #include <assert.h>
+ #include <time.h>
+ #include <pthread.h>
++
++#if defined(HAVE_CPU_AFFINITY)
++#ifdef __FreeBSD__
++#include <sys/types.h>
++#include <sys/cpuset.h>
++#include <pthread_np.h>
++typedef cpuset_t cpu_set_t;
++#else
+ #include <sched.h>
++#endif
++#endif
+
+ #include <arpa/inet.h>
+ #include <netinet/in.h>
diff --git a/devel/pecl-swoole/files/patch-src_network_Server.c b/devel/pecl-swoole/files/patch-src_network_Server.c
new file mode 100644
index 000000000000..0dae3fa5df46
--- /dev/null
+++ b/devel/pecl-swoole/files/patch-src_network_Server.c
@@ -0,0 +1,16 @@
+--- src/network/Server.c.orig 2017-02-06 09:30:50 UTC
++++ src/network/Server.c
+@@ -522,7 +522,13 @@ int swServer_worker_init(swServer *serv,
+ {
+ CPU_SET(SwooleWG.id % SW_CPU_NUM, &cpu_set);
+ }
++
++#ifdef __FreeBSD__
++ if (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
++ sizeof(cpu_set), &cpu_set) < 0)
++#else
+ if (sched_setaffinity(getpid(), sizeof(cpu_set), &cpu_set) < 0)
++#endif
+ {
+ swSysError("sched_setaffinity() failed.");
+ }
diff --git a/devel/pecl-swoole/files/patch-swoole__process.c b/devel/pecl-swoole/files/patch-swoole__process.c
new file mode 100644
index 000000000000..ddd1d1678bb2
--- /dev/null
+++ b/devel/pecl-swoole/files/patch-swoole__process.c
@@ -0,0 +1,15 @@
+--- swoole_process.c.orig 2017-02-06 09:32:48 UTC
++++ swoole_process.c
+@@ -963,7 +963,12 @@ static PHP_METHOD(swoole_process, setaff
+ CPU_SET(Z_LVAL_P(value), &cpu_set);
+ SW_HASHTABLE_FOREACH_END();
+
++#ifdef __FreeBSD__
++ if (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
++ sizeof(cpu_set), &cpu_set) < 0)
++#else
+ if (sched_setaffinity(getpid(), sizeof(cpu_set), &cpu_set) < 0)
++#endif
+ {
+ swoole_php_sys_error(E_WARNING, "sched_setaffinity() failed.");
+ RETURN_FALSE;