From a6e8978fd9b5786607438689f8cd8b8efb8ef77e Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Wed, 3 Aug 2016 00:19:06 +0200 Subject: 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. --- include/ouroboros/dev.h | 2 ++ include/ouroboros/shm_ap_rbuff.h | 3 +++ include/ouroboros/shm_du_map.h | 13 ++++++------- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'include') 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 #include +#include #include #include @@ -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 +#include #include 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); -- cgit v1.2.3