This has the following advantages:
- faster and leaner when C11 atomics are not efficient (e.g. on LLVM
this is almost always the case, as LLVM will only use efficient
atomics if it doesn't has to bail out to library calls even for
exotic things)
- Even for GCC e.g. on the nucleo-f429zi this safes 72 B of .text
for examples/filesystem despite runtime checks added for
over- and underflow
- less pain in the ass for C++ and rust users, as both C++ and
c2rust are incompatible with C11 atomics
- adds test for overflow of the open file counter for more robust
operation
- adds `assumes()` so that underflows are detected in non-production
code
In most places, picolibc and newlib are the same, so use
the existing newlib code when compiling with picolibc.
Signed-off-by: Keith Packard <keithp@keithp.com>