[Libvir] gnulib: take2, trunk-relative patch

Here's the complete patch (but still none of the new files), rebased and relative to the trunk. As before, this passes "make distcheck". And as Daniel Veillard noted, you'd need git. However the next patch will cvs-add all of the bootstrap-imported files, so you won't need git unless you want to try this particular patch. ------------------------------------------------------------- Use gnulib, starting with its physmem and getaddrinfo modules. New files go into these directories: gnulib/lib gnulib/m4 tests/gnulib * bootstrap: A wrapper around gnulib-tool. * configure.in: Invoke gl_EARLY and gl_INIT, being careful to put gl_EARLY before any macro that uses AC_COMPILE_IFELSE. (AC_OUTPUT): Add lib/Makefile and gl-tests/Makefile. Remove m4/Makefile. * Makefile.am (SUBDIRS): Add gnulib/lib and tests/gnulib. Remove m4. * m4/Makefile.am: Remove file. Not needed. * src/Makefile.am (INCLUDES): Add -I$(top_srcdir)/gnulib/lib -I../gnulib/lib. (LDADDS, libvirt_la_LIBADD): Add ../gnulib/lib/libgnu.la. * src/nodeinfo.c: Include "physmem.h". * qemud/qemud.c, src/remote_internal.c: Include "getaddrinfo.h". (MEMINFO_PATH, linuxNodeInfoMemPopulate): Remove definitions. (virNodeInfoPopulate): Use physmem_total, not linuxNodeInfoMemPopulate. * tests/Makefile.am (INCLUDES): Add -I$(top_srcdir)/gnulib/lib -I../gnulib/lib. (LDADDS): Add ../gnulib/lib/libgnu.la. * qemud/Makefile.am (libvirtd_LDADD): Add ../gnulib/lib/libgnu.la. * tests/nodeinfotest.c (linuxTestCompareFiles): No longer read total memory from a file. Update expected output not to include "Memory: NNNN" * tests/nodeinfodata/linux-nodeinfo-1.txt: * tests/nodeinfodata/linux-nodeinfo-2.txt: * tests/nodeinfodata/linux-nodeinfo-3.txt: * tests/nodeinfodata/linux-nodeinfo-4.txt: * tests/nodeinfodata/linux-nodeinfo-5.txt: * tests/nodeinfodata/linux-nodeinfo-6.txt: * src/test.c [WITH_TEST]: Remove definition of _GNU_SOURCE that would conflict with the one now in "config.h". * autogen.sh: Add -I gnulib/m4. Signed-off-by: Jim Meyering <meyering@redhat.com> --- Makefile.am | 5 +- autogen.sh | 2 +- bootstrap | 108 +++++++++++++++++++++++++++++++ configure.in | 11 ++- m4/Makefile.am | 3 - qemud/Makefile.am | 3 +- qemud/qemud.c | 1 + src/Makefile.am | 8 ++- src/nodeinfo.c | 55 +++------------- src/remote_internal.c | 1 + src/test.c | 2 - tests/Makefile.am | 2 + tests/nodeinfodata/linux-nodeinfo-1.txt | 2 +- tests/nodeinfodata/linux-nodeinfo-2.txt | 2 +- tests/nodeinfodata/linux-nodeinfo-3.txt | 2 +- tests/nodeinfodata/linux-nodeinfo-4.txt | 2 +- tests/nodeinfodata/linux-nodeinfo-5.txt | 2 +- tests/nodeinfodata/linux-nodeinfo-6.txt | 2 +- tests/nodeinfotest.c | 23 ++----- 19 files changed, 151 insertions(+), 85 deletions(-) create mode 100755 bootstrap delete mode 100644 m4/Makefile.am diff --git a/Makefile.am b/Makefile.am index eaa204e..1f2ca52 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,9 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = src qemud proxy include docs @PYTHON_SUBDIR@ tests po m4 scripts +SUBDIRS = gnulib/lib src qemud proxy include docs @PYTHON_SUBDIR@ \ + tests/gnulib tests po scripts -ACLOCAL_AMFLAGS = -I m4 +ACLOCAL_AMFLAGS = -I m4 -I gnulib/m4 EXTRA_DIST = libvirt.spec.in libvirt.spec COPYING.LIB \ libvirt.pc.in libvirt.pc TODO AUTHORS ChangeLog \ diff --git a/autogen.sh b/autogen.sh index 97b636d..3bcffd3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -57,7 +57,7 @@ fi autopoint --force #rm -rf m4 libtoolize --copy --force -aclocal -I m4 +aclocal -I m4 -I gnulib/m4 autoheader automake --add-missing autoconf diff --git a/bootstrap b/bootstrap new file mode 100755 index 0000000..ca186bd --- /dev/null +++ b/bootstrap @@ -0,0 +1,108 @@ +#!/bin/sh +# Run this after autogen.sh, to pull in all of the gnulib-related bits. +# It's important to run *after* autogen.sh, since it updates some of +# the same files autogen.sh does, yet those from gnulib are newer, +# and match the tests. So if a gnulib bug has been fixed since the +# snapshot taken for whatever gettext release you're using, yet you +# run "make check" against the wrong version, the corresponding unit +# test in gl-tests/ may well fail. + +usage() { + echo >&2 "\ +Usage: $0 [OPTION]... +Bootstrap this package from the checked-out sources. + +Options: + --gnulib-srcdir=DIRNAME Specify the local directory where gnulib + sources reside. Use this if you already + have gnulib sources on your machine, and + do not want to waste your bandwidth downloading + them again. + +If the file bootstrap.conf exists in the current working directory, its +contents are read as shell variables to configure the bootstrap. + +Running without arguments will suffice in most cases. +" +} + +for option +do + case $option in + --help) + usage + exit;; + --gnulib-srcdir=*) + GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;; + *) + echo >&2 "$0: $option: unknown option" + exit 1;; + esac +done + +cleanup_gnulib() { + st=$? + rm -fr .gnulib + exit $st +} + +case ${GNULIB_SRCDIR--} in +-) + if [ ! -d gnulib ]; then + echo "$0: getting gnulib files..." + + trap cleanup_gnulib 1 2 13 15 + + git clone --depth 1 git://git.sv.gnu.org/gnulib .gnulib || + cleanup_gnulib + + trap - 1 2 13 15 + fi + GNULIB_SRCDIR=.gnulib +esac + +gnulib_tool=$GNULIB_SRCDIR/gnulib-tool +<$gnulib_tool || exit + +# Tell gnulib to: +# put tests in new tests/gnulib/ dir +# put *.m4 files in new gnulib/m4/ dir +# put *.[ch] files in new gnulib/lib/ dir. +# With --avoid=snprintf, we drop support for systems (many!) with +# losing snprintf but pull in about 30 fewer files +# With the current gnulib and gettext-0.17, the following +# files are added to m4/ by both. But gnulib is stable enough +# and gettext-0.16.1 is new enough that they are identical. +# compiler-flags.m4 +# inttypes_h.m4 +# longlong.m4 +# size_max.m4 +# stdint_h.m4 +# wchar_t.m4 +# wint_t.m4 +# xsize.m4 + +# Note that if we don't exclude the snprintf module, there are two tests +# that have incompatible licenses, so we would have to exclude them. Even +# excluding those two test modules, find reports a total of 94 added files. +# Yes, snprintf has some heavy-duty dependents. +# --avoid=snprintf-tests +# --avoid=vasnprintf-tests + +avoid='--avoid=snprintf' + +avoid=' + --avoid=snprintf-tests + --avoid=vasnprintf-tests +' + +$gnulib_tool \ + --lgpl \ + $avoid \ + --avoid=snprintf-tests \ + --avoid=vasnprintf-tests \ + --with-tests \ + --m4-base=gnulib/m4 \ + --source-base=gnulib/lib \ + --tests-base=tests/gnulib \ + --import physmem getaddrinfo diff --git a/configure.in b/configure.in index 6cd7fe2..0cc8b6d 100644 --- a/configure.in +++ b/configure.in @@ -28,11 +28,15 @@ AVAHI_REQUIRED="0.6.0" dnl Checks for C compiler. AC_PROG_CC -AM_PROG_CC_STDC -AC_C_CONST AC_PROG_INSTALL AC_PROG_CPP +gl_EARLY +gl_INIT + +AM_PROG_CC_STDC +AC_C_CONST + dnl Make sure we have an ANSI compiler AM_C_PROTOTYPES test "x$U" != "x" && AC_MSG_ERROR(Compiler not ANSI compliant) @@ -555,11 +559,12 @@ cp COPYING.LIB COPYING AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \ docs/examples/Makefile docs/devhelp/Makefile \ docs/examples/python/Makefile \ + gnulib/lib/Makefile tests/gnulib/Makefile \ libvirt.pc libvirt.spec \ po/Makefile.in scripts/Makefile \ include/libvirt/Makefile include/libvirt/libvirt.h \ python/Makefile python/tests/Makefile \ - qemud/Makefile m4/Makefile \ + qemud/Makefile \ tests/Makefile proxy/Makefile \ tests/xml2sexprdata/Makefile \ tests/sexpr2xmldata/Makefile \ diff --git a/m4/Makefile.am b/m4/Makefile.am deleted file mode 100644 index 188b2fe..0000000 --- a/m4/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ - -EXTRA_DIST = compiler-flags.m4 - diff --git a/qemud/Makefile.am b/qemud/Makefile.am index 1737176..7e3b694 100644 --- a/qemud/Makefile.am +++ b/qemud/Makefile.am @@ -27,6 +27,7 @@ libvirtd_SOURCES = \ #-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L libvirtd_CFLAGS = \ + -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \ -I$(top_srcdir)/include -I$(top_builddir)/include \ $(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) \ $(WARN_CFLAGS) -DLOCAL_STATE_DIR="\"$(localstatedir)\"" \ @@ -37,7 +38,7 @@ libvirtd_CFLAGS = \ libvirtd_LDFLAGS = $(WARN_CFLAGS) $(LIBXML_LIBS) $(GNUTLS_LIBS) libvirtd_DEPENDENCIES = ../src/libvirt.la -libvirtd_LDADD = ../src/libvirt.la +libvirtd_LDADD = ../src/libvirt.la ../gnulib/lib/libgnu.la if HAVE_AVAHI libvirtd_SOURCES += mdns.c mdns.h diff --git a/qemud/qemud.c b/qemud/qemud.c index f88ed42..caccd29 100644 --- a/qemud/qemud.c +++ b/qemud/qemud.c @@ -53,6 +53,7 @@ #include <libvirt/virterror.h> #include "internal.h" +#include "getaddrinfo.h" #include "../src/internal.h" #include "../src/remote_internal.h" #include "../src/conf.h" diff --git a/src/Makefile.am b/src/Makefile.am index 52ffbaf..f9a2308 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,8 @@ ## Process this file with automake to produce Makefile.in -INCLUDES = -I$(top_builddir)/include \ +INCLUDES = \ + -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \ + -I../include \ -I@top_srcdir@/include \ -I@top_srcdir@/qemud \ $(LIBXML_CFLAGS) \ @@ -14,7 +16,7 @@ INCLUDES = -I$(top_builddir)/include \ $(WARN_CFLAGS) \ $(LIBVIRT_FEATURES) DEPS = libvirt.la -LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) libvirt.la +LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) libvirt.la ../gnulib/lib/libgnu.la VIRSH_LIBS = @VIRSH_LIBS@ confdir = $(sysconfdir)/libvirt/ @@ -60,7 +62,7 @@ SERVER_SOURCES = \ libvirt_la_SOURCES = $(CLIENT_SOURCES) $(SERVER_SOURCES) libvirt_la_LIBADD = $(LIBXML_LIBS) $(GNUTLS_LIBS) $(LTLIBOBJS) \ - @CYGWIN_EXTRA_LIBADD@ + @CYGWIN_EXTRA_LIBADD@ ../gnulib/lib/libgnu.la libvirt_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libvirt_sym.version \ -version-info @LIBVIRT_VERSION_INFO@ \ $(COVERAGE_CFLAGS:-f%=-Wc,-f%) \ diff --git a/src/nodeinfo.c b/src/nodeinfo.c index a0a26eb..2ef49cb 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -29,14 +29,14 @@ #include <ctype.h> #include "nodeinfo.h" +#include "physmem.h" #ifdef __linux__ -#define MEMINFO_PATH "/proc/meminfo" #define CPUINFO_PATH "/proc/cpuinfo" /* NB, these are not static as we need to call them from testsuite */ -int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr nodeinfo); -int linuxNodeInfoMemPopulate(virConnectPtr conn, FILE *meminfo, virNodeInfoPtr nodeinfo); +int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, + virNodeInfoPtr nodeinfo); int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr nodeinfo) { char line[1024]; @@ -114,44 +114,11 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n return 0; } - -int linuxNodeInfoMemPopulate(virConnectPtr conn, FILE *meminfo, - virNodeInfoPtr nodeinfo) { - char line[1024]; - - nodeinfo->memory = 0; - - while (fgets(line, sizeof(line), meminfo) != NULL) { - if (STREQLEN(line, "MemTotal:", 9)) { - char *p; - unsigned int ui; - if (xstrtol_ui(line + 10, &p, 10, &ui) == 0 - && (*p == '\0' || isspace(*p))) { - nodeinfo->memory = ui; - break; - } - } - } - if (!nodeinfo->memory) { - __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, - VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, - "no memory found"); - return -1; - } - - return 0; -} - - #endif int virNodeInfoPopulate(virConnectPtr conn, virNodeInfoPtr nodeinfo) { struct utsname info; -#ifdef __linux__ - int ret; - FILE *cpuinfo, *meminfo; -#endif if (uname(&info) < 0) { __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, @@ -164,7 +131,9 @@ int virNodeInfoPopulate(virConnectPtr conn, nodeinfo->model[sizeof(nodeinfo->model)-1] = '\0'; #ifdef __linux__ - cpuinfo = fopen(CPUINFO_PATH, "r"); + { + int ret; + FILE *cpuinfo = fopen(CPUINFO_PATH, "r"); if (!cpuinfo) { __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, @@ -176,17 +145,11 @@ int virNodeInfoPopulate(virConnectPtr conn, if (ret < 0) return -1; - meminfo = fopen(MEMINFO_PATH, "r"); - if (!meminfo) { - __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, - VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, - "cannot open %s %s", MEMINFO_PATH, strerror(errno)); - return -1; - } - ret = linuxNodeInfoMemPopulate(conn, meminfo, nodeinfo); - fclose(meminfo); + /* Convert to KB. */ + nodeinfo->memory = physmem_total () / 1024; return ret; + } #else /* XXX Solaris will need an impl later if they port QEMU driver */ __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, diff --git a/src/remote_internal.c b/src/remote_internal.c index a8227f3..275405a 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -52,6 +52,7 @@ #include "internal.h" #include "driver.h" +#include "getaddrinfo.h" #include "remote_internal.h" #include "remote_protocol.h" diff --git a/src/test.c b/src/test.c index 010ea15..bab280f 100644 --- a/src/test.c +++ b/src/test.c @@ -25,8 +25,6 @@ #ifdef WITH_TEST -#define _GNU_SOURCE /* for asprintf */ - #include <stdio.h> #include <string.h> #include <sys/time.h> diff --git a/tests/Makefile.am b/tests/Makefile.am index 512162b..8220e1b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,6 +11,7 @@ SUBDIRS = virshdata confdata sexpr2xmldata xml2sexprdata xmconfigdata xencapsdat LIBVIRT = $(wildcard $(top_builddir)/src/.libs/libvirt_la-*.o) INCLUDES = \ + -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \ -I$(top_builddir)/include \ -I$(top_builddir)/src \ -I$(top_srcdir)/include \ @@ -29,6 +30,7 @@ LDADDS = \ $(GNUTLS_LIBS) \ $(WARN_CFLAGS) \ $(LIBVIRT) \ + ../gnulib/lib/libgnu.la \ $(COVERAGE_LDFLAGS) EXTRA_DIST = \ diff --git a/tests/nodeinfodata/linux-nodeinfo-1.txt b/tests/nodeinfodata/linux-nodeinfo-1.txt index 1a38ad1..e52e20a 100644 --- a/tests/nodeinfodata/linux-nodeinfo-1.txt +++ b/tests/nodeinfodata/linux-nodeinfo-1.txt @@ -1 +1 @@ -CPUs: 2, MHz: 2800, Nodes: 1, Sockets: 1, Cores: 2, Threads: 1, Memory: 2053960 +CPUs: 2, MHz: 2800, Nodes: 1, Sockets: 1, Cores: 2, Threads: 1 diff --git a/tests/nodeinfodata/linux-nodeinfo-2.txt b/tests/nodeinfodata/linux-nodeinfo-2.txt index 1c31a0c..12e819b 100644 --- a/tests/nodeinfodata/linux-nodeinfo-2.txt +++ b/tests/nodeinfodata/linux-nodeinfo-2.txt @@ -1 +1 @@ -CPUs: 2, MHz: 2211, Nodes: 1, Sockets: 1, Cores: 2, Threads: 1, Memory: 4059540 +CPUs: 2, MHz: 2211, Nodes: 1, Sockets: 1, Cores: 2, Threads: 1 diff --git a/tests/nodeinfodata/linux-nodeinfo-3.txt b/tests/nodeinfodata/linux-nodeinfo-3.txt index e2cc841..d285781 100644 --- a/tests/nodeinfodata/linux-nodeinfo-3.txt +++ b/tests/nodeinfodata/linux-nodeinfo-3.txt @@ -1 +1 @@ -CPUs: 4, MHz: 1595, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1, Memory: 4059272 +CPUs: 4, MHz: 1595, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1 diff --git a/tests/nodeinfodata/linux-nodeinfo-4.txt b/tests/nodeinfodata/linux-nodeinfo-4.txt index 2c75ea3..991d4f9 100644 --- a/tests/nodeinfodata/linux-nodeinfo-4.txt +++ b/tests/nodeinfodata/linux-nodeinfo-4.txt @@ -1 +1 @@ -CPUs: 4, MHz: 1000, Nodes: 1, Sockets: 1, Cores: 4, Threads: 1, Memory: 4059272 +CPUs: 4, MHz: 1000, Nodes: 1, Sockets: 1, Cores: 4, Threads: 1 diff --git a/tests/nodeinfodata/linux-nodeinfo-5.txt b/tests/nodeinfodata/linux-nodeinfo-5.txt index 01fee52..dce7ada 100644 --- a/tests/nodeinfodata/linux-nodeinfo-5.txt +++ b/tests/nodeinfodata/linux-nodeinfo-5.txt @@ -1 +1 @@ -CPUs: 4, MHz: 2814, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1, Memory: 4059272 +CPUs: 4, MHz: 2814, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1 diff --git a/tests/nodeinfodata/linux-nodeinfo-6.txt b/tests/nodeinfodata/linux-nodeinfo-6.txt index a7a2cfe..75cdaa9 100644 --- a/tests/nodeinfodata/linux-nodeinfo-6.txt +++ b/tests/nodeinfodata/linux-nodeinfo-6.txt @@ -1 +1 @@ -CPUs: 4, MHz: 1000, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1, Memory: 4059272 +CPUs: 4, MHz: 1000, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1 diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c index 7275cc3..fb563b5 100644 --- a/tests/nodeinfotest.c +++ b/tests/nodeinfotest.c @@ -21,14 +21,13 @@ static char *abs_top_srcdir; #ifdef __linux__ extern int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr nodeinfo); -extern int linuxNodeInfoMemPopulate(virConnectPtr conn, FILE *meminfo, virNodeInfoPtr nodeinfo); -static int linuxTestCompareFiles(const char *cpuinfofile, const char *meminfofile, const char *outputfile) { +static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile) { char actualData[MAX_FILE]; char expectData[MAX_FILE]; char *expect = &expectData[0]; virNodeInfo nodeinfo; - FILE *cpuinfo, *meminfo; + FILE *cpuinfo; if (virtTestLoadFile(outputfile, &expect, MAX_FILE) < 0) return -1; @@ -42,19 +41,10 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *meminfofil } fclose(cpuinfo); - meminfo = fopen(meminfofile, "r"); - if (!meminfo) - return -1; - if (linuxNodeInfoMemPopulate(NULL, meminfo, &nodeinfo) < 0) { - fclose(meminfo); - return -1; - } - fclose(meminfo); - snprintf(actualData, MAX_FILE, - "CPUs: %u, MHz: %u, Nodes: %u, Sockets: %u, Cores: %u, Threads: %u, Memory: %lu\n", + "CPUs: %u, MHz: %u, Nodes: %u, Sockets: %u, Cores: %u, Threads: %u\n", nodeinfo.cpus, nodeinfo.mhz, nodeinfo.nodes, nodeinfo.sockets, - nodeinfo.cores, nodeinfo.threads, nodeinfo.memory); + nodeinfo.cores, nodeinfo.threads); if (STRNEQ(actualData, expectData)) { if (getenv("DEBUG_TESTS")) { @@ -70,15 +60,12 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *meminfofil static int linuxTestNodeInfo(const void *data) { char cpuinfo[PATH_MAX]; - char meminfo[PATH_MAX]; char output[PATH_MAX]; snprintf(cpuinfo, PATH_MAX, "%s/tests/nodeinfodata/linux-%s.cpuinfo", abs_top_srcdir, (const char*)data); - snprintf(meminfo, PATH_MAX, "%s/tests/nodeinfodata/linux-%s.meminfo", - abs_top_srcdir, (const char*)data); snprintf(output, PATH_MAX, "%s/tests/nodeinfodata/linux-%s.txt", abs_top_srcdir, (const char*)data); - return linuxTestCompareFiles(cpuinfo, meminfo, output); + return linuxTestCompareFiles(cpuinfo, output); } #endif -- 1.5.3.6.950.g92b7b

