From 282b682caba2fc3d932591d7842cb953ad2357f8 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Thu, 31 Aug 2017 14:57:34 +0300 Subject: [PATCH] tests: ipcpipeline: provide pipe2() on systems that don't have it https://bugzilla.gnome.org/show_bug.cgi?id=786763 --- configure.ac | 2 +- meson.build | 1 + tests/check/pipelines/ipcpipeline.c | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6593bc2..a6c0abd 100644 --- a/configure.ac +++ b/configure.ac @@ -171,7 +171,7 @@ dnl *** checks for structures *** dnl *** checks for compiler characteristics *** dnl *** checks for library functions *** -AC_CHECK_FUNCS([gmtime_r]) +AC_CHECK_FUNCS([gmtime_r pipe2]) dnl *** checks for headers *** AC_CHECK_HEADERS([sys/utsname.h]) diff --git a/meson.build b/meson.build index cd79e52..6724e6c 100644 --- a/meson.build +++ b/meson.build @@ -195,6 +195,7 @@ check_functions = [ # check token HAVE_ORC # check token HAVE_OSX # check token HAVE_OSX_VIDEO + ['HAVE_PIPE2', 'pipe2'], # check token HAVE_PNG # check token HAVE_PVR # check token HAVE_QUICKTIME diff --git a/tests/check/pipelines/ipcpipeline.c b/tests/check/pipelines/ipcpipeline.c index 3384ae2..0adf7e2 100644 --- a/tests/check/pipelines/ipcpipeline.c +++ b/tests/check/pipelines/ipcpipeline.c @@ -22,6 +22,10 @@ * Boston, MA 02110-1301, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #define _GNU_SOURCE /* See feature_test_macros(7) */ #include #include @@ -33,6 +37,25 @@ #include #include +#ifndef HAVE_PIPE2 +static int +pipe2 (int pipedes[2], int flags) +{ + int ret = pipe (pipedes); + if (ret < 0) + return ret; + if (flags != 0) { + ret = fcntl (pipedes[0], F_SETFL, flags); + if (ret < 0) + return ret; + ret = fcntl (pipedes[1], F_SETFL, flags); + if (ret < 0) + return ret; + } + return 0; +} +#endif + /* This enum contains flags that are used to configure the setup that * test_base() will do internally */ typedef enum -- 2.7.4