Page MenuHomeFreeBSD

sys/stdint.h: add C23 _WIDTH macros
Needs ReviewPublic

Authored by fuz on Wed, Nov 19, 7:27 PM.
Tags
None
Referenced Files
F136864151: D53830.id.diff
Thu, Nov 20, 5:29 AM
Unknown Object (File)
Thu, Nov 20, 2:07 AM
Unknown Object (File)
Thu, Nov 20, 1:55 AM
Unknown Object (File)
Thu, Nov 20, 1:45 AM
Unknown Object (File)
Thu, Nov 20, 1:28 AM
Unknown Object (File)
Thu, Nov 20, 1:09 AM
Unknown Object (File)
Wed, Nov 19, 9:09 PM
Unknown Object (File)
Wed, Nov 19, 8:35 PM

Details

Summary

The platform-dependent macros are added to the various
_stdint.h headers, those that are always the same are
added directly to _stdint.h.

We may want to move the definitions for WCHAR_* and
WINT_* out of the platform header files as those are
always the same.

Test Plan

see following DR

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 68744
Build 65627: arc lint + arc unit

Event Timeline

fuz requested review of this revision.Wed, Nov 19, 7:27 PM
markj added inline comments.
sys/arm64/include/_stdint.h
167

Presumably this one should be INT64_WIDTH.

I'm not sure how to handle CHERI here, but @brooks can hopefully comment on that.

I don't feel super strongly about this, but I'm not entirely convinced we should be defining these from first principles. I believe that compilers we care about define __*_WIDTH__ macros we could use instead and things are likely to go very badly wrong if there's disagreement.

sys/arm64/include/_stdint.h
167

Once fixed these should be correct. WIDTH is about representability not storage.

sys/riscv/include/_stdint.h
163

I don't feel super strongly about this, but I'm not entirely convinced we should be defining these from first principles. I believe that compilers we care about define __*_WIDTH__ macros we could use instead and things are likely to go very badly wrong if there's disagreement.

I agree with this. If desired, I can prepare an alternative patch set that (a) replaces the existing sys/${ARCH}/include/_types and sys/${ARCH}/include/_stdint stuff with a generic approach where possible and then (b) adds the C23 features on top. This would be an alternative approach that is more intrusive, but ultimately simpler.

sys/arm64/include/_stdint.h
167

Yes, that's a typo. Will push a fix once my arm64 machine has completed a test build (it takes a while...)

  • fix INTPTR_WIDTH on arm64 and riscv