diff --git a/src/cmd/INIT/ar.freebsd12.amd64 b/src/cmd/INIT/ar.freebsd12.amd64 deleted file mode 100755 index 896427648..000000000 --- a/src/cmd/INIT/ar.freebsd12.amd64 +++ /dev/null @@ -1,6 +0,0 @@ -: freebsd12.amd64 ar wrapper - -case $1 in -*x*) /usr/bin/ar "$@" ;; -*) /usr/bin/ar U"$@" ;; -esac diff --git a/src/cmd/INIT/ar.linux.i386-64 b/src/cmd/INIT/ar.linux.i386-64 deleted file mode 100755 index dc34f235e..000000000 --- a/src/cmd/INIT/ar.linux.i386-64 +++ /dev/null @@ -1,6 +0,0 @@ -: linux.i386-64 ar wrapper - -case $1 in -*x*) /usr/bin/ar "$@" ;; -*) /usr/bin/ar U"$@" ;; -esac diff --git a/src/cmd/INIT/cc.freebsd b/src/cmd/INIT/cc.freebsd deleted file mode 100755 index af3576cef..000000000 --- a/src/cmd/INIT/cc.freebsd +++ /dev/null @@ -1,9 +0,0 @@ -: FreeBSD cc wrapper - -HOSTTYPE=freebsd.generic - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -exec /usr/bin/cc -P "$@" diff --git a/src/cmd/INIT/cc.linux b/src/cmd/INIT/cc.linux deleted file mode 100755 index 75fe0cf16..000000000 --- a/src/cmd/INIT/cc.linux +++ /dev/null @@ -1,9 +0,0 @@ -: linux cc wrapper : 2021-04-08 : - -HOSTTYPE=linux.generic - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -exec /usr/bin/cc -P -D_LARGEFILE64_SOURCE "$@" diff --git a/src/cmd/INIT/cc.linux.aarch64 b/src/cmd/INIT/cc.linux.aarch64 deleted file mode 100755 index c4e558e46..000000000 --- a/src/cmd/INIT/cc.linux.aarch64 +++ /dev/null @@ -1,9 +0,0 @@ -: linux.aarch64 cc wrapper : 2006-02-14 : - -HOSTTYPE=linux.aarch64 - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -/usr/bin/cc -P "$@" diff --git a/src/cmd/INIT/cc.linux.i386-64 b/src/cmd/INIT/cc.linux.i386-64 deleted file mode 100755 index d7f3d7001..000000000 --- a/src/cmd/INIT/cc.linux.i386-64 +++ /dev/null @@ -1,9 +0,0 @@ -: linux.i386-64 cc wrapper : 2006-02-14 : - -HOSTTYPE=linux.i386-64 - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -/usr/bin/cc -P "$@" diff --git a/src/cmd/INIT/cc.linux.i386-64-icc b/src/cmd/INIT/cc.linux.i386-64-icc deleted file mode 100755 index 4d945bf5c..000000000 --- a/src/cmd/INIT/cc.linux.i386-64-icc +++ /dev/null @@ -1,22 +0,0 @@ -: linux.i386-64 icc wrapper : 2011-10-18 : - -HOSTTYPE=linux.i386-64-icc - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -icc=$(which icc 2>/dev/null) -case $icc in -"") if test -f /etc/profile.d/icc.sh - then . /etc/profile.d/icc.sh - fi - icc=$(which icc 2>/dev/null) - case $icc in - "") echo icc: not found >&2 - exit 127 - ;; - esac - ;; -esac -$icc "$@" diff --git a/src/cmd/INIT/cc.linux.i386-icc b/src/cmd/INIT/cc.linux.i386-icc deleted file mode 100755 index da09c82fd..000000000 --- a/src/cmd/INIT/cc.linux.i386-icc +++ /dev/null @@ -1,22 +0,0 @@ -: linux.i386 icc wrapper : 2021-01-31 : - -HOSTTYPE=linux.ia64-icc - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -icc=$(which icc 2>/dev/null) -case $icc in -"") if test -f /etc/profile.d/icc.sh - then . /etc/profile.d/icc.sh - fi - icc=$(which icc 2>/dev/null) - case $icc in - "") echo icc: not found >&2 - exit 127 - ;; - esac - ;; -esac -exec "$icc" -D_LARGEFILE64_SOURCE "$@" diff --git a/src/cmd/INIT/cc.linux.ia64-icc b/src/cmd/INIT/cc.linux.ia64-icc deleted file mode 100755 index 09dc25c08..000000000 --- a/src/cmd/INIT/cc.linux.ia64-icc +++ /dev/null @@ -1,22 +0,0 @@ -: linux.ia64 icc wrapper : 2011-10-18 : - -HOSTTYPE=linux.ia64-icc - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -icc=$(which icc 2>/dev/null) -case $icc in -"") if test -f /etc/profile.d/icc.sh - then . /etc/profile.d/icc.sh - fi - icc=$(which icc 2>/dev/null) - case $icc in - "") echo icc: not found >&2 - exit 127 - ;; - esac - ;; -esac -$icc "$@" diff --git a/src/cmd/INIT/cc.openbsd b/src/cmd/INIT/cc.openbsd deleted file mode 100755 index fb8916729..000000000 --- a/src/cmd/INIT/cc.openbsd +++ /dev/null @@ -1,9 +0,0 @@ -: OpenBSD cc wrapper - -HOSTTYPE=openbsd.generic - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -exec /usr/bin/cc -P "$@" diff --git a/src/cmd/INIT/cc.sol11.i386 b/src/cmd/INIT/cc.sol11.i386 deleted file mode 100755 index 9a7ed32e4..000000000 --- a/src/cmd/INIT/cc.sol11.i386 +++ /dev/null @@ -1,18 +0,0 @@ -: solaris.i386 cc wrapper for 32 bit : 2021-05-12 : - -HOSTTYPE=sol11.i386 - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -# Solaris build scripts set $CC_EXPLICIT. If not set, function without it. -case ${CC_EXPLICIT:=$CC} in -'' | cc) - PATH=`/usr/bin/getconf PATH` # avoid infinite recursion executing 'cc' - CC_EXPLICIT=cc -esac - -# Note: the _XPG6 macro is now defined in src/lib/libast/features/common - -$CC_EXPLICIT -m32 -std=c11 "$@" diff --git a/src/cmd/INIT/cc.sol11.i386-64 b/src/cmd/INIT/cc.sol11.i386-64 deleted file mode 100755 index e980618ba..000000000 --- a/src/cmd/INIT/cc.sol11.i386-64 +++ /dev/null @@ -1,18 +0,0 @@ -: solaris.i386-64 cc wrapper for 64 bit : 2021-05-12 : - -HOSTTYPE=sol11.i386-64 - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -# Solaris build scripts set $CC_EXPLICIT. If not set, function without it. -case ${CC_EXPLICIT:=$CC} in -'' | cc) - PATH=`/usr/bin/getconf PATH` # avoid infinite recursion executing 'cc' - CC_EXPLICIT=cc -esac - -# Note: the _XPG6 macro is now defined in src/lib/libast/features/common - -$CC_EXPLICIT -m64 -std=c11 "$@" diff --git a/src/cmd/INIT/cc.sol11.sparc b/src/cmd/INIT/cc.sol11.sparc deleted file mode 100755 index cdad08d57..000000000 --- a/src/cmd/INIT/cc.sol11.sparc +++ /dev/null @@ -1,18 +0,0 @@ -: solaris.sparc cc wrapper for 32 bit : 2021-05-12 : - -HOSTTYPE=sol11.sparc - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -# Solaris build scripts set $CC_EXPLICIT. If not set, function without it. -case ${CC_EXPLICIT:=$CC} in -'' | cc) - PATH=`/usr/bin/getconf PATH` # avoid infinite recursion executing 'cc' - CC_EXPLICIT=cc -esac - -# Note: the _XPG6 macro is now defined in src/lib/libast/features/common - -$CC_EXPLICIT -m32 -std=c11 "$@" diff --git a/src/cmd/INIT/cc.sol11.sparc-64 b/src/cmd/INIT/cc.sol11.sparc-64 deleted file mode 100755 index 0c4f3129f..000000000 --- a/src/cmd/INIT/cc.sol11.sparc-64 +++ /dev/null @@ -1,18 +0,0 @@ -: solaris.sparc-64 cc wrapper for 64 bit : 2021-05-12 : - -HOSTTYPE=sol11.sparc-64 - -case " $* " in -*" -dumpmachine "*) echo $HOSTTYPE; exit ;; -esac - -# Solaris build scripts set $CC_EXPLICIT. If not set, function without it. -case ${CC_EXPLICIT:=$CC} in -'' | cc) - PATH=`/usr/bin/getconf PATH` # avoid infinite recursion executing 'cc' - CC_EXPLICIT=cc -esac - -# Note: the _XPG6 macro is now defined in src/lib/libast/features/common - -$CC_EXPLICIT -m64 -std=c11 "$@" diff --git a/src/lib/libast/features/standards b/src/lib/libast/features/standards index 75702d092..1a6a392e8 100644 --- a/src/lib/libast/features/standards +++ b/src/lib/libast/features/standards @@ -6,44 +6,151 @@ set stdio # Affected: Mac OS X, UnixWare. typ u_long -# In FreeBSD, definitions like _POSIX_SOURCE and such are used to *limit* -# functionality to known API; they don't enable anything. The general intent in -# BSD is to enable everything by default. So we look for that here, but stay -# careful that we don't get fooled by presence of FreeBSD that underpins some -# subsystems in Mac OS X; there are other Apple-specific portability hacks -# elsewhere we should not interfere with. -if tst note{ FreeBSD or DragonFly BSD }end compile{ +# +# The following tests try to define the features/standards macros that expose +# as much functionality as possible on the current system. We've got our own +# feature test framework, iffe, so we want POSIX + all possible extensions. +# +# The results of these are included in everything that uses libast and +# (as of 2021-12-06) also in all subsequent feature tests run by iffe. +# +# Note: The code between compile{ ... }end is the feature test; the text +# in the subsequent { ... } block is output literally to FEATURE/standards. +# + +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 + #include #include - #if (!defined(__FreeBSD__) && !defined(__DragonFly__)) || defined(__APPLE__) || defined(__MACH__) - #error not one of the listed systems + #include + #if !(BSD && !__APPLE__ && !__MACH__ && !NeXTBSD) /* NeXT/macOS falsely claim to be BSD */ + #error not BSD + #endif + int _do_these_compile_ = _POSIX_PATH_MAX & _SC_PAGESIZE; + #if _typ_u_long + u_long _test_dummy_; #endif }end { + /* No standards or features macro here. On BSD, everything is enabled by default */ + } +elif tst note{ Darwin (macOS, Mac OS X) }end compile{ + /* + * From compat(5) on macOS 10.14.6: + * + * Defining _POSIX_C_SOURCE or _DARWIN_C_SOURCE causes library and kernel calls to + * conform to the SUSv3 standards even if doing so would alter the behavior of func- + * tions used in 10.3. Defining _POSIX_C_SOURCE also removes functions, types, and + * other interfaces that are not part of SUSv3 from the normal C namespace, unless + * _DARWIN_C_SOURCE is also defined (i.e., _DARWIN_C_SOURCE is _POSIX_C_SOURCE with + * non-POSIX extensions). + */ + #define _DARWIN_C_SOURCE 1 + #include + #include + #include + #include + #if !(__APPLE__ && __MACH__ && NeXTBSD) + #error not Darwin + #endif + int _do_these_compile_ = _POSIX_PATH_MAX & _SC_PAGESIZE; + #if _typ_u_long + u_long _test_dummy_; + #endif + }end { + #ifndef _DARWIN_C_SOURCE + #define _DARWIN_C_SOURCE 1 + #endif } elif tst note{ SunOS (Solaris, illumos) }end compile{ + /* + * On Solaris/illumos, we ignore the standards(5) manual completely because + * defining any standards macro, and even defining __EXTENSIONS__ (!), will + * disable functionality that libast depends on. Instead we define unofficial + * _XPG* macros that enable up-to-date declarations and functionality in + * Solaris system headers. + * (Note that we must also avoid passing any -std=... flag to the compiler, + * because that will disable essential functionality as well.) + */ + #define _XPG7 + #define _XPG6 + #define _XPG5 + #define _XPG4_2 + #define _XPG4 + #define _XPG3 + #define __EXTENSIONS__ 1 + #define _XOPEN_SOURCE 9900 + #undef _POSIX_C_SOURCE + #include + #include + #include #if !__sun #error dark #endif + int _do_these_compile_ = _POSIX_PATH_MAX & _SC_PAGESIZE; + #if _typ_u_long + u_long _test_dummy_; + #endif }end { - #define _XPG7 1 - #define _XPG6 1 - #define _XPG5 1 - #define _XPG4 1 - #define __EXTENSIONS__ 1 + #define _XPG7 + #define _XPG6 + #define _XPG5 + #define _XPG4_2 + #define _XPG4 + #define _XPG3 + #define __EXTENSIONS__ 1 #define _XOPEN_SOURCE 9900 + #undef _POSIX_C_SOURCE } -elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & _GNU_SOURCE & _DARWIN_C_SOURCE & __EXTENSIONS__ works }end compile{ +elif tst note{ GNU (glibc) }end compile{ + /* + * GNU (GNU's Not UNIX). From feature_test_macros(7) on a GNU/Linux system with glibc 2.32: + * + * _GNU_SOURCE + * Defining this macro (with any value) implicitly defines _ATFILE_SOURCE, _LARGE‐ + * FILE64_SOURCE, _ISOC99_SOURCE, _XOPEN_SOURCE_EXTENDED, _POSIX_SOURCE, + * _POSIX_C_SOURCE with the value 200809L (200112L in glibc versions before 2.10; + * 199506L in glibc versions before 2.5; 199309L in glibc versions before 2.1) and + * _XOPEN_SOURCE with the value 700 (600 in glibc versions before 2.10; 500 in + * glibc versions before 2.2). In addition, various GNU-specific extensions are + * also exposed. + * Since glibc 2.19, defining _GNU_SOURCE also has the effect of implicitly defin‐ + * ing _DEFAULT_SOURCE. In glibc versions before 2.20, defining _GNU_SOURCE also + * had the effect of implicitly defining _BSD_SOURCE and _SVID_SOURCE. + */ + #define _GNU_SOURCE 1 + #include + #include + #include + #include + #if !__GLIBC__ + #error not GNU + #endif + int _do_these_compile_ = _POSIX_PATH_MAX & _SC_PAGESIZE; + #if _typ_u_long + u_long _test_dummy_; + #endif + }end { + #ifndef _GNU_SOURCE + #define _GNU_SOURCE 1 + #endif + } +elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{ #define _ALL_SOURCE 1 #define _POSIX_SOURCE 1 #define _POSIX_C_SOURCE 21000101L #define _XOPEN_SOURCE 9900 - #define _GNU_SOURCE 1 - #define _DARWIN_C_SOURCE 1 #define __EXTENSIONS__ 1 #include #include #include #include #include + #include + int _do_these_compile_ = _POSIX_PATH_MAX & _SC_PAGESIZE; #if _typ_u_long u_long _test_dummy_; #endif @@ -60,28 +167,22 @@ elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & _ #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 9900 #endif - #ifndef _GNU_SOURCE - #define _GNU_SOURCE 1 - #endif - #ifndef _DARWIN_C_SOURCE - #define _DARWIN_C_SOURCE 1 - #endif #ifndef __EXTENSIONS__ #define __EXTENSIONS__ 1 #endif } -elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _XOPEN_SOURCE & _GNU_SOURCE & _DARWIN_C_SOURCE & __EXTENSIONS__ works }end compile{ +elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{ #define _ALL_SOURCE 1 #define _POSIX_SOURCE 1 #define _XOPEN_SOURCE 9900 - #define _GNU_SOURCE 1 - #define _DARWIN_C_SOURCE 1 #define __EXTENSIONS__ 1 #include #include #include #include #include + #include + int _do_these_compile_ = _POSIX_PATH_MAX & _SC_PAGESIZE; #if _typ_u_long u_long _test_dummy; #endif @@ -95,28 +196,22 @@ elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _XOPEN_SOURCE & _GNU_SOURCE & _DARW #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 9900 #endif - #ifndef _GNU_SOURCE - #define _GNU_SOURCE 1 - #endif - #ifndef _DARWIN_C_SOURCE - #define _DARWIN_C_SOURCE 1 - #endif #ifndef __EXTENSIONS__ #define __EXTENSIONS__ 1 #endif } -elif tst note{ _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & _GNU_SOURCE & _DARWIN_C_SOURCE & __EXTENSIONS__ works }end compile{ +elif tst note{ _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{ #define _POSIX_SOURCE 1 #define _POSIX_C_SOURCE 21000101L #define _XOPEN_SOURCE 9900 - #define _GNU_SOURCE 1 - #define _DARWIN_C_SOURCE 1 #define __EXTENSIONS__ 1 #include #include #include #include #include + #include + int _do_these_compile_ = _POSIX_PATH_MAX & _SC_PAGESIZE; #if _typ_u_long u_long _test_dummy; #endif @@ -130,12 +225,6 @@ elif tst note{ _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & _GNU_SOURCE & _ #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 9900 #endif - #ifndef _GNU_SOURCE - #define _GNU_SOURCE 1 - #endif - #ifndef _DARWIN_C_SOURCE - #define _DARWIN_C_SOURCE 1 - #endif #ifndef __EXTENSIONS__ #define __EXTENSIONS__ 1 #endif @@ -149,6 +238,8 @@ elif tst note{ _POSIX_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile #include #include #include + #include + int _do_these_compile_ = _POSIX_PATH_MAX & _SC_PAGESIZE; #if _typ_u_long u_long _test_dummy; #endif @@ -171,6 +262,8 @@ elif tst note{ _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{ #include #include #include + #include + int _do_these_compile_ = _POSIX_PATH_MAX & _SC_PAGESIZE; #if _typ_u_long u_long _test_dummy; #endif @@ -189,6 +282,8 @@ elif tst note{ _XOPEN_SOURCE works }end compile{ #include #include #include + #include + int _do_these_compile_ = _POSIX_PATH_MAX & _SC_PAGESIZE; #if _typ_u_long u_long _test_dummy; #endif @@ -202,6 +297,8 @@ else tst note{ __EXTENSIONS__ works }end compile{ #include #include #include + #include + int _do_these_compile_ = _POSIX_PATH_MAX & _SC_PAGESIZE; #if _typ_u_long u_long _test_dummy; #endif