Xenomai  3.0.8
pipe.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_PIPE_H
19 #define _XENOMAI_ALCHEMY_PIPE_H
20 
21 #include <stdint.h>
22 #include <cobalt/uapi/kernel/pipe.h>
23 #include <alchemy/timer.h>
24 #include <alchemy/compat.h>
25 
32 #define P_MINOR_AUTO XNPIPE_MINOR_AUTO
33 
35 #define P_URGENT XNPIPE_URGENT
36 #define P_NORMAL XNPIPE_NORMAL
37 
38 struct RT_PIPE {
39  uintptr_t handle;
40 };
41 
42 typedef struct RT_PIPE RT_PIPE;
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 CURRENT_DECL(int, rt_pipe_create(RT_PIPE *pipe,
49  const char *name,
50  int minor, size_t poolsize));
51 
52 int rt_pipe_delete(RT_PIPE *pipe);
53 
54 ssize_t rt_pipe_read_timed(RT_PIPE *pipe,
55  void *buf, size_t size,
56  const struct timespec *abs_timeout);
57 
58 static inline
59 ssize_t rt_pipe_read_until(RT_PIPE *pipe,
60  void *buf, size_t size, RTIME timeout)
61 {
62  struct timespec ts;
63  return rt_pipe_read_timed(pipe, buf, size,
64  alchemy_abs_timeout(timeout, &ts));
65 }
66 
67 static inline
68 ssize_t rt_pipe_read(RT_PIPE *pipe,
69  void *buf, size_t size, RTIME timeout)
70 {
71  struct timespec ts;
72  return rt_pipe_read_timed(pipe, buf, size,
73  alchemy_rel_timeout(timeout, &ts));
74 }
75 
76 ssize_t rt_pipe_write(RT_PIPE *pipe,
77  const void *buf, size_t size, int mode);
78 
79 ssize_t rt_pipe_stream(RT_PIPE *pipe,
80  const void *buf, size_t size);
81 
82 int rt_pipe_bind(RT_PIPE *pipe,
83  const char *name, RTIME timeout);
84 
85 int rt_pipe_unbind(RT_PIPE *pipe);
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
93 #endif /* _XENOMAI_ALCHEMY_PIPE_H */
static ssize_t rt_pipe_read_until(RT_PIPE *pipe, void *buf, size_t size, RTIME timeout)
Read from a pipe (with absolute scalar timeout).
Definition: pipe.h:59
int rt_pipe_bind(RT_PIPE *pipe, const char *name, RTIME timeout)
Bind to a message pipe.
Definition: pipe.c:610
int rt_pipe_create(RT_PIPE *pipe, const char *name, int minor, size_t poolsize)
Create a message pipe.
Definition: pipe.c:136
ssize_t rt_pipe_write(RT_PIPE *pipe, const void *buf, size_t size, int mode)
Write a message to a pipe.
Definition: pipe.c:507
int rt_pipe_delete(RT_PIPE *pipe)
Delete a message pipe.
Definition: pipe.c:256
ssize_t rt_pipe_stream(RT_PIPE *pipe, const void *buf, size_t size)
Stream bytes through a pipe.
Definition: pipe.c:561
int rt_pipe_unbind(RT_PIPE *pipe)
Unbind from a message pipe.
Definition: pipe.c:632
static ssize_t rt_pipe_read(RT_PIPE *pipe, void *buf, size_t size, RTIME timeout)
Read from a pipe (with relative scalar timeout).
Definition: pipe.h:68
ssize_t rt_pipe_read_timed(RT_PIPE *pipe, void *buf, size_t size, const struct timespec *abs_timeout)
Read a message from a pipe.
Definition: pipe.c:393