libroot: unistd.h defines constants for unsupported POSIX features
|Reported by:||simonsouth||Owned by:||waddlesplash|
|Has a Patch:||yes||Platform:||All|
Haiku does not yet support certain features related to POSIX threads. For this reason,
unistd.h defines the
_POSIX_THREAD_PRIORITY_SCHEDULING constants to -1, meant to signal the absence of these features.
However, a careful reading of the POSIX spec suggests these constants should actually be left undefined. Referring to
The following symbolic constants are always defined to unspecified values to indicate that this functionality from the POSIX Threads Extension is always present on XSI-conformant systems:
If _XOPEN_REALTIME_THREADS is defined to have a value other than -1, then the following symbolic constants will be defined to an unspecified value to indicate that the features are supported:
Emphasis mine. The implication is that if the features are not available the constants should not be defined to any value; that is, they should be left undefined.
This seems to match how these constants are actually used in the wild.
The attached patch corrects the implementation by modifying
unistd.hto undefine the two constants (they are left in the file to indicate they have not simply been forgotten) and
sysconfreturns -1 when the presence of these features is tested (which matches the existing behaviour; POSIX says simply "the results are unspecified" in this case).
These changes are needed to build Apache Thrift on Haiku.
Change History (5)
by , 4 years ago