Subversion Repositories HelenOS

Rev

Rev 4588 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4588 Rev 4704
Line 29... Line 29...
29
/** @addtogroup net
29
/** @addtogroup net
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
-
 
34
 *  Dynamic first in first out positive integer queue implementation.
34
 */
35
 */
35
 
36
 
36
#include <errno.h>
37
#include <errno.h>
37
#include <malloc.h>
38
#include <malloc.h>
38
#include <mem.h>
39
#include <mem.h>
39
 
40
 
40
#include "dynamic_fifo.h"
41
#include "dynamic_fifo.h"
41
 
42
 
-
 
43
/** Internal magic value for a&nbsp;consistency check.
-
 
44
 */
42
#define DYN_FIFO_MAGIC_VALUE    0x58627659
45
#define DYN_FIFO_MAGIC_VALUE    0x58627659
43
 
46
 
-
 
47
/** Returns the next queue index.
-
 
48
 *  The queue field is circular.
-
 
49
 *  @param fifo The dynamic queue. Input parameter.
-
 
50
 *  @param index The actual index to be shifted. Input parameter.
-
 
51
 */
44
#define NEXT_INDEX( fifo, index )   ((( index ) + 1 ) % (( fifo )->size + 1 ))
52
#define NEXT_INDEX( fifo, index )   ((( index ) + 1 ) % (( fifo )->size + 1 ))
45
 
53
 
-
 
54
/** Checks if the queue is valid.
-
 
55
 *  @param fifo The dynamic queue. Input parameter.
-
 
56
 *  @returns TRUE if the queue is valid.
-
 
57
 *  @returns FALSE otherwise.
-
 
58
 */
46
int dyn_fifo_is_valid( dyn_fifo_ref fifo );
59
int dyn_fifo_is_valid( dyn_fifo_ref fifo );
47
 
60
 
48
int dyn_fifo_is_valid( dyn_fifo_ref fifo ){
61
int dyn_fifo_is_valid( dyn_fifo_ref fifo ){
49
    return fifo && ( fifo->magic_value == DYN_FIFO_MAGIC_VALUE );
62
    return fifo && ( fifo->magic_value == DYN_FIFO_MAGIC_VALUE );
50
}
63
}