X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fpipe.h;fp=src%2Fcommon%2Fpipe.h;h=0000000000000000000000000000000000000000;hp=d9f43d66e03265d71342aeace9e4d91b5dd8bebc;hb=c9e313bc594f40a86eed237dce222c0fc99c957f;hpb=4878de5c7deb512bbdac4fdfc498907efa06fb7c diff --git a/src/common/pipe.h b/src/common/pipe.h deleted file mode 100644 index d9f43d66e..000000000 --- a/src/common/pipe.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2013 David Goulet - * - * SPDX-License-Identifier: GPL-2.0-only - * - */ - -#ifndef LTTNG_PIPE_H -#define LTTNG_PIPE_H - -#include -#include -#include - -enum lttng_pipe_state { - LTTNG_PIPE_STATE_OPENED = 1, - LTTNG_PIPE_STATE_CLOSED = 2, -}; - -struct lttng_pipe { - /* Read: 0, Write: 1. */ - int fd[2]; - /* - * Flags of the pipe once opened. pipe(2) specifies either O_NONBLOCK or - * O_CLOEXEC can be used. Flags are set using fcntl(2) call. - */ - int flags; - - /* - * These states are protected by the operation mutex below. - */ - enum lttng_pipe_state r_state; - enum lttng_pipe_state w_state; - - /* Held for each read(2) operation. */ - pthread_mutex_t read_mutex; - /* Held for each write(2) operation. */ - pthread_mutex_t write_mutex; -}; - -/* - * Return 1 if read side is open else 0. - */ -static inline int lttng_pipe_is_read_open(const struct lttng_pipe *pipe) -{ - return pipe->r_state == LTTNG_PIPE_STATE_OPENED ? 1 : 0; -} - -/* - * Return 1 if write side is open else 0. - */ -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(const struct lttng_pipe *pipe) -{ - return pipe->fd[0]; -} - -static inline int lttng_pipe_get_writefd(const struct lttng_pipe *pipe) -{ - return pipe->fd[1]; -} - -struct lttng_pipe *lttng_pipe_open(int flags); -struct lttng_pipe *lttng_pipe_named_open(const char *path, mode_t mode, - int flags); -int lttng_pipe_write_close(struct lttng_pipe *pipe); -int lttng_pipe_read_close(struct lttng_pipe *pipe); -/* Close both side of pipe. */ -int lttng_pipe_close(struct lttng_pipe *pipe); -void lttng_pipe_destroy(struct lttng_pipe *pipe); - -ssize_t lttng_pipe_read(struct lttng_pipe *pipe, void *buf, size_t count); -ssize_t lttng_pipe_write(struct lttng_pipe *pipe, const void *buf, - size_t count); -/* Returns and releases the read end of the pipe. */ -int lttng_pipe_release_readfd(struct lttng_pipe *pipe); -/* Returns and releases the write end of the pipe. */ -int lttng_pipe_release_writefd(struct lttng_pipe *pipe); - -#endif /* LTTNG_PIPE_H */