summaryrefslogtreecommitdiffstats
path: root/src/zix_config.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-06-28 16:14:45 -0400
committerDavid Robillard <d@drobilla.net>2022-06-28 18:52:19 -0400
commitacb8ea62ac287efcfb50f20cd419b70f6c5a15a9 (patch)
tree657337f0bf6566b40e3a07002697347b5e35a0d9 /src/zix_config.h
parent58d7fe43076a9825cf1f99d94ce224445ab9e405 (diff)
downloadzix-acb8ea62ac287efcfb50f20cd419b70f6c5a15a9.tar.gz
zix-acb8ea62ac287efcfb50f20cd419b70f6c5a15a9.tar.bz2
zix-acb8ea62ac287efcfb50f20cd419b70f6c5a15a9.zip
Clean up build configuration
Diffstat (limited to 'src/zix_config.h')
-rw-r--r--src/zix_config.h46
1 files changed, 37 insertions, 9 deletions
diff --git a/src/zix_config.h b/src/zix_config.h
index 832b50f..7be46e4 100644
--- a/src/zix_config.h
+++ b/src/zix_config.h
@@ -1,15 +1,26 @@
-// Copyright 2021 David Robillard <d@drobilla.net>
+// Copyright 2021-2022 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
/*
Configuration header that defines reasonable defaults at compile time.
- This allows compile-time configuration from the command line (typically via
- the build system) while still allowing the source to be built without any
- configuration. The build system can define ZIX_NO_DEFAULT_CONFIG to disable
- defaults, in which case it must define things like HAVE_FEATURE to enable
- features. The design here ensures that compiler warnings or
- include-what-you-use will catch any mistakes.
+ This allows compile-time configuration from the command line, while still
+ allowing the source to be built "as-is" without any configuration. The idea
+ is to support an advanced build system with configuration checks, while still
+ allowing the code to be simply "thrown at a compiler" with features
+ determined from the compiler or system headers. Everything can be
+ overridden, so it should never be necessary to edit this file to build
+ successfully.
+
+ To ensure that all configure checks are performed, the build system can
+ define ZIX_NO_DEFAULT_CONFIG to disable defaults. In this case, it must
+ define all HAVE_FEATURE symbols below to 1 or 0 to enable or disable
+ features. Any missing definitions will generate a compiler warning.
+
+ To ensure that this header is always included properly, all code that uses
+ configuration variables includes this header and checks their value with #if
+ (not #ifdef). Variables like USE_FEATURE are internal and should never be
+ defined on the command line.
*/
#ifndef ZIX_CONFIG_H
@@ -28,10 +39,21 @@
# endif
# endif
+// POSIX.1-2001: mlock()
+# ifndef HAVE_MLOCK
+# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
+# define HAVE_MLOCK 1
+# else
+# define HAVE_MLOCK 0
+# endif
+# endif
+
// POSIX.1-2001: posix_memalign()
# ifndef HAVE_POSIX_MEMALIGN
# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
-# define HAVE_POSIX_MEMALIGN
+# define HAVE_POSIX_MEMALIGN 1
+# else
+# define HAVE_POSIX_MEMALIGN 0
# endif
# endif
@@ -45,7 +67,13 @@
if the build system defines them all.
*/
-#ifdef HAVE_POSIX_MEMALIGN
+#if HAVE_MLOCK
+# define USE_MLOCK 1
+#else
+# define USE_MLOCK 0
+#endif
+
+#if HAVE_POSIX_MEMALIGN
# define USE_POSIX_MEMALIGN 1
#else
# define USE_POSIX_MEMALIGN 0