Ignore:
Timestamp:
2010-09-26T15:20:55Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4edd39fc
Parents:
2544442
Message:

Cleanup of dynamic FIFO.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/adt/dynamic_fifo.h

    r2544442 r7093a32  
    3232
    3333/** @file
    34  *  Dynamic first in first out positive integer queue.
    35  *  Possitive integer values only.
     34 * Dynamic first in first out positive integer queue.
     35 * Possitive integer values only.
    3636 */
    3737
     
    4040
    4141/** Type definition of the dynamic fifo queue.
    42  *  @see dyn_fifo
     42 * @see dyn_fifo
    4343 */
    4444typedef struct dyn_fifo dyn_fifo_t;
     
    4747 *  @see dyn_fifo
    4848 */
    49 typedef dyn_fifo_t *    dyn_fifo_ref;
     49typedef dyn_fifo_t *dyn_fifo_ref;
    5050
    5151/** Dynamic first in first out positive integer queue.
    52  *  Possitive integer values only.
    53  *  The queue automatically resizes if needed.
     52 * Possitive integer values only.
     53 * The queue automatically resizes if needed.
    5454 */
    55 struct dyn_fifo{
    56         /** Stored item field.
    57          */
    58         int *   items;
    59         /** Actual field size.
    60          */
     55struct dyn_fifo {
     56        /** Stored item field. */
     57        int *items;
     58        /** Actual field size. */
    6159        int size;
    62         /** First item in the queue index.
    63          */
     60        /** First item in the queue index. */
    6461        int head;
    65         /** Last item in the queue index.
    66          */
     62        /** Last item in the queue index. */
    6763        int tail;
    68         /** Consistency check magic value.
    69          */
     64        /** Consistency check magic value. */
    7065        int magic_value;
    7166};
    7267
    73 /** Initializes the dynamic queue.
    74  *  @param[in,out] fifo The dynamic queue.
    75  *  @param[in] size The initial queue size.
    76  *  @returns EOK on success.
    77  *  @returns EINVAL if the queue is not valid.
    78  *  @returns EBADMEM if the fifo parameter is NULL.
    79  *  @returns ENOMEM if there is not enough memory left.
    80  */
    81 extern int dyn_fifo_initialize(dyn_fifo_ref fifo, int size);
    82 
    83 /** Appends a new item to the queue end.
    84  *  @param[in,out] fifo The dynamic queue.
    85  *  @param[in] value The new item value. Should be positive.
    86  *  @param[in] max_size The maximum queue size. The queue is not resized beyound this limit. May be zero or negative (<=0) to indicate no limit.
    87  *  @returns EOK on success.
    88  *  @returns EINVAL if the queue is not valid.
    89  *  @returns ENOMEM if there is not enough memory left.
    90  */
    91 extern int dyn_fifo_push(dyn_fifo_ref fifo, int value, int max_size);
    92 
    93 /** Returns and excludes the first item in the queue.
    94  *  @param[in,out] fifo The dynamic queue.
    95  *  @returns Value of the first item in the queue.
    96  *  @returns EINVAL if the queue is not valid.
    97  *  @returns ENOENT if the queue is empty.
    98  */
    99 extern int dyn_fifo_pop(dyn_fifo_ref fifo);
    100 
    101 /** Returns and keeps the first item in the queue.
    102  *  @param[in,out] fifo The dynamic queue.
    103  *  @returns Value of the first item in the queue.
    104  *  @returns EINVAL if the queue is not valid.
    105  *  @returns ENOENT if the queue is empty.
    106  */
    107 extern int dyn_fifo_value(dyn_fifo_ref fifo);
    108 
    109 /** Clears and destroys the queue.
    110  *  @param[in,out] fifo The dynamic queue.
    111  *  @returns EOK on success.
    112  *  @returns EINVAL if the queue is not valid.
    113  */
    114 extern int dyn_fifo_destroy(dyn_fifo_ref fifo);
     68extern int dyn_fifo_initialize(dyn_fifo_ref, int);
     69extern int dyn_fifo_destroy(dyn_fifo_ref);
     70extern int dyn_fifo_push(dyn_fifo_ref, int, int);
     71extern int dyn_fifo_pop(dyn_fifo_ref);
     72extern int dyn_fifo_value(dyn_fifo_ref);
    11573
    11674#endif
Note: See TracChangeset for help on using the changeset viewer.