WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] libxenlight: correct broken osdeps.[ch] a

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxenlight: correct broken osdeps.[ch] and make #includes consistent
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 22 Nov 2009 23:35:35 -0800
Delivery-date: Sun, 22 Nov 2009 23:37:07 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1258959608 0
# Node ID 20063cea1606072ee5f69669daaf5a4e8db98ca2
# Parent  b72f273507030e5c01cd4a5d0d5064011fe30527
libxenlight: correct broken osdeps.[ch] and make #includes consistent

osdeps.[hc] previously mistakenly declared and defined [v]asprintf.
These functions are available in the libc on most platforms.  Also,
osdeps.h is used by xc.c but xc.c is not part of the library, so
osdeps.h is part of the public interface and should have a better
name.

So now, instead:

 * osdeps.h is libxl_osdeps.h.

 * _GNU_SOURCE is #defined in libxl_osdeps.h so that we get the system
   [v]asprintf (and various other functions)

 * libxl_osdeps.h is included first in every libxl*.c file (it needs
   to be before any system headers so that _GNU_SOURCE) takes effect.

 * osdeps.[hc] only provide their own reimplementation of [v]asprintf
   if NEED_OWN_ASPRINTF is defined.  Currently it is not ever defined
   but this is provided for any platform which needs it.

 * While I was editing the #includes in each .c file, I put them all
   into the same order: "libxl_osdeps.h", then system headers,
   then local headers.

 * xs.h is included in libxl.h.  This is needed for "bool"; it has to
   not be typedefed in libxl.h because otherwise we get a duplicate
   definition when including xs.h.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/osdeps.h         |   26 --------------------------
 tools/libxl/Makefile         |    3 +--
 tools/libxl/libxl.c          |    3 +++
 tools/libxl/libxl.h          |    5 ++---
 tools/libxl/libxl_device.c   |    7 +++++--
 tools/libxl/libxl_dom.c      |   16 ++++++++++------
 tools/libxl/libxl_exec.c     |    3 +++
 tools/libxl/libxl_internal.c |   10 +++++++---
 tools/libxl/libxl_osdeps.h   |   33 +++++++++++++++++++++++++++++++++
 tools/libxl/libxl_utils.c    |    6 ++++--
 tools/libxl/libxl_xshelp.c   |    7 +++++--
 tools/libxl/osdeps.c         |    4 ++++
 tools/libxl/xl.c             |    7 +++++--
 13 files changed, 82 insertions(+), 48 deletions(-)

diff -r b72f27350703 -r 20063cea1606 tools/libxl/Makefile
--- a/tools/libxl/Makefile      Mon Nov 23 06:59:06 2009 +0000
+++ b/tools/libxl/Makefile      Mon Nov 23 07:00:08 2009 +0000
@@ -23,8 +23,7 @@ LIBCONFIG_SOURCE = libconfig-1.3.2
 LIBCONFIG_SOURCE = libconfig-1.3.2
 LIBCONFIG_OUTPUT = $(LIBCONFIG_SOURCE)/.libs
 
-LIBXL_OBJS-y =
-LIBXL_OBJS-$(CONFIG_Linux) += osdeps.o
+LIBXL_OBJS-y = osdeps.o
 LIBXL_OBJS = flexarray.o libxl.o libxl_dom.o libxl_exec.o libxl_xshelp.o 
libxl_device.o libxl_internal.o xenguest.o libxl_utils.o $(LIBXL_OBJS-y)
 
 CLIENTS = xl
diff -r b72f27350703 -r 20063cea1606 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Nov 23 06:59:06 2009 +0000
+++ b/tools/libxl/libxl.c       Mon Nov 23 07:00:08 2009 +0000
@@ -14,6 +14,8 @@
  * GNU Lesser General Public License for more details.
  */
 
+#include "libxl_osdeps.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -25,6 +27,7 @@
 #include <unistd.h> /* for write, unlink and close */
 #include <stdint.h>
 #include <inttypes.h>
+
 #include "libxl.h"
 #include "libxl_utils.h"
 #include "libxl_internal.h"
diff -r b72f27350703 -r 20063cea1606 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Mon Nov 23 06:59:06 2009 +0000
+++ b/tools/libxl/libxl.h       Mon Nov 23 07:00:08 2009 +0000
@@ -15,14 +15,13 @@
 #ifndef LIBXL_H
 #define LIBXL_H
 
-#include "osdeps.h"
 #include <stdint.h>
 #include <stdarg.h>
 #include <netinet/in.h>
 #include <xenctrl.h>
+#include <xs.h>
+
 #include "xen_uuid.h"
-
-typedef int bool;
 
 typedef void (*libxl_log_callback)(void *userdata, int loglevel, const char 
*file,
                                    int line, const char *func, char *s);
diff -r b72f27350703 -r 20063cea1606 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Mon Nov 23 06:59:06 2009 +0000
+++ b/tools/libxl/libxl_device.c        Mon Nov 23 07:00:08 2009 +0000
@@ -14,14 +14,17 @@
  * GNU Lesser General Public License for more details.
  */
 
+#include "libxl_osdeps.h"
+
 #include <string.h>
 #include <stdio.h>
-#include "libxl.h"
-#include "libxl_internal.h"
 #include <sys/time.h> /* for struct timeval */
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+
+#include "libxl.h"
+#include "libxl_internal.h"
 
 char *string_of_kinds[] = {
     [DEVICE_VIF] = "vif",
diff -r b72f27350703 -r 20063cea1606 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Mon Nov 23 06:59:06 2009 +0000
+++ b/tools/libxl/libxl_dom.c   Mon Nov 23 07:00:08 2009 +0000
@@ -13,16 +13,20 @@
  * GNU Lesser General Public License for more details.
  */
 
-#include "libxl.h"
-#include "libxl_internal.h"
+#include "libxl_osdeps.h"
+
 #include <stdio.h>
 #include <inttypes.h>
-#include <xenguest.h>
-#include <xenctrl.h>
-#include <xc_dom.h>
 #include <string.h>
 #include <sys/time.h> /* for struct timeval */
 #include <unistd.h> /* for sleep(2) */
+
+#include <xenctrl.h>
+#include <xc_dom.h>
+#include <xenguest.h>
+
+#include "libxl.h"
+#include "libxl_internal.h"
 
 int is_hvm(struct libxl_ctx *ctx, uint32_t domid)
 {
@@ -110,7 +114,7 @@ int build_pv(struct libxl_ctx *ctx, uint
 
     dom = xc_dom_allocate(info->u.pv.cmdline, info->u.pv.features);
     if (!dom) {
-        XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, dom, "xc_dom_allocate failed");
+        XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "xc_dom_allocate failed");
         return -1;
     }
     if ((ret = xc_dom_linux_build(ctx->xch, dom, domid, info->max_memkb / 1024,
diff -r b72f27350703 -r 20063cea1606 tools/libxl/libxl_exec.c
--- a/tools/libxl/libxl_exec.c  Mon Nov 23 06:59:06 2009 +0000
+++ b/tools/libxl/libxl_exec.c  Mon Nov 23 07:00:08 2009 +0000
@@ -15,9 +15,12 @@
  * GNU Lesser General Public License for more details.
  */
 
+#include "libxl_osdeps.h"
+
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
+
 #include "libxl.h"
 #include "libxl_internal.h"
 
diff -r b72f27350703 -r 20063cea1606 tools/libxl/libxl_internal.c
--- a/tools/libxl/libxl_internal.c      Mon Nov 23 06:59:06 2009 +0000
+++ b/tools/libxl/libxl_internal.c      Mon Nov 23 07:00:08 2009 +0000
@@ -12,12 +12,16 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Lesser General Public License for more details.
  */
+
+#include "libxl_osdeps.h"
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+
 #include "libxl.h"
 #include "libxl_internal.h"
 #include "libxl_utils.h"
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
 
 int libxl_error_set(struct libxl_ctx *ctx, int code)
 {
diff -r b72f27350703 -r 20063cea1606 tools/libxl/libxl_osdeps.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/libxl_osdeps.h        Mon Nov 23 07:00:08 2009 +0000
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2009      Citrix Ltd.
+ * Author Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+/*
+ * This header must be included first, before any system headers,
+ * so that _GNU_SOURCE takes effect properly.
+ */
+
+#ifndef LIBXL_OSDEP
+#define LIBXL_OSDEP
+
+#define _GNU_SOURCE
+
+#ifdef NEED_OWN_ASPRINTF
+#include <stdarg.h>
+
+int asprintf(char **buffer, char *fmt, ...);
+int vasprintf(char **buffer, const char *fmt, va_list ap);
+#endif /*NEED_OWN_ASPRINTF*/
+
+#endif
diff -r b72f27350703 -r 20063cea1606 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Mon Nov 23 06:59:06 2009 +0000
+++ b/tools/libxl/libxl_utils.c Mon Nov 23 07:00:08 2009 +0000
@@ -13,8 +13,8 @@
  * GNU Lesser General Public License for more details.
  */
 
-#include "libxl_utils.h"
-#include "libxl_internal.h"
+#include "libxl_osdeps.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -24,6 +24,8 @@
 #include <ctype.h>
 #include <errno.h>
 
+#include "libxl_utils.h"
+#include "libxl_internal.h"
 
 
 unsigned long libxl_get_required_shadow_memory(unsigned long maxmem_kb, 
unsigned int smp_cpus)
diff -r b72f27350703 -r 20063cea1606 tools/libxl/libxl_xshelp.c
--- a/tools/libxl/libxl_xshelp.c        Mon Nov 23 06:59:06 2009 +0000
+++ b/tools/libxl/libxl_xshelp.c        Mon Nov 23 07:00:08 2009 +0000
@@ -13,12 +13,15 @@
  * 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 "libxl.h"
 #include "libxl_internal.h"
-#include <stdio.h>
-#include <stdarg.h>
 
 char **libxl_xs_kvs_of_flexarray(struct libxl_ctx *ctx, flexarray_t *array, 
int length)
 {
diff -r b72f27350703 -r 20063cea1606 tools/libxl/osdeps.c
--- a/tools/libxl/osdeps.c      Mon Nov 23 06:59:06 2009 +0000
+++ b/tools/libxl/osdeps.c      Mon Nov 23 07:00:08 2009 +0000
@@ -18,6 +18,8 @@
 #include <stdio.h>
 #include <sys/time.h>
 #include <stdlib.h>
+
+#ifdef NEED_OWN_ASPRINTF
 
 int vasprintf(char **buffer, const char *fmt, va_list ap)
 {
@@ -60,3 +62,5 @@ int asprintf(char **buffer, char *fmt, .
     va_end (ap);
     return status;
 }
+
+#endif
diff -r b72f27350703 -r 20063cea1606 tools/libxl/osdeps.h
--- a/tools/libxl/osdeps.h      Mon Nov 23 06:59:06 2009 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2009      Citrix Ltd.
- * Author Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- */
-
-#ifndef LIBXL_OSDEP
-#define LIBXL_OSDEP
-
-#include <stdarg.h>
-
-#if defined(__linux__)
-int asprintf(char **buffer, char *fmt, ...);
-int vasprintf(char **buffer, const char *fmt, va_list ap);
-#endif
-
-#endif
diff -r b72f27350703 -r 20063cea1606 tools/libxl/xl.c
--- a/tools/libxl/xl.c  Mon Nov 23 06:59:06 2009 +0000
+++ b/tools/libxl/xl.c  Mon Nov 23 07:00:08 2009 +0000
@@ -14,8 +14,8 @@
  * GNU Lesser General Public License for more details.
  */
 
-#include "libxl.h"
-#include "libxl_utils.h"
+#include "libxl_osdeps.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -28,6 +28,9 @@
 #include <sys/socket.h>
 #include <arpa/inet.h>
 #include <xenctrl.h>
+
+#include "libxl.h"
+#include "libxl_utils.h"
 
 void log_callback(void *userdata, int loglevel, const char *file, int line, 
const char *func, char *s)
 {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxenlight: correct broken osdeps.[ch] and make #includes consistent, Xen patchbot-unstable <=