Jim Meyering wrote: [...] Tested and it works, except for a couple of tiny things: (1) Need to add ``--avoid=alloca-opt-tests'' to bootstrap. (2) Need to remove #define _GNU_SOURCE from any *.c files which include "config.h", since now it appears that "config.h" is defining _GNU_SOURCE. There are two instances which I removed. (Not sure if defining _GNU_SOURCE in "config.h" is itself a problem). Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim Meyering wrote: [...]
Tested and it works, except for a couple of tiny things:
Thanks for the testing.
(1) Need to add ``--avoid=alloca-opt-tests'' to bootstrap.
I wonder why I didn't hit that. Did you add any modules to the list in bootstrap?
(2) Need to remove #define _GNU_SOURCE from any *.c files which include "config.h", since now it appears that "config.h" is defining _GNU_SOURCE. There are two instances which I removed.
I had removed one already. You must be using libvirt code on that system that is not preprocessed on Linux.
(Not sure if defining _GNU_SOURCE in "config.h" is itself a problem).
It's a good thing: deliberate, and a requirement.

Jim Meyering wrote:
(1) Need to add ``--avoid=alloca-opt-tests'' to bootstrap.
I wonder why I didn't hit that. Did you add any modules to the list in bootstrap?
Not yet :-) Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

On Wed, Dec 05, 2007 at 03:08:11PM +0100, Jim Meyering wrote:
Here's the complete patch (but still none of the new files), rebased and relative to the trunk. As before, this passes "make distcheck". And as Daniel Veillard noted, you'd need git.
However the next patch will cvs-add all of the bootstrap-imported files, so you won't need git unless you want to try this particular patch.
diff --git a/Makefile.am b/Makefile.am index eaa204e..1f2ca52 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,9 @@ ## Process this file with automake to produce Makefile.in
-SUBDIRS = src qemud proxy include docs @PYTHON_SUBDIR@ tests po m4 scripts +SUBDIRS = gnulib/lib src qemud proxy include docs @PYTHON_SUBDIR@ \ + tests/gnulib tests po scripts
Shouldn't the gnulib/lib SUBDIR actually just be 'gnulib' and then a gnulib/Makefile.am have SUBDIRS = lib Likewise, the tests/gnulib, should just be in the SUBDIRS target for the tests/Makefile.am That aside, I'm fine with this being added to CVS now. Regards, Dan -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Wed, Dec 05, 2007 at 03:08:11PM +0100, Jim Meyering wrote:
Here's the complete patch (but still none of the new files), rebased and relative to the trunk. As before, this passes "make distcheck". And as Daniel Veillard noted, you'd need git.
However the next patch will cvs-add all of the bootstrap-imported files, so you won't need git unless you want to try this particular patch.
diff --git a/Makefile.am b/Makefile.am index eaa204e..1f2ca52 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,9 @@ ## Process this file with automake to produce Makefile.in
-SUBDIRS = src qemud proxy include docs @PYTHON_SUBDIR@ tests po m4 scripts +SUBDIRS = gnulib/lib src qemud proxy include docs @PYTHON_SUBDIR@ \ + tests/gnulib tests po scripts
Shouldn't the gnulib/lib SUBDIR actually just be 'gnulib' and then a gnulib/Makefile.am have SUBDIRS = lib
There's no need for that. Doing it the way I did avoids adding a nearly-empty and otherwise-useless gnulib/Makefile.am.
Likewise, the tests/gnulib, should just be in the SUBDIRS target for the tests/Makefile.am
I put "tests/gnulib" before "tests" there to make it clear that the gnulib tests run before any bit of libvirt's own unit tests. Either way works.
That aside, I'm fine with this being added to CVS now.

