From 9bec291f4c30293a4c52722759c5917f30a0de16 Mon Sep 17 00:00:00 2001 From: hueso Date: Mon, 9 Feb 2026 04:56:12 -0300 Subject: [PATCH] volatile modifier propagation --- src/animation.c | 2 +- src/animation.h | 28 ++++++++++++++-------------- src/bmlist.c | 24 ++++++++++++------------ src/bmlist.h | 18 +++++++++--------- src/main.c | 12 ++++++------ src/usb/dev.c | 4 ++-- 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/animation.c b/src/animation.c index 9a55660..daf9202 100644 --- a/src/animation.c +++ b/src/animation.c @@ -485,7 +485,7 @@ void ani_marque(bm_t *bm, uint16_t *fb, int step) } -void ani_flash(bm_t *bm, uint16_t *fb, int step) +void ani_flash(volatile bm_t *bm, uint16_t *fb, int step) { if (!(step % 2)) fb_fill(fb, 0); diff --git a/src/animation.h b/src/animation.h index f5eb48e..7383d1e 100644 --- a/src/animation.h +++ b/src/animation.h @@ -13,22 +13,22 @@ int ani_xbm_scrollup_inf(xbm_t *xbm, uint16_t *fb, int vh, int col, int row); void fb_fill(uint16_t *fb, uint16_t v); -void ani_shift_y(bm_t *bm, uint16_t *fb, int dir, int frame); +void ani_shift_y(volatile bm_t *bm, uint16_t *fb, int dir, int frame); -void ani_scroll_x(bm_t *bm, uint16_t *fb, int dir); -void ani_scroll_y(bm_t *bm, uint16_t *fb); +void ani_scroll_x(volatile bm_t *bm, uint16_t *fb, int dir); +void ani_scroll_y(volatile bm_t *bm, uint16_t *fb); -int ani_scroll_left(bm_t *bm, uint16_t *fb); -int ani_scroll_right(bm_t *bm, uint16_t *fb); -int ani_scroll_up(bm_t *bm, uint16_t *fb); -int ani_scroll_down(bm_t *bm, uint16_t *fb); -int ani_fixed(bm_t *bm, uint16_t *fb); -int ani_laser(bm_t *bm, uint16_t *fb); -int ani_snowflake(bm_t *bm, uint16_t *fb); -int ani_animation(bm_t *bm, uint16_t *fb); -int ani_picture(bm_t *bm, uint16_t *fb); +int ani_scroll_left(volatile bm_t *bm, uint16_t *fb); +int ani_scroll_right(volatile bm_t *bm, uint16_t *fb); +int ani_scroll_up(volatile bm_t *bm, uint16_t *fb); +int ani_scroll_down(volatile bm_t *bm, uint16_t *fb); +int ani_fixed(volatile bm_t *bm, uint16_t *fb); +int ani_laser(volatile bm_t *bm, uint16_t *fb); +int ani_snowflake(volatile bm_t *bm, uint16_t *fb); +int ani_animation(volatile bm_t *bm, uint16_t *fb); +int ani_picture(volatile bm_t *bm, uint16_t *fb); -void ani_marque(bm_t *bm, uint16_t *fb, int step); -void ani_flash(bm_t *bm, uint16_t *fb, int step); +void ani_marque(volatile bm_t *bm, uint16_t *fb, int step); +void ani_flash(volatile bm_t *bm, uint16_t *fb, int step); #endif /* __ANIMATION_H__ */ diff --git a/src/bmlist.c b/src/bmlist.c index 14d8d25..3fd1327 100644 --- a/src/bmlist.c +++ b/src/bmlist.c @@ -1,9 +1,9 @@ #include "bmlist.h" #include -static bm_t *current, *head, *tail; +volatile static bm_t *current, *head, *tail; -static void bm_add(bm_t *new, bm_t *prev, bm_t *next) +static void bm_add(bm_t *new, volatile bm_t *prev, volatile bm_t *next) { next->prev = new; new->next = next; @@ -11,7 +11,7 @@ static void bm_add(bm_t *new, bm_t *prev, bm_t *next) prev->next = new; } -bm_t *bmlist_insert(bm_t *at, bm_t *new) +bm_t *bmlist_insert(volatile bm_t *at, bm_t *new) { bm_add(new, at, at->next); return new; @@ -24,52 +24,52 @@ bm_t *bmlist_append(bm_t *new) return new; } -bm_t *bmlist_gonext() +volatile bm_t *bmlist_gonext() { current = current->next; current->anim_step = 0; return current; } -bm_t *bmlist_goprev() +volatile bm_t *bmlist_goprev() { current = current->prev; current->anim_step = 0; return current; } -bm_t *bmlist_gohead() +volatile bm_t *bmlist_gohead() { current = head; current->anim_step = 0; return current; } -bm_t *bmlist_head() +volatile bm_t *bmlist_head() { return head; } -bm_t *bmlist_current() +volatile bm_t *bmlist_current() { return current; } -static void list_del(bm_t *prev, bm_t *next) +static void list_del(volatile bm_t *prev, volatile bm_t *next) { prev->next = next; next->prev = prev; } -bm_t *bmlist_drop(bm_t *bm) +volatile bm_t *bmlist_drop(volatile bm_t *bm) { - bm_t *next = bm->next; + volatile bm_t *next = bm->next; list_del(bm->prev, bm->next); if (bm == head) head = bm->next; if (bm == tail) tail = bm->prev; - free(bm); + free((bm_t *)bm); return next; } diff --git a/src/bmlist.h b/src/bmlist.h index 73df3e4..4ac217a 100644 --- a/src/bmlist.h +++ b/src/bmlist.h @@ -16,8 +16,8 @@ typedef struct bm_st { uint32_t timeout; // zero mean no timeout uint32_t anim_step; // Animation step, zero means restart animation - struct bm_st *next; - struct bm_st *prev; + volatile struct bm_st *next; + volatile struct bm_st *prev; } bm_t; bm_t *bm_new(uint16_t width); @@ -27,16 +27,16 @@ static inline void bm_free(bm_t *bm) free(bm); } -bm_t *bmlist_insert(bm_t *at, bm_t *new); +bm_t *bmlist_insert(volatile bm_t *at, bm_t *new); bm_t *bmlist_append(bm_t *new); -bm_t *bmlist_drop(bm_t *bm); +volatile bm_t *bmlist_drop(volatile bm_t *bm); -bm_t *bmlist_gonext(); -bm_t *bmlist_goprev() ; -bm_t *bmlist_gohead(); -bm_t *bmlist_current(); +volatile bm_t *bmlist_gonext(); +volatile bm_t *bmlist_goprev() ; +volatile bm_t *bmlist_gohead(); +volatile bm_t *bmlist_current(); -bm_t *bmlist_head(); +volatile bm_t *bmlist_head(); void bmlist_init(uint16_t first_bm_width); diff --git a/src/main.c b/src/main.c index 377e14e..116d12f 100644 --- a/src/main.c +++ b/src/main.c @@ -105,7 +105,7 @@ void load_bmlist() if (memcmp(header.header, "wang", 5)) return; // There is no bitmap stored in flash - bm_t *curr_bm = bmlist_current(); + volatile bm_t *curr_bm = bmlist_current(); for (int i=0; i<8; i++) { bm_t *bm = flash2newbm(i); @@ -133,7 +133,7 @@ static uint16_t common_tasks(tmosTaskID task_id, uint16_t events) if(events & ANI_NEXT_STEP) { - static int (*animations[])(bm_t *bm, uint16_t *fb) = { + static int (*animations[])(volatile bm_t *bm, uint16_t *fb) = { ani_scroll_left, ani_scroll_right, ani_scroll_up, @@ -145,7 +145,7 @@ static uint16_t common_tasks(tmosTaskID task_id, uint16_t events) ani_laser }; - bm_t *bm = bmlist_current(); + volatile bm_t *bm = bmlist_current(); if (animations[LEGACY_GET_ANIMATION(bm->modes)]) if (animations[LEGACY_GET_ANIMATION(bm->modes)](bm, fb) == 0 && is_play_sequentially) { @@ -166,7 +166,7 @@ static uint16_t common_tasks(tmosTaskID task_id, uint16_t events) } if (events & ANI_MARQUE) { - bm_t *bm = bmlist_current(); + volatile bm_t *bm = bmlist_current(); marque_step++; if (bm->is_marquee) { ani_marque(bm, fb, marque_step); @@ -186,7 +186,7 @@ static uint16_t common_tasks(tmosTaskID task_id, uint16_t events) } if (events & ANI_FLASH) { - bm_t *bm = bmlist_current(); + volatile bm_t *bm = bmlist_current(); flash_step++; if (bm->is_flash) { @@ -381,7 +381,7 @@ static void mode_setup_download() void clean_bmlist() { - bm_t *curr_bm = bmlist_current(); + volatile bm_t *curr_bm = bmlist_current(); while (curr_bm->next != curr_bm) bmlist_drop(curr_bm->next); } diff --git a/src/usb/dev.c b/src/usb/dev.c index cfca8fd..a5bac8f 100644 --- a/src/usb/dev.c +++ b/src/usb/dev.c @@ -57,8 +57,8 @@ static uint16_t serial_number[] = { #ifdef USBC_VERSION 4 + #endif - (12 + sizeof(VERSION_ABBR) - 1) * 2 | /* bLength */ - 0x03 << 8, /* bDescriptorType */ + ((12 + sizeof(VERSION_ABBR) - 1) * 2 | /* bLength */ + 0x03 << 8), /* bDescriptorType */ /* bString */ 'B', 'M', '1', '1', '4', '4',