X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fpipe.h;h=d5f1d396f0a0b1af7c8f0f937f1fecbd9f3d899c;hp=1a1087c10e12ed1d4b8a6637a8c3f635e1530044;hb=2aa28610e2bff8b40ad2810cbf0c7ea3b79e106d;hpb=9c2bd8db1c70269d37537b7d02bae41ccab29056 diff --git a/src/common/pipe.h b/src/common/pipe.h index 1a1087c10..d5f1d396f 100644 --- a/src/common/pipe.h +++ b/src/common/pipe.h @@ -1,18 +1,8 @@ /* - * Copyright (C) 2013 - David Goulet + * Copyright (C) 2013 David Goulet * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License, version 2 only, as - * published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef LTTNG_PIPE_H @@ -20,6 +10,7 @@ #include #include +#include enum lttng_pipe_state { LTTNG_PIPE_STATE_OPENED = 1, @@ -50,7 +41,7 @@ struct lttng_pipe { /* * Return 1 if read side is open else 0. */ -static inline int lttng_pipe_is_read_open(struct lttng_pipe *pipe) +static inline int lttng_pipe_is_read_open(const struct lttng_pipe *pipe) { return pipe->r_state == LTTNG_PIPE_STATE_OPENED ? 1 : 0; } @@ -58,17 +49,17 @@ static inline int lttng_pipe_is_read_open(struct lttng_pipe *pipe) /* * Return 1 if write side is open else 0. */ -static inline int lttng_pipe_is_write_open(struct lttng_pipe *pipe) +static inline int lttng_pipe_is_write_open(const struct lttng_pipe *pipe) { return pipe->w_state == LTTNG_PIPE_STATE_OPENED ? 1 : 0; } -static inline int lttng_pipe_get_readfd(struct lttng_pipe *pipe) +static inline int lttng_pipe_get_readfd(const struct lttng_pipe *pipe) { return pipe->fd[0]; } -static inline int lttng_pipe_get_writefd(struct lttng_pipe *pipe) +static inline int lttng_pipe_get_writefd(const struct lttng_pipe *pipe) { return pipe->fd[1]; } @@ -93,5 +84,11 @@ ssize_t lttng_pipe_read(struct lttng_pipe *pipe, void *buf, size_t count); LTTNG_HIDDEN ssize_t lttng_pipe_write(struct lttng_pipe *pipe, const void *buf, size_t count); +/* Returns and releases the read end of the pipe. */ +LTTNG_HIDDEN +int lttng_pipe_release_readfd(struct lttng_pipe *pipe); +/* Returns and releases the write end of the pipe. */ +LTTNG_HIDDEN +int lttng_pipe_release_writefd(struct lttng_pipe *pipe); #endif /* LTTNG_PIPE_H */