Add READ_ONCE and WRITE_ONCE (XCC)
[akaros.git] / kern / lib / circular_buffer.c
index 87f000b..b720d0a 100644 (file)
@@ -16,7 +16,7 @@ bool circular_buffer_init(struct circular_buffer *cb, size_t size, char *mem)
        if (mem)
                cb->base = mem;
        else
-               cb->base = kmalloc(size, KMALLOC_WAIT);
+               cb->base = kmalloc(size, MEM_WAIT);
        if (cb->base) {
                cb->rdptr = cb->wrptr = cb->base;
                cb->size = 0;
@@ -43,8 +43,8 @@ void circular_buffer_clear(struct circular_buffer *cb)
 }
 
 static bool circular_buffer_is_overlap(const struct circular_buffer *cb,
-                                                                          const char *rptr, const char *wptr,
-                                                                          size_t size)
+                                       const char *rptr, const char *wptr,
+                                       size_t size)
 {
        /* Check if the current write operation [wptr, wptr+size) is overwriting
         * the block at which rptr in pointing to.
@@ -53,7 +53,7 @@ static bool circular_buffer_is_overlap(const struct circular_buffer *cb,
 }
 
 static void circular_buffer_write_skip(struct circular_buffer *cb, char *wrptr,
-                                                                          size_t size)
+                                       size_t size)
 {
        /* Move the read pointer forward, so that the incoming write does not
         * overwrite the block the read pointer is looking at.
@@ -74,7 +74,7 @@ static void circular_buffer_write_skip(struct circular_buffer *cb, char *wrptr,
 }
 
 size_t circular_buffer_write(struct circular_buffer *cb,
-                                                        const char *data, size_t size)
+                             const char *data, size_t size)
 {
        /* Data is written and evetually discarded in atomic blocks, in order to
         * maintain the consistency of the information stored in the buffer.
@@ -107,7 +107,7 @@ size_t circular_buffer_write(struct circular_buffer *cb,
 }
 
 size_t circular_buffer_read(struct circular_buffer *cb, char *data, size_t size,
-                                                       size_t off)
+                            size_t off)
 {
        size_t asize = cb->size, rsize = 0;
        const char *rdptr = cb->rdptr;