cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
baremetal.c File Reference

OS services the core expects but newlib on bare metal lacks. More...

Include dependency graph for baremetal.c:

Go to the source code of this file.

Detailed Description

OS services the core expects but newlib on bare metal lacks.

Built only into the CWIST_BAREMETAL archive (make baremetal). newlib declares the POSIX thread and timer APIs once the build enables them (-D_POSIX_THREADS, -D_POSIX_TIMERS, ...; see BAREMETAL_CFLAGS) but ships no implementation, so this file provides one for a single-threaded runtime, on top of the firmware hooks in <cwist/sys/port.h>:

  • pthread: mutexes and rwlocks cannot contend, condition variables never block (callers re-check their predicate), pthread_create() fails with EAGAIN so every background-thread path takes its no-thread fallback. Same contract as libttak's WASI preview1 stubs.
  • clock_gettime(), nanosleep() and timegm() live in baremetal_time.c, which the host unit test (tests/test_baremetal_port.c) also builds.
  • sched_yield() is a no-op.
  • 64-bit __atomic_* helpers: ARMv7-M/ARMv8-M have no LDREXD/STREXD, so GCC emits libcalls that libgcc does not implement for Cortex-M.

Definition in file baremetal.c.