Skip to content

Commit

Permalink
features/standards: use standards macros for BSDs (re: 18d24dd)
Browse files Browse the repository at this point in the history
The features/standards iffe script claims:
/*
 * On BSD systems, _POSIX_SOURCE and such are used to *limit*
 * functionality to a known API; they don't enable anything. The
 * general intent in BSD is to enable everything by default.
 */
But this is completely false. I don't remember where on earth I
ever got that idea. All sorts of stuff is disabled by default and
needs to be enabled using _POSIX_SOURCE, _XOPEN_SORUCE, and (on
OpenBSD) _BSD_SOURCE or (on NetBSD) _NETBSD_SOURCE.

I discovered this when parallel building became impossible on all
the BSDs as of the referenced commit, because the SA_RESTART macro
is not defined by default on any of them. <sigh>
  • Loading branch information
McDutchie committed Aug 15, 2024
1 parent 4a84e42 commit d41c52d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/cmd/INIT/mamake.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ static const char usage[] =
#elif defined(__QNX__) && !defined(_QNX_SOURCE)
#define _QNX_SOURCE 1

/* Everything else (minus BSD, as the defaults there are acceptable) */
#elif !(BSD && !__APPLE__ && !__MACH__ && !NeXTBSD) && !defined(_POSIX_C_SOURCE)
/* Everything else */
#else
#define _XOPEN_SOURCE 9900
#define _POSIX_C_SOURCE 21000101L
#endif

Expand Down
9 changes: 4 additions & 5 deletions src/lib/libast/features/standards
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ set define
#

if tst note{ BSD (Free, Net, Open, et al) }end compile{
/*
* On BSD systems, _POSIX_SOURCE and such are used to *limit* functionality to a known API;
* they don't enable anything. The general intent in BSD is to enable everything by default.
*/
#include <limits.h>
#include <unistd.h>
#include <sys/param.h>
Expand All @@ -56,7 +52,10 @@ if tst note{ BSD (Free, Net, Open, et al) }end compile{
return 0;
}
}end {
/* No standards or features macro here. On BSD, everything is enabled by default */
#define _XOPEN_SOURCE 9900
#define _POSIX_C_SOURCE 21000101L
#define _BSD_SOURCE 1
#define _NETBSD_SOURCE 1
}
elif tst note{ Darwin (macOS, Mac OS X) }end compile{
/*
Expand Down

0 comments on commit d41c52d

Please sign in to comment.