Xenomai 3.3.2
Loading...
Searching...
No Matches
buffer.h
1/*
2 * Copyright (C) 2011 Philippe Gerum <rpm@xenomai.org>.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 */
18#ifndef _XENOMAI_ALCHEMY_BUFFER_H
19#define _XENOMAI_ALCHEMY_BUFFER_H
20
21#include <stdint.h>
22#include <alchemy/timer.h>
23
30#define B_PRIO 0x1 /* Pend by task priority order. */
31#define B_FIFO 0x0 /* Pend by FIFO order. */
32
33struct RT_BUFFER {
34 uintptr_t handle;
35};
36
37typedef struct RT_BUFFER RT_BUFFER;
38
60 size_t totalmem;
64 size_t availmem;
68 char name[XNOBJECT_NAME_LEN];
69};
70
71typedef struct RT_BUFFER_INFO RT_BUFFER_INFO;
72
73#ifdef __cplusplus
74extern "C" {
75#endif
76
77int rt_buffer_create(RT_BUFFER *bf,
78 const char *name,
79 size_t bufsz,
80 int mode);
81
82int rt_buffer_delete(RT_BUFFER *bf);
83
84ssize_t rt_buffer_write_timed(RT_BUFFER *bf,
85 const void *ptr, size_t size,
86 const struct timespec *abs_timeout);
87
88static inline
89ssize_t rt_buffer_write_until(RT_BUFFER *bf,
90 const void *ptr, size_t size,
91 RTIME timeout)
92{
93 struct timespec ts;
94 return rt_buffer_write_timed(bf, ptr, size,
95 alchemy_abs_timeout(timeout, &ts));
96}
97
98static inline
99ssize_t rt_buffer_write(RT_BUFFER *bf,
100 const void *ptr, size_t size,
101 RTIME timeout)
102{
103 struct timespec ts;
104 return rt_buffer_write_timed(bf, ptr, size,
105 alchemy_rel_timeout(timeout, &ts));
106}
107
108ssize_t rt_buffer_read_timed(RT_BUFFER *bf,
109 void *ptr, size_t size,
110 const struct timespec *abs_timeout);
111
112static inline
113ssize_t rt_buffer_read_until(RT_BUFFER *bf,
114 void *ptr, size_t size,
115 RTIME timeout)
116{
117 struct timespec ts;
118 return rt_buffer_read_timed(bf, ptr, size,
119 alchemy_abs_timeout(timeout, &ts));
120}
121
122static inline
123ssize_t rt_buffer_read(RT_BUFFER *bf,
124 void *ptr, size_t size,
125 RTIME timeout)
126{
127 struct timespec ts;
128 return rt_buffer_read_timed(bf, ptr, size,
129 alchemy_rel_timeout(timeout, &ts));
130}
131
132int rt_buffer_clear(RT_BUFFER *bf);
133
134int rt_buffer_inquire(RT_BUFFER *bf,
135 RT_BUFFER_INFO *info);
136
137int rt_buffer_bind(RT_BUFFER *bf,
138 const char *name, RTIME timeout);
139
140int rt_buffer_unbind(RT_BUFFER *bf);
141
142#ifdef __cplusplus
143}
144#endif
145
148#endif /* _XENOMAI_ALCHEMY_BUFFER_H */
static ssize_t rt_buffer_write(RT_BUFFER *bf, const void *ptr, size_t size, RTIME timeout)
Write to an IPC buffer (with relative scalar timeout).
Definition buffer.h:99
static ssize_t rt_buffer_read(RT_BUFFER *bf, void *ptr, size_t size, RTIME timeout)
Read from an IPC buffer (with relative scalar timeout).
Definition buffer.h:123
int rt_buffer_create(RT_BUFFER *bf, const char *name, size_t bufsz, int mode)
Create an IPC buffer.
Definition buffer.c:213
static ssize_t rt_buffer_read_until(RT_BUFFER *bf, void *ptr, size_t size, RTIME timeout)
Read from an IPC buffer (with absolute scalar timeout).
Definition buffer.h:113
int rt_buffer_unbind(RT_BUFFER *bf)
Unbind from an IPC buffer.
Definition buffer.c:947
ssize_t rt_buffer_write_timed(RT_BUFFER *bf, const void *ptr, size_t size, const struct timespec *abs_timeout)
Write to an IPC buffer.
Definition buffer.c:672
ssize_t rt_buffer_read_timed(RT_BUFFER *bf, void *ptr, size_t size, const struct timespec *abs_timeout)
Read from an IPC buffer.
Definition buffer.c:453
int rt_buffer_inquire(RT_BUFFER *bf, RT_BUFFER_INFO *info)
Query buffer status.
Definition buffer.c:856
int rt_buffer_bind(RT_BUFFER *bf, const char *name, RTIME timeout)
Bind to an IPC buffer.
Definition buffer.c:925
static ssize_t rt_buffer_write_until(RT_BUFFER *bf, const void *ptr, size_t size, RTIME timeout)
Write to an IPC buffer (with absolute scalar timeout).
Definition buffer.h:89
int rt_buffer_delete(RT_BUFFER *bf)
Delete an IPC buffer.
Definition buffer.c:307
int rt_buffer_clear(RT_BUFFER *bf)
Clear an IPC buffer.
Definition buffer.c:812
Buffer status descriptor .
Definition buffer.h:46
int owaiters
Number of tasks waiting on the write side of the buffer for sending out data.
Definition buffer.h:56
int iwaiters
Number of tasks waiting on the read side of the buffer for input data.
Definition buffer.h:51
size_t totalmem
Overall size of buffer (in bytes).
Definition buffer.h:60
size_t availmem
Amount of memory currently available for holding more data.
Definition buffer.h:64
char name[XNOBJECT_NAME_LEN]
Name of the buffer.
Definition buffer.h:68