summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-08-11 17:28:05 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-08-18 13:00:39 +0000
commit00ee6a6121844c6c81e974d459c9474cfe1ab4a8 (patch)
treeae59674ac5d82071ab89b1356c6cb06fb7d8561f
parent1cea6020ebd3395f227ae085a3712dbc171dd983 (diff)
QBluetoothUuid: inline the (quint128, Endian) ctor
We can actually write a body that works for both unsigned __int128 as well as the legacy struct quint128, using QUuid::fromBytes(), so do that. This removes the need to keep a complex implementation behind the ABI boundary, and thus allows to remove the function from the ABI so we don't run into even more BiC problems once MSVC starts supporting __int128, possibly with just a newer /std flag which, as per current rules, isn't supposed to change the ABI. Change-Id: I1975cf68bc5f5421bf90f81a691ddf68bfa928dd Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit 0f689ee079aa98b26efe097c8dc6652055f9010b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/bluetooth/qbluetoothuuid.cpp20
-rw-r--r--src/bluetooth/qbluetoothuuid.h4
2 files changed, 4 insertions, 20 deletions
diff --git a/src/bluetooth/qbluetoothuuid.cpp b/src/bluetooth/qbluetoothuuid.cpp
index 4f7f8b93..ef6db13c 100644
--- a/src/bluetooth/qbluetoothuuid.cpp
+++ b/src/bluetooth/qbluetoothuuid.cpp
@@ -549,20 +549,7 @@ quint128 QBluetoothUuid::toUInt128(QSysInfo::Endian order) const noexcept
memcpy(&r, bytes.data, sizeof(quint128));
return r;
}
-#endif
-
-static QUuid::Id128Bytes to_id128_bytes(quint128 v) noexcept
-{
-#ifdef QT_SUPPORTS_INT128
- // quint128 is `unsigned __int128`:
- return {.data128 = {v}};
-#else
- // quint128 is our legacy struct from qbluetoothuuid.h:
- QUuid::Id128Bytes result;
- memcpy(result.data, v.data, sizeof(v.data));
- return result;
-#endif
-}
+#endif // !QT_SUPPORTS_INT128
/*!
\fn QBluetoothUuid::QBluetoothUuid(quint128 uuid, QSysInfo::Endian order)
@@ -573,11 +560,6 @@ static QUuid::Id128Bytes to_id128_bytes(quint128 v) noexcept
and the function was hard-coded to big-endian order.
*/
-QBluetoothUuid::QBluetoothUuid(quint128 uuid, QSysInfo::Endian order) noexcept
- : QUuid{to_id128_bytes(uuid), order}
-{
-}
-
/*!
Creates a QBluetoothUuid object from the string \a uuid,
which must be formatted as five hex fields separated by '-',
diff --git a/src/bluetooth/qbluetoothuuid.h b/src/bluetooth/qbluetoothuuid.h
index 1eaf7808..07298da7 100644
--- a/src/bluetooth/qbluetoothuuid.h
+++ b/src/bluetooth/qbluetoothuuid.h
@@ -355,7 +355,9 @@ public:
#if QT_BLUETOOTH_REMOVED_SINCE(6, 6)
explicit QBluetoothUuid(quint128 uuid);
#endif
- explicit QBluetoothUuid(quint128 uuid, QSysInfo::Endian order = QSysInfo::BigEndian) noexcept;
+ QT6_ONLY(QT_POST_CXX17_API_IN_EXPORTED_CLASS) // quint128 changes based on QT_SUPPORTS_INT128!
+ explicit QBluetoothUuid(quint128 uuid, QSysInfo::Endian order = QSysInfo::BigEndian) noexcept
+ : QUuid{fromBytes(&uuid, order)} {}
explicit QBluetoothUuid(Id128Bytes uuid, QSysInfo::Endian order = QSysInfo::BigEndian) noexcept
: QUuid(uuid, order) {};
explicit QBluetoothUuid(const QString &uuid);