Re: [RFC] Add stdckdint.h header for C23

2023-06-14 Thread Zack Weinberg via Gcc-patches
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() >> > # include_next >> > #endif >> >> I do

Re: [RFC] Add stdckdint.h header for C23

2023-06-14 Thread Joseph Myers
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() > > # include_next > > #endif > > I don't see how you could implement __has_include_next() for > a

Re: [RFC] Add stdckdint.h header for C23

2023-06-14 Thread Florian Weimer via Gcc-patches
* Paul Eggert: > I don't see how you could implement __has_include_next() > for arbitrary non-GCC compilers, which is what we'd need for glibc > users. This is not a requirement for glibc in general. For example, only works with compilers to which it has been ported. Thanks, Florian

Re: [RFC] Add stdckdint.h header for C23

2023-06-13 Thread Jakub Jelinek via Gcc-patches
On Tue, Jun 13, 2023 at 07:54:25PM -0700, Paul Eggert wrote: > I don't see how you could implement __has_include_next() 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.

Re: [RFC] Add stdckdint.h header for C23

2023-06-13 Thread Paul Eggert
On 6/12/23 23:28, Jakub Jelinek via Libc-alpha wrote: On Mon, Jun 12, 2023 at 09:51:02PM +, Joseph Myers wrote: On Sat, 10 Jun 2023, Jakub Jelinek via Gcc-patches wrote: I have looked at gnulib stdckdint.h and they are full of workarounds for various compilers, EDG doesn't do this, clang <

Re: [RFC] Add stdckdint.h header for C23

2023-06-13 Thread Joseph Myers
On Tue, 13 Jun 2023, Jakub Jelinek via Gcc-patches wrote: > Yeah, having say __builtin_{clz,ctz,ffs,popcount,parity} variants which would > be typegeneric and would allow say any normal integral or _BitInt type > (or just unsigned versions thereof?) would be useful. Even without _BitInt > we have

Re: [RFC] Add stdckdint.h header for C23

2023-06-13 Thread Jakub Jelinek via Gcc-patches
On Tue, Jun 13, 2023 at 03:10:48PM +, Joseph Myers wrote: > > So why does C2X say > > Recommended practice > > It is recommended to produce a diagnostic message if type2 or type3 are > > not suitable integer types, or if *result is not a modifiable lvalue of > > a suitable integer type. > > ? >

Re: [RFC] Add stdckdint.h header for C23

2023-06-13 Thread Joseph Myers
On Tue, 13 Jun 2023, Jakub Jelinek via Gcc-patches 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() > # include_next > #endif > perhaps guarded with some macro at the end of the GCC versio

Re: [RFC] Add stdckdint.h header for C23

2023-06-12 Thread Jakub Jelinek via Gcc-patches
On Mon, Jun 12, 2023 at 09:51:02PM +, Joseph Myers wrote: > On Sat, 10 Jun 2023, Jakub Jelinek via Gcc-patches wrote: > > > I have looked at gnulib stdckdint.h and they are full of workarounds > > for various compilers, EDG doesn't do this, clang <= 14 can't multiply > > __int128, ..., so I th

Re: [RFC] Add stdckdint.h header for C23

2023-06-12 Thread Joseph Myers
On Sat, 10 Jun 2023, Jakub Jelinek via Gcc-patches wrote: > I have looked at gnulib stdckdint.h and they are full of workarounds > for various compilers, EDG doesn't do this, clang <= 14 can't multiply > __int128, ..., so I think the header belongs into the compiler rather > than C library, becaus

Re: [RFC] Add stdckdint.h header for C23

2023-06-12 Thread Eric Gallager via Gcc-patches
On Sat, Jun 10, 2023 at 6:38 AM Jakub Jelinek via Gcc-patches wrote: > > Hi! > > The following patch is an attempt to implement the C23 stdckdint.h > header on top of our GNU extension - __builtin_{add,sub,mul}_overflow > builtins. > > I have looked at gnulib stdckdint.h and they are full of worka

Re: [RFC] Add stdckdint.h header for C23

2023-06-11 Thread Martin Uecker via Gcc-patches
Hi Jakup, two comments which may or may not be helpful: Clang extended _Generic in a similar way: https://github.com/llvm/llvm-project/commit/12728e144994efe84715f4e5dbb8c3104e9f0b5a Although for _Generic you can achieve the same with checking for compatiblilty of pointer to the type, and I do

Re: [RFC] Add stdckdint.h header for C23

2023-06-10 Thread Jakub Jelinek via Gcc-patches
On Sat, Jun 10, 2023 at 12:37:40PM +0200, Jakub Jelinek via Gcc-patches wrote: > I think changing __builtin_classify_type behavior after 35 years > would be dangerous, shall we introduce a new similar builtin which > would just never promote the argument/perform array/function/enum > conversions on

[RFC] Add stdckdint.h header for C23

2023-06-10 Thread Jakub Jelinek via Gcc-patches
Hi! The following patch is an attempt to implement the C23 stdckdint.h header on top of our GNU extension - __builtin_{add,sub,mul}_overflow builtins. I have looked at gnulib stdckdint.h and they are full of workarounds for various compilers, EDG doesn't do this, clang <= 14 can't multiply __int1