On Wed, Dec 05, 2007 at 05:36:48PM +0100, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Wed, Dec 05, 2007 at 03:08:11PM +0100, Jim Meyering wrote:
Here's the complete patch (but still none of the new files), rebased and relative to the trunk. As before, this passes "make distcheck". And as Daniel Veillard noted, you'd need git.
However the next patch will cvs-add all of the bootstrap-imported files, so you won't need git unless you want to try this particular patch.
diff --git a/Makefile.am b/Makefile.am index eaa204e..1f2ca52 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,9 @@ ## Process this file with automake to produce Makefile.in
-SUBDIRS = src qemud proxy include docs @PYTHON_SUBDIR@ tests po m4 scripts +SUBDIRS = gnulib/lib src qemud proxy include docs @PYTHON_SUBDIR@ \ + tests/gnulib tests po scripts
Shouldn't the gnulib/lib SUBDIR actually just be 'gnulib' and then a gnulib/Makefile.am have SUBDIRS = lib
There's no need for that. Doing it the way I did avoids adding a nearly-empty and otherwise-useless gnulib/Makefile.am.
Likewise, the tests/gnulib, should just be in the SUBDIRS target for the tests/Makefile.am
I put "tests/gnulib" before "tests" there to make it clear that the gnulib tests run before any bit of libvirt's own unit tests. Either way works.
We already have many SUBDIRS listed in the tests/Makefile.am, so having one listed elsewhere is very confusing. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Wed, Dec 05, 2007 at 05:36:48PM +0100, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Wed, Dec 05, 2007 at 03:08:11PM +0100, Jim Meyering wrote:
Here's the complete patch (but still none of the new files), rebased and relative to the trunk. As before, this passes "make distcheck". And as Daniel Veillard noted, you'd need git.
However the next patch will cvs-add all of the bootstrap-imported files, so you won't need git unless you want to try this particular patch.
diff --git a/Makefile.am b/Makefile.am index eaa204e..1f2ca52 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,9 @@ ## Process this file with automake to produce Makefile.in
-SUBDIRS = src qemud proxy include docs @PYTHON_SUBDIR@ tests po m4 scripts +SUBDIRS = gnulib/lib src qemud proxy include docs @PYTHON_SUBDIR@ \ + tests/gnulib tests po scripts
Shouldn't the gnulib/lib SUBDIR actually just be 'gnulib' and then a gnulib/Makefile.am have SUBDIRS = lib
There's no need for that. Doing it the way I did avoids adding a nearly-empty and otherwise-useless gnulib/Makefile.am.
Likewise, the tests/gnulib, should just be in the SUBDIRS target for the tests/Makefile.am
I put "tests/gnulib" before "tests" there to make it clear that the gnulib tests run before any bit of libvirt's own unit tests. Either way works.
We already have many SUBDIRS listed in the tests/Makefile.am, so having one listed elsewhere is very confusing.
Well then, how about moving tests/gnulib into gnulib/tests?

