Add checks used by Qt

This commit is contained in:
Francois Kritzinger 2022-01-26 14:32:13 +02:00
parent 17aa02d771
commit a0aa26a578
21 changed files with 361 additions and 10 deletions

View File

@ -141,7 +141,9 @@ The first line in this header file must be in the form:
If the name is followed by the `!` modifier, then it is *unprefixable* (see
the previous section for details). The name can also be followed by `:` and a
list of base checks. Such checks are automatically inserted before the rest of
the lines in the resulting substitution.
the lines in the resulting substitution. One notable check that you may
want to use as a base is [`LIBC_VERSION`][libc-version] (see comments for
details).
Subsequent lines should be C-style comments or preprocessor directives that
`#define` or `#undef` `<NAME>` depending on whether the feature is available
@ -178,3 +180,4 @@ ways that deal with duplication (for example, include guards).
[module-in]: https://build2.org/build2/doc/build2-build-system-manual.xhtml#module-in
[proj-config]: https://build2.org/build2/doc/build2-build-system-manual.xhtml#proj-config
[checks]: https://github.com/build2/libbuild2-autoconf/tree/master/libbuild2-autoconf/libbuild2/autoconf/checks/
[libc-version]: https://github.com/build2/libbuild2-autoconf/tree/master/libbuild2-autoconf/libbuild2/autoconf/checks/LIBC_VERSION.h

View File

@ -1,2 +1,3 @@
config.h
driver
driver-posix

View File

@ -43,8 +43,8 @@
# define BIG_ENDIAN 4321
# define LITTLE_ENDIAN 1234
# define BYTE_ORDER LITTLE_ENDIAN
# elif defined(__BYTE_ORDER__) && \
defined(__ORDER_BIG_ENDIAN__) && \
# elif defined(__BYTE_ORDER__) && \
defined(__ORDER_BIG_ENDIAN__) && \
defined(__ORDER_LITTLE_ENDIAN__)
/* GCC, Clang (and others, potentially).
*/

View File

@ -0,0 +1,14 @@
// HAVE_CLOCK_GETTIME : LIBC_VERSION
#undef HAVE_CLOCK_GETTIME
/* Since Linux 2.6/glibc 2.2 (based on glibc commit history), FreeBSD 3.0,
* OpenBSD 2.1, NetBSD 1.4, and Mac OSX 10.12.
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 2) || \
BUILD2_AUTOCONF_FREEBSD_PREREQ(3, 0) || \
BUILD2_AUTOCONF_OPENBSD_PREREQ(199706) || \
BUILD2_AUTOCONF_NETBSD_PREREQ(1, 4) || \
BUILD2_AUTOCONF_MACOS_PREREQ(10, 12)
# define HAVE_CLOCK_GETTIME 1
#endif

View File

@ -0,0 +1,13 @@
// HAVE_DLOPEN : LIBC_VERSION
#undef HAVE_DLOPEN
/* Since Linux/glibc 2.0 and all versions of other supported UNIXes.
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 0) || \
defined(__FreeBSD__) || \
defined(__OpenBSD__) || \
defined(__NetBSD__) || \
(defined(__APPLE__) && defined(__MACH__))
# define HAVE_DLOPEN 1
#endif

View File

@ -0,0 +1,13 @@
// HAVE_EVENTFD : LIBC_VERSION
#undef HAVE_EVENTFD
/* Since Linux/glibc 2.8, FreeBSD 13.
*
* @@ TODO eventfd() looks likely to be added to NetBSD 10 which does not yet
* have a release date.
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 8) || \
BUILD2_AUTOCONF_FREEBSD_PREREQ(13, 0)
# define HAVE_EVENTFD 1
#endif

View File

@ -1,12 +1,11 @@
// HAVE_EXPLICIT_BZERO
// HAVE_EXPLICIT_BZERO : LIBC_VERSION
#undef HAVE_EXPLICIT_BZERO
/* Since FreeBSD 11, OpenBSD 5.5, and glibc 2.25.
*/
#if (defined(__FreeBSD__) && __FreeBSD__ >= 11) || \
(defined(__OpenBSD__) && defined(OpenBSD) && OpenBSD >= 201405) || \
(defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
(__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 25))
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 25) || \
BUILD2_AUTOCONF_FREEBSD_PREREQ(11, 0) || \
BUILD2_AUTOCONF_OPENBSD_PREREQ(201405)
# define HAVE_EXPLICIT_BZERO 1
#endif

View File

