/usr/include/stdatomic.h is not self-contained (fwd from Cygwin list)
Corinna Vinschen <[email protected]> Mon, 9 Feb 2026 15:38:04 +0100
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
[Forwarding to the newlib mailing list] ----- Forwarded message from kikairoya via Cygwin <[email protected]> ----- > Date: Sun, 08 Feb 2026 02:02:48 +0000 > From: kikairoya via Cygwin <[email protected]> > Subject: /usr/include/stdatomic.h is not self-contained > To: [email protected] > > Hello, > > I noticed that /usr/include/stdatomic.h is not self-contained due to lack of > including <stdint.h>. > > > $ echo '#include "/usr/include/stdatomic.h"' | gcc -xc - -fsyntax-only > In file included from <stdin>:1: > /usr/include/stdatomic.h:207:17: error: unknown type name 'int_least8_t' > 207 | typedef _Atomic(int_least8_t) atomic_int_least8_t; > | ^~~~~~~~~~~~ > /usr/include/stdatomic.h:208:17: error: unknown type name 'uint_least8_t' > 208 | typedef _Atomic(uint_least8_t) atomic_uint_least8_t; > | ^~~~~~~~~~~~~ > [...] > -- > Tomohiro Kashiwada (@kikairoya) Newlib's stdatomic.h header is more or less verbatim from FreeBSD(*) On FreeBSD, the least and fast types are apparently included when including sys/_types.h, but on Newlib they are not. Theoretically it would be nice if we could define the atomic types in terms of the underscored types, e.g., typedef _Atomic(__int_least8_t) atomic_int_least8_t; or typedef _Atomic(__INT_LEAST8_TYPE__) atomic_int_least8_t; instead of typedef _Atomic(int_least8_t) atomic_int_least8_t; but that falls flat for the fast types, because the macros __INT_FASTn_TYPE__ / __UINT_FASTn_TYPE__ are not defined on all compilers apparently. We're explicitely checking for their existence in stdint.h. Therefore we either have to include stdint.h from stdatomic.h, as Tomohiro suggested, or we have to rearrange the headers slightly and move the FAST definitions into machine/_default_types.h. The latter might be the better way. We define the underscored __int_fastN_t and __uint_fastN_t types in machine/_default_types.h and then define the non-underscored int_fastN_t / uint_fastN_t type in stdint.h in terms of the underscored types. Any input from other newlib users on that? Thanks, Corinna (*) But needs an update because it doesn't handle atomic_char8_t at all and disabled the atomic definitions for atomic_char16_t and atomic_char32_t, all of which are defined on Cygwin.