[vlc-commits] Implement vlc_pipe()

Rémi Denis-Courmont git at videolan.org
Wed Feb 9 22:01:46 CET 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Feb  9 22:46:09 2011 +0200| [c8778a818a80125ce4864199d2aaa9c741cf35ea] | committer: Rémi Denis-Courmont

Implement vlc_pipe()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c8778a818a80125ce4864199d2aaa9c741cf35ea
---

 configure.ac           |    2 +-
 include/vlc_fs.h       |    1 +
 src/libvlccore.sym     |    1 +
 src/misc/filesystem.c  |   20 ++++++++++++++++++++
 src/win32/filesystem.c |    5 +++++
 5 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 45b5242..e987183 100644
--- a/configure.ac
+++ b/configure.ac
@@ -557,7 +557,7 @@ AC_CHECK_FUNCS(fdatasync,,
 AC_FUNC_STRCOLL
 
 dnl Check for non-standard system calls
-AC_CHECK_FUNCS([accept4 dup3 eventfd vmsplice sched_getaffinity])
+AC_CHECK_FUNCS([accept4 dup3 pipe2 eventfd vmsplice sched_getaffinity])
 
 AH_BOTTOM([#include <vlc_fixups.h>])
 
diff --git a/include/vlc_fs.h b/include/vlc_fs.h
index 56d2f57..da6d28e 100644
--- a/include/vlc_fs.h
+++ b/include/vlc_fs.h
@@ -73,4 +73,5 @@ VLC_EXPORT( int, vlc_lstat, ( const char *filename, struct stat *buf ) );
 VLC_EXPORT( int, vlc_mkstemp, ( char * ) );
 
 VLC_EXPORT( int, vlc_dup, ( int ) );
+VLC_EXPORT( int, vlc_pipe, ( int[2] ) );
 #endif
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index a59f8af..bd4a087 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -467,6 +467,7 @@ vlc_strcasestr
 vlc_unlink
 vlc_rename
 vlc_dup
+vlc_pipe
 vlc_accept
 utf8_vfprintf
 var_AddCallback
diff --git a/src/misc/filesystem.c b/src/misc/filesystem.c
index 9138ae9..80576e1 100644
--- a/src/misc/filesystem.c
+++ b/src/misc/filesystem.c
@@ -334,6 +334,26 @@ int vlc_dup (int oldfd)
     return newfd;
 }
 
+/**
+ * Creates a pipe (see "man pipe" for further reference).
+ */
+int vlc_pipe (int fds[2])
+{
+#ifdef HAVE_PIPE2
+    if (pipe2 (fds, O_CLOEXEC) == 0)
+        return 0;
+    if (errno != ENOSYS)
+        return -1;
+#endif
+
+    if (pipe (fds))
+        return -1;
+
+    fcntl (fds[0], F_SETFD, FD_CLOEXEC);
+    fcntl (fds[1], F_SETFD, FD_CLOEXEC);
+    return 0;
+}
+
 #include <vlc_network.h>
 
 /**
diff --git a/src/win32/filesystem.c b/src/win32/filesystem.c
index 62c0b1e..e236186 100644
--- a/src/win32/filesystem.c
+++ b/src/win32/filesystem.c
@@ -255,6 +255,11 @@ int vlc_dup (int oldfd)
 #endif
 }
 
+int vlc_pipe (int fds[2])
+{
+    return _pipe (fds, 32768, O_BINARY);
+}
+
 #include <vlc_network.h>
 
 int vlc_socket (int pf, int type, int proto, bool nonblock)



More information about the vlc-commits mailing list