On Wed, Dec 05, 2007 at 05:41:52PM +0100, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@redhat.com> wrote:
I put "tests/gnulib" before "tests" there to make it clear that the gnulib tests run before any bit of libvirt's own unit tests. Either way works.
We already have many SUBDIRS listed in the tests/Makefile.am, so having one listed elsewhere is very confusing.
Well then, how about moving tests/gnulib into gnulib/tests?
I would find this a bit surprizing as a newcomer to the library, but there is some logic to it too, Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

Daniel Veillard <veillard@redhat.com> wrote:
On Wed, Dec 05, 2007 at 05:41:52PM +0100, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@redhat.com> wrote:
I put "tests/gnulib" before "tests" there to make it clear that the gnulib tests run before any bit of libvirt's own unit tests. Either way works.
We already have many SUBDIRS listed in the tests/Makefile.am, so having one listed elsewhere is very confusing.
Well then, how about moving tests/gnulib into gnulib/tests?
I would find this a bit surprizing as a newcomer to the library, but there is some logic to it too,
I'm moving gnulib's tests from tests/gnulib into gnulib/tests and arranging to run them a little earlier: before the python tests. Much easier to move things *before* they're checked in to cvs...

"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Wed, Dec 05, 2007 at 03:08:11PM +0100, Jim Meyering wrote:
Here's the complete patch (but still none of the new files), rebased and relative to the trunk. As before, this passes "make distcheck". And as Daniel Veillard noted, you'd need git.
However the next patch will cvs-add all of the bootstrap-imported files, so you won't need git unless you want to try this particular patch.
diff --git a/Makefile.am b/Makefile.am index eaa204e..1f2ca52 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,9 @@ ## Process this file with automake to produce Makefile.in
-SUBDIRS = src qemud proxy include docs @PYTHON_SUBDIR@ tests po m4 scripts +SUBDIRS = gnulib/lib src qemud proxy include docs @PYTHON_SUBDIR@ \ + tests/gnulib tests po scripts
Shouldn't the gnulib/lib SUBDIR actually just be 'gnulib' and then a gnulib/Makefile.am have SUBDIRS = lib
Likewise, the tests/gnulib, should just be in the SUBDIRS target for the tests/Makefile.am
That aside, I'm fine with this being added to CVS now.
Actually, I've just noticed the the python tests were running before the gnulib ones. So I'm going to move the gnulib tests to precede the PYTHON_SUBDIR: SUBDIRS = gnulib/lib src qemud proxy include docs tests/gnulib \ @PYTHON_SUBDIR@ tests po scripts

