From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [PATCH 03/10] libxl: move a lot more includes into libxl_internal.h
Date: Fri, 6 Jan 2012 20:35:00 +0000 [thread overview]
Message-ID: <1325882107-5794-4-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1325882107-5794-1-git-send-email-ian.jackson@eu.citrix.com>
Move a lot of
#include <stdfoo.h>
from individual files into libxl_internal.h. This helps avoid
portability mistakes where necessary system headers are omitted from
individual files, and is also of course a convenience when developing.
Also add
#include "libxl_osdeps.h" /* must come before any other headers */
to the top of most libxl*.c files, so that anyone who adds any headers
before libxl_internal.h will put the in the right place.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
tools/libxl/libxl.c | 15 ---------------
tools/libxl/libxl_blktap2.c | 4 +---
tools/libxl/libxl_bootloader.c | 7 +------
tools/libxl/libxl_cpuid.c | 2 ++
tools/libxl/libxl_create.c | 13 +++----------
tools/libxl/libxl_device.c | 10 +---------
tools/libxl/libxl_dm.c | 10 +---------
tools/libxl/libxl_dom.c | 11 +----------
tools/libxl/libxl_exec.c | 13 +------------
tools/libxl/libxl_flask.c | 8 +-------
tools/libxl/libxl_internal.c | 10 +---------
tools/libxl/libxl_internal.h | 22 +++++++++++++++++++---
tools/libxl/libxl_json.c | 4 +---
tools/libxl/libxl_linux.c | 2 +-
tools/libxl/libxl_netbsd.c | 2 +-
tools/libxl/libxl_noblktap2.c | 2 ++
tools/libxl/libxl_nocpuid.c | 2 ++
tools/libxl/libxl_paths.c | 1 +
tools/libxl/libxl_pci.c | 16 +---------------
tools/libxl/libxl_qmp.c | 4 +---
tools/libxl/libxl_utils.c | 13 +------------
tools/libxl/libxl_uuid.c | 2 +-
tools/libxl/libxl_xshelp.c | 8 +-------
tools/libxl/libxlu_cfg.c | 2 ++
tools/libxl/libxlu_cfg_i.h | 1 +
tools/libxl/libxlu_disk.c | 1 +
tools/libxl/libxlu_disk_i.h | 2 ++
27 files changed, 51 insertions(+), 136 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 2b8f8f4..2d3e8cd 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -16,21 +16,6 @@
#include "libxl_osdeps.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/select.h>
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <signal.h>
-#include <unistd.h> /* for write, unlink and close */
-#include <stdint.h>
-#include <inttypes.h>
-#include <assert.h>
-
#include "libxl_internal.h"
#define PAGE_TO_MEMKB(pages) ((pages) * 4)
diff --git a/tools/libxl/libxl_blktap2.c b/tools/libxl/libxl_blktap2.c
index acf4110..2c40182 100644
--- a/tools/libxl/libxl_blktap2.c
+++ b/tools/libxl/libxl_blktap2.c
@@ -12,13 +12,11 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
#include "tap-ctl.h"
-#include <string.h>
-
int libxl__blktap_enabled(libxl__gc *gc)
{
const char *msg;
diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c
index ce83b8e..2da1d90 100644
--- a/tools/libxl/libxl_bootloader.c
+++ b/tools/libxl/libxl_bootloader.c
@@ -12,15 +12,10 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
+#include "libxl_osdeps.h" /* must come before any other headers */
-#include <unistd.h>
-#include <fcntl.h>
#include <termios.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
#include "libxl_internal.h"
#define XENCONSOLED_BUF_SIZE 16
diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index 56a00cd..dcdb9d02 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -10,6 +10,8 @@
* GNU Lesser General Public License for more details.
*/
+#include "libxl_osdeps.h" /* must come before any other headers */
+
#include "libxl_internal.h"
void libxl_cpuid_dispose(libxl_cpuid_policy_list *p_cpuid_list)
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index ebf2ed7..9a6a94a 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -15,20 +15,13 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <xenctrl.h>
-#include <xc_dom.h>
-#include <xenguest.h>
-#include <assert.h>
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
+#include <xc_dom.h>
+#include <xenguest.h>
+
void libxl_domain_config_dispose(libxl_domain_config *d_config)
{
int i;
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 9b1fc57..5d05e90 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -14,15 +14,7 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
-
-#include <string.h>
-#include <stdio.h>
-#include <sys/time.h> /* for struct timeval */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 97d91b4..f0bf014 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -15,15 +15,7 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <assert.h>
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index c898d89..b2259f8 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -13,22 +13,13 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
+#include "libxl_osdeps.h" /* must come before any other headers */
-#include <stdio.h>
-#include <assert.h>
#include <glob.h>
-#include <inttypes.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/time.h> /* for struct timeval */
-#include <sys/stat.h> /* for stat */
-#include <unistd.h> /* for sleep(2) */
#include <xenctrl.h>
#include <xc_dom.h>
#include <xenguest.h>
-#include <fcntl.h>
#include <xen/hvm/hvm_info_table.h>
diff --git a/tools/libxl/libxl_exec.c b/tools/libxl/libxl_exec.c
index 52d40d1..b10e79f 100644
--- a/tools/libxl/libxl_exec.c
+++ b/tools/libxl/libxl_exec.c
@@ -15,18 +15,7 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h> /* for SIGKILL */
-#include <fcntl.h>
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
diff --git a/tools/libxl/libxl_flask.c b/tools/libxl/libxl_flask.c
index 6b548dd..23f2476 100644
--- a/tools/libxl/libxl_flask.c
+++ b/tools/libxl/libxl_flask.c
@@ -7,13 +7,7 @@
* as published by the Free Software Foundation.
*/
-#include "libxl_osdeps.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <xenctrl.h>
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index cfa8c61..49b0dab 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -13,15 +13,7 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
-
-#include <stdio.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <unistd.h>
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 1bca869..d681d73 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -17,17 +17,33 @@
#ifndef LIBXL_INTERNAL_H
#define LIBXL_INTERNAL_H
-#include "libxl_osdeps.h"
+#include "libxl_osdeps.h" /* must come before any other headers */
-#include <stdint.h>
+#include <assert.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <signal.h>
#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <pthread.h>
+#include <unistd.h>
+
+#include <sys/mman.h>
+#include <sys/select.h>
+#include <sys/stat.h>
#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <xs.h>
#include <xenctrl.h>
+
#include "xentoollog.h"
#include <xen/io/xenbus.h>
diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c
index c0f869e..6ff2910 100644
--- a/tools/libxl/libxl_json.c
+++ b/tools/libxl/libxl_json.c
@@ -12,10 +12,8 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
+#include "libxl_osdeps.h" /* must come before any other headers */
-#include <assert.h>
-#include <string.h>
#include <math.h>
#include <yajl/yajl_parse.h>
diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c
index 786c6b5..925248b 100644
--- a/tools/libxl/libxl_linux.c
+++ b/tools/libxl/libxl_linux.c
@@ -13,7 +13,7 @@
* GNU Lesser General Public License for more details.
*/
-#include <sys/stat.h>
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c
index 1e8d622..9e0ed6d 100644
--- a/tools/libxl/libxl_netbsd.c
+++ b/tools/libxl/libxl_netbsd.c
@@ -13,7 +13,7 @@
* GNU Lesser General Public License for more details.
*/
-#include <sys/stat.h>
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
diff --git a/tools/libxl/libxl_noblktap2.c b/tools/libxl/libxl_noblktap2.c
index 3307551..246b0de 100644
--- a/tools/libxl/libxl_noblktap2.c
+++ b/tools/libxl/libxl_noblktap2.c
@@ -12,6 +12,8 @@
* GNU Lesser General Public License for more details.
*/
+#include "libxl_osdeps.h" /* must come before any other headers */
+
#include "libxl_internal.h"
int libxl__blktap_enabled(libxl__gc *gc)
diff --git a/tools/libxl/libxl_nocpuid.c b/tools/libxl/libxl_nocpuid.c
index 2e9490c..9e52f8d 100644
--- a/tools/libxl/libxl_nocpuid.c
+++ b/tools/libxl/libxl_nocpuid.c
@@ -10,6 +10,8 @@
* GNU Lesser General Public License for more details.
*/
+#include "libxl_osdeps.h" /* must come before any other headers */
+
#include "libxl_internal.h"
void libxl_cpuid_destroy(libxl_cpuid_policy_list *p_cpuid_list)
diff --git a/tools/libxl/libxl_paths.c b/tools/libxl/libxl_paths.c
index e7bd1a2..a95d29f 100644
--- a/tools/libxl/libxl_paths.c
+++ b/tools/libxl/libxl_paths.c
@@ -12,6 +12,7 @@
* GNU Lesser General Public License for more details.
*/
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
#include "_libxl_paths.h"
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 8b2a1c5..c3828f6 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -14,21 +14,7 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/select.h>
-#include <sys/mman.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <unistd.h> /* for write, unlink and close */
-#include <inttypes.h>
-#include <dirent.h>
-#include <assert.h>
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index 3dfa43a..61d9769 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -18,12 +18,10 @@
* Specification, see in the QEMU repository.
*/
-#include "libxl_osdeps.h"
+#include "libxl_osdeps.h" /* must come before any other headers */
-#include <unistd.h>
#include <sys/un.h>
#include <sys/queue.h>
-#include <fcntl.h>
#include <yajl/yajl_gen.h>
diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
index d36c737..dbe8891 100644
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -13,20 +13,9 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <xs.h>
-#include <xenctrl.h>
+#include "libxl_osdeps.h" /* must come before any other headers */
+
#include <ctype.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <assert.h>
#include "libxl_internal.h"
diff --git a/tools/libxl/libxl_uuid.c b/tools/libxl/libxl_uuid.c
index 80ab789..7c18d71 100644
--- a/tools/libxl/libxl_uuid.c
+++ b/tools/libxl/libxl_uuid.c
@@ -12,7 +12,7 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
+#include "libxl_osdeps.h" /* must come before any other headers */
#include <libxl_uuid.h>
diff --git a/tools/libxl/libxl_xshelp.c b/tools/libxl/libxl_xshelp.c
index ea835e2..6958d21 100644
--- a/tools/libxl/libxl_xshelp.c
+++ b/tools/libxl/libxl_xshelp.c
@@ -13,13 +13,7 @@
* GNU Lesser General Public License for more details.
*/
-#include "libxl_osdeps.h"
-
-#include <string.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <inttypes.h>
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxl_internal.h"
diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c
index 0d1c5d3..e3659c7 100644
--- a/tools/libxl/libxlu_cfg.c
+++ b/tools/libxl/libxlu_cfg.c
@@ -16,6 +16,8 @@
*/
+#include "libxl_osdeps.h" /* must come before any other headers */
+
#include <limits.h>
#include "libxlu_internal.h"
diff --git a/tools/libxl/libxlu_cfg_i.h b/tools/libxl/libxlu_cfg_i.h
index ea6a326..54d033c 100644
--- a/tools/libxl/libxlu_cfg_i.h
+++ b/tools/libxl/libxlu_cfg_i.h
@@ -18,6 +18,7 @@
#ifndef LIBXLU_CFG_I_H
#define LIBXLU_CFG_I_H
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxlu_internal.h"
#include "libxlu_cfg_y.h"
diff --git a/tools/libxl/libxlu_disk.c b/tools/libxl/libxlu_disk.c
index 88b79ac..6cd86e9 100644
--- a/tools/libxl/libxlu_disk.c
+++ b/tools/libxl/libxlu_disk.c
@@ -1,3 +1,4 @@
+#include "libxl_osdeps.h" /* must come before any other headers */
#include "libxlu_internal.h"
#include "libxlu_disk_l.h"
#include "libxlu_disk_i.h"
diff --git a/tools/libxl/libxlu_disk_i.h b/tools/libxl/libxlu_disk_i.h
index 4fccd4a..37246f2 100644
--- a/tools/libxl/libxlu_disk_i.h
+++ b/tools/libxl/libxlu_disk_i.h
@@ -1,6 +1,8 @@
#ifndef LIBXLU_DISK_I_H
#define LIBXLU_DISK_I_H
+#include "libxl_osdeps.h" /* must come before any other headers */
+
#include "libxlu_internal.h"
--
1.7.2.5
next prev parent reply other threads:[~2012-01-06 20:35 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-06 20:34 [PATCH v6 00/10] libxl: event API Ian Jackson
2012-01-06 20:34 ` [PATCH 01/10] libxl: make LIBXL_INIT_GC a statement, not an initialiser Ian Jackson
2012-01-06 20:34 ` [PATCH 02/10] xenstore: New function xs_path_is_subpath Ian Jackson
2012-01-13 10:39 ` Ian Campbell
2012-01-06 20:35 ` Ian Jackson [this message]
2012-01-13 10:41 ` [PATCH 03/10] libxl: move a lot more includes into libxl_internal.h Ian Campbell
2012-01-13 13:37 ` Ian Jackson
2012-01-13 13:39 ` Ian Campbell
2012-01-13 16:23 ` Ian Jackson
2012-01-06 20:35 ` [PATCH 04/10] libxl: Provide more formal libxl__ctx_lock and _unlock Ian Jackson
2012-01-13 10:42 ` Ian Campbell
2012-01-06 20:35 ` [PATCH 05/10] libxl: Fix leaks on context init failure Ian Jackson
2012-01-13 10:43 ` Ian Campbell
2012-01-13 15:58 ` Ian Jackson
2012-01-06 20:35 ` [PATCH 06/10] DROP: libxl: rename libxl__free_all Ian Jackson
2012-01-06 20:35 ` [PATCH 07/10] libxl: New API for providing OS events to libxl Ian Jackson
2012-01-11 17:32 ` Stefano Stabellini
2012-01-12 11:28 ` Ian Campbell
2012-01-12 13:49 ` Stefano Stabellini
2012-01-12 15:49 ` Ian Jackson
2012-01-12 15:56 ` Ian Jackson
2012-01-13 15:07 ` Ian Campbell
2012-01-13 15:47 ` Ian Jackson
2012-01-13 15:56 ` Ian Campbell
2012-01-13 16:34 ` Ian Jackson
2012-01-06 20:35 ` [PATCH 08/10] libxl: New event generation API Ian Jackson
2012-01-13 15:22 ` Ian Campbell
2012-01-13 15:49 ` Ian Jackson
2012-01-06 20:35 ` [PATCH 09/10] libxl: introduce libxl_fd_set_nonblock, rationalise _cloexec Ian Jackson
2012-01-13 10:45 ` Ian Campbell
2012-01-13 15:54 ` Ian Jackson
2012-01-06 20:35 ` [PATCH 10/10] libxl: Permit multithreaded event waiting Ian Jackson
2012-01-09 17:34 ` [PATCH RFC v6.1 11-14/10] libxl: asynchronous operations Ian Jackson
2012-01-09 17:34 ` [PATCH 11/10] libxl: Asynchronous/long-running operation infrastructure Ian Jackson
2012-01-09 17:34 ` [PATCH 12/10] libxl: New convenience macro CONTAINING_STRUCT Ian Jackson
2012-01-13 10:49 ` Ian Campbell
2012-01-13 13:53 ` Ian Jackson
2012-01-13 15:06 ` Ian Campbell
2012-01-09 17:34 ` [PATCH 13/10] libxl: Introduce libxl__ev_devstate Ian Jackson
2012-01-09 17:34 ` [PATCH 14/10] libxl: Convert to asynchronous: device removal Ian Jackson
2012-01-13 14:50 ` [PATCH v6 00/10] libxl: event API Ian Campbell
2012-01-13 15:03 ` Ian Jackson
2012-01-13 17:43 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1325882107-5794-4-git-send-email-ian.jackson@eu.citrix.com \
--to=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).