@ -1,9 +1,9 @@
// HAVE_EXPLICIT_MEMSET
// HAVE_EXPLICIT_MEMSET : LIBC_VERSION
#undef HAVE_EXPLICIT_MEMSET
/* Since NetBSD 7.0.0.
*/
#if defined(__NetBSD_Version__) && __NetBSD_Version__ >= 700000000
#if BUILD2_AUTOCONF_NETBSD_PREREQ(7, 0)
# define HAVE_EXPLICIT_MEMSET 1
#endif

View File

@ -0,0 +1,14 @@
// HAVE_FUTIMENS : LIBC_VERSION
#undef HAVE_FUTIMENS
/* Since Linux/glibc 2.6, FreeBSD 10.3, OpenBSD 5.0, NetBSD 6.0, Mac OS 10.6
* (2009).
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 6) || \
BUILD2_AUTOCONF_FREEBSD_PREREQ(10, 3) || \
BUILD2_AUTOCONF_OPENBSD_PREREQ(201111) || \
BUILD2_AUTOCONF_NETBSD_PREREQ(6, 0) || \
BUILD2_AUTOCONF_MACOS_PREREQ(10, 6)
# define HAVE_FUTIMENS 1
#endif

View File

@ -0,0 +1,15 @@
// HAVE_FUTIMES : LIBC_VERSION
#undef HAVE_FUTIMES
/* Since Linux/glibc 2.3, FreeBSD 3.x, OpenBSD 1.2 (but the `OpenBSD` macro
* was only added in 2.0 with a value of 199610), NetBSD 1.2, Mac OS (all
* versions).
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 3) || \
BUILD2_AUTOCONF_FREEBSD_PREREQ(3, 0) || \
BUILD2_AUTOCONF_OPENBSD_PREREQ(199610) || \
BUILD2_AUTOCONF_NETBSD_PREREQ(1, 2) || \
(defined(__APPLE__) && defined(__MACH__))
# define HAVE_FUTIMES 1
#endif

View File

@ -0,0 +1,9 @@
// HAVE_GETAUXVAL : LIBC_VERSION
#undef HAVE_GETAUXVAL
/* Since glibc 2.16.
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 16)
# define HAVE_GETAUXVAL 1
#endif

View File

@ -0,0 +1,15 @@
// HAVE_GETENTROPY : LIBC_VERSION
#undef HAVE_GETENTROPY
/* Since Linux/glibc 2.25, OpenBSD 5.6, FreeBSD 12, and Mac OS 12.
*
* @@ TODO Update when NetBSD releases its support (see
* https://mail-index.netbsd.org/tech-userlevel/2020/05/02/msg012333.html).
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 25) || \
BUILD2_AUTOCONF_FREEBSD_PREREQ(12, 0) || \
BUILD2_AUTOCONF_OPENBSD_PREREQ(201411) || \
BUILD2_AUTOCONF_MACOS_PREREQ(10, 12)
# define HAVE_GETENTROPY 1
#endif

View File

@ -0,0 +1,9 @@
// HAVE_INOTIFY : LIBC_VERSION
#undef HAVE_INOTIFY
/* Since Linux 2.6.3/glibc 2.4.
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 4)
# define HAVE_INOTIFY 1
#endif

View File

@ -0,0 +1,15 @@
// HAVE_LINKAT : LIBC_VERSION
#undef HAVE_LINKAT
/* Since Linux 2.6.16/glibc 2.4, FreeBSD 8.0, OpenBSD 5.0, NetBSD 7.0 (it was
* only partially implemented in earlier versions according to the manpage),
* Mac OS (all versions).
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 4) || \
BUILD2_AUTOCONF_FREEBSD_PREREQ(8, 0) || \
BUILD2_AUTOCONF_OPENBSD_PREREQ(201111) || \
BUILD2_AUTOCONF_NETBSD_PREREQ(7, 0) || \
(defined(__APPLE__) && defined(__MACH__))
# define HAVE_LINKAT 1
#endif

View File

@ -0,0 +1,15 @@
// HAVE_POLL : LIBC_VERSION
#undef HAVE_POLL
/* Since Linux 2.1.23/glibc (all versions; emulated using select() on older
* kernels), FreeBSD (all versions), OpenBSD (all versions), NetBSD 1.3, Mac
* OS (all versions).
*/
#if defined(__GLIBC__) || \
defined(__FreeBSD__) || \
defined(__OpenBSD__) || \
BUILD2_AUTOCONF_NETBSD_PREREQ(1, 3) || \
(defined(__APPLE__) && defined(__MACH__))
# define HAVE_POLL 1
#endif

