Page MenuHomeFreeBSD

cdefs: Start the __BSD_VISIBLE crackdown
Needs ReviewPublic

Authored by imp on Fri, Mar 21, 4:55 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

BSD_VISIBLE never should have been defined by user programs. That was
just supposed to be _BSD_SOURCE. However, we didn't document that well,
and implemented _BSD_SOURCE as 'nothing else defined'. Fix both of
these: For the moment,
BSD_VISIBLE being defined by the user will
defined, it will override everything else because our #includes depend
on everything being maximal when it's defined.

This also fixes a problem where people have mistakenly defined
BSD_VISIBLE to get some symbol, depending on an internal detail of our
headers, that we change when those functions are part of a newer POSIX
version. If they don't also bump that, they won't get the
symbol.
BSD_VISIBLE is our internal way of saying we want extra
symbols beyond the latest POSIX version, in the implementation. This is
why it is wrong for users to define it: what happens changes from major
release to major release and that's not a good outward facing interface.

Transitioning to having an explicit _BSD_SOURCE that overrides
everything and translating this mistake as above fixes the problem for
now. In the future, defining __BSD_VISIBLE before inclusion of
sys/cdefs.h will be an #error, but there's way too much to cleanup
since this mistake has been copied too many times.

A followup commit will indent this mess of tangled #ifdefs to make it
easier to follow.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 63033
Build 59917: arc lint + arc unit

Event Timeline

imp requested review of this revision.Fri, Mar 21, 4:55 PM
imp created this revision.
sef added inline comments.
sys/sys/cdefs.h
511

Do we want to have #error Stop using this it is bad and makes the compiler cry or similar?

sys/sys/cdefs.h
511

Want? Yes.
Can make it happen? Not any time soon. Thousands of ports break, though only a few hundred directly.