aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2010-01-11 15:18:50 +0100
committerMartin Willi <martin@strongswan.org>2010-01-11 15:35:41 +0100
commitdbee988e289081d0ee2f183b9e309c9bcfafb934 (patch)
tree2cbef0931dfada437014e325e2d2150e77f2a870 /src/libstrongswan
parent8fb389b299af8ef6cf9b4138f641dbd69f985bfc (diff)
downloadstrongswan-dbee988e289081d0ee2f183b9e309c9bcfafb934.tar.bz2
strongswan-dbee988e289081d0ee2f183b9e309c9bcfafb934.tar.xz
Cast unaligned memcpy() args to char*, avoids over-optimization on ARM
See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3934.html
Diffstat (limited to 'src/libstrongswan')
-rw-r--r--src/libstrongswan/utils.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libstrongswan/utils.h b/src/libstrongswan/utils.h
index 1ac16ec17..e744f39a5 100644
--- a/src/libstrongswan/utils.h
+++ b/src/libstrongswan/utils.h
@@ -349,8 +349,10 @@ bool return_false();
*/
static inline void htoun16(void *network, u_int16_t host)
{
+ char *unaligned = (char*)network;
+
host = htons(host);
- memcpy(network, &host, sizeof(host));
+ memcpy(unaligned, &host, sizeof(host));
}
/**
@@ -361,8 +363,10 @@ static inline void htoun16(void *network, u_int16_t host)
*/
static inline void htoun32(void *network, u_int32_t host)
{
+ char *unaligned = (char*)network;
+
host = htonl(host);
- memcpy(network, &host, sizeof(host));
+ memcpy((char*)unaligned, &host, sizeof(host));
}
/**
@@ -373,9 +377,10 @@ static inline void htoun32(void *network, u_int32_t host)
*/
static inline u_int16_t untoh16(void *network)
{
+ char *unaligned = (char*)network;
u_int16_t tmp;
- memcpy(&tmp, network, sizeof(tmp));
+ memcpy(&tmp, unaligned, sizeof(tmp));
return ntohs(tmp);
}
@@ -387,9 +392,10 @@ static inline u_int16_t untoh16(void *network)
*/
static inline u_int32_t untoh32(void *network)
{
+ char *unaligned = (char*)network;
u_int32_t tmp;
- memcpy(&tmp, network, sizeof(tmp));
+ memcpy(&tmp, unaligned, sizeof(tmp));
return ntohl(tmp);
}