From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v8 1/6] tools/libxl: Check if fdt_{first, next}_subnode are present in libfdt Date: Wed, 13 May 2015 15:07:26 +0100 Message-ID: <1431526046.8263.285.camel@citrix.com> References: <1431441192-27897-1-git-send-email-julien.grall@citrix.com> <1431441192-27897-2-git-send-email-julien.grall@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YsXKV-0003Pg-1d for xen-devel@lists.xenproject.org; Wed, 13 May 2015 14:08:11 +0000 In-Reply-To: <1431441192-27897-2-git-send-email-julien.grall@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: Wei Liu , Ian Jackson , Julien Grall , tim@xen.org, stefano.stabellini@citrix.com, xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org On Tue, 2015-05-12 at 15:33 +0100, Julien Grall wrote: > From: Julien Grall > > The functions fdt_{fisrt,next}_subnode may not be available because: "first" > * It has been introduced in 2013 => Doesn't work on Wheezy > * The prototype exists but the functions are not exposed. Don't ask > why... > > The later has been fixed recently in the dtc repo [1] > > When the functions are not available, implement our own in order to use > them in a following patch. > > [1] git://git.kernel.org/pub/scm/utils/dtc/dtc.git > commit a4b093f7366fdb429ca1781144d3985fa50d0fbb > > Signed-off-by: Julien Grall > Signed-off-by: Ian Jackson > Cc: Wei Liu I'm afraid this failed to build again this time with: tools/libxl/libxenlight.so: undefined reference to `fdt_first_property_offset' tools/libxl/libxenlight.so: undefined reference to `fdt_get_property_by_offset' tools/libxl/libxenlight.so: undefined reference to `fdt_next_property_offset' That's with arm32 == Debian Wheezy and arm64 == Ubuntu Saucy. The arm32 machine is marilith-n13 here in Cambridge which you should have access to. arm64 is a chroot on my workstation, I could give you access if that would be helpful, but I expect solving this for arm32 would solve it for arm64 too. > tools/libxl/libxl_internal.h | 1 + Spurious change, please drop. > tools/libxl/libxl_libfdt_compat.c | 94 +++++++++++++++++++++++++++++++++++++++ > tools/libxl/libxl_libfdt_compat.h | 80 +++++++++++++++++++++++++++++++++ > 5 files changed, 182 insertions(+), 1 deletion(-) > create mode 100644 tools/libxl/libxl_libfdt_compat.c > create mode 100644 tools/libxl/libxl_libfdt_compat.h > > diff --git a/tools/configure.ac b/tools/configure.ac > index d31c2f3..5b48ab2 100644 > --- a/tools/configure.ac > +++ b/tools/configure.ac > @@ -355,6 +355,12 @@ AC_SUBST(libiconv) > case "$host_cpu" in > arm*|aarch64) > AC_CHECK_LIB([fdt], [fdt_create], [], [AC_MSG_ERROR([Could not find libfdt])]) > + > +# The functions fdt_{first,next}_subnode may not be available because: > +# * It has been introduced in 2013 => Doesn't work on Wheezy > +# * The prototype exists but the functions are not exposed. Don't ask why... > +AC_CHECK_FUNCS([fdt_first_subnode fdt_next_subnode]) > +AC_CHECK_DECLS([fdt_first_subnode, fdt_next_subnode],,,[#include ]) > esac > > # Checks for header files. > diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile > index 1b16598..2afb146 100644 > --- a/tools/libxl/Makefile > +++ b/tools/libxl/Makefile > @@ -59,7 +59,7 @@ endif > LIBXL_OBJS-y += libxl_remus_device.o libxl_remus_disk_drbd.o > > LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o > -LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o > +LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o > > ifeq ($(CONFIG_NetBSD),y) > LIBXL_OBJS-y += libxl_netbsd.o > diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h > index 8eb38aa..857abd4 100644 > --- a/tools/libxl/libxl_internal.h > +++ b/tools/libxl/libxl_internal.h > @@ -3692,6 +3692,7 @@ static inline void libxl__update_config_vtpm(libxl__gc *gc, > */ > void libxl__bitmap_copy_best_effort(libxl__gc *gc, libxl_bitmap *dptr, > const libxl_bitmap *sptr); > + > #endif > > /* > diff --git a/tools/libxl/libxl_libfdt_compat.c b/tools/libxl/libxl_libfdt_compat.c > new file mode 100644 > index 0000000..a1823b2 > --- /dev/null > +++ b/tools/libxl/libxl_libfdt_compat.c > @@ -0,0 +1,94 @@ > +/* > + * Copyright (C) 2006 David Gibson, IBM Corporation. > + * > + * This file is part of libxl, and was originally taken from libfdt. > + * > + * 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. > + * > + * Additionally, this particular file is dual licensed. That is, > + * alternatively, at your option: > + * > + * Redistribution and use in source and binary forms, with or > + * without modification, are permitted provided that the following > + * conditions are met: > + * > + * 1. Redistributions of source code must retain the above > + * copyright notice, this list of conditions and the following > + * disclaimer. > + * 2. Redistributions in binary form must reproduce the above > + * copyright notice, this list of conditions and the following > + * disclaimer in the documentation and/or other materials > + * provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, > + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF > + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR > + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; > + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN > + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR > + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, > + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > + * > + * Note that this applies only to this file, and other files with a > + * similar notice. Also, note that when the same code is distributed > + * along with the rest of libxl, you must comply with the terms of the > + * LGPLv2.1 for the whole of libxl including this file. > + * > + * The intent is to permit, in particular, upstream libfdt to > + * incorporate improvements to this file within upstream libfdt. At > + * the time of writing, upstream libfdt is dual licensed: 2-clause BSD > + * (as above) and GPLv2-or-later. The 2-clause BSD licence is > + * compatible with both GPLv2-or-later and LGPLv2.1-only; this permits > + * copying in both directions, and the optional licence upgrade to a > + * copyleft licence by libdft upstream or the Xen Project, > + * respectively. > + */ > + > +#include > + > +#include "libxl_libfdt_compat.h" > + > +#ifndef HAVE_FDT_FIRST_SUBNODE > +int fdt_first_subnode(const void *fdt, int offset) > +{ > + int depth = 0; > + > + offset = fdt_next_node(fdt, offset, &depth); > + if (offset < 0 || depth != 1) > + return -FDT_ERR_NOTFOUND; > + > + return offset; > +} > +#endif > + > +#ifndef HAVE_FDT_NEXT_SUBNODE > +int fdt_next_subnode(const void *fdt, int offset) > +{ > + int depth = 1; > + > + /* > + * With respect to the parent, the depth of the next subnode will be > + * the same as the last. > + */ > + do { > + offset = fdt_next_node(fdt, offset, &depth); > + if (offset < 0 || depth < 1) > + return -FDT_ERR_NOTFOUND; > + } while (depth > 1); > + > + return offset; > +} > +#endif > diff --git a/tools/libxl/libxl_libfdt_compat.h b/tools/libxl/libxl_libfdt_compat.h > new file mode 100644 > index 0000000..cf414f5 > --- /dev/null > +++ b/tools/libxl/libxl_libfdt_compat.h > @@ -0,0 +1,80 @@ > +/* > + * Copyright (C) 2006 David Gibson, IBM Corporation. > + * > + * This file is part of libxl, and was originally taken from libfdt. > + * > + * 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. > + * > + * Additionally, this particular file is dual licensed. That is, > + * alternatively, at your option: > + * > + * Redistribution and use in source and binary forms, with or > + * without modification, are permitted provided that the following > + * conditions are met: > + * > + * 1. Redistributions of source code must retain the above > + * copyright notice, this list of conditions and the following > + * disclaimer. > + * 2. Redistributions in binary form must reproduce the above > + * copyright notice, this list of conditions and the following > + * disclaimer in the documentation and/or other materials > + * provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, > + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF > + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR > + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; > + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN > + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR > + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, > + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > + * > + * Note that this applies only to this file, and other files with a > + * similar notice. Also, note that when the same code is distributed > + * along with the rest of libxl, you must comply with the terms of the > + * LGPLv2.1 for the whole of libxl including this file. > + * > + * The intent is to permit, in particular, upstream libfdt to > + * incorporate improvements to this file within upstream libfdt. At > + * the time of writing, upstream libfdt is dual licensed: 2-clause BSD > + * (as above) and GPLv2-or-later. The 2-clause BSD licence is > + * compatible with both GPLv2-or-later and LGPLv2.1-only; this permits > + * copying in both directions, and the optional licence upgrade to a > + * copyleft licence by libdft upstream or the Xen Project, > + * respectively. > + */ > + > +#ifndef LIBXL_LIBFDT_COMPAT_H > +#define LIBXL_LIBFDT_COMPAT_H > + > +#if !HAVE_DECL_FDT_FIRST_SUBNODE > +int fdt_first_subnode(const void *fdt, int offset); > +#endif > + > +#if !HAVE_DECL_FDT_NEXT_SUBNODE > +int fdt_next_subnode(const void *fdt, int offset); > +#endif > + > +#endif > + > +/* > + * Local variables: > + * mode: C > + * c-basic-offset: 4 > + * indent-tabs-mode: nil > + * End: > + */ > +