Opened 3 years ago

Closed 3 years ago

#12542 closed bug (fixed)

libroot: unistd.h defines constants for unsupported POSIX features

Reported by: simonsouth Owned by: waddlesplash
Priority: normal Milestone: Unscheduled
Component: System/POSIX Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
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_ATTR_STACKADDR and _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 _POSIX_THREAD_ATTR_STACKADDR:

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.h to undefine the two constants (they are left in the file to indicate they have not simply been forgotten) and
  • conf.cpp so sysconf returns -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.

Attachments (1)

0001-libroot-Undefine-constants-for-unsupported-POSIX-fea.patch (2.3 KB) - added by simonsouth 3 years ago.
libroot: Undefine constants for unsupported POSIX features

Download all attachments as: .zip

Change History (5)

Changed 3 years ago by simonsouth

libroot: Undefine constants for unsupported POSIX features

comment:1 Changed 3 years ago by simonsouth

Has a Patch: set

comment:2 Changed 3 years ago by simonsouth

Component: - GeneralSystem/POSIX

comment:3 Changed 3 years ago by waddlesplash

Owner: changed from nobody to waddlesplash
Status: newin-progress

comment:4 Changed 3 years ago by waddlesplash

Resolution: fixed
Status: in-progressclosed

Applied in hrev49935. Thanks!

On a side node, you're welcome to join us in the #haiku channel on Freenode.

Note: See TracTickets for help on using tickets.