View File

@ -0,0 +1,9 @@
// HAVE_POLLTS : LIBC_VERSION
#undef HAVE_POLLTS
/* Since NetBSD 3.0.
*/
#if BUILD2_AUTOCONF_NETBSD_PREREQ(3, 0)
# define HAVE_POLLTS 1
#endif

View File

@ -0,0 +1,14 @@
// HAVE_POSIX_FALLOCATE : LIBC_VERSION
#undef HAVE_POSIX_FALLOCATE
/* Since Linux/glibc 2.2, FreeBSD 9.0
*
* posix_fallocate(3) on Linux says since glibc 2.1.94 but use 2.2 as
* https://sourceware.org/glibc/wiki/Glibc%20Timeline does not show that
* version and the glibc macros can't check for patch versions.
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 2) || \
BUILD2_AUTOCONF_FREEBSD_PREREQ(9, 0)
# define HAVE_POSIX_FALLOCATE 1
#endif

View File

@ -0,0 +1,11 @@
// HAVE_PPOLL : LIBC_VERSION
#undef HAVE_PPOLL
/* Since Linux 2.6.16/glibc 2.4, FreeBSD 11, OpenBSD 5.4.
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 4) || \
BUILD2_AUTOCONF_FREEBSD_PREREQ(11, 0) || \
BUILD2_AUTOCONF_OPENBSD_PREREQ(201311)
# define HAVE_PPOLL 1
#endif

View File

@ -0,0 +1,9 @@
// HAVE_RENAMEAT2 : LIBC_VERSION
#undef HAVE_RENAMEAT2
// Since Linux 3.15/glibc 2.28.
//
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 28)
# define HAVE_RENAMEAT2 1
#endif

View File

@ -0,0 +1,9 @@
// HAVE_STATX : LIBC_VERSION
#undef HAVE_STATX
/* Since Linux 4.11/glibc 2.28.
*/
#if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 28)
# define HAVE_STATX 1
#endif

View File

