Skip to content

Commit

Permalink
[gcc] Enable atomic builtins for AVR
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Apr 20, 2024
1 parent 85d1324 commit 78b2e26
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

using _a8 = uint8_t;
using _a16 = uint16_t;
using _a32 = unsigned int;
using _a32 = {{uint32_t}};
using _a64 = uint64_t;

// =========================== atomics for >64 bits ===========================
Expand Down
2 changes: 1 addition & 1 deletion ext/gcc/libstdc++
16 changes: 10 additions & 6 deletions ext/gcc/module_c.lb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def init(module):
Refines the C language to make it easier to use on embedded targets.
## ARM Cortex-M
For AVR and ARMv6-M, C11 atomics are implemented via atomic lock.
For ARMv6-M, C11 atomics are implemented via atomic lock.
## ARM Cortex-M
Additional compiler options:
Expand All @@ -32,10 +32,12 @@ Additional compiler options:

def prepare(module, options):
core = options[":target"].get_driver("core")["type"]

if core.startswith("avr") or core.startswith("cortex-m"):
module.depends(":architecture:assert")
if core.startswith("cortex-m0"):
module.depends(":architecture:atomic")

if core.startswith("avr") or core.startswith("cortex-m0"):
module.depends(":architecture:atomic")

return True

Expand All @@ -46,10 +48,12 @@ def build(env):

env.outbasepath = "modm/ext/gcc"

if core.startswith("avr") or core.startswith("cortex-m0"):
uint32_t = "uint32_t" if core.startswith("avr") else "unsigned int"
env.template("atomics_c11.cpp.in", substitutions={"uint32_t": uint32_t})

if core.startswith("cortex-m"):
env.copy("cabi_cortex.c", "cabi.c")
if core.startswith("cortex-m0"):
env.template("atomics_c11_cortex.cpp.in")

# Compiler options for targets
env.collect(":build:linkflags", "--specs=nosys.specs")
Expand Down

0 comments on commit 78b2e26

Please sign in to comment.