Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion examples/bzlmod/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")

build_test(
name = "arm_linux_test",
targets = ["//arm-linux:hex"],
targets = [
"//arm-linux:hex",
"//arm-linux:atomics",
],
)

build_test(
Expand Down
11 changes: 7 additions & 4 deletions examples/bzlmod/arm-linux/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ cc_library(
"-mthumb",
],
includes = ["includes"],
target_compatible_with = [
"@platforms//cpu:arm",
"@platforms//os:linux",
],
)

cc_library(
name = "atomics",
srcs = ["atomics.c"],
copts = ["-std=c11"],
visibility = ["//visibility:public"],
)

cc_binary(
Expand Down
21 changes: 21 additions & 0 deletions examples/bzlmod/arm-linux/atomics.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>

// This should pick up the C-variant, not C++ one,
#include <stdatomic.h>

/**
* Minimal C11 stdatomic.h example without threads.
*
* This example is designed to test the compiler's support for the
* C11 _Atomic type specifier and the functions provided by <stdatomic.h>.
*/
int main(void) {
atomic_int counter = ATOMIC_VAR_INIT(0);
atomic_fetch_add(&counter, 1);
int final_value = atomic_load(&counter);

printf("Atomic counter initialized to 0, incremented once.\n");
printf("Final value (read atomically): %d\n", final_value);

return 0;
}
1 change: 0 additions & 1 deletion examples/bzlmod/custom/toolchain/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ arm_none_eabi_toolchain(
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
],
gcc_tool = "g++",
linkopts = [
"-mcpu=cortex-m4",
"-mthumb",
Expand Down