@ -0,0 +1,164 @@
// LIBC_VERSION!
/* Include headers required to make various libc version number macros
* available.
*
* Note that besides the platform-specific macros listed below, this
* check also defines the following helper macros:
*
* BUILD2_AUTOCONF_GLIBC_PREREQ(maj, min)
* BUILD2_AUTOCONF_FREEBSD_PREREQ(maj, min)
* BUILD2_AUTOCONF_OPENBSD_PREREQ(yyyymm)
* BUILD2_AUTOCONF_NETBSD_PREREQ(maj, min)
* BUILD2_AUTOCONF_MACOS_PREREQ(maj, min)
*
* Note that all of the above macros are always defined and evaluate to false
* on platforms to which they do not apply. Which means that instead of:
*
* #if defined(__GLIBC__) && BUILD2_AUTOCONF_GLIBC_PREREQ(2, 3)
*
* You can just write:
*
* #if BUILD2_AUTOCONF_GLIBC_PREREQ(2, 3)
*
* Note also that for checking just for the specific platform we still use one
* of the system macros below. For example:
*
* #if defined(__GLIBC__)
* #if defined(__FreeBSD__)
* #if defined(__OpenBSD__)
* #if defined(__NetBSD__)
* #if defined(__APPLE__) && defined(__MACH__)
*
* Note that just __APPLE__ covers all the Apple platforms (MacOS, iOS, etc).
*
* Macros for detecting platforms and their versions:
*
* __GLIBC__: The glibc major version number.
*
* __GLIBC_MINOR__: The glibc minor version number.
*
* __GLIBC_PREREQ(major,minor): Return 1 if a given version number is greater
* than or equal to the current glibc version
* (__GLIBC__.__GLIBC_MINOR__), or 0 otherwise.
*
* __FreeBSD__: Defined if on FreeBSD. The value is the FreeBSD major version
* number but it's typically used only for OS detection. This is
* a predefined macro so no header needs to be included.
*
* __FreeBSD_version: The FreeBSD version in the following format: MMmmXXX
* where `MM` is the major and `mm` the minor version
* numbers. The `XXX` portion can be disregarded for the
* purposes of feature checking (because it's too
* fine-grained).
*
* __OpenBSD__: Defined if on OpenBSD. This is a predefined macro so no header
* needs to be included.
*
* OpenBSD: The OpenBSD version in the following format: YYYYMM (year and
* month of release). There are always two releases per year: one
* with an odd-numbered minor version earlier in the year and one
* with an even-numbered minor version later in the year. OpenBSD 7.0
* was released in October 2021 so its OpenBSD macro value is 202110.
*
*
* __NetBSD__: Defined if on NetBSD. This is a predefined macro so no header
* needs to be included.
*
* __NetBSD_Version__: The NetBSD version in the following format: MMmmrrpp00
* where `MM` is the major and `mm` the minor version
* numbers, `rr` is always 0 after NetBSD version 2.0I,
* and `pp` is the patch level. The `rrpp00` portion can
* be disregarded for the purposes of feature checking
* (because it's too fine-grained).
*
* __MAC_OS_X_VERSION_MIN_REQUIRED: The minimum supported Mac OS version. Up
* to Mac OS X 10.9, formatted as `MMm0`
* where `m` was the (always single-digit)
* minor version. Since Mac OS X 10.10 it is
* formatted as `MMmmpp` where `mm` is the
* (now potentially double-digit) minor
* version and `pp` is the patch version.
*/
#if defined(__linux__)
# include <features.h> /* __GLIBC__, __GLIBC_MINOR__, __GLIBC_PREREQ() */
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
# include <sys/param.h> /* __FreeBSD_version, OpenBSD, __NetBSD_Version__ */
#elif defined(__APPLE__)
# include <Availability.h> /* __MAC_OS_X_VERSION_MIN_REQUIRED */
#endif
/* BUILD2_AUTOCONF_GLIBC_PREREQ(maj, min)
*
* Return 1 if the given version number is >= the glibc version, or 0
* otherwise.
*
* __GLIBC_PREREQ() was only added in glibc 2.2 (released in 2000) so define
* BUILD2_AUTOCONF_GLIBC_PREREQ() using its latest glibc implementation if it
* is not defined.
*/
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
# if defined(__GLIBC_PREREQ)
# define BUILD2_AUTOCONF_GLIBC_PREREQ(maj, min) __GLIBC_PREREQ(maj, min)
# else
# define BUILD2_AUTOCONF_GLIBC_PREREQ(maj, min) \
((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
# endif
#else
# define BUILD2_AUTOCONF_GLIBC_PREREQ(maj, min) 0
#endif
/* BUILD2_AUTOCONF_FREEBSD_PREREQ(maj, min)
*
* Return 1 if the given version number is >= the FreeBSD version, or 0
* otherwise.
*/
#if defined(__FreeBSD__) && defined(__FreeBSD_version)
# define BUILD2_AUTOCONF_FREEBSD_PREREQ(maj, min) \
(__FreeBSD_version >= (maj)*100000 + (min)*1000)
#else
# define BUILD2_AUTOCONF_FREEBSD_PREREQ(maj, min) 0
#endif
/* BUILD2_AUTOCONF_OPENBSD_PREREQ(yyyymm)
*
* Return 1 if the given release date is >= the release date of the OpenBSD
* version, or 0 otherwise.
*/
#if defined(__OpenBSD__) && defined(OpenBSD)
# define BUILD2_AUTOCONF_OPENBSD_PREREQ(yyyymm) (OpenBSD >= (yyyymm))
#else
# define BUILD2_AUTOCONF_OPENBSD_PREREQ(yyyymm) 0
#endif
/* BUILD2_AUTOCONF_NETBSD_PREREQ(maj, min)
*
* Return 1 if the given version number is >= the NetBSD version, or 0
* otherwise.
*/
#if defined(__NetBSD__) && defined(__NetBSD_Version__)
# define BUILD2_AUTOCONF_NETBSD_PREREQ(maj, min) \
(__NetBSD_Version__ >= (maj)*100000000 + (min)*1000000)
#else
# define BUILD2_AUTOCONF_NETBSD_PREREQ(maj, min) 0
#endif
/* BUILD2_AUTOCONF_MACOS_PREREQ(maj, min)
*
* Return 1 if the given version number is >= the Mac OS version, or 0
* otherwise.
*/
#if defined(__APPLE__) && defined(__MACH__)
# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
# error __MAC_OS_X_VERSION_MIN_REQUIRED not defined
# endif
# if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1090
# define BUILD2_AUTOCONF_MACOS_PREREQ(maj, min) \
(__MAC_OS_X_VERSION_MIN_REQUIRED >= (maj)*100 + (min)*10)
# else
# define BUILD2_AUTOCONF_MACOS_PREREQ(maj, min) \
(__MAC_OS_X_VERSION_MIN_REQUIRED >= (maj)*10000 + (min)*100)
# endif
#else
# define BUILD2_AUTOCONF_MACOS_PREREQ(maj, min) 0
#endif