34 #ifndef SORTQUEUE_H_DEFINED
35 #define SORTQUEUE_H_DEFINED
63 #define ADJUST_ROLLOVER_POINT 0x80000000
70 #define ADJUST_ROLLOVER_VALUE 0x10000
78 static inline int sq_lt_compare (
unsigned int a,
unsigned int b) {
97 static inline int sq_lte_compare (
unsigned int a,
unsigned int b) {
118 static inline int sq_init (
125 sq->
size = item_count;
131 sq->
items = malloc (item_count * size_per_item);
132 if (sq->
items == NULL) {
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));
155 static inline void sq_reinit (
struct sq *sq,
unsigned int head_seqid)
171 static inline void sq_assert (
const struct sq *sq,
unsigned int pos)
177 for (i = sq->
pos_max + 1; i < sq->size; i++) {
187 static inline void sq_copy (
struct sq *sq_dest,
const struct sq *sq_src)
189 sq_assert (sq_src, 20);
208 static inline void sq_free (
struct sq *sq) {
221 static inline void *sq_item_add (
227 unsigned int sq_position;
230 if (sq_position > sq->
pos_max) {
254 static 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",
282 static inline unsigned int sq_item_miss_count (
286 unsigned int sq_position;
298 static inline unsigned int sq_size_get (
310 static inline unsigned int sq_in_range (
328 if (seq_id < sq->head_seqid) {
346 static inline unsigned int sq_item_get (
352 unsigned int sq_position;
373 *sq_item_out = sq_item;
382 static inline void sq_items_release (
struct sq *sq,
unsigned int seqid)
384 unsigned int oldhead;
392 memset (&sq->
items_inuse[oldhead], 0, (sq->
size - oldhead) * sizeof (
unsigned int));
397 (seqid - sq->
head_seqid + 1) * sizeof (
unsigned int));
399 (seqid - sq->
head_seqid + 1) * sizeof (
unsigned int));
unsigned int size_per_item
unsigned int * items_inuse
#define ADJUST_ROLLOVER_POINT
ADJUST_ROLLOVER_POINT is the value used to determine when a window should be used to calculate a less...
unsigned int * items_miss_count
#define ADJUST_ROLLOVER_VALUE
ADJUST_ROLLOVER_VALUE is the value by which both values in a comparison are adjusted if either value ...