Jim, I also needed the attached patch, and then I had to do this: cd docs/examples && ./index.py Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim, I also needed the attached patch, and then I had to do this:
cd docs/examples && ./index.py ... -LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la +LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \\ + $(top_builddir)/gnulib/lib/libgnu.la
rebuild: examples.xml index.html
Thanks. Will incorporate.

"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim, I also needed the attached patch, and then I had to do this:
cd docs/examples && ./index.py ... -LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la +LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \\ + $(top_builddir)/gnulib/lib/libgnu.la
Hi Rich, I don't seem to need it. I.e., ./index.py works fine without it: $ ./index.py loading ../libvirt-api.xml Parsing info1.c Parsing suspend.c If you could give me details of why you needed it, I'd feel better about applying it.

Jim Meyering wrote:
"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim, I also needed the attached patch, and then I had to do this:
cd docs/examples && ./index.py ... -LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la +LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \\ + $(top_builddir)/gnulib/lib/libgnu.la
Hi Rich,
I don't seem to need it. I.e., ./index.py works fine without it:
$ ./index.py loading ../libvirt-api.xml Parsing info1.c Parsing suspend.c
If you could give me details of why you needed it, I'd feel better about applying it.
Hi Jim, It's not index.py that fails, but the Makefile.am (which in that directory is generated). More specifically, a program called 'info1' fails to link: gcc -g -O2 -o .libs/info1 info1.o -Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables -Werror ../../src/.libs/libvirt.so -lxml2 -lgnutls -lxenstore ../../src/.libs/libvirt.so: undefined reference to `physmem_total' collect2: ld returned 1 exit status make[4]: *** [info1] Error 1 make[4]: Leaving directory `/home/rjones/d/libvirt-mingw/docs/examples' make[3]: *** [all-recursive] Error 1 make[3]: Leaving directory `/home/rjones/d/libvirt-mingw/docs/examples' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/rjones/d/libvirt-mingw/docs' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/rjones/d/libvirt-mingw' make: *** [all] Error 2 Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim Meyering wrote:
"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim, I also needed the attached patch, and then I had to do this:
cd docs/examples && ./index.py ... -LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la +LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \\ + $(top_builddir)/gnulib/lib/libgnu.la
Hi Rich,
I don't seem to need it. I.e., ./index.py works fine without it:
$ ./index.py loading ../libvirt-api.xml Parsing info1.c Parsing suspend.c
If you could give me details of why you needed it, I'd feel better about applying it.
Hi Jim,
It's not index.py that fails, but the Makefile.am (which in that directory is generated). More specifically, a program called 'info1' fails to link:
gcc -g -O2 -o .libs/info1 info1.o -Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables -Werror ../../src/.libs/libvirt.so -lxml2 -lgnutls -lxenstore ../../src/.libs/libvirt.so: undefined reference to `physmem_total' ... make[1]: Leaving directory `/home/rjones/d/libvirt-mingw' make: *** [all] Error 2
That suggests something is wrong with your libvirt library. It should include physmem_total. That's why it works for me: $ rm info1.o && make info1 gcc -DHAVE_CONFIG_H -I. -I../.. -I../../include -I../../include \ -I./include -g -O2 -MT info1.o -MD -MP -MF .deps/info1.Tpo -c -o \ info1.o info1.c mv -f .deps/info1.Tpo .deps/info1.Po /bin/sh ../../libtool --tag=CC --mode=link gcc -g -O2 -o info1 \ info1.o -Wall -Wformat -Wformat-security -Wmissing-prototypes \ -Wnested-externs -Wpointer-arith -Wextra -Wshadow -Wcast-align \ -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline \ -Wredundant-decls -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 \ -fexceptions -fasynchronous-unwind-tables ../../src/libvirt.la \ -lxenstore libtool: link: gcc -g -O2 -o .libs/info1 info1.o -Wall -Wformat \ -Wformat-security -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings \ -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls \ -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \ -fasynchronous-unwind-tables ../../src/.libs/libvirt.so -lxml2 \ -lgnutls -lxenstore -Wl,-rpath -Wl,/usr/local/lib libtool: link: creating info1 $ Please check your library. Here's what I get: $ nm -e ../../src/.libs/libvirt.a|grep physmem U physmem_total physmem.o: 0000000000000060 T physmem_available 0000000000000000 T physmem_total $ And you? It looks like you're seeing this failure on mingw, so I think the problem may be a little deeper.

