aboutsummaryrefslogtreecommitdiffstats
path: root/z80irq.h
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-12-09 22:11:06 -0800
committerH. Peter Anvin <hpa@zytor.com>2019-12-09 22:11:06 -0800
commitc20338e17250c88c024b04aa15be185189d5692f (patch)
tree93b24f426fed7d0f24459731f3a24e7424e2f449 /z80irq.h
parent1214ac7ae82615f8cd2465374d00205739031cad (diff)
downloadabc80sim-c20338e17250c88c024b04aa15be185189d5692f.tar.gz
abc80sim-c20338e17250c88c024b04aa15be185189d5692f.tar.xz
abc80sim-c20338e17250c88c024b04aa15be185189d5692f.zip
Use C11 <stdatomic.h>; enable script files
The only really portable way to do lockless atomics is <stdatomic.h>, so use it even though it is C11. It is almost 2020 after all... This hopefully will work better on non-x86 platforms? Add support for an auto-typed script file. Idea by Mikael Bonnier.
Diffstat (limited to 'z80irq.h')
-rw-r--r--z80irq.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/z80irq.h b/z80irq.h
index 3a04a5b..f43f278 100644
--- a/z80irq.h
+++ b/z80irq.h
@@ -20,7 +20,7 @@ struct z80_irq {
#define MAX_IRQ 32
-extern volatile unsigned int irq_pending;
+extern atomic_uint irq_pending;
extern unsigned int irq_mask; /* 0 = inside handler (irq->handled == true) */
static inline bool poll_irq(void)
@@ -33,12 +33,12 @@ int z80_intack(void);
void z80_eoi(void);
static inline void z80_interrupt(struct z80_irq *irq)
{
- atomic_set_bit(&irq_pending, irq->prio);
+ atomic_fetch_or(&irq_pending, 1U << irq->prio);
}
static inline void z80_clear_interrupt(struct z80_irq *irq)
{
- atomic_clear_bit(&irq_pending, irq->prio);
+ atomic_fetch_and(&irq_pending, ~(1U << irq->prio));
}
#endif /* Z80IRQ_H */