| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target arm_cpu_cortex_m7_ok } */ |
| 3 |
/* { dg-additional-options "-O2" } */ |
| 4 |
/* { dg-add-options arm_cpu_cortex_m7 } */ |
| 5 |
|
| 6 |
|
| 7 |
typedef unsigned long long uint64_t; |
| 8 |
struct timer { |
| 9 |
int active; |
| 10 |
uint64_t expire; |
| 11 |
void *arg; |
| 12 |
}; |
| 13 |
int irq_disable(); |
| 14 |
void irq_restore(int); |
| 15 |
static inline uint64_t h(const uint64_t *p64) |
| 16 |
{ |
| 17 |
uint64_t tmp; |
| 18 |
asm( |
| 19 |
"ldrd %Q[r], %R[r], %[p]\n" |
| 20 |
: [r]"=lh"(tmp) |
| 21 |
: [p]"m"(*p64) |
| 22 |
: "memory" |
| 23 |
); |
| 24 |
return tmp; |
| 25 |
} |
| 26 |
uint64_t monotonic; |
| 27 |
void timer_callout(timer *tmr, uint64_t nsec, void *arg) |
| 28 |
{ |
| 29 |
const int s = irq_disable(); |
| 30 |
if (tmr->active) |
| 31 |
tmr->arg = arg; |
| 32 |
tmr->expire = h(&monotonic) + 100000 + (nsec == 1 ? 0 : nsec); |
| 33 |
irq_restore(s); |
| 34 |
} |