summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2018-12-03 18:14:26 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2018-12-14 15:09:13 +0100
commit0b19387dae782b33bb341e58ab3c7ff804ca4f14 (patch)
treea3914adc8ac8141e4380fbe6b20efc7307067030
parent3c377643339be97940554323909d51b12c933f9e (diff)
downloadlvm2-0b19387dae782b33bb341e58ab3c7ff804ca4f14.tar.gz
headers: use configure.h as 1st. header
Ensure configure.h is always 1st. included header. Maybe we could eventually introduce gcc -include option, but for now this better uses dependency tracking. Also move _REENTRANT and _GNU_SOURCE into configure.h so it doesn't need to be present in various source files. This ensures consistent compilation of headers like stdio.h since it may produce different declaration.
-rw-r--r--base/data-struct/radix-tree-adaptive.c1
-rw-r--r--base/data-struct/radix-tree.h2
-rw-r--r--base/memory/zalloc.h2
-rwxr-xr-xconfigure9
-rw-r--r--configure.ac5
-rw-r--r--daemons/cmirrord/logging.h2
-rw-r--r--daemons/lvmlockd/lvmlockd-core.c1
-rw-r--r--daemons/lvmpolld/lvmpolld-common.h2
-rw-r--r--device_mapper/all.h2
-rw-r--r--device_mapper/ioctl/libdm-iface.c1
-rw-r--r--device_mapper/misc/dmlib.h5
-rw-r--r--include/configure.h.in6
-rw-r--r--lib/device/bcache.c2
-rw-r--r--lib/device/bcache.h1
-rw-r--r--lib/label/label.c2
-rw-r--r--lib/misc/lib.h9
-rw-r--r--libdaemon/client/config-util.c4
-rw-r--r--libdaemon/client/daemon-client.c6
-rw-r--r--libdaemon/client/daemon-io.c4
-rw-r--r--libdaemon/server/daemon-log.c2
-rw-r--r--libdaemon/server/daemon-server.c4
-rw-r--r--libdm/dm-tools/dmsetup.c2
-rw-r--r--libdm/misc/dmlib.h3
-rw-r--r--test/lib/harness.c3
-rw-r--r--test/unit/bcache_utils_t.c2
-rw-r--r--test/unit/io_engine_t.c2
-rw-r--r--tools/tool.h6
27 files changed, 37 insertions, 53 deletions
diff --git a/base/data-struct/radix-tree-adaptive.c b/base/data-struct/radix-tree-adaptive.c
index 5e065b600..b9ba4179f 100644
--- a/base/data-struct/radix-tree-adaptive.c
+++ b/base/data-struct/radix-tree-adaptive.c
@@ -18,6 +18,7 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
//----------------------------------------------------------------
diff --git a/base/data-struct/radix-tree.h b/base/data-struct/radix-tree.h
index 5d4d04c63..685b8280f 100644
--- a/base/data-struct/radix-tree.h
+++ b/base/data-struct/radix-tree.h
@@ -13,6 +13,8 @@
#ifndef BASE_DATA_STRUCT_RADIX_TREE_H
#define BASE_DATA_STRUCT_RADIX_TREE_H
+#include "configure.h"
+
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
diff --git a/base/memory/zalloc.h b/base/memory/zalloc.h
index 4f6df542f..069c59999 100644
--- a/base/memory/zalloc.h
+++ b/base/memory/zalloc.h
@@ -13,8 +13,8 @@
#ifndef BASE_MEMORY_ZALLOC_H
#define BASE_MEMORY_ZALLOC_H
+#include "configure.h"
#include <stdlib.h>
-#include <string.h>
//----------------------------------------------------------------
diff --git a/configure b/configure
index 66acdb2ee..53f5023d9 100755
--- a/configure
+++ b/configure
@@ -6623,6 +6623,15 @@ fi
+
+
+$as_echo "#define _GNU_SOURCE 1" >>confdefs.h
+
+
+$as_echo "#define _REENTRANT 1" >>confdefs.h
+
+
+
################################################################################
for ac_func in ftruncate gethostname getpagesize gettimeofday localtime_r \
memchr memset mkdir mkfifo munmap nl_langinfo realpath rmdir setenv \
diff --git a/configure.ac b/configure.ac
index 2b2921078..2ece3f963 100644
--- a/configure.ac
+++ b/configure.ac
@@ -144,6 +144,11 @@ AC_TYPE_UINT64_T
AX_GCC_BUILTIN([__builtin_clz])
AX_GCC_BUILTIN([__builtin_clzll])
+
+AC_DEFINE([_GNU_SOURCE], 1, [Define to get access to GNU/Linux extension])
+AC_DEFINE([_REENTRANT], 1, [Define to use re-entrant thread safe versions])
+
+
################################################################################
dnl -- Check for functions
AC_CHECK_FUNCS([ftruncate gethostname getpagesize gettimeofday localtime_r \
diff --git a/daemons/cmirrord/logging.h b/daemons/cmirrord/logging.h
index 13e6b3982..5f640cf67 100644
--- a/daemons/cmirrord/logging.h
+++ b/daemons/cmirrord/logging.h
@@ -13,8 +13,6 @@
#ifndef _LVM_CLOG_LOGGING_H
#define _LVM_CLOG_LOGGING_H
-#define _GNU_SOURCE
-
#include "configure.h"
#include <stdio.h>
#include <stdint.h>
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 5bdbefe81..dd5227034 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -10,7 +10,6 @@
#define _XOPEN_SOURCE 500 /* pthread */
#define _ISOC99_SOURCE
-#define _REENTRANT
#include "tools/tool.h"
diff --git a/daemons/lvmpolld/lvmpolld-common.h b/daemons/lvmpolld/lvmpolld-common.h
index 4ada5810b..ccd9b1319 100644
--- a/daemons/lvmpolld/lvmpolld-common.h
+++ b/daemons/lvmpolld/lvmpolld-common.h
@@ -18,8 +18,6 @@
#ifndef _LVM_LVMPOLLD_COMMON_H
#define _LVM_LVMPOLLD_COMMON_H
-#define _REENTRANT
-
#include "tools/tool.h"
#include "lvmpolld-cmd-utils.h"
diff --git a/device_mapper/all.h b/device_mapper/all.h
index 0c1dc2938..8c17c09a6 100644
--- a/device_mapper/all.h
+++ b/device_mapper/all.h
@@ -17,6 +17,8 @@
#ifndef LIB_DEVICE_MAPPER_H
#define LIB_DEVICE_MAPPER_H
+#include "configure.h"
+
#include "base/data-struct/list.h"
#include "base/data-struct/hash.h"
#include "vdo/target.h"
diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c
index f86d3b3de..d33342661 100644
--- a/device_mapper/ioctl/libdm-iface.c
+++ b/device_mapper/ioctl/libdm-iface.c
@@ -19,7 +19,6 @@
#include "device_mapper/ioctl/libdm-targets.h"
#include "device_mapper/libdm-common.h"
-#include <stdio.h> /* getline() */
#include <stddef.h>
#include <fcntl.h>
#include <dirent.h>
diff --git a/device_mapper/misc/dmlib.h b/device_mapper/misc/dmlib.h
index fe64bd75e..51fe5a332 100644
--- a/device_mapper/misc/dmlib.h
+++ b/device_mapper/misc/dmlib.h
@@ -21,11 +21,6 @@
// FIXME: get rid of this whole file
-#include "configure.h"
-
-#define _REENTRANT
-#define _GNU_SOURCE
-
#include "device_mapper/all.h"
#include "lib/misc/util.h"
#include "dm-logging.h"
diff --git a/include/configure.h.in b/include/configure.h.in
index c66b37bd5..dde55fe5f 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -669,6 +669,12 @@
/* Define to 1 to include built-in support for writecache. */
#undef WRITECACHE_INTERNAL
+/* Define to get access to GNU/Linux extension */
+#undef _GNU_SOURCE
+
+/* Define to use re-entrant thread safe versions */
+#undef _REENTRANT
+
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 18ffcf058..d646d2b98 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -12,8 +12,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _GNU_SOURCE
-
#include "lib/device/bcache.h"
#include "base/data-struct/radix-tree.h"
diff --git a/lib/device/bcache.h b/lib/device/bcache.h
index 2edc54adb..8c16caa19 100644
--- a/lib/device/bcache.h
+++ b/lib/device/bcache.h
@@ -15,7 +15,6 @@
#ifndef BCACHE_H
#define BCACHE_H
-#include "configure.h"
#include "device_mapper/all.h"
#include <linux/fs.h>
diff --git a/lib/label/label.c b/lib/label/label.c
index 0517312d5..6fe1e41ec 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -13,8 +13,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _GNU_SOURCE
-
#include "base/memory/zalloc.h"
#include "lib/misc/lib.h"
#include "lib/label/label.h"
diff --git a/lib/misc/lib.h b/lib/misc/lib.h
index f7baf9dba..c14f437a0 100644
--- a/lib/misc/lib.h
+++ b/lib/misc/lib.h
@@ -19,11 +19,6 @@
#ifndef _LVM_LIB_H
#define _LVM_LIB_H
-#include "configure.h"
-
-#define _REENTRANT
-#define _GNU_SOURCE
-
/*
* Symbol export control macros
*
@@ -78,10 +73,10 @@
#endif
-#include "lib/misc/intl.h"
#include "device_mapper/all.h"
-#include "lib/misc/util.h"
#include "base/memory/zalloc.h"
+#include "lib/misc/intl.h"
+#include "lib/misc/util.h"
#ifdef DM
# include "libdm/misc/dm-logging.h"
diff --git a/libdaemon/client/config-util.c b/libdaemon/client/config-util.c
index bdbdd3ae4..3f27f3149 100644
--- a/libdaemon/client/config-util.c
+++ b/libdaemon/client/config-util.c
@@ -12,11 +12,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _REENTRANT
-
#include "tools/tool.h"
-#include "libdaemon/client/daemon-io.h"
+#include "daemon-io.h"
#include "device_mapper/misc/dm-logging.h"
#include <math.h> /* fabs() */
diff --git a/libdaemon/client/daemon-client.c b/libdaemon/client/daemon-client.c
index 53f449556..804968632 100644
--- a/libdaemon/client/daemon-client.c
+++ b/libdaemon/client/daemon-client.c
@@ -12,12 +12,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _REENTRANT
-
#include "tools/tool.h"
-#include "libdaemon/client/daemon-io.h"
-#include "libdaemon/client/daemon-client.h"
+#include "daemon-io.h"
+#include "daemon-client.h"
#include "device_mapper/misc/dm-logging.h"
#include <sys/un.h>
diff --git a/libdaemon/client/daemon-io.c b/libdaemon/client/daemon-io.c
index bd24cdb01..1f9d84053 100644
--- a/libdaemon/client/daemon-io.c
+++ b/libdaemon/client/daemon-io.c
@@ -12,11 +12,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _REENTRANT
-
#include "tools/tool.h"
-#include "libdaemon/client/daemon-io.h"
+#include "daemon-io.h"
#include <errno.h>
diff --git a/libdaemon/server/daemon-log.c b/libdaemon/server/daemon-log.c
index 864f504f6..7198c293c 100644
--- a/libdaemon/server/daemon-log.c
+++ b/libdaemon/server/daemon-log.c
@@ -10,8 +10,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _REENTRANT
-
#include "tools/tool.h"
#include "daemon-server.h"
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index 78c8221e2..a2216ac2e 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -10,13 +10,11 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _REENTRANT
-
#include "tools/tool.h"
-#include "libdaemon/client/daemon-io.h"
#include "daemon-server.h"
#include "daemon-log.h"
+#include "libdaemon/client/daemon-io.h"
#include <dlfcn.h>
#include <errno.h>
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index 4b14a237b..efeb978ff 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -17,8 +17,6 @@
*/
// For canonicalize_file_name()
-#define _GNU_SOURCE
-
#include "configure.h"
#include "libdm/misc/dm-logging.h"
#include "libdm/dm-tools/util.h"
diff --git a/libdm/misc/dmlib.h b/libdm/misc/dmlib.h
index 4c6bcfc2d..60787feb9 100644
--- a/libdm/misc/dmlib.h
+++ b/libdm/misc/dmlib.h
@@ -21,9 +21,6 @@
#include "configure.h"
-#define _REENTRANT
-#define _GNU_SOURCE
-
/*
* Symbol export control macros
*
diff --git a/test/lib/harness.c b/test/lib/harness.c
index ace3f5a18..d1274ed05 100644
--- a/test/lib/harness.c
+++ b/test/lib/harness.c
@@ -12,7 +12,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _GNU_SOURCE
+#include "configure.h"
+
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
diff --git a/test/unit/bcache_utils_t.c b/test/unit/bcache_utils_t.c
index 2e0832096..d022c5115 100644
--- a/test/unit/bcache_utils_t.c
+++ b/test/unit/bcache_utils_t.c
@@ -12,8 +12,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _GNU_SOURCE
-
#include "units.h"
#include "lib/device/bcache.h"
diff --git a/test/unit/io_engine_t.c b/test/unit/io_engine_t.c
index bac9c3862..44e93e025 100644
--- a/test/unit/io_engine_t.c
+++ b/test/unit/io_engine_t.c
@@ -12,8 +12,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _GNU_SOURCE
-
#include "units.h"
#include "lib/device/bcache.h"
diff --git a/tools/tool.h b/tools/tool.h
index fb6cab82f..6fd4da0ae 100644
--- a/tools/tool.h
+++ b/tools/tool.h
@@ -18,14 +18,12 @@
#ifndef _LVM_TOOL_H
#define _LVM_TOOL_H
-#define _GNU_SOURCE
-
#include "configure.h"
-#include <unistd.h>
-
#include "base/memory/zalloc.h"
#include "device_mapper/all.h"
#include "lib/misc/util.h"
+#include <unistd.h>
+
#endif /* _LVM_TOOL_H */