build: fix build with older dbus headers

Compilation on a RHEL 5 host failed, due to the older dbus headers
present on that machine, and triggered by commit 2aa167ca:

util/virdbus.c: In function 'virDBusMessageIterDecode':
util/virdbus.c:952: error: 'DBusBasicValue' undeclared (first use in this function)

* m4/virt-dbus.m4 (LIBVIRT_CHECK_DBUS): Check for DBusBasicValue.
* src/util/virdbuspriv.h (DBusBasicValue): Provide fallback.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2014-11-19 14:57:30 -07:00
parent 225f483314
commit c0e7022161
2 changed files with 18 additions and 2 deletions

View File

@ -1,6 +1,6 @@
dnl The libdbus.so library dnl The libdbus.so library
dnl dnl
dnl Copyright (C) 2012-2013 Red Hat, Inc. dnl Copyright (C) 2012-2014 Red Hat, Inc.
dnl dnl
dnl This library is free software; you can redistribute it and/or dnl This library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Lesser General Public dnl modify it under the terms of the GNU Lesser General Public
@ -26,6 +26,7 @@ AC_DEFUN([LIBVIRT_CHECK_DBUS],[
CFLAGS="$CFLAGS $DBUS_CFLAGS" CFLAGS="$CFLAGS $DBUS_CFLAGS"
LIBS="$LIBS $DBUS_LIBS" LIBS="$LIBS $DBUS_LIBS"
AC_CHECK_FUNCS([dbus_watch_get_unix_fd]) AC_CHECK_FUNCS([dbus_watch_get_unix_fd])
AC_CHECK_TYPES([DBusBasicValue], [], [], [[#include <dbus/dbus.h>]])
CFLAGS="$old_CFLAGS" CFLAGS="$old_CFLAGS"
LIBS="$old_LIBS" LIBS="$old_LIBS"
fi fi

View File

@ -1,7 +1,7 @@
/* /*
* virdbuspriv.h: internal APIs for testing DBus code * virdbuspriv.h: internal APIs for testing DBus code
* *
* Copyright (C) 2012-2013 Red Hat, Inc. * Copyright (C) 2012-2014 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -24,6 +24,21 @@
# include "virdbus.h" # include "virdbus.h"
# if !HAVE_DBUSBASICVALUE
/* Copied (and simplified) from dbus 1.6.12, for use with older dbus headers */
typedef union
{
dbus_int16_t i16; /**< as int16 */
dbus_uint16_t u16; /**< as int16 */
dbus_int32_t i32; /**< as int32 */
dbus_uint32_t u32; /**< as int32 */
dbus_bool_t bool_val; /**< as boolean */
dbus_int64_t i64; /**< as int64 */
dbus_uint64_t u64; /**< as int64 */
double dbl; /**< as double */
unsigned char byt; /**< as byte */
} DBusBasicValue;
# endif
int virDBusMessageEncodeArgs(DBusMessage* msg, int virDBusMessageEncodeArgs(DBusMessage* msg,
const char *types, const char *types,