Jim, and this one. This is actually something which I accidentally committed to CVS, but if you agree I think it should be removed. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

Jim, to use the gnulib <string.h> replacement with GCC 4.1.2 compiled under MinGW, I needed to patch lib/string.h as follows: --- gnulib/lib/string.h~ 2007-12-05 18:29:29.000000000 +0000 +++ gnulib/lib/string.h 2007-12-05 19:36:22.000000000 +0000 @@ -280,7 +280,7 @@ See also strtok_r(). */ #if 1 # if ! 0 -extern char *strsep (char **restrict __stringp, char const *restrict __delim); +extern char *strsep (char **__restrict__ __stringp, char const *__restrict__ __delim); # endif # if defined GNULIB_POSIXCHECK # undef strsep This seems to be because C99's restrict keyword is not enabled by default. You need to pass the -std=c99 parameter to the compiler to get this. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim, to use the gnulib <string.h> replacement with GCC 4.1.2 compiled under MinGW, I needed to patch lib/string.h as follows:
--- gnulib/lib/string.h~ 2007-12-05 18:29:29.000000000 +0000 +++ gnulib/lib/string.h 2007-12-05 19:36:22.000000000 +0000 @@ -280,7 +280,7 @@ See also strtok_r(). */ #if 1 # if ! 0 -extern char *strsep (char **restrict __stringp, char const *restrict __delim); +extern char *strsep (char **__restrict__ __stringp, char const *__restrict__ __delim); # endif # if defined GNULIB_POSIXCHECK # undef strsep
This seems to be because C99's restrict keyword is not enabled by default. You need to pass the -std=c99 parameter to the compiler to get this.
Thanks for the report. That file is generated from string.in.h, based on settings determined at configure time. And one of the autoconf checks performed for the string module is to require the AC_C_RESTRICT macro which is supposed to detect which flavor of restrict to use. Then it puts the appropriate definition of e.g. #define restrict __restrict__ in config.h. Ahh... I've got it. There are a bunch of files that don't include config.h. There's a rule in "autoconf" land saying that nearly every .c file should include "config.h" before anything else. Most of the time people don't notice when it's forgotten, but porting to "different" systems highlights the trouble. You can list the files that include string.h yet do *not* include config.h, git-grep -l 'include <string\.h>'|xargs grep -L config.h And here's a proposed patch to fix those. There may well be others, but this should solve your build failure: Include "config.h". * qemud/event.c: Likewise. * src/buf.c: Likewise. * src/hash.c: Likewise. * src/nodeinfo.c: Likewise. * src/openvz_conf.c: Likewise. * src/proxy_internal.c: Likewise. * src/virterror.c: Likewise. * src/xmlrpc.c: Likewise. * src/xs_internal.c: Likewise. * tests/conftest.c: Likewise. * tests/xmlrpctest.c: Likewise. Signed-off-by: Jim Meyering <meyering@redhat.com> --- qemud/event.c | 1 + src/buf.c | 2 ++ src/hash.c | 2 ++ src/nodeinfo.c | 2 ++ src/openvz_conf.c | 2 ++ src/proxy_internal.c | 2 ++ src/virterror.c | 2 ++ src/xmlrpc.c | 2 ++ src/xs_internal.c | 2 ++ tests/conftest.c | 2 ++ tests/xmlrpctest.c | 2 ++ 11 files changed, 21 insertions(+), 0 deletions(-) diff --git a/qemud/event.c b/qemud/event.c index 72d490e..1faeaf1 100644 --- a/qemud/event.c +++ b/qemud/event.c @@ -21,6 +21,7 @@ * Author: Daniel P. Berrange <berrange@redhat.com> */ +#include "config.h" #include <stdlib.h> #include <string.h> diff --git a/src/buf.c b/src/buf.c index 0252357..5b7f15d 100644 --- a/src/buf.c +++ b/src/buf.c @@ -8,6 +8,8 @@ * Daniel Veillard <veillard@redhat.com> */ +#include "config.h" + #include "libvirt/libvirt.h" #include <stdio.h> diff --git a/src/hash.c b/src/hash.c index 2b4b6ec..b7962d9 100644 --- a/src/hash.c +++ b/src/hash.c @@ -18,6 +18,8 @@ * Daniel Veillard <veillard@redhat.com> */ +#include "config.h" + #include <string.h> #include <stdlib.h> #include <libxml/threads.h> diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 2ef49cb..98e72e8 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -21,6 +21,8 @@ * Author: Daniel P. Berrange <berrange@redhat.com> */ +#include "config.h" + #include <stdio.h> #include <string.h> #include <stdlib.h> diff --git a/src/openvz_conf.c b/src/openvz_conf.c index 88491f7..0502a1d 100644 --- a/src/openvz_conf.c +++ b/src/openvz_conf.c @@ -27,6 +27,8 @@ #ifdef WITH_OPENVZ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <unistd.h> diff --git a/src/proxy_internal.c b/src/proxy_internal.c index 6f142c5..2b98c61 100644 --- a/src/proxy_internal.c +++ b/src/proxy_internal.c @@ -8,6 +8,8 @@ * Daniel Veillard <veillard@redhat.com> */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <unistd.h> diff --git a/src/virterror.c b/src/virterror.c index 105d65f..0c0423b 100644 --- a/src/virterror.c +++ b/src/virterror.c @@ -8,6 +8,8 @@ * Author: Daniel Veillard <veillard@redhat.com> */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/src/xmlrpc.c b/src/xmlrpc.c index d58f887..d65a7a9 100644 --- a/src/xmlrpc.c +++ b/src/xmlrpc.c @@ -8,6 +8,8 @@ * Anthony Liguori <aliguori@us.ibm.com> */ +#include "config.h" + #include "xmlrpc.h" #include "internal.h" diff --git a/src/xs_internal.c b/src/xs_internal.c index 391803e..3995e3e 100644 --- a/src/xs_internal.c +++ b/src/xs_internal.c @@ -9,6 +9,8 @@ */ #ifdef WITH_XEN +#include "config.h" + #include <stdio.h> #include <string.h> #include <unistd.h> diff --git a/tests/conftest.c b/tests/conftest.c index 9c8e3a6..abb68fd 100644 --- a/tests/conftest.c +++ b/tests/conftest.c @@ -1,3 +1,5 @@ +#include "config.h" + #include <unistd.h> #include <stdlib.h> #include <stdio.h> diff --git a/tests/xmlrpctest.c b/tests/xmlrpctest.c index 64591e3..5fa937f 100644 --- a/tests/xmlrpctest.c +++ b/tests/xmlrpctest.c @@ -10,6 +10,8 @@ * $Id$ */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <stdarg.h> -- 1.5.3.6.950.g92b7b

