public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/107008] New: Combine config/os/*/error_constants.h into one file
Date: Thu, 22 Sep 2022 10:33:51 +0000	[thread overview]
Message-ID: <bug-107008-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2022-09-22 10:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 10:33 redi at gcc dot gnu.org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107008-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).