diff options
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/fd.c | 8 | ||||
| -rw-r--r-- | fs/fifo.c | 4 | ||||
| -rw-r--r-- | fs/fifo.h | 2 | ||||
| -rw-r--r-- | fs/stdstreams.c | 1 |
4 files changed, 15 insertions, 0 deletions
@@ -246,6 +246,8 @@ int fds_from_pipe(fd pipefds[2]) mem+=4; *mem=1; + read.can_write=0; + read.read=pipe_get; wrt.read=0; @@ -312,6 +314,11 @@ fd fd_from_sysfs(void(*g)(ringbuffer *r,void (*f)(ringbuffer *r,char *fmt, ...)) return f; } +bool fifo_can_write(fifo *f) +{ + return !(f->full(f->data)); +} + fd fd_from_fifo(fifo* fif) { fd f; @@ -323,5 +330,6 @@ fd fd_from_fifo(fifo* fif) f.has=fifo_has; f.dupl=default_dupl; f.close=default_close; + f.can_write=fifo_can_write; return f; } @@ -14,3 +14,7 @@ bool fifo_has(fifo* f) { return f->has(f->data); } +bool fifo_full(fifo* f) +{ + return f->full(f->data); +} @@ -11,6 +11,7 @@ typedef struct fifo_struct bool (*put)(struct fifo_struct*,uint8_t); uint8_t (*get)(struct fifo_struct*); bool (*has)(struct fifo_struct*); + bool (*full)(struct fifo_struct*); void *data; // opaque data }fifo; @@ -18,6 +19,7 @@ typedef struct fifo_struct bool fifo_put(fifo*,uint8_t); uint8_t fifo_get(fifo*); bool fifo_has(fifo*); +bool fifo_full(fifo*); fifo fifo_create_buffered(uint8_t size); #endif diff --git a/fs/stdstreams.c b/fs/stdstreams.c index 1cb9402..e5a2a08 100644 --- a/fs/stdstreams.c +++ b/fs/stdstreams.c @@ -52,5 +52,6 @@ fd fd_from_ringbuffer() f->put=ringbuffer_put; f->get=ringbuffer_get; f->has=ringbuffer_has; + f->full=ringbuffer_full; return fd_from_fifo(f); } |
