summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-08-01 01:59:58 +0200
committerLennart Poettering <lennart@poettering.net>2009-08-01 01:59:58 +0200
commite5c2256e360df3662295b8cc0594568e425e8679 (patch)
tree855ce0e26013ed5fddd5fb0a5233d624def7317c /src/pulsecore
parent0113e7282cc5c0131f9f681b84459fcdf2e806c4 (diff)
pipe: replace PIPE_BUF macro pa pa_pipe_buf call
This should help portability to platforms that lack PIPE_BUF. Based on a patch from Samuel Thibault. See ticket #546
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/core-util.c16
-rw-r--r--src/pulsecore/core-util.h3
2 files changed, 19 insertions, 0 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 5f777d5b..d01efa23 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2779,3 +2779,19 @@ char* pa_maybe_prefix_path(const char *path, const char *prefix) {
return pa_sprintf_malloc("%s" PA_PATH_SEP "%s", prefix, path);
}
+
+size_t pa_pipe_buf(int fd) {
+
+#ifdef _PC_PIPE_BUF
+ long n;
+
+ if ((n = fpathconf(fd, _PC_PIPE_BUF)) >= 0)
+ return (size_t) n;
+#endif
+
+#ifdef PIPE_BUF
+ return PIPE_BUF;
+#else
+ return 4096;
+#endif
+}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 96a0480a..b5e8453b 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -236,4 +236,7 @@ char **pa_split_spaces_strv(const char *s);
char* pa_maybe_prefix_path(const char *path, const char *prefix);
+/* Returns size of the specified pipe or 4096 on failure */
+size_t pa_pipe_buf(int fd);
+
#endif