public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/107008] New: Combine config/os/*/error_constants.h into one file
@ 2022-09-22 10:33 redi at gcc dot gnu.org
2022-09-22 10:38 ` [Bug libstdc++/107008] " redi at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-22 10:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107008
Bug ID: 107008
Summary: Combine config/os/*/error_constants.h into one file
Product: gcc
Version: 12.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
There's no reason to have multiple files and select one for the target:
config/os/djgpp/error_constants.h
config/os/generic/error_constants.h
config/os/mingw32-w64/error_constants.h
config/os/mingw32/error_constants.h
We can just ensure the generic one has a #ifdef for every errno macro that
isn't present on all targets, and use that everywhere.
Once we only have one error_constants.h file for all targets, we can also make
it work for freestanding like so:
#if _GLIBCXX_HOSTED
#include <cerrno>
namespace std {
enum class errc
{
address_family_not_supported = EAFNOSUPPORT,
address_in_use = EADDRINUSE,
// ...
};
}
#else
namespace std {
// For freestanding we have no <errno.h> but also no errors from the OS,
// so we can just make up our own values for the library's purposes.
enum class errc
{
address_family_not_supported = 1,
address_in_use,
// ...
};
}
#endif
This will allow a freestanding <charconv> to use std::errc.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/107008] Combine config/os/*/error_constants.h into one file
2022-09-22 10:33 [Bug libstdc++/107008] New: Combine config/os/*/error_constants.h into one file redi at gcc dot gnu.org
@ 2022-09-22 10:38 ` redi at gcc dot gnu.org
2022-09-22 10:44 ` redi at gcc dot gnu.org
2022-09-22 10:45 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-22 10:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107008
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
In theory the existing per-target error_constants.h allows an out-of-tree port
for a new OS to use its own error_constants.h more easily. Meh. They would
still need to edit configure.host to overrride ${error_constants_dir}, so they
can just edit the error_constants.h file instead. Adding a couple of #ifdef
conditions in there seems easier than providing a whole new file anyway.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/107008] Combine config/os/*/error_constants.h into one file
2022-09-22 10:33 [Bug libstdc++/107008] New: Combine config/os/*/error_constants.h into one file redi at gcc dot gnu.org
2022-09-22 10:38 ` [Bug libstdc++/107008] " redi at gcc dot gnu.org
@ 2022-09-22 10:44 ` redi at gcc dot gnu.org
2022-09-22 10:45 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-22 10:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107008
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
A related topic is that we simply don't define the errc enumerators that don't
have a corresponding EXXXX macro, which is non-conforming. The C++ standard
says the enumerators should all be there.
We could do something like this for each enumerator:
#ifdef EFOO
foo = EFOO,
#else
foo = _GLIBCXX_ERRC_ORIGIN + __LINE__,
#endif
Where _GLIBCXX_ERRC_ORIGIN is some value intended to be higher than the highest
errno value on the OS. We only need fewer than 100 errc enumerators so
INT_MAX/2 might be OK.
We can use #line to set the __LINE__ to a fixed value in the file, so that the
constants don't change if we add/remove lines before the errc definition.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/107008] Combine config/os/*/error_constants.h into one file
2022-09-22 10:33 [Bug libstdc++/107008] New: Combine config/os/*/error_constants.h into one file redi at gcc dot gnu.org
2022-09-22 10:38 ` [Bug libstdc++/107008] " redi at gcc dot gnu.org
2022-09-22 10:44 ` redi at gcc dot gnu.org
@ 2022-09-22 10:45 ` redi at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-22 10:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107008
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=104883
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #2)
> A related topic is that we simply don't define the errc enumerators that
> don't have a corresponding EXXXX macro, which is non-conforming. The C++
> standard says the enumerators should all be there.
Oh that's PR 104883
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-22 10:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22 10:33 [Bug libstdc++/107008] New: Combine config/os/*/error_constants.h into one file redi at gcc dot gnu.org
2022-09-22 10:38 ` [Bug libstdc++/107008] " redi at gcc dot gnu.org
2022-09-22 10:44 ` redi at gcc dot gnu.org
2022-09-22 10:45 ` redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).