Make headers compilable with g++ 4.7
This commit is contained in:
parent
4f5d9e6499
commit
548d156090
@ -1,7 +1,7 @@
|
|||||||
Summary: Bluetooth utilities
|
Summary: Bluetooth utilities
|
||||||
Name: bluez
|
Name: bluez
|
||||||
Version: 4.98
|
Version: 4.98
|
||||||
Release: 2%{?dist}
|
Release: 3%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: http://www.bluez.org/
|
URL: http://www.bluez.org/
|
||||||
@ -22,6 +22,8 @@ Patch5: 0001-Add-sixaxis-cable-pairing-plugin.patch
|
|||||||
Patch6: 0001-systemd-install-systemd-unit-files.patch
|
Patch6: 0001-systemd-install-systemd-unit-files.patch
|
||||||
|
|
||||||
Patch7: sbc_mmx.patch
|
Patch7: sbc_mmx.patch
|
||||||
|
# Bug #791292
|
||||||
|
Patch8: cplusplus_void_cast.patch
|
||||||
|
|
||||||
BuildRequires: flex
|
BuildRequires: flex
|
||||||
BuildRequires: dbus-devel >= 0.90
|
BuildRequires: dbus-devel >= 0.90
|
||||||
@ -147,6 +149,7 @@ and mouse.
|
|||||||
%patch5 -p1 -b .cable-pairing
|
%patch5 -p1 -b .cable-pairing
|
||||||
%patch6 -p1 -b .systemd
|
%patch6 -p1 -b .systemd
|
||||||
%patch7 -p1 -b .mmx
|
%patch7 -p1 -b .mmx
|
||||||
|
%patch8 -p1 -b .cplusplus
|
||||||
|
|
||||||
%build
|
%build
|
||||||
libtoolize -f -c
|
libtoolize -f -c
|
||||||
@ -311,6 +314,9 @@ fi
|
|||||||
%exclude /usr/lib/udev/rules.d/97-bluetooth-hid2hci.rules
|
%exclude /usr/lib/udev/rules.d/97-bluetooth-hid2hci.rules
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Feb 28 2012 Petr Pisar <ppisar@redhat.com> - 4.98-3
|
||||||
|
- Make headers compilable with g++ 4.7 (bug #791292)
|
||||||
|
|
||||||
* Fri Feb 24 2012 Peter Robinson <pbrobinson@fedoraproject.org> 4.98-2
|
* Fri Feb 24 2012 Peter Robinson <pbrobinson@fedoraproject.org> 4.98-2
|
||||||
- Add mmx patch to fix build of sbc component
|
- Add mmx patch to fix build of sbc component
|
||||||
- clean up spec, drop ancient obsoletes
|
- clean up spec, drop ancient obsoletes
|
||||||
|
82
cplusplus_void_cast.patch
Normal file
82
cplusplus_void_cast.patch
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
From 21c794102c27d8474809cb54578941f8bbe63218 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||||||
|
Date: Tue, 28 Feb 2012 11:22:11 +0100
|
||||||
|
Subject: [PATCH] Fix compiling C++ applications
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
The compiler error is:
|
||||||
|
/usr/include/bluetooth/bluetooth.h::131:9: error: invalid conversion from 'void*' to 'bt_get_le64(void*)::<anonymous struct>*'
|
||||||
|
...
|
||||||
|
|
||||||
|
The reason is that C++, in contrast to C, does not allow conversion of
|
||||||
|
void * to anything, and this code gets compiled as C++ when the app is
|
||||||
|
written in C++. The macro with the assignment itself is older, but only
|
||||||
|
recent Bluez starts to use it in inline functions, thus triggering the
|
||||||
|
problem.
|
||||||
|
|
||||||
|
This patch keeps the "struct __attribute__((packed))" magic and merely
|
||||||
|
changes the typecast so that it works in C and C++. Like the existing
|
||||||
|
macro this patch relies on support for typeof.
|
||||||
|
|
||||||
|
The new variant of the code is in an ifdef and only used for C++
|
||||||
|
to avoid unexpected regressions in C applications.
|
||||||
|
|
||||||
|
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
|
||||||
|
---
|
||||||
|
lib/bluetooth.h | 31 +++++++++++++++++++++++++++++++
|
||||||
|
1 files changed, 31 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/bluetooth.h b/lib/bluetooth.h
|
||||||
|
index 5bd4f03..3f1a177 100644
|
||||||
|
--- a/lib/bluetooth.h
|
||||||
|
+++ b/lib/bluetooth.h
|
||||||
|
@@ -109,6 +109,12 @@ enum {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Bluetooth unaligned access */
|
||||||
|
+#ifndef __cplusplus
|
||||||
|
+/*
|
||||||
|
+ * traditional code, doesn't work in C++ because
|
||||||
|
+ * of the void * to struct pointer assignment
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
#define bt_get_unaligned(ptr) \
|
||||||
|
({ \
|
||||||
|
struct __attribute__((packed)) { \
|
||||||
|
@@ -125,6 +131,31 @@ do { \
|
||||||
|
__p->__v = (val); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
+#else /* __cplusplus */
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * modified code with typeof typecast, for C++;
|
||||||
|
+ * the traditional code continues to be used for
|
||||||
|
+ * C to avoid unexpected regressions with this
|
||||||
|
+ * code here (it should work in C and C++, though)
|
||||||
|
+ */
|
||||||
|
+#define bt_get_unaligned(ptr) \
|
||||||
|
+({ \
|
||||||
|
+ struct __attribute__((packed)) { \
|
||||||
|
+ typeof(*(ptr)) __v; \
|
||||||
|
+ } *__p = (typeof(__p)) (ptr); \
|
||||||
|
+ __p->__v; \
|
||||||
|
+})
|
||||||
|
+
|
||||||
|
+#define bt_put_unaligned(val, ptr) \
|
||||||
|
+do { \
|
||||||
|
+ struct __attribute__((packed)) { \
|
||||||
|
+ typeof(*(ptr)) __v; \
|
||||||
|
+ } *__p = (typeof(__p)) (ptr); \
|
||||||
|
+ __p->__v = (val); \
|
||||||
|
+} while(0)
|
||||||
|
+#endif /* __cplusplus */
|
||||||
|
+
|
||||||
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
static inline uint64_t bt_get_le64(void *ptr)
|
||||||
|
{
|
||||||
|
--
|
||||||
|
1.7.7.6
|
||||||
|
|
Loading…
Reference in New Issue
Block a user