On Wed, Dec 05, 2007 at 09:51:15PM +0100, Jim Meyering wrote:
"Richard W.M. Jones" <rjones@redhat.com> wrote:
Jim, to use the gnulib <string.h> replacement with GCC 4.1.2 compiled under MinGW, I needed to patch lib/string.h as follows:
--- gnulib/lib/string.h~ 2007-12-05 18:29:29.000000000 +0000 +++ gnulib/lib/string.h 2007-12-05 19:36:22.000000000 +0000 @@ -280,7 +280,7 @@ See also strtok_r(). */ #if 1 # if ! 0 -extern char *strsep (char **restrict __stringp, char const *restrict __delim); +extern char *strsep (char **__restrict__ __stringp, char const *__restrict__ __delim); # endif # if defined GNULIB_POSIXCHECK # undef strsep
This seems to be because C99's restrict keyword is not enabled by default. You need to pass the -std=c99 parameter to the compiler to get this.
Thanks for the report. That file is generated from string.in.h, based on settings determined at configure time.
And one of the autoconf checks performed for the string module is to require the AC_C_RESTRICT macro which is supposed to detect which flavor of restrict to use. Then it puts the appropriate definition of e.g.
#define restrict __restrict__
in config.h.
Ahh... I've got it. There are a bunch of files that don't include config.h.
There's a rule in "autoconf" land saying that nearly every .c file should include "config.h" before anything else. Most of the time people don't notice when it's forgotten, but porting to "different" systems highlights the trouble.
You can list the files that include string.h yet do *not* include config.h,
git-grep -l 'include <string\.h>'|xargs grep -L config.h
And here's a proposed patch to fix those. There may well be others, but this should solve your build failure:
Include "config.h".
* qemud/event.c: Likewise. * src/buf.c: Likewise. * src/hash.c: Likewise. * src/nodeinfo.c: Likewise. * src/openvz_conf.c: Likewise. * src/proxy_internal.c: Likewise. * src/virterror.c: Likewise. * src/xmlrpc.c: Likewise. * src/xs_internal.c: Likewise. * tests/conftest.c: Likewise. * tests/xmlrpctest.c: Likewise.
Hum, right, that should be commited to CVS, this makes sense even if gnulib is not in yet, thanks ! Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

+1 ... I've been (slowly) adding #include "config.h" to any files I can find too. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903
participants (4)
-
Daniel P. Berrange
-
Daniel Veillard
-
Jim Meyering
-
Richard W.M. Jones