From 898b2bdd10edff5da7b3093cacbd2e5db46cd0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20A=C5=9F=C4=B1c=C4=B1?= Date: Thu, 22 Jan 2015 13:14:41 +0200 Subject: [PATCH] Fix build with -no-c++11 With -no-c++11, - Enum type names cannot be used as namespaces. Use old style naming. - For errno, errno.h must be included. - stdint.h must be included to use uint*_t types. Use quint* equivalents instead. Change-Id: I992f531a46cfc997df0aa6fc7ff6bf75fb750fc6 Sent-Upstream: https://codereview.qt-project.org/104254 Signed-off-by: Fatih Aşıcı --- src/bluetooth/bluez/bluez5_helper.cpp | 16 ++--- src/bluetooth/bluez/bluez_data_p.h | 94 ++++++++++++++-------------- src/bluetooth/bluez/hcimanager.cpp | 1 + src/bluetooth/qlowenergycontroller_bluez.cpp | 2 + 4 files changed, 58 insertions(+), 55 deletions(-) diff --git a/src/bluetooth/bluez/bluez5_helper.cpp b/src/bluetooth/bluez/bluez5_helper.cpp index eebeae9..0e3c006 100644 --- a/src/bluetooth/bluez/bluez5_helper.cpp +++ b/src/bluetooth/bluez/bluez5_helper.cpp @@ -45,16 +45,16 @@ Q_DECLARE_LOGGING_CATEGORY(QT_BT_BLUEZ) typedef enum Bluez5TestResultType { - Unknown, - Bluez4, - Bluez5 + BluezVersionUnknown, + BluezVersion4, + BluezVersion5 } Bluez5TestResult; -Q_GLOBAL_STATIC_WITH_ARGS(Bluez5TestResult, bluezVersion, (Bluez5TestResult::Unknown)); +Q_GLOBAL_STATIC_WITH_ARGS(Bluez5TestResult, bluezVersion, (BluezVersionUnknown)); bool isBluez5() { - if (*bluezVersion() == Bluez5TestResultType::Unknown) { + if (*bluezVersion() == BluezVersionUnknown) { OrgFreedesktopDBusObjectManagerInterface manager(QStringLiteral("org.bluez"), QStringLiteral("/"), QDBusConnection::systemBus()); @@ -65,15 +65,15 @@ bool isBluez5() QDBusPendingReply reply = manager.GetManagedObjects(); reply.waitForFinished(); if (reply.isError()) { - *bluezVersion() = Bluez5TestResultType::Bluez4; + *bluezVersion() = BluezVersion4; qCDebug(QT_BT_BLUEZ) << "Bluez 4 detected."; } else { - *bluezVersion() = Bluez5TestResultType::Bluez5; + *bluezVersion() = BluezVersion5; qCDebug(QT_BT_BLUEZ) << "Bluez 5 detected."; } } - return (*bluezVersion() == Bluez5TestResultType::Bluez5); + return (*bluezVersion() == BluezVersion5); } struct AdapterData diff --git a/src/bluetooth/bluez/bluez_data_p.h b/src/bluetooth/bluez/bluez_data_p.h index 7c79997..9d2d96b 100644 --- a/src/bluetooth/bluez/bluez_data_p.h +++ b/src/bluetooth/bluez/bluez_data_p.h @@ -75,8 +75,8 @@ #define BT_SECURITY 4 struct bt_security { - uint8_t level; - uint8_t key_size; + quint8 level; + quint8 key_size; }; #define BT_SECURITY_SDP 0 #define BT_SECURITY_LOW 1 @@ -162,14 +162,14 @@ static inline void ntoh128(const quint128 *src, quint128 *dst) dst->data[15 - i] = src->data[i]; } -static inline uint16_t bt_get_le16(const void *ptr) +static inline quint16 bt_get_le16(const void *ptr) { - return bt_get_unaligned((const uint16_t *) ptr); + return bt_get_unaligned((const quint16 *) ptr); } #elif __BYTE_ORDER == __BIG_ENDIAN -static inline uint16_t bt_get_le16(const void *ptr) +static inline quint16 bt_get_le16(const void *ptr) { - return bswap_16(bt_get_unaligned((const uint16_t *) ptr)); + return bswap_16(bt_get_unaligned((const quint16 *) ptr)); } static inline void btoh128(const quint128 *src, quint128 *dst) @@ -213,79 +213,79 @@ struct sockaddr_hci { }; struct hci_dev_req { - uint16_t dev_id; - uint32_t dev_opt; + quint16 dev_id; + quint32 dev_opt; }; struct hci_dev_list_req { - uint16_t dev_num; + quint16 dev_num; struct hci_dev_req dev_req[0]; }; struct hci_dev_stats { - uint32_t err_rx; - uint32_t err_tx; - uint32_t cmd_tx; - uint32_t evt_rx; - uint32_t acl_tx; - uint32_t acl_rx; - uint32_t sco_tx; - uint32_t sco_rx; - uint32_t byte_rx; - uint32_t byte_tx; + quint32 err_rx; + quint32 err_tx; + quint32 cmd_tx; + quint32 evt_rx; + quint32 acl_tx; + quint32 acl_rx; + quint32 sco_tx; + quint32 sco_rx; + quint32 byte_rx; + quint32 byte_tx; }; struct hci_dev_info { - uint16_t dev_id; + quint16 dev_id; char name[8]; bdaddr_t bdaddr; - uint32_t flags; - uint8_t type; + quint32 flags; + quint8 type; - uint8_t features[8]; + quint8 features[8]; - uint32_t pkt_type; - uint32_t link_policy; - uint32_t link_mode; + quint32 pkt_type; + quint32 link_policy; + quint32 link_mode; - uint16_t acl_mtu; - uint16_t acl_pkts; - uint16_t sco_mtu; - uint16_t sco_pkts; + quint16 acl_mtu; + quint16 acl_pkts; + quint16 sco_mtu; + quint16 sco_pkts; struct hci_dev_stats stat; }; struct hci_conn_info { - uint16_t handle; + quint16 handle; bdaddr_t bdaddr; - uint8_t type; - uint8_t out; - uint16_t state; - uint32_t link_mode; + quint8 type; + quint8 out; + quint16 state; + quint32 link_mode; }; struct hci_conn_list_req { - uint16_t dev_id; - uint16_t conn_num; + quint16 dev_id; + quint16 conn_num; struct hci_conn_info conn_info[0]; }; struct hci_filter { - uint32_t type_mask; - uint32_t event_mask[2]; - uint16_t opcode; + quint32 type_mask; + quint32 event_mask[2]; + quint16 opcode; }; static inline void hci_set_bit(int nr, void *addr) { - *((uint32_t *) addr + (nr >> 5)) |= (1 << (nr & 31)); + *((quint32 *) addr + (nr >> 5)) |= (1 << (nr & 31)); } static inline void hci_clear_bit(int nr, void *addr) { - *((uint32_t *) addr + (nr >> 5)) &= ~(1 << (nr & 31)); + *((quint32 *) addr + (nr >> 5)) &= ~(1 << (nr & 31)); } static inline void hci_filter_clear(struct hci_filter *f) { @@ -317,16 +317,16 @@ static inline void hci_filter_all_events(struct hci_filter *f) } typedef struct { - uint8_t evt; - uint8_t plen; + quint8 evt; + quint8 plen; } __attribute__ ((packed)) hci_event_hdr; #define HCI_EVENT_HDR_SIZE 2 #define EVT_ENCRYPT_CHANGE 0x08 typedef struct { - uint8_t status; - uint16_t handle; - uint8_t encrypt; + quint8 status; + quint16 handle; + quint8 encrypt; } __attribute__ ((packed)) evt_encrypt_change; #define EVT_ENCRYPT_CHANGE_SIZE 4 diff --git a/src/bluetooth/bluez/hcimanager.cpp b/src/bluetooth/bluez/hcimanager.cpp index 17d54a4..3245058 100644 --- a/src/bluetooth/bluez/hcimanager.cpp +++ b/src/bluetooth/bluez/hcimanager.cpp @@ -38,6 +38,7 @@ #include +#include #include #include #include diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index 5629966..f22cea7 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -41,6 +41,8 @@ #include #include +#include + #define ATTRIBUTE_CHANNEL_ID 4 #define ATT_DEFAULT_LE_MTU 23 -- 1.9.1