Opened 8 years ago

Closed 8 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:
Platform: All

Description

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:

And to _POSIX_THREAD_PRIORITY_SCHEDULING:

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 8 years ago.
libroot: Undefine constants for unsupported POSIX features

Download all attachments as: .zip

Change History (5)

by simonsouth, 8 years ago

libroot: Undefine constants for unsupported POSIX features

comment:1 by simonsouth, 8 years ago

patch: 01

comment:2 by simonsouth, 8 years ago

Component: - GeneralSystem/POSIX

comment:3 by waddlesplash, 8 years ago

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

comment:4 by waddlesplash, 8 years ago

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.