From 03a3acd11bce3ab11e225574ac6d3e0f93669056 Mon Sep 17 00:00:00 2001 From: Brett Weiland Date: Fri, 27 Oct 2023 07:35:48 -0500 Subject: I will never be able to sleep before an exam --- software_pwm.c | 14 +++++++++----- 1 file 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) { -- cgit v1.2.3