-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Feature gate: #![feature(c_size_t)].
This is a tracking issue for std::os::raw::{c_size_t, c_ssize_t}, which are guaranteed to be the same size as the underlying C size_t and ssize_t types from stddef.h.
Currently, on all targets, this is equivalent to usize and isize, however Rust has historically gone somewhat out of its way to avoid promising this. There are some targets with vaguely-planned support where this is not true (W65, used for SNES homebrew, for example)
Further reading here is available:
- https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/.60usize.60.20vs.20.60size_t.60
- https://internals.rust-lang.org/t/abi-discussion-for-w65/15092
- size_t vs usize rust-bindgen#1671
And probably more.
Public API
// std::os::raw
pub type c_size_t = usize;
pub type c_ssize_t = isize;Steps / History
- Implementation: Add
c_size_tandc_ssize_ttostd::os::raw. #88340 - Final comment period (FCP)
- Stabilization PR
Unresolved Questions
- Do we want to instead guarantee
usizeandsize_tare the same? See https://internals.rust-lang.org/t/pre-rfc-usize-is-not-size-t/15369 - Should this instead live in
libcoresomehow, given that probablylibstdmay never support platforms where this is not true. (This may not be true, since I imagine CHERI will support libstd) - Do we need both the signed and unsigned version, given that
size_tis more common in function signatures. - ...
MTCoster, zopsicle, alex, haraldh, MatrixDev and 2 morepetrochenkov and euclio
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.