diff options
-rw-r--r-- | software_pwm.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/software_pwm.c b/software_pwm.c index 561edfd..73c40c8 100644 --- a/software_pwm.c +++ b/software_pwm.c @@ -24,11 +24,15 @@ static struct pwm_event { } events[SOFTPWM_PIN_COUNT + 1]; -#define LIST_INSERT(new, former, member) (\ - list_insert(&(new.member), &(former.member), offsetof(struct pwm_event, time))) - -static void list_insert(struct link_pair *new_links, struct link_pair *former_links, size_t parent_offset) { - +#define LIST_INSERT(new, prev, member) (\ + list_insert(&(new.member), &(prev.member), offsetof(struct pwm_event, member))) + +//TODO GYAAAAAAAGH!!! +static void list_insert(struct link_pair *new_links, struct link_pair *prev_links, size_t parent_offset) { + new_links->next = prev_links->next; + new_links->prev = (struct pwm_event *)(char *)prev_links - parent_offset; + ((struct link_pair *)(char *)prev_links->next + parent_offset)->prev = (struct pwm_event *)(char *)new_links - parent_offset; //GYAAAAGH + prev_links->next = (struct pwm_event *)(char *)new_links - parent_offset; } static void list_remove(struct link_pair *event) { |