public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Zack Weinberg" <zack@owlfolio.org>
To: "Joseph Myers" <joseph@codesourcery.com>,
	"Paul Eggert" <eggert@cs.ucla.edu>
Cc: "Jakub Jelinek" <jakub@redhat.com>,
	"Marek Polacek" <polacek@redhat.com>,
	gcc-patches@gcc.gnu.org,
	"GNU libc development" <libc-alpha@sourceware.org>
Subject: Re: [RFC] Add stdckdint.h header for C23
Date: Wed, 14 Jun 2023 11:50:40 -0400	[thread overview]
Message-ID: <712c5a01-b6a2-403a-b0be-172b295454f3@app.fastmail.com> (raw)
In-Reply-To: <fed1be44-4995-90ff-f784-1ebde7d3ee@codesourcery.com>

On Wed, Jun 14, 2023, at 10:52 AM, Joseph Myers wrote:
> On Tue, 13 Jun 2023, Paul Eggert wrote:
>
>> > There is always the possibility to have the header co-owned by both
>> > the compiler and C library, limits.h style. Just
>> > #if __has_include_next(<stdckdint.h>)
>> > # include_next <stdckdint.h>
>> > #endif
>>
>> I don't see how you could implement
>> __has_include_next(<stdckdint.h>) for arbitrary non-GCC compilers,
>> which is what we'd need for glibc users. For glibc internals we can
>> use "#include_next" more readily, since we assume a new-enough GCC.
>> I.e. we could do something like this:
>
> Given the possibility of library functions being included in
> <stdckdint.h> in future standard versions, it seems important to look
> at ways of splitting responsibility for the header between the
> compiler and library, whether with __has_include_next, or compiler
> version conditionals, or some other such variation.

limits.h is a horrible mess, with both the compiler and the library
trying to get the last word, and I don't think we should take it as a
model. I suggest a better model is GCC 12's stdint.h, where the compiler
provides "stdint-gcc.h" that's used *only* in freestanding mode, and a
wrapper header that defers to the C library (using #include_next, which
is safe in GCC-provided headers) when __STDC_HOSTED__ is defined;
meanwhile, glibc's stdint.h doesn't look for compiler-provided headers
at all.

In this case it sounds like glibc needs the compiler to provide some of
the definitions, and I suggest this should be done via private predefined
macros, in the mode of __INTx_TYPE__ and friends.

zw

      reply	other threads:[~2023-06-14 15:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-10 10:37 Jakub Jelinek
2023-06-10 11:37 ` Jakub Jelinek
2023-06-11 14:05   ` Martin Uecker
2023-06-12 10:35 ` Eric Gallager
2023-06-12 21:51 ` Joseph Myers
2023-06-13  6:28   ` Jakub Jelinek
2023-06-13 15:10     ` Joseph Myers
2023-06-13 15:20       ` Jakub Jelinek
2023-06-13 15:45         ` Joseph Myers
2023-06-14  2:54     ` Paul Eggert
2023-06-14  6:49       ` Jakub Jelinek
2023-06-14 11:46       ` Florian Weimer
2023-06-14 14:52       ` Joseph Myers
2023-06-14 15:50         ` Zack Weinberg [this message]

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=712c5a01-b6a2-403a-b0be-172b295454f3@app.fastmail.com \
    --to=zack@owlfolio.org \
    --cc=eggert@cs.ucla.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=polacek@redhat.com \
    /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).