summaryrefslogtreecommitdiff
path: root/fs/ringbuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ringbuffer.c')
-rw-r--r--fs/ringbuffer.c71
1 files changed, 0 insertions, 71 deletions
diff --git a/fs/ringbuffer.c b/fs/ringbuffer.c
deleted file mode 100644
index 449ad88..0000000
--- a/fs/ringbuffer.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#define FOOLOS_MODULE_NAME "ringbuffer"
-#include "lib/logger/log.h"
-
-#include "ringbuffer.h"
-
-static int sl=9;
-
-ringbuffer ringbuffer_init(uint32_t size)
-{
- ringbuffer f;
- f.data=kballoc(size);
- f.size=size*4096;
- f.front=f.size-1;
- f.back=f.size-1;
- return f;
-}
-
-bool ringbuffer_put(ringbuffer* f,uint8_t c)
-{
- x86_int_disable();
- lock_spin(sl);
-
- if((f->back-1+f->size)%f->size==f->front)
- {
- lock_release(sl);
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"unlocked by put");
- x86_int_enable();
- return false;
- }
-
- f->data[f->back]=c;
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"put %d %d (%c)", f->back, f->front,c);
- f->back--;
- f->back+=f->size;
- f->back%=f->size;
-
- lock_release(sl);
- x86_int_enable();
-
- return true;
-}
-
-uint8_t ringbuffer_get(ringbuffer* f) // blocking
-{
-
- char c;
-
- x86_int_disable();
- lock_spin(sl);
-
- if(f->front==f->back)
- {
- lock_release(sl);
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"unlocked by get");
- x86_int_enable();
- c='_';
- return false;
- }
-
- c=f->data[f->front];
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_FINE,"get %d %d (%c)", f->back, f->front,c);
-
- f->front--;
- f->front+=f->size;
- f->front%=f->size;
-
- lock_release(sl);
- x86_int_enable();
-
- return true;
-}