Loading...
Searching...
No Matches
pipe.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 René Kijewski <rene.kijewski@fu-berlin.de>
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#pragma once
7
23
24#include <sys/types.h>
25
26#include "mutex.h"
27#include "ringbuffer.h"
28#include "thread.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#ifndef PIPE_BUF
35# define PIPE_BUF (128)
36#endif
37
50
58void pipe_init(pipe_t *pipe, ringbuffer_t *rb, void (*free)(void *));
59
72ssize_t pipe_read(pipe_t *pipe, void *buf, size_t n);
73
86ssize_t pipe_write(pipe_t *pipe, const void *buf, size_t n);
87
95pipe_t *pipe_malloc(unsigned size);
96
105
106#ifdef __cplusplus
107}
108#endif
109
struct _thread thread_t
forward declaration for thread_t, defined in thread.h
Definition sched.h:150
void free(void *ptr)
This is a no-op.
pipe_t * pipe_malloc(unsigned size)
Dynamically allocate a pipe with room for size bytes.
ssize_t pipe_read(pipe_t *pipe, void *buf, size_t n)
Read from a pipe.
void pipe_free(pipe_t *rp)
Free a pipe.
struct riot_pipe pipe_t
A generic pipe.
ssize_t pipe_write(pipe_t *pipe, const void *buf, size_t n)
Write to a pipe.
void pipe_init(pipe_t *pipe, ringbuffer_t *rb, void(*free)(void *))
Initialize a pipe.
Mutex for thread synchronization.
A utility for storing and retrieving byte data using a ring buffer.
Ringbuffer.
Definition ringbuffer.h:34
A generic pipe.
Definition pipe.h:41
thread_t * read_blocked
A thread that wants to write to this full pipe.
Definition pipe.h:43
ringbuffer_t * rb
Wrapped ringbuffer.
Definition pipe.h:42
void(* free)(void *)
Function to call by pipe_free().
Definition pipe.h:47
thread_t * write_blocked
A thread that wants to read from this empty pipe.
Definition pipe.h:45