summaryrefslogtreecommitdiffstats
path: root/tools/regression
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2005-01-28 02:58:32 +0000
committermarcel <marcel@FreeBSD.org>2005-01-28 02:58:32 +0000
commita52d6034c25c293be752e89574f77b0c7059ae46 (patch)
tree9a398ed9168b67be2fb2b44a5309db5de1d71d23 /tools/regression
parent83ff245674966bd02fc26997d1be7982caa5c91d (diff)
downloadFreeBSD-src-a52d6034c25c293be752e89574f77b0c7059ae46.zip
FreeBSD-src-a52d6034c25c293be752e89574f77b0c7059ae46.tar.gz
Wrap calls to memcpy(3) in a function called block_copy(). This way,
and as long as we're not compiling with IPA, gcc(1) won't optimize the call away. The whole purpose of using memcpy(3) is to avoid misaligned loads and stores when we need to read or write the value in the unaligned memory location. But if gcc(1) optimizes the call to memcpy(3) away, it will typically introduce misaligned loads and stores. In this context that's not a good idea.
Diffstat (limited to 'tools/regression')
-rw-r--r--tools/regression/ia64/unaligned/test.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/regression/ia64/unaligned/test.c b/tools/regression/ia64/unaligned/test.c
index e6c8bb4..869c864 100644
--- a/tools/regression/ia64/unaligned/test.c
+++ b/tools/regression/ia64/unaligned/test.c
@@ -101,6 +101,13 @@ DATA_TYPE *aligned = &data.aligned;
DATA_TYPE *misaligned = (DATA_TYPE *)data.misaligned;
DATA_TYPE value = DATA_VALUE;
+void
+block_copy(void *dst, void *src, size_t sz)
+{
+
+ memcpy(dst, src, sz);
+}
+
int
main()
{
@@ -112,7 +119,7 @@ main()
/*
* LOAD
*/
- memcpy(misaligned, &value, sizeof(DATA_TYPE));
+ block_copy(misaligned, &value, sizeof(DATA_TYPE));
# if POSTINC == NoPostInc
/* Misaligned load. */
@@ -179,7 +186,7 @@ main()
return (1);
# endif
- memcpy(aligned, data.misaligned, sizeof(DATA_TYPE));
+ block_copy(aligned, data.misaligned, sizeof(DATA_TYPE));
#endif
if (*aligned != value)
OpenPOWER on IntegriCloud