Changeset 49698fa in mainline for uspace/drv/ns8250/cyclic_buffer.h


Ignore:
Timestamp:
2010-10-23T10:25:37Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
663f41c4
Parents:
472020fc
Message:

Cstyle fixes in ns8250 driver.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ns8250/cyclic_buffer.h

    r472020fc r49698fa  
    11/*
    2  * Copyright (c) 2010 Lenka Trochtova 
     2 * Copyright (c) 2010 Lenka Trochtova
    33 * All rights reserved.
    44 *
     
    3232/** @file
    3333 */
    34  
    35 #ifndef CYCLIC_BUFFER_H
    36 #define CYCLIC_BUFFER_H
    3734
    38 #define BUF_LEN 256  // the length of the buffer
     35#ifndef CYCLIC_BUFFER_H_
     36#define CYCLIC_BUFFER_H_
     37
     38#define BUF_LEN 256
    3939
    4040typedef struct cyclic_buffer {
    41         uint8_t buf[BUF_LEN];  // the buffer
     41        uint8_t buf[BUF_LEN];
    4242        int start;
    4343        int cnt;
    44 }  cyclic_buffer_t; 
     44}  cyclic_buffer_t;
    4545
    46 // returns false if the buffer is full
    47 static inline bool buf_push_back(cyclic_buffer_t *buf, uint8_t item)
     46/*
     47 * @returns             False if the buffer is full.
     48 */
     49static inline bool buf_push_back(cyclic_buffer_t *buf, uint8_t item)
    4850{
    49         if (buf->cnt >= BUF_LEN) {
     51        if (buf->cnt >= BUF_LEN)
    5052                return false;
    51         }
    52        
    5353        int pos = (buf->start + buf->cnt) % BUF_LEN;
    5454        buf->buf[pos] = item;
     
    5757}
    5858
    59 static inline bool buf_is_empty(cyclic_buffer_t *buf) 
     59static inline bool buf_is_empty(cyclic_buffer_t *buf)
    6060{
    6161        return buf->cnt == 0;
    6262}
    6363
    64 // call it on non empty buffer!
    65 static inline uint8_t buf_pop_front(cyclic_buffer_t *buf)
     64static inline uint8_t buf_pop_front(cyclic_buffer_t *buf)
    6665{
    6766        assert(!buf_is_empty(buf));
    6867       
    6968        uint8_t res = buf->buf[buf->start];
    70         buf->start = (buf->start + 1) % BUF_LEN;       
     69        buf->start = (buf->start + 1) % BUF_LEN;
    7170        buf->cnt--;
    7271        return res;
    7372}
    7473
    75 static inline void buf_clear(cyclic_buffer_t *buf) 
     74static inline void buf_clear(cyclic_buffer_t *buf)
    7675{
    7776        buf->cnt = 0;
Note: See TracChangeset for help on using the changeset viewer.