diff options
author | marcel <marcel@FreeBSD.org> | 2005-01-28 02:58:32 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2005-01-28 02:58:32 +0000 |
commit | a52d6034c25c293be752e89574f77b0c7059ae46 (patch) | |
tree | 9a398ed9168b67be2fb2b44a5309db5de1d71d23 /tools | |
parent | 83ff245674966bd02fc26997d1be7982caa5c91d (diff) | |
download | FreeBSD-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')
-rw-r--r-- | tools/regression/ia64/unaligned/test.c | 11 |
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) |