Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

who implements C23 <stdbit.h> and <stdckdint.h>? #62248

Closed
enh-google opened this issue Apr 19, 2023 · 11 comments
Closed

who implements C23 <stdbit.h> and <stdckdint.h>? #62248

enh-google opened this issue Apr 19, 2023 · 11 comments
Assignees
Labels
c23 clang:headers Headers provided by Clang, e.g. for intrinsics question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@enh-google
Copy link
Contributor

enh-google commented Apr 19, 2023

Are these like <stdnoreturn.h>, or like <stdio.h>? I don't care, but it would be silly for me to add them to bionic if Clang will just provide its own anyway :-)

(the Clang <tgmath.h> in particular makes me think this might be one you'd rather do yourselves?)

@tbaederr tbaederr added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Apr 20, 2023
@AaronBallman AaronBallman added c23 clang:headers Headers provided by Clang, e.g. for intrinsics and removed new issue labels Apr 20, 2023
@AaronBallman
Copy link
Collaborator

I think <stdchkdint.h> will likely come from the C standard library, but I can see <stdbit.h> going either way (it's part of the freestanding requirements, but we're leaning more and more towards the user having to supply their own freestanding-compatible libc so that our headers basically only provide macros.

CC @jyknight @zygoloid @efriedma-quic @rjmccall for further opinions

@llvmbot
Copy link
Member

llvmbot commented Apr 20, 2023

@llvm/issue-subscribers-c2x

@enh-google
Copy link
Contributor Author

I think <stdchkdint.h> will likely come from the C standard library, but I can see <stdbit.h> going either way

did you mean that, or did you mean the opposite? <stdckdint.h> is macro-only, whereas <stdbit.h> says "It is unspecified whether any generic function declared in <stdbit.h> is a macro or an identifier declared with external linkage".

tbh, i think these are only useful as macros, because the whole point is that they're all just builtins that hopefully resolve to a single instruction. which is why it seems like maybe the compilers (who own the builtins) should own the headers too?

(i'm happy to contribute headers --- i'm interested in reducing duplication, not specifically about getting out of doing work myself :-) )

@efriedma-quic
Copy link
Collaborator

stdbit.h can't really be implemented as just a header because it's legal to take the address of some of the functions. (I mean, maybe you could do something tricky to make the implementations linkonce, but I don't think we want to.)

@MaskRay
Copy link
Member

MaskRay commented Apr 20, 2023

(other C vendors) @DimitryAndric @richfelker

@enh-google
Copy link
Contributor Author

stdbit.h can't really be implemented as just a header because it's legal to take the address of some of the functions

doesn't the part of the standard i quoted above explicitly give us the latitude to not have them be real functions? "It is unspecified whether any generic function declared in <stdbit.h> is a macro or an identifier declared with external linkage."

@AaronBallman
Copy link
Collaborator

did you mean that, or did you mean the opposite? <stdckdint.h> is macro-only, whereas <stdbit.h> says "It is unspecified whether any generic function declared in <stdbit.h> is a macro or an identifier declared with external linkage".

Oh, you're right, stdchkdint.h is just macros; I thought there were functions in there.

stdbit.h can't really be implemented as just a header because it's legal to take the address of some of the functions

doesn't the part of the standard i quoted above explicitly give us the latitude to not have them be real functions? "It is unspecified whether any generic function declared in <stdbit.h> is a macro or an identifier declared with external linkage."

Agreed, I think we have that latitude here.

@efriedma-quic
Copy link
Collaborator

The standard says it's "unspecified whether any generic function declared in <stdbit.h> [...]". Note the word "generic"; I'm pretty sure the rule is only supposed to apply to the type-generic functions, and the non-generic functions follow the ordinary rules for standard library functions.

@AaronBallman
Copy link
Collaborator

The standard says it's "unspecified whether any generic function declared in <stdbit.h> [...]". Note the word "generic"; I'm pretty sure the rule is only supposed to apply to the type-generic functions, and the non-generic functions follow the ordinary rules for standard library functions.

Oh shoot, you're right Eli (sorry for waffling). The allowances in 7.1.4 don't save us (they're what obligate us to make the non-generic APIs be real functions at the end of the day).

@enh-google enh-google changed the title who implements C23 <stdbit.h> and <stdchkdint.h>? who implements C23 <stdbit.h> and <stdckdint.h>? Jul 27, 2023
@pirama-arumuga-nainar
Copy link
Collaborator

The consensus, IIUC, is that clang will provide <stdckdint.h> and the C standard library should provide <stdbit.h>. @ZijunZhaoCCK is working on adding stdckdint.h.

@AaronBallman
Copy link
Collaborator

I agree, that's the consensus here. And thank you to @ZijunZhaoCCK for looking into adding stdckdint.h!

ZijunZhaoCCK added a commit that referenced this issue Oct 17, 2023
#62248

Reviewed By: yabinc, aaron.ballman, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D157331
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c23 clang:headers Headers provided by Clang, e.g. for intrinsics question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

8 participants