34#ifndef SORTQUEUE_H_DEFINED
35#define SORTQUEUE_H_DEFINED
63#define ADJUST_ROLLOVER_POINT 0x80000000
70#define ADJUST_ROLLOVER_VALUE 0x10000
78static inline int sq_lt_compare (
unsigned int a,
unsigned int b) {
97static inline int sq_lte_compare (
unsigned int a,
unsigned int b) {
118static inline int sq_init (
131 sq->
items = malloc (item_count * size_per_item);
135 memset (
sq->
items, 0, item_count * size_per_item);
137 if ((
sq->
items_inuse = malloc (item_count *
sizeof (
unsigned int)))
145 memset (
sq->
items_inuse, 0, item_count * sizeof (
unsigned int));
155static inline void sq_reinit (
struct sq *
sq,
unsigned int head_seqid)
171static inline void sq_assert (
const struct sq *
sq,
unsigned int pos)
177 for (i =
sq->
pos_max + 1; i < sq->size; i++) {
187static inline void sq_copy (
struct sq *sq_dest,
const struct sq *sq_src)
189 sq_assert (sq_src, 20);
208static inline void sq_free (
struct sq *
sq) {
221static inline void *sq_item_add (
227 unsigned int sq_position;
254static inline unsigned int sq_item_inuse (
256 unsigned int seq_id) {
258 unsigned int sq_position;
266 if (seq_id < sq->head_seqid) {
267 fprintf(stderr,
"sq_item_inuse: seqid %d, head %d\n",
282static inline unsigned int sq_item_miss_count (
286 unsigned int sq_position;
298static inline unsigned int sq_size_get (
310static inline unsigned int sq_in_range (
328 if (seq_id < sq->head_seqid) {
346static inline unsigned int sq_item_get (
352 unsigned int sq_position;
373 *sq_item_out = sq_item;
382static inline void sq_items_release (
struct sq *
sq,
unsigned int seqid)
384 unsigned int oldhead;
#define ADJUST_ROLLOVER_POINT
ADJUST_ROLLOVER_POINT is the value used to determine when a window should be used to calculate a less...
#define ADJUST_ROLLOVER_VALUE
ADJUST_ROLLOVER_VALUE is the value by which both values in a comparison are adjusted if either value ...
unsigned int size_per_item
unsigned int * items_miss_count
unsigned int * items_inuse