Lots of system APIs get new flag values added over time, or have other changes. Also, some APIs are available on many but not all platforms. It would be ideal if libc made this available downstream in a better way than having undefined items. This would allow progressive enhancement based on the target system's capabilities.
My main idea is to provide a library that downstream projects can use in their build scripts. The library would make it easy to define features that can be used in cfg attributes in the downstream project.
Examples
The tempfile crate could use open(2) with O_TMPFILE on Linux 3.11+ where it exists, and fall back to mkstemp(3) + unlink(2) where it doesn't.
A server might use vmsplice(2) on Linux to avoid copies, with write(2) or send(2) as a fallback.
This could be provided by a third party crate as the maintenance burden is fairly high, and the testing story would be a bit rough. Any thoughts?
Lots of system APIs get new flag values added over time, or have other changes. Also, some APIs are available on many but not all platforms. It would be ideal if libc made this available downstream in a better way than having undefined items. This would allow progressive enhancement based on the target system's capabilities.
My main idea is to provide a library that downstream projects can use in their build scripts. The library would make it easy to define features that can be used in
cfgattributes in the downstream project.Examples
The tempfile crate could use
open(2)withO_TMPFILEon Linux 3.11+ where it exists, and fall back tomkstemp(3)+unlink(2)where it doesn't.A server might use
vmsplice(2)on Linux to avoid copies, withwrite(2)orsend(2)as a fallback.This could be provided by a third party crate as the maintenance burden is fairly high, and the testing story would be a bit rough. Any thoughts?