diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-11-11 19:22:43 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2016-06-09 15:59:24 +0000 |
commit | b05741937c2827c05d2160ccf98f389eb03b6f35 (patch) | |
tree | 5c01b5778751ca30c04bfcbc215b19a951c8840d | |
parent | 7835b260a9f60c98ee41468b040ac080782afe2f (diff) |
Plug padding holes in QHostAddressPrivate
On ABIs where quint64 is aligned on 8-byte boundaries (such 32-bit
Windows and all 64-bit systems), there was a padding hole of 4 bytes
between QHostAddressPrivate::a and the anonymous union. If we move the
member to after the union, there is no hole anymore.
That operation causes the tail padding to grow from 3 to 7 bytes. Since
we also don't need full 32 bits for the protocol, we can shrink the
structure by 8 bytes on those architectures and by 4 bytes on 32-bit
Unix systems.
Change-Id: I461e9fc7199748faa187ffff1415d6601a7bd777
Reviewed-by: hjk <hjk@theqtcompany.com>
-rw-r--r-- | src/corelib/global/qhooks.cpp | 2 | ||||
-rw-r--r-- | src/network/kernel/qhostaddress.cpp | 7 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp index da401ffd78..b91ec64786 100644 --- a/src/corelib/global/qhooks.cpp +++ b/src/corelib/global/qhooks.cpp @@ -67,7 +67,7 @@ quintptr Q_CORE_EXPORT qtHookData[] = { // The required sizes and offsets are tested in tests/auto/other/toolsupport. // When this fails and the change was intentional, adjust the test and // adjust this value here. - 4 + 5 }; Q_STATIC_ASSERT(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0])); diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 0dbe1112cd..2c09e63d6e 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -115,14 +115,13 @@ public: QString ipString; QString scopeId; - quint32 a; // IPv4 address union { Q_IPV6ADDR a6; // IPv6 address struct { quint64 c[2]; } a6_64; struct { quint32 c[4]; } a6_32; }; - QAbstractSocket::NetworkLayerProtocol protocol; - + quint32 a; // IPv4 address + qint8 protocol; bool isParsed; friend class QHostAddress; @@ -701,7 +700,7 @@ quint32 QHostAddress::toIPv4Address(bool *ok) const QAbstractSocket::NetworkLayerProtocol QHostAddress::protocol() const { QT_ENSURE_PARSED(this); - return d->protocol; + return QAbstractSocket::NetworkLayerProtocol(d->protocol); } /*! |