Skip to content

Commit

Permalink
Build in -std=c18 mode
Browse files Browse the repository at this point in the history
Make sure snek code uses only standard C18 language constructs.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed Dec 11, 2022
1 parent 482648b commit e693926
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion chips/avr/ao-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#define ao_arch_reboot() /* XXX */

#define ao_arch_nop() asm("nop")
#define ao_arch_nop() __asm__("nop")

#define ao_arch_interrupt(n) /* nothing */

Expand Down
10 changes: 5 additions & 5 deletions chips/samd21/ao-arch-funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,25 @@ typedef uint32_t ao_arch_irq_t;
static inline uint32_t
ao_arch_irqsave(void) {
uint32_t primask;
asm("mrs %0,primask" : "=&r" (primask));
__asm__("mrs %0,primask" : "=&r" (primask));
ao_arch_block_interrupts();
return primask;
}

static inline void
ao_arch_irqrestore(uint32_t primask) {
asm("msr primask,%0" : : "r" (primask));
__asm__("msr primask,%0" : : "r" (primask));
}

static inline void
ao_arch_memory_barrier(void) {
asm volatile("" ::: "memory");
__asm__ volatile("" ::: "memory");
}

#define ao_arch_wait_interrupt() do { \
asm("\twfi\n"); \
__asm__("\twfi\n"); \
ao_arch_release_interrupts(); \
asm(".global ao_idle_loc\nao_idle_loc:"); \
__asm__(".global ao_idle_loc\nao_idle_loc:"); \
ao_arch_block_interrupts(); \
} while (0)

Expand Down
6 changes: 3 additions & 3 deletions chips/samd21/ao-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
(samd21_scb.aircr = ((SAMD21_SCB_AIRCR_VECTKEY_KEY << SAMD21_SCB_AIRCR_VECTKEY) | \
(1 << SAMD21_SCB_AIRCR_SYSRESETREQ)))

#define ao_arch_nop() asm("nop")
#define ao_arch_nop() __asm__("nop")
#define ao_arch_interrupt(n) /* nothing */
#define ao_arch_block_interrupts() asm("cpsid i")
#define ao_arch_release_interrupts() asm("cpsie i")
#define ao_arch_block_interrupts() __asm__("cpsid i")
#define ao_arch_release_interrupts() __asm__("cpsie i")

/*
* ao_timer.c
Expand Down
2 changes: 1 addition & 1 deletion snek-pow.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "snek.h"
#include <math.h>

#ifdef AVR
#ifdef __AVR__
#define float double
#endif

Expand Down
1 change: 1 addition & 0 deletions snek.defs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ SNEK_WARNINGS = \
-Wimplicit-fallthrough

SNEK_BASE_CFLAGS = \
--std=c18 \
-D_DEFAULT_SOURCE \
$(SNEK_PACKAGE_CFLAGS) \
-I$(SNEK_ROOT) $(SNEK_LOCAL_CFLAGS) \
Expand Down

0 comments on commit e693926

Please sign in to comment.