summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-03 00:19:06 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-03 00:29:34 +0200
commita6e8978fd9b5786607438689f8cd8b8efb8ef77e (patch)
tree3c2e0982771540ab9b5a061a1645a8a36568bacf /include
parentd409fd569683d8f0e8c8f65d4820087dbf7c0786 (diff)
downloadouroboros-a6e8978fd9b5786607438689f8cd8b8efb8ef77e.tar.gz
ouroboros-a6e8978fd9b5786607438689f8cd8b8efb8ef77e.zip
lib: dev: Add select-like call
This adds a flow_select() call that will sleep until an SDU can be read on a flow. It returns the file descriptor for which an SDU is ready. It takes as optional argument a timespec struct to specify a timeout.
Diffstat (limited to 'include')
-rw-r--r--include/ouroboros/dev.h2
-rw-r--r--include/ouroboros/shm_ap_rbuff.h3
-rw-r--r--include/ouroboros/shm_du_map.h13
3 files changed, 11 insertions, 7 deletions
diff --git a/include/ouroboros/dev.h b/include/ouroboros/dev.h
index eb779953..91d5c7de 100644
--- a/include/ouroboros/dev.h
+++ b/include/ouroboros/dev.h
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <stdint.h>
+#include <sys/time.h>
#include <ouroboros/qos.h>
#include <ouroboros/flow.h>
@@ -53,5 +54,6 @@ int flow_dealloc(int fd);
int flow_cntl(int fd, int cmd, int oflags);
ssize_t flow_write(int fd, void * buf, size_t count);
ssize_t flow_read(int fd, void * buf, size_t count);
+int flow_select(const struct timespec * timeout);
#endif
diff --git a/include/ouroboros/shm_ap_rbuff.h b/include/ouroboros/shm_ap_rbuff.h
index 78926869..257a289d 100644
--- a/include/ouroboros/shm_ap_rbuff.h
+++ b/include/ouroboros/shm_ap_rbuff.h
@@ -25,6 +25,7 @@
#define OUROBOROS_SHM_AP_RBUFF_H
#include <sys/types.h>
+#include <sys/time.h>
#include <stdbool.h>
struct shm_ap_rbuff;
@@ -41,6 +42,8 @@ void shm_ap_rbuff_destroy(struct shm_ap_rbuff * rb);
int shm_ap_rbuff_write(struct shm_ap_rbuff * rb,
struct rb_entry * e);
struct rb_entry * shm_ap_rbuff_read(struct shm_ap_rbuff * rb);
+int shm_ap_rbuff_peek(struct shm_ap_rbuff * rb,
+ const struct timespec * timeout);
ssize_t shm_ap_rbuff_read_port(struct shm_ap_rbuff * rb,
int port_id);
pid_t shm_ap_rbuff_get_api(struct shm_ap_rbuff * rb);
diff --git a/include/ouroboros/shm_du_map.h b/include/ouroboros/shm_du_map.h
index 11fe35c6..b9c56cf8 100644
--- a/include/ouroboros/shm_du_map.h
+++ b/include/ouroboros/shm_du_map.h
@@ -39,13 +39,12 @@ void shm_du_map_destroy(struct shm_du_map * dum);
void * shm_du_map_sanitize(void * o);
/* returns the index of the buffer in the DU map */
-ssize_t shm_du_map_write(struct shm_du_map * dum,
- pid_t dst_api,
- size_t headspace,
- size_t tailspace,
- uint8_t * data,
- size_t data_len);
-
+ssize_t shm_du_map_write(struct shm_du_map * dum,
+ pid_t dst_api,
+ size_t headspace,
+ size_t tailspace,
+ uint8_t * data,
+ size_t data_len);
int shm_du_map_read(uint8_t ** dst,
struct shm_du_map * dum,
ssize_t idx);