https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103676

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|1                           |0
             Status|WAITING                     |UNCONFIRMED

--- Comment #14 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Semi-reduced testcase (single file):
typedef unsigned long long uint64_t;
typedef uint64_t uint_fast64_t;
uint64_t timer_monotonic_coarse();
struct list {
 struct list *next;
 struct list *prev;
};

static inline list *
list_insert(list *prev, list *node)
{

 node->next = prev->next;
 node->prev = prev;
 prev->next->prev = node;
 prev->next = node;
 return node;
}




static inline list *
list_remove(list *node)
{
 node->prev->next = node->next;
 node->next->prev = node->prev;
 return node;
}

struct timer {
 list link;
 int active;
 uint_fast64_t expire;
 uint_fast64_t interval;
 void (*func)(void *);
 void *arg;
};
int irq_disable();
void irq_restore(int);
template<class T> struct atomic { T a; };
__attribute__((section(".fast_bss"))) atomic<uint64_t> monotonic;

extern "C" uint64_t
__atomic_load_8(const volatile void *p, int m)
{

 const volatile uint64_t *p64 = static_cast<const volatile uint64_t *>(p);
 uint64_t tmp;
 asm volatile(
  "ldrd %Q[r], %R[r], %[p]\n"
  : [r]"=lh"(tmp)
  : [p]"m"(*p64)
  : "memory"
 );
 return tmp;
}


uint_fast64_t
timer_monotonic_coarse()
{
 return __atomic_load_n(&monotonic.a, 0);
}

void
timer_callout(timer *tmr, uint_fast64_t nsec, uint_fast64_t interval,
       void (*func)(void *), void *arg)
{

 const uint_fast64_t period = 1000000000 / 1000;

 const int s = irq_disable();
 if (tmr->active)
  list_remove(&tmr->link);
 tmr->func = func;
 tmr->arg = arg;
 tmr->active = 1;
 tmr->interval = interval;



 tmr->expire = timer_monotonic_coarse() + period + (nsec == 1 ? 0 : nsec);
 //timer_insert(tmr);
 irq_restore(s);
}

----- CUT ----
Compile with -mcpu=cortex-m7 -mthumb -g -pipe -Wall -O2 -Wframe-larger-than=384
-fno-pie  -masm-syntax-unified -mslow-flash-data -Wframe-larger-than=384
-Wundef -fno-pie  -masm-syntax-unified -mslow-flash-data -nostdinc++
-fno-exceptions -std=gnu++20 -DKERNEL -D_GNU_SOURCE  -fuse-linker-plugin
-fno-use-cxa-atexit  -mfloat-abi=soft

Reply via email to