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