SF #3559331: Add macros for byte-ordering
This commit is contained in:
Родитель
111fba0481
Коммит
06204c4865
|
@ -313,4 +313,16 @@ extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW;
|
|||
#define INADDR_MAX_LOCAL_GROUP 0xe00000ff
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(POCO_ARCH_BIG_ENDIAN)
|
||||
#define poco_ntoh_16(x) (x)
|
||||
#define poco_ntoh_32(x) (x)
|
||||
#else
|
||||
#define poco_ntoh_16(x) \
|
||||
((((x) >> 8) & 0x00ff) | (((x) << 8) & 0xff00))
|
||||
#define poco_ntoh_32(x) \
|
||||
((((x) >> 24) & 0x000000ff) | (((x) >> 8) & 0x0000ff00) | (((x) << 8) & 0x00ff0000) | (((x) << 24) & 0xff000000))
|
||||
#endif
|
||||
|
||||
|
||||
#endif // Net_SocketDefs_INCLUDED
|
||||
|
|
|
@ -630,6 +630,15 @@ void IPAddressTest::testRelationals6()
|
|||
}
|
||||
|
||||
|
||||
void IPAddressTest::testByteOrderMacros()
|
||||
{
|
||||
Poco::UInt16 a16 = 0xDEAD;
|
||||
assert (poco_ntoh_16(a16) == ntohs(a16));
|
||||
Poco::UInt32 a32 = 0xDEADBEEF;
|
||||
assert (poco_ntoh_32(a32) == ntohl(a32));
|
||||
}
|
||||
|
||||
|
||||
void IPAddressTest::setUp()
|
||||
{
|
||||
}
|
||||
|
@ -658,6 +667,7 @@ CppUnit::Test* IPAddressTest::suite()
|
|||
CppUnit_addTest(pSuite, IPAddressTest, testPrefixCons);
|
||||
CppUnit_addTest(pSuite, IPAddressTest, testPrefixLen);
|
||||
CppUnit_addTest(pSuite, IPAddressTest, testOperators);
|
||||
CppUnit_addTest(pSuite, IPAddressTest, testByteOrderMacros);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,8 @@ public:
|
|||
void testPrefixCons();
|
||||
void testPrefixLen();
|
||||
void testOperators();
|
||||
|
||||
void testByteOrderMacros();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче