Utility functions. More...
Go to the source code of this file.
Functions | |
int | str2ffmt (char *str) |
uint8_t | set_bit_in_byte (uint8_t src, int bit, int val) |
uint16_t | set_bit_in_word (uint16_t src, int bit, int val) |
uint64_t | get_program_time (void) |
DList * | dlist_add (DList *head, AvrClass *data, DListFP_Cmp cmp) |
DList * | dlist_add_head (DList *head, AvrClass *data) |
DList * | dlist_delete (DList *head, AvrClass *data, DListFP_Cmp cmp) |
void | dlist_delete_all (DList *head) |
AvrClass * | dlist_lookup (DList *head, AvrClass *data, DListFP_Cmp cmp) |
AvrClass * | dlist_get_head_data (DList *head) |
DList * | dlist_iterator (DList *head, DListFP_Iter func, void *user_data) |
Utility functions.
This module provides general purpose utilities.
Definition in file utils.c.
int str2ffmt | ( | char * | str | ) |
uint8_t set_bit_in_byte | ( | uint8_t | src, | |
int | bit, | |||
int | val | |||
) |
Set a bit in src to 1 if val != 0, clears bit if val == 0.
uint16_t set_bit_in_word | ( | uint16_t | src, | |
int | bit, | |||
int | val | |||
) |
Set a bit in src to 1 if val != 0, clears bit if val == 0.
uint64_t get_program_time | ( | void | ) |
Return the number of milliseconds of elapsed program time.
Definition at line 76 of file utils.c.
References avr_error.
Referenced by avr_core_run().
DList* dlist_add | ( | DList * | head, | |
AvrClass * | data, | |||
DListFP_Cmp | cmp | |||
) |
Add a new node to the end of the list.
If cmp argument is not NULL, use cmp() to see if node already exists and don't add node if it exists.
It is the responsibility of this function to unref data if not added.
Definition at line 159 of file utils.c.
References class_unref().
DList* dlist_add_head | ( | DList * | head, | |
AvrClass * | data | |||
) |
DList* dlist_delete | ( | DList * | head, | |
AvrClass * | data, | |||
DListFP_Cmp | cmp | |||
) |
Conditionally delete a node from the list.
Delete a node from the list if the node's data matches the specified data. Returns the head of the modified list.
Definition at line 215 of file utils.c.
References avr_error, and class_unref().
Referenced by dlist_iterator().
void dlist_delete_all | ( | DList * | head | ) |
Blow away the entire list.
Definition at line 266 of file utils.c.
References class_unref().
Referenced by avr_core_destroy().
AvrClass* dlist_lookup | ( | DList * | head, | |
AvrClass * | data, | |||
DListFP_Cmp | cmp | |||
) |
Lookup an item in the list.
Walk the list pointed to by head and return a pointer to the data if found. If not found, return NULL.
head | The head of the list to be iterated. | |
data | The data to be passed to the func when it is applied. | |
cmp | A function to be used for comparing the items. |
Definition at line 291 of file utils.c.
References avr_error.
Referenced by mem_get_vdevice_by_name().
AvrClass* dlist_get_head_data | ( | DList * | head | ) |
DList* dlist_iterator | ( | DList * | head, | |
DListFP_Iter | func, | |||
void * | user_data | |||
) |
Iterate over all elements of the list.
For each element, call the user supplied iterator function and pass it the node data and the user_data. If the iterator function return non-zero, remove the node from the list.
head | The head of the list to be iterated. | |
func | The function to be applied. | |
user_data | The data to be passed to the func when it is applied. |
Definition at line 357 of file utils.c.
References avr_error, and dlist_delete().