43 #include "avrmalloc.h"
52 if (strncmp (str,
"bin", 3) == 0)
54 if (strncmp (str,
"ihex", 4) == 0)
56 if (strncmp (str,
"elf", 3) == 0)
68 extern inline uint16_t
set_bit_in_word (uint16_t src,
int bit,
int val);
81 if (gettimeofday (&tv, NULL) < 0)
82 avr_error (
"Failed to get program time.");
84 result = ((uint64_t) tv.tv_sec * 1000) + ((uint64_t) tv.tv_usec / 1000);
95 static DList *dlist_new_node (AvrClass *data);
96 static void dlist_construct_node (DList *node, AvrClass *data);
97 static void dlist_destroy_node (
void *node);
113 dlist_new_node (AvrClass *data)
118 dlist_construct_node (node, data);
125 dlist_construct_node (DList *node, AvrClass *data)
139 dlist_destroy_node (
void *node)
141 DList *_node = (DList *)node;
159 dlist_add (DList *head, AvrClass *data, DListFP_Cmp cmp)
165 return dlist_new_node (data);
171 if (cmp && ((*cmp) (node->data, data) == 0))
178 if (node->next == NULL)
181 node->next = dlist_new_node (data);
182 node->next->prev = node;
198 DList *node = dlist_new_node (data);;
220 avr_error (
"compare function not specified");
224 if ((*cmp) (node->data, data) == 0)
226 if ((node->prev == NULL) && (node->next == NULL))
231 else if (node->prev == NULL)
234 node->next->prev = NULL;
237 else if (node->next == NULL)
240 node->prev->next = NULL;
245 node->prev->next = node->next;
246 node->next->prev = node->prev;
296 avr_error (
"compare function not specified");
300 if ((*cmp) (node->data, data) == 0)
335 dlist_iterator_cmp (AvrClass *n1, AvrClass *n2)
341 return (
int)(n1 - n2);
363 avr_error (
"no iteration func supplied");
369 if ((*func) (node->data, user_data))
372 head =
dlist_delete (head, node->data, dlist